Database Reference
In-Depth Information
MBeanAttributeInfo[] attributeArray = info.getAttributes();
for( int x=0; x<attributeArray.length; x++ ) {
String attributeClass = attributeArray[ x ].getType();
//set XML attributes for class: is-getter, readable,
writable
attributeElement.setAttribute( "description",
attributeArray[ x ].getDescription() );
// Output the XML document to the caller
XMLOutputter out = new XMLOutputter( );
out.output( root, res.getOutputStream() );
......
}
The result is the creation of a complete DOM document with your MBean's attributes tree.
Using domain keys and attribute names, you can filter it or just construct the required part.
This abstract class is extended by the JMX statistic servlet; this is where you connect to
your server and gather statistics:
public class StatsServlet extends AbstractStatsServlet
....
String config = getServletContext().getResource("/
WEB-INF/xml/stats.xml").toString();
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build( config );
Element root = doc.getRootElement();
Element adminServer = root.getChild( " admin-server " );
String port = adminServer.getAttributeValue( "port" );
url = "t3://localhost:" + port;
username = adminServer.getAttributeValue( "username"
);
password = adminServer.getAttributeValue( "password"
);
As you can see from Steven Haines' code, the connection is established with the admin
server to acquire information from runtime servers. The direct connection to manage a
server bean, as depicted in the earlier figure, is not advisable.
Search WWH ::




Custom Search