Package org.butor.json

Examples of org.butor.json.JsonServiceRequest


        // remove context from args passed to service as json args
        Object[] serviceArgs = new Object[args_.length-1];
        for (int ii=1; ii<args_.length;ii++)
          serviceArgs[ii-1] = args_[ii];

        JsonServiceRequest jsr = (JsonServiceRequest)ctx.getRequest();
        jsr.setService(method_.getName());
        jsr.setServiceArgsJson(_sc.serialize(serviceArgs));

        _sc.call(jsr, ctx.getResponseHandler());

        return null;
      }
View Full Code Here


  public String serialize(Object args_) {
    return _jsh.serialize(args_);
  }
  public JsonServiceRequest createRequest(String service_,
      Object serviceArgs_, String userId_, String sessionId_) {
    JsonServiceRequest req = new JsonServiceRequest();
    req.setSessionId(sessionId_);
    req.setReqId("R-" +UUID.randomUUID().toString());
    req.setUserId(userId_);
    req.setNamespace(_namespace);
    req.setService(service_);
    req.setServiceArgsJson(serviceArgs_ instanceof String ?
        (String)serviceArgs_ : serialize(serviceArgs_));

    return req;
  }
View Full Code Here

    }
    return cmp.isBinary();
  }
  @Override
  public void invoke(final Context ctx_) {
    JsonServiceRequest req = (JsonServiceRequest)ctx_.getRequest();
    final String namespace = req.getNamespace();
    final ServiceComponent cmp = _cmps.get(namespace);
    if (cmp == null) {
      String msg = String.format("No service component found with ns=%s", namespace);
      _logger.info(msg);
      return;
    }


    List<?> params = _jsh.deserialize(req.getServiceArgsJson(), List.class);
    int nbArgs = params.size() +1; // +1 for context arg

    final String serviceName = req.getService();
    final Method serviceMethod = cmp.getService(serviceName, nbArgs);

    if (serviceMethod == null) {
      String msg = String.format("No service=%s found with ns=%s",
          serviceName, namespace);
      _logger.info(msg);
      ctx_.getResponseHandler().addMessage(new Message(0, MessageType.ERROR, msg));
      return;
    }

    try {
      final CommonRequestArgs cr = new CommonRequestArgs();
      cr.setLang(req.getLang());
      cr.setReqId(req.getReqId());
      cr.setSessionId(req.getSessionId());
      cr.setUserId(req.getUserId());
      Context ctx = new Context() {
        @Override
        public ResponseHandler<Object> getResponseHandler() {
          return ctx_.getResponseHandler();
        }
View Full Code Here

  public String serialize(Object args_) {
    return _jsh.serialize(args_);
  }
  protected JsonServiceRequest createRequest(String service_,
      Object serviceArgs_, String userId_, String sessionId_) {
    JsonServiceRequest req = new JsonServiceRequest();
    req.setSessionId(sessionId_);
    req.setReqId("R-" +UUID.randomUUID().toString());
    req.setUserId(userId_);
    req.setNamespace(_namespace);
    req.setService(service_);
    req.setServiceArgsJson(serviceArgs_ instanceof String ?
        (String)serviceArgs_ : serialize(serviceArgs_));

    return req;
  }
View Full Code Here

      final String userId_,
      final String sessionId_,
      final String lang_,
      final ResponseHandler<?> handler_) {

    final JsonServiceRequest jsr = _sc.createRequest(
        "", null, userId_, sessionId_);

    jsr.setLang(lang_);
    Context ctx = new Context() {
      @Override
      public ResponseHandler getResponseHandler() {
        return handler_;
      }
View Full Code Here

        // remove context from args passed to service as json args
        Object[] serviceArgs = new Object[args_.length-1];
        for (int ii=1; ii<args_.length;ii++)
          serviceArgs[ii-1] = args_[ii];

        JsonServiceRequest jsr = (JsonServiceRequest)ctx.getRequest();
        jsr.setService(method_.getName());
        jsr.setServiceArgsJson(_sc.serialize(serviceArgs));

        _sc.call(jsr, ctx.getResponseHandler());

        return null;
      }
View Full Code Here

    _cmps.remove(cmp_.getNamespace());
  }

  @Override
  public void invoke(final Context ctx_) {
    JsonServiceRequest req = (JsonServiceRequest)ctx_.getRequest();
    final String namespace = req.getNamespace();
    final ServiceComponent cmp = _cmps.get(namespace);
    if (cmp == null) {
      String msg = String.format("No service component found with ns=%s", namespace);
      _logger.info(msg);
      return;
    }


    List<?> params = _jsh.deserialize(req.getServiceArgsJson(), List.class);
    int nbArgs = params.size() +1; // +1 for context arg

    final String serviceName = req.getService();
    final Method serviceMethod = cmp.getService(serviceName, nbArgs);

    if (serviceMethod == null) {
      String msg = String.format("No service=%s found with ns=%s",
          serviceName, namespace);
      _logger.info(msg);
      ctx_.getResponseHandler().addMessage(new Message(0, MessageType.ERROR, msg));
      return;
    }

    try {
      final CommonRequestArgs cr = new CommonRequestArgs();
      cr.setLang(req.getLang());
      cr.setReqId(req.getReqId());
      cr.setSessionId(req.getSessionId());
      cr.setUserId(req.getUserId());
      Context ctx = new Context() {
        @Override
        public ResponseHandler<Object> getResponseHandler() {
          return ctx_.getResponseHandler();
        }
View Full Code Here

TOP

Related Classes of org.butor.json.JsonServiceRequest

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.