Package com.almende.eve.rpc.jsonrpc

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


          // TODO: cleanup logger info
          logger.info("request agentUrl =" + agentUrl + ", agentId=" + agentId + " request=" + json + ", sender=" + from.getId());

          // invoke the agent
          JSONRequest request = new JSONRequest(json);
          JSONResponse response = agentFactory.invoke(agentId, request, params);

          // reply to message
              Message msg = new MessageBuilder()
                .withRecipientJids(from)
View Full Code Here


            }
          }
          else if (isRequest(json)) {
            // this is a request
            String senderUrl = message.getFrom();
            JSONRequest request = new JSONRequest(json);
            invoke(senderUrl, request);
          }
          else {
            throw new Exception("Request does not contain a valid JSON-RPC request or response");
          }
View Full Code Here

    // http://docs.oracle.com/javase/1.4.2/docs/guide/reflection/proxy.html
    T proxy = (T) Proxy.newProxyInstance(agentInterface.getClassLoader(),
        new Class[] { agentInterface }, new InvocationHandler() {
          public Object invoke(Object proxy, Method method,
              Object[] args) throws Throwable {
            JSONRequest request = JSONRPC.createRequest(method,
                args);
            JSONResponse response = send(sender, receiverUrl,
                request);

            JSONRPCException err = response.getError();
View Full Code Here

              JSONRPCException {
           
            // TODO: if method calls for Namespace getter, return
            // new proxy for subtype. All calls to that proxy need
            // to add namespace to method name for JSON-RPC.
            JSONRequest request = JSONRPC.createRequest(method,
                args);
            JSONResponse response = send(sender, receiverUrl,
                request);
           
            JSONRPCException err = response.getError();
View Full Code Here

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

  @Access(AccessType.UNAVAILABLE)
  public final <T> void sendAsync(URI url, String method, ObjectNode params,
      final AsyncCallback<T> callback, Class<T> type)
      throws ProtocolException, JSONRPCException {
    String id = UUID.randomUUID().toString();
    JSONRequest request = new JSONRequest(id, method, params);
    sendAsync(url, request, callback, JOM.getTypeFactory()
        .uncheckedSimpleType(type));
  }
View Full Code Here

  @Access(AccessType.UNAVAILABLE)
  public final <T> void sendAsync(URI url, String method, ObjectNode params,
      final AsyncCallback<T> callback, final Type type)
      throws ProtocolException, JSONRPCException {
    String id = UUID.randomUUID().toString();
    JSONRequest request = new JSONRequest(id, method, params);
    sendAsync(url, request, callback,
        JOM.getTypeFactory().constructType(type));
  }
View Full Code Here

  @Access(AccessType.UNAVAILABLE)
  public final <T> void sendAsync(URI url, String method, ObjectNode params,
      final AsyncCallback<T> callback, final JavaType type)
      throws ProtocolException, JSONRPCException {
    String id = UUID.randomUUID().toString();
    JSONRequest request = new JSONRequest(id, method, params);
    sendAsync(url, request, callback, type);
  }
View Full Code Here

        ObjectNode parms = (ObjectNode) JOM.getInstance().readTree(
            subscription.getParams());
        triggerParams = (ObjectNode) parms.putAll(triggerParams);
      }
      taskParams.put("params", triggerParams);
      JSONRequest request = new JSONRequest("event.doTrigger", taskParams);
      long delay = 0;
      myAgent.getScheduler().createTask(request, delay);
    }
  }
View Full Code Here

  public void setTimeToLive(long interval) {
    // remove existing timeout
    cancelTimeToLive();
   
    // create a new timeout
    JSONRequest request = new JSONRequest("killMe", null);
    String timeoutId = getScheduler().createTask(request, interval);
    getState().put("timeoutId", timeoutId);
  }
View Full Code Here

TOP

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

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.