I want to show performance statistics for particular request type. When Controller class gets the HTTP Request from browser, it then marshals request xml in to a request object. From request object I can get request type.
Is it possible to inject JMX MBeans for particular request type and broadcast it to JConsole?
Is it possible to inject JMX MBeans for particular request type and broadcast it to JConsole?
Jconsole does polling of statistics and you can't "broadcast" a request type that you define since that class won't be in the Jconsole jar.
What you can do is keep a count of the request types in a map and then return a String[]
of type -> count
string output if you like. Something like:
public String[] getResultTypeCount() {
List<String> list = new ArrayList<String>();
for (Map.Entry<String, Integer> entry : typeMap.entrySet()) {
list.add(entry.getKey() + " => " + entry.getValue());
}
return list.toArray(new String[list.size()]);
}
You might want to look into JMX notifications.