ObjectName name =
new ObjectName(ClientSessionServiceMXBean.MXBEAN_NAME);
// Ensure the object was registered at startup
ClientSessionServiceMXBean bean = (ClientSessionServiceMXBean)
profileCollector.getRegisteredMBean(
ClientSessionServiceMXBean.MXBEAN_NAME);
assertNotNull(bean);
// Get individual fields
long reg = (Long) mbsc.getAttribute(name,
"AddSessionStatusListenerCalls");
long get = (Long) mbsc.getAttribute(name,
"GetSessionProtocolCalls");
// Create the proxy for the object
ClientSessionServiceMXBean proxy =
JMX.newMXBeanProxy(mbsc, name, ClientSessionServiceMXBean.class);
assertTrue(reg <= proxy.getAddSessionStatusListenerCalls());
assertTrue(get <= proxy.getGetSessionProtocolCalls());
serverNode.getClientSessionService().
getSessionProtocol(new BigInteger("555"));
assertTrue(get < proxy.getGetSessionProtocolCalls());
assertTrue(get < bean.getGetSessionProtocolCalls());
}