Examples of JSONAware


Examples of org.json.simple.JSONAware

    }

    /** {@inheritDoc} */
    @Override
    public Object convertToObject(ArrayType type, Object pFrom) {
        JSONAware value = toJSON(pFrom);
        // prepare each value in the array and then process the array of values
        if (!(value instanceof JSONArray)) {
            throw new IllegalArgumentException(
                    "Can not convert " + value + " to type " +
                    type + " because JSON object type " + value.getClass() + " is not a JSONArray");

        }

        JSONArray jsonArray = (JSONArray) value;
        OpenType elementOpenType = type.getElementOpenType();
View Full Code Here

Examples of org.json.simple.JSONAware

        }
    }

    @SuppressWarnings({ "PMD.AvoidCatchingThrowable", "PMD.AvoidInstanceofChecksInCatchClause" })
    private void handle(ServletRequestHandler pReqHandler,HttpServletRequest pReq, HttpServletResponse pResp) throws IOException {
        JSONAware json = null;
        try {
            // Check access policy
            requestHandler.checkAccess(pReq.getRemoteHost(), pReq.getRemoteAddr(),
                                       getOriginOrReferer(pReq));

            // Remember the agent URL upon the first request. Needed for discovery
            updateAgentUrlIfNeeded(pReq);

            // Dispatch for the proper HTTP request method
            json = handleSecurely(pReqHandler, pReq, pResp);
        } catch (Throwable exp) {
            json = requestHandler.handleThrowable(
                    exp instanceof RuntimeMBeanException ? ((RuntimeMBeanException) exp).getTargetException() : exp);
        } finally {
            setCorsHeader(pReq, pResp);

            String callback = pReq.getParameter(ConfigKey.CALLBACK.getKeyValue());
            String answer = json != null ?
                    json.toJSONString() :
                    requestHandler.handleThrowable(new Exception("Internal error while handling an exception")).toJSONString();
            if (callback != null) {
                // Send a JSONP response
                sendResponse(pResp, "text/javascript", callback + "(" + answer + ");");
            } else {
View Full Code Here

Examples of org.json.simple.JSONAware

    public void doHandle(HttpExchange pExchange) throws IOException {
        if (requestHandler == null) {
            throw new IllegalStateException("Handler not yet started");
        }

        JSONAware json = null;
        URI uri = pExchange.getRequestURI();
        ParsedUri parsedUri = new ParsedUri(uri,context);
        try {
            // Check access policy
            InetSocketAddress address = pExchange.getRemoteAddress();
View Full Code Here

Examples of org.json.simple.JSONAware

  public int dispatch(final RequestAndResponse req) {
    return runWithContextClassLoader(new PrivilegedAction<Integer>() {
      public Integer run() {
        int returnCode = 200;
        JSONAware json = null;
        try {
          switch (req.getMode()) {
          case RequestAndResponse.GET_REQUEST:
            json = handler.handleGetRequest(req.getUri(),
                req.getPath(), req.getParameters());
            break;
          case RequestAndResponse.POST_REQUEST:
            json = handler.handlePostRequest(req.getUri(),
                new ByteArrayInputStream(req.getBody()),
                req.getEncoding(), req.getParameters());

            break;
          }
        } catch (Throwable exp) {
          json = handler
              .handleThrowable(exp instanceof RuntimeMBeanException ? ((RuntimeMBeanException) exp)
                  .getTargetException() : exp);
        } finally {
          String callback = req.getParameter(ConfigKey.CALLBACK
              .getKeyValue());
          String answer = json != null ? json.toJSONString()
              : handler
                  .handleThrowable(
                      new Exception(
                          "Internal error while handling an exception"))
                  .toJSONString();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.