I implement the servlet as a JMX manager that runs on the same Tomcat instance as all monitored servlets. I can see the data of controlled servlets when opening JConsole. From my servlet manager, I can list all the available standard MBeans, including the ones that I created in controlled servlets, using this code as follows:
JMXServiceURL url = new JMXServiceURL( "service:jmx:rmi://localhost:1099/jndi/rmi://localhost:1099/jmxrmi" ); mConnector = JMXConnectorFactory.connect( url ); mMBSC = mConnector.getMBeanServerConnection(); mObjectName = new ObjectName( "com.blahCompany.blah.blah:type=BlahBlah" ); // just looking for one specific bean Set<ObjectName> myMbean = mMBSC.queryNames( mObjectName, null ); if( myMBean.size() == 1 ) // I know it exists { MBeanInfo mbeanInfo = mMBSC.getMBeanInfo( <ObjectName extracted from Set> ); MBeanAttributeInfo[] mbeanAttributeInfos = mbeanInfo.getAttributes(); for( MBeanAttributeInfo attribInfo : mbeanAttributeInfos ) { if( attribInfo.isReadable() ) { String attribName = attribInfo.getName(); String attribReturnType = attribInfo.getType(); // The data somewhere ... where???? // In the MBeanInfo? // In the MBeanAttributeInfo?? } } }
The problem is that I do not know how to extract data from these MBeans. The answer should be obvious, because no one seems to be asking, but I have a gift to ignore the obvious. Your help would be greatly appreciated.
Bill
source share