<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.management.*" %>
<%@ page import="javax.management.remote.*" %>
<%@page contentType="text/html;charset=UTF-8"%><HTML>
<HEAD>
<TITLE>JMX Dump</TITLE>
</HEAD>
<BODY>
<%
// Environment map
//
out.println("<br>Initialize the environment map");
HashMap env = new HashMap();
// Provide the credentials required by the server to successfully
// perform user authentication
//
String[] credentials = new String[] { "admin" , "adminadmin" };
env.put("jmx.remote.credentials", credentials);
// Create an RMI connector client and
// connect it to the RMI connector server
//
out.println("<br>Create an RMI connector client and "
+ "connect it to the RMI connector server");
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:38688/management/rmi-jmx-connector");
JMXConnector jmxc = JMXConnectorFactory.connect(url, env);
// Get an MBeanServerConnection
//
out.println("<br>Get an MBeanServerConnection");
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
// Get Servlet MBean
ObjectName on = new ObjectName("com.sun.appserv:j2eeType=Servlet,*");
Set mbeans = mbsc.queryMBeans(on, null);
Iterator iter = mbeans.iterator();
while(iter.hasNext()) {
ObjectInstance oi = (ObjectInstance)iter.next();
ObjectName objectName = oi.getObjectName();
out.println("<br>ObjectName: " + objectName);
MBeanInfo mi = mbsc.getMBeanInfo(objectName);
MBeanAttributeInfo[] mais = mi.getAttributes();
for(int i=0; i<mais.length; i++) {
MBeanAttributeInfo mai = mais[i];
String attributeName = mai.getName();
Object value = mbsc.getAttribute(objectName, attributeName);
out.println("<br> " + attributeName + "=" + value);
}
}
// Close MBeanServer connection
//
out.println("<br>Close the connection to the server");
jmxc.close();
%>
</BODY>
</HTML>