Package one.nio.http

Examples of one.nio.http.Response


    }

    @Path("/jmx")
    public Response getJmxResponse(@Param("name") String name, @Param("prop=") String prop, @Param("attr") String attr) {
        if (name == null) {
            return new Response(Response.BAD_REQUEST, Response.EMPTY);
        }

        try {
            Set<ObjectName> objNames = Management.resolvePattern(name);
            StringBuilder result = new StringBuilder();

            for (ObjectName objName : objNames) {
                result.append(objName.toString());
                if (prop != null) {
                    for (String property : prop.split(",")) {
                        result.append('\t').append(objName.getKeyProperty(property));
                    }
                }
                if (attr != null) {
                    for (Object value : Management.getAttributes(objName, attr.split(","))) {
                        result.append('\t').append(value);
                    }
                }
                result.append("\r\n");
            }

            return Response.ok(result.toString());
        } catch (JMException e) {
            String errorMessage = e.toString() + "\r\n";
            return new Response(Response.INTERNAL_ERROR, Utf8.toBytes(errorMessage));
        }
    }
View Full Code Here


        this.available = new AtomicBoolean(true);
        this.failures = new AtomicInteger();
    }

    public String invoke(Request request) throws Exception {
        Response response = client.invoke(request);
        if (response.getStatus() != 200) {
            throw new IOException(this + " call failed with status " + response.getHeaders()[0]);
        }
        if (response.getBody() == null) {
            throw new IOException(this + " returned empty body");
        }
        return new String(response.getBody(), UTF8);
    }
View Full Code Here

        return available.get();
    }

    @Override
    public boolean check() throws Exception {
        Response response = client.head("/");
        if (response.getStatus() >= 500) {
            throw new IOException(this + " check failed with status " + response.getHeaders()[0]);
        }
        return true;
    }
View Full Code Here

TOP

Related Classes of one.nio.http.Response

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.