Search in sources :

Example 1 with JmxMBeanRepresentation

use of org.neo4j.server.rest.management.repr.JmxMBeanRepresentation in project neo4j by neo4j.

the class JmxService method queryBeans.

@POST
@Consumes(MediaType.APPLICATION_JSON)
@Path(QUERY_PATH)
@SuppressWarnings("unchecked")
public Response queryBeans(String query) {
    try {
        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
        String json = dodgeStartingUnicodeMarker(query);
        Collection<Object> queries = (Collection<Object>) JsonHelper.readJson(json);
        ArrayList<JmxMBeanRepresentation> beans = new ArrayList<JmxMBeanRepresentation>();
        for (Object queryObj : queries) {
            assert queryObj instanceof String;
            for (Object objName : server.queryNames(new ObjectName((String) queryObj), null)) {
                beans.add(new JmxMBeanRepresentation((ObjectName) objName));
            }
        }
        return output.ok(new ListRepresentation("jmxBean", beans));
    } catch (JsonParseException e) {
        return output.badRequest(e);
    } catch (MalformedObjectNameException e) {
        return output.badRequest(e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) ArrayList(java.util.ArrayList) Collection(java.util.Collection) JmxMBeanRepresentation(org.neo4j.server.rest.management.repr.JmxMBeanRepresentation) JsonParseException(org.neo4j.server.rest.domain.JsonParseException) ListRepresentation(org.neo4j.server.rest.repr.ListRepresentation) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 2 with JmxMBeanRepresentation

use of org.neo4j.server.rest.management.repr.JmxMBeanRepresentation in project neo4j by neo4j.

the class JmxService method getBean.

@GET
@Path(BEAN_TEMPLATE)
public Response getBean(@PathParam("domain") String domainName, @PathParam("objectName") String objectName) {
    MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    ArrayList<JmxMBeanRepresentation> beans = new ArrayList<JmxMBeanRepresentation>();
    for (Object objName : server.queryNames(createObjectName(domainName, objectName), null)) {
        beans.add(new JmxMBeanRepresentation((ObjectName) objName));
    }
    return output.ok(new ListRepresentation("bean", beans));
}
Also used : ArrayList(java.util.ArrayList) JmxMBeanRepresentation(org.neo4j.server.rest.management.repr.JmxMBeanRepresentation) ListRepresentation(org.neo4j.server.rest.repr.ListRepresentation) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

ArrayList (java.util.ArrayList)2 MBeanServer (javax.management.MBeanServer)2 ObjectName (javax.management.ObjectName)2 Path (javax.ws.rs.Path)2 JmxMBeanRepresentation (org.neo4j.server.rest.management.repr.JmxMBeanRepresentation)2 ListRepresentation (org.neo4j.server.rest.repr.ListRepresentation)2 Collection (java.util.Collection)1 MalformedObjectNameException (javax.management.MalformedObjectNameException)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1 JsonParseException (org.neo4j.server.rest.domain.JsonParseException)1