}
@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));
}
}