Package com.almende.eve.rpc.jsonrpc

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


   *            the agent
   */
  public void init(final ResultMonitor monitor, final AgentInterface agent) {
    final ObjectNode params = JOM.createObjectNode();
    params.put("monitorId", monitor.getId());
    final JSONRequest request = new JSONRequest("monitor.doPoll", params);
   
    // Try to cancel any protential existing tasks.
    cancel(monitor, agent);
   
    taskId = agent.getScheduler()
View Full Code Here


        IOException {
      // TODO: throw exceptions when agentId, request are null or
      // delay < 0
     
      agentId = params.get("agentId");
      request = new JSONRequest(params.get("request"));
      timestamp = new DateTime(params.get("timestamp"));
      interval = Long.valueOf(params.get("interval"));
      sequential = Boolean.valueOf(params.get("sequential"));
     
      long delay = 0;
View Full Code Here

      throws Exception {
    // 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

  }

  @Override
  public void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    JSONRequest jsonRequest = null;
    JSONResponse jsonResponse = null;   
    try {
      // retrieve the request body
      String body = StringUtil.streamToString(req.getInputStream());
      jsonRequest = new JSONRequest(body);
     
      // TODO: append authorized sender url to the request parameters
      RequestParams requestParams = new RequestParams();
      requestParams.put(Sender.class, null);
View Full Code Here

        JsonMappingException, JSONRPCException, IOException {
      // TODO: throw exceptions when agentId, request are null or delay <
      // 0
     
      agentId = params.get("agentId");
      request = new JSONRequest(params.get("request"));
      timestamp = new DateTime(params.get("timestamp"));
      interval = new Long(params.get("interval"));
      sequential = new Boolean(params.get("sequential"));
     
      long delay = 0;
View Full Code Here

   * JSON-RPC request as body. Response will be a JSON-RPC response.
   */
  @Override
  public void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    JSONRequest jsonRequest = null;
    JSONResponse jsonResponse = null;
    String body = null;
    String agentUrl = null;
    String agentId = null;
    try {
      // retrieve the agent url and the request body
      body = StringUtil.streamToString(req.getInputStream());
      jsonRequest = new JSONRequest(body);

      agentUrl = req.getRequestURI();
      agentId = httpTransport.getAgentId(agentUrl);
      if (agentId == null || agentId.isEmpty()) {
        resp.sendError(400, "No agentId found in url.");
View Full Code Here

      ObjectNode taskParams = JOM.createObjectNode();
      taskParams.put("url", subscription.url);
      taskParams.put("method", subscription.method);
      taskParams.put("params", callbackParams);
      JSONRequest request = new JSONRequest("onTrigger", taskParams);
      long delay = 0;
      getScheduler().createTask(request, delay);
    }
  }
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;
    }
View Full Code Here

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

      String[] path = uri.split("\\/");
      String agentId = (path.length > 2) ? path[path.length - 2] : null;
      String method = (path.length > 1) ? path[path.length - 1] : null;

      // get query parameters
      JSONRequest request = new JSONRequest();
      request.setMethod(method);
      Enumeration<String> params = req.getParameterNames();
      while (params.hasMoreElements()) {
        String param = params.nextElement();
        request.putParam(param, req.getParameter(param));
      }

      // TODO: provide authorized sender url
      RequestParams requestParams = new RequestParams();
      requestParams.put(Sender.class, null);
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.