Package com.almende.eve.rpc.jsonrpc

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


   * 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(HttpServletResponse.SC_BAD_REQUEST,
View Full Code Here


              callback.onSuccess(new JSONResponse(body));
            }
          } else if (isRequest(json)) {
            // this is a request
            String senderUrl = "xmpp:"+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

      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

            + pushParams);
      }
      String method = pushParams.get("method").textValue();
      ObjectNode params = (ObjectNode) JOM.getInstance().readTree(
          pushParams.get("params").textValue());
      JSONResponse res = JSONRPC.invoke(myAgent, new JSONRequest(method,
          params), myAgent);
     
      JsonNode result = res.getResult();
      if (pushParams.has("onChange")
          && pushParams.get("onChange").asBoolean()) {
View Full Code Here

    params.put("pushKey", pushKey);
   
    LOG.info("Register Push:" + pushKey);
    if (pushParams.has("interval")) {
      int interval = pushParams.get("interval").intValue();
      JSONRequest request = new JSONRequest("monitor.doPush", params);
      result.put(
          "taskId",
          myAgent.getScheduler().createTask(request, interval, true,
              false));
    }
View Full Code Here

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

    return json;
  }
 
  private void sendAuthorizationToAgent(String agentUrl, String agentMethod,
      ObjectNode auth) throws IOException {
    JSONRequest rpcRequest = new JSONRequest(agentMethod, auth);
    HttpUtil.post(agentUrl, rpcRequest.toString());
  }
View Full Code Here

   
    // stop any running task
    stopAutoUpdate();

    // schedule an update task and store the task id
    JSONRequest request = new JSONRequest("update", null);
    String task = getScheduler().createTask(request, interval);
    state.put("updateTask", task);

    logger.info("Auto update started. Interval = " + interval
        + " milliseconds");
View Full Code Here

   
    // stop any running task
    stopAutoUpdate();

    // schedule an update task and store the task id
    JSONRequest request = new JSONRequest("update", null);
    String task = getScheduler().createTask(request, interval);
    state.put("updateTask", task);

    logger.info("Auto update started. Interval = " + interval
        + " milliseconds");
View Full Code Here

          // 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.receive(agentId, request, params);

          // reply to message
              Message msg = new MessageBuilder()
                .withRecipientJids(from)
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.