Package com.almende.eve.rpc.jsonrpc

Examples of com.almende.eve.rpc.jsonrpc.JSONRPCException


              }
              try {
                host.sendAsync(receiverUrl, request, agent,
                    null);
              } catch (final IOException e1) {
                throw new JSONRPCException(
                    CODE.REMOTE_EXCEPTION, "", e1);
              }
             
              JSONResponse response;
              try {
                response = callback.get();
              } catch (final Exception e) {
                throw new JSONRPCException(
                    CODE.REMOTE_EXCEPTION, "", e);
              }
              final JSONRPCException err = response.getError();
              if (err != null) {
                throw err;
              } else if (response.getResult() != null
                  && !method.getReturnType()
                      .equals(Void.TYPE)) {
View Full Code Here


    if (myAgent.getState().containsKey(pushKey)) {
      final ObjectNode pushParams = (ObjectNode) JOM.getInstance()
          .readTree(myAgent.getState().get(pushKey, String.class))
          .get("config");
      if (!(pushParams.has("method") && pushParams.has("params"))) {
        throw new JSONRPCException("Missing push configuration fields:"
            + pushParams);
      }
      final String method = pushParams.get("method").textValue();
      final ObjectNode params = (ObjectNode) JOM.getInstance().readTree(
          pushParams.get("params").textValue());
View Full Code Here

   
    // TODO: THis is unclean!
    final String[] ids = pushId.split("_");
   
    if (ids.length != 2) {
      throw new JSONRPCException("PushId is invalid!");
    }
    final String monitorId = ids[0];
   
    try {
     
View Full Code Here

    send(request, url, callback, null);
    JSONResponse response;
    try {
      response = callback.get();
    } catch (final Exception e) {
      throw new JSONRPCException(CODE.REMOTE_EXCEPTION, "", e);
    }
    final JSONRPCException err = response.getError();
    if (err != null) {
      throw err;
    }
    return response;
  }
View Full Code Here

            try {
              final T res = (T) TypeUtil.inject(
                  response.getResult(), type);
              callback.onSuccess(res);
            } catch (final ClassCastException cce) {
              callback.onFailure(new JSONRPCException(
                  "Incorrect return type received for JSON-RPC call:"
                      + request.getMethod() + "@" + url,
                  cce));
            }
           
View Full Code Here

      }
    } catch (final Exception e) {
      LOG.log(Level.WARNING, "Exception in receiving message", e);
      // generate JSON error response, skipped if it was an incoming
      // notification i.s.o. request.
      final JSONRPCException jsonError = new JSONRPCException(
          JSONRPCException.CODE.INTERNAL_ERROR, e.getMessage(), e);
      final JSONResponse response = new JSONResponse(jsonError);
      response.setId(id);
      signalAgent(new AgentSignal<JSONResponse>(AgentSignal.EXCEPTION,
          response));
View Full Code Here

      // invoke the agent
      jsonResponse = agentFactory.receive(agentId, jsonRequest, requestParams);
    } catch (Exception err) {
      // generate JSON error response
      JSONRPCException jsonError = null;
      if (err instanceof JSONRPCException) {
        jsonError = (JSONRPCException) err;
      }
      else {
        jsonError = new JSONRPCException(
            JSONRPCException.CODE.INTERNAL_ERROR, err.getMessage());       
        jsonError.setData(err);
      }
      jsonResponse = new JSONResponse(jsonError);
    }

    // return response
View Full Code Here

      jsonResponse = agentFactory.receive(agentId, jsonRequest,
          requestParams);
    } catch (Exception err) {
      // generate JSON error response
      err.printStackTrace();
      JSONRPCException jsonError = null;
      if (err instanceof JSONRPCException) {
        jsonError = (JSONRPCException) err;
      } else {
        jsonError = new JSONRPCException(
            JSONRPCException.CODE.INTERNAL_ERROR, err.getMessage());
        jsonError.setData(err);
      }
      jsonResponse = new JSONResponse(jsonError);
    }

    // return response
View Full Code Here

    // invoke the other agent via the state, allowing the state
    // to route the request internally or externally
    String id = UUID.randomUUID().toString();
    JSONRequest request = new JSONRequest(id, method, jsonParams);
    JSONResponse response = getAgentFactory().send(this, url, request);
    JSONRPCException err = response.getError();
    if (err != null) {
      throw err;
    }
    if (type != null && type != void.class) {
      return response.getResult(type);
View Full Code Here

          throw new Exception("Request does not contain a valid JSON-RPC request or response");
        }
      }
      catch (Exception err) {
        // generate JSON error response
        JSONRPCException jsonError = new JSONRPCException(
            JSONRPCException.CODE.INTERNAL_ERROR, err.getMessage());
        JSONResponse response = new JSONResponse(jsonError);
       
        // send exception as response
            Message msg = new MessageBuilder()
View Full Code Here

TOP

Related Classes of com.almende.eve.rpc.jsonrpc.JSONRPCException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.