Package com.google.gson

Examples of com.google.gson.Gson$FutureTypeAdapter


    instance.getJmxAdapter().resumeJob(instance, instance.getSchedulerByName(job.getSchedulerName()), job);
   
    Result result = new Result();
    result.setMessage("Job已恢复");
    result.setCallbackType("");
    JsonUtil.toJson(new Gson().toJson(result));
    return null;
  }
View Full Code Here


    log.info("add job successfully!");
   
    Result result = new Result();
    result.setMessage("添加成功");
    result.setCallbackType("");
    JsonUtil.toJson(new Gson().toJson(result));
    return null;
  }
View Full Code Here

        return e.getAsString();
    }

    private static String encode (Map<String, Object> m) {
        try {
            Gson gson;
            final GsonBuilder builder = new GsonBuilder();
            builder.registerTypeAdapterFactory(new EnumAdaptorFactory());
            builder.registerTypeAdapter(Date.class, new DateAdapter());
            builder.registerTypeAdapter(File.class, new FileAdapter());
            builder.enableComplexMapKeySerialization();
            builder.setPrettyPrinting();
            gson = builder.create();
            return gson.toJson(m);
        } catch (Exception e) {
            Logger.logError("Error encoding Authlib JSON", e);
            return null;
        }
View Full Code Here

    }

    void process(Class<? extends BatchDescription> description) throws IOException {
        LOG.info("Extracting metadata: {}", description.getName());
        BatchSpec spec = toSpec(description);
        Gson gson = new GsonBuilder()
            .setPrettyPrinting()
            .create();

        OutputStream output = getEnvironment().openResource(Constants.PATH);
        try {
            Writer writer = new OutputStreamWriter(output, Constants.ENCODING);
            gson.toJson(spec, BatchSpec.class, writer);
            writer.close();
        } finally {
            output.close();
        }

        if (LOG.isDebugEnabled()) {
            LOG.debug("{} => {}", description.getName(), gson.toJson(spec, BatchSpec.class));
        }
    }
View Full Code Here

        result.initialize(env);
        return result;
    }

    private BatchSpec load(File file) throws IOException {
        Gson gson = new Gson();
        InputStream in = new FileInputStream(file);
        try {
            Reader reader = new InputStreamReader(in, Constants.ENCODING);
            BatchSpec result = gson.fromJson(reader, BatchSpec.class);
            reader.close();
            return result;
        } finally {
            in.close();
        }
View Full Code Here

    }

    private static void explainBatch(BatchScript script) throws IOException {
        assert script != null;
        JsonObject batch = analyzeBatch(script);
        Gson gson = new GsonBuilder()
            .disableHtmlEscaping()
            .setPrettyPrinting()
            .create();
        Writer writer = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
        gson.toJson(batch, writer);
        writer.flush();
    }
View Full Code Here

        @Override
        public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
            response.setStatusCode(200);
            response.setEntity(new StringEntity(
                    new Gson().toJson(responseElement).toString(), HttpJobClient.CONTENT_TYPE));
            if (request instanceof HttpEntityEnclosingRequest) {
                HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
                String content = EntityUtils.toString(entity, "UTF-8");
                JsonElement element = parse(content);
                if (element instanceof JsonObject) {
View Full Code Here

            response.setStatusCode(status);
            if (code != null) {
                JsonObject object = new JsonObject();
                object.addProperty("error", code);
                object.addProperty("message", code);
                response.setEntity(new StringEntity(new Gson().toJson(object).toString(), HttpJobClient.CONTENT_TYPE));
            }
            if (request instanceof HttpEntityEnclosingRequest) {
                HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
                String content = EntityUtils.toString(entity, "UTF-8");
                JsonElement element = parse(content);
View Full Code Here

        try {
            final HttpClient client = clientFor(url);
            final PostMethod post = new PostMethod(url.toString());
            post.setDoAuthentication(true);
            post.setRequestHeader("Accept", "application/json;stream=true");
            final Gson gson = new Gson();
            final String postData = gson.toJson(data);
            post.setRequestEntity(new StringRequestEntity(postData, "application/json", "UTF-8"));
            final int status = client.executeMethod(post);
            if (status != 200) throw new RuntimeException("Return Status Code "+post.getStatusCode()+" "+post.getStatusLine());
            return gson.fromJson(post.getResponseBodyAsString(), resultType);
        } catch (Exception e) {
            throw new RuntimeException("Error executing request to "+url+" with "+data+":" + e.getMessage());
        }
    }
View Full Code Here

    public void init() {
        SessionService.setDatabaseInfo(ConsoleFilter.getDatabase());
        consoleService = new ConsoleService();
        post(new spark.Route("r/share") {
            public Object handle(Request request, Response response) {
                final Map input = new Gson().fromJson(request.body(), Map.class);
                return consoleService.share(request, input);
            }
        });
        get(new spark.Route("r/*") {
            public Object handle(Request request, Response response) {
View Full Code Here

TOP

Related Classes of com.google.gson.Gson$FutureTypeAdapter

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.