Database Reference
In-Depth Information
Just to give you some ideas about servlets' implementation in conjunction with another
tool, keep in mind that different log aggregators have different MEPs around the data
flow; for instance, Nagios is generally a puller, so you can even consider converting
Steven's JMX Servlet into a REST service by providing MBean attributes as JSON or
XML. Initially, the proposed servlet has two main parts. The first one is the abstract where
all operations are declared, including the main one, that is, service:
public abstract class AbstractStatsServlet extends
HttpServlet
public void service( HttpServletRequest req,
HttpServletResponse res ) throws ServletException
MBeanServer server = ( MBeanServer )this.ctx.getAttribute(
"mbean-server" );
// Ask the Servlet instance for the root of the document
Element root = this.getPerformanceRoot( server, objectNames
);
// Dump the MBean info
Element mbeans = new Element( "mbeans" );
for( Iterator i=objectNames.keySet().iterator();
i.hasNext(); ) {
String key = ( String )i.next();
Element domain = new Element( "domain" );
domain.setAttribute( "name", key );
Map typeNames = ( Map )objectNames.get( key );
for( Iterator j=typeNames.keySet().iterator(); j.hasNext();
){
String typeName = ( String )j.next();
Element typeElement = new Element( "type" );
typeElement.setAttribute( "name", typeName );
List beans = ( List )typeNames.get( typeName );
for( Iterator k=beans.iterator(); k.hasNext(); ) {
ObjectName on = ( ObjectName )k.next();
Element bean = new Element( "mbean" );
bean.setAttribute( "name", on.getCanonicalName() );
// List the attributes
if( showAttributes ){
try {
MBeanInfo info = server.getMBeanInfo( on );
Element attributesElement = new Element( "attributes" );
Search WWH ::




Custom Search