<%@page contentType="text/html" import="java.net.*,java.util.*,javax.management.*,javax.management.modelmbean.*, org.jboss.jmx.adaptor.control.Server, org.jboss.jmx.adaptor.control.AttrResultInfo, org.jboss.jmx.adaptor.model.*, org.jdom.output.XMLOutputter, java.lang.reflect.Array" %> <%! XMLOutputter xmlOutput = new XMLOutputter(); String sep = System.getProperty("line.separator", "\n"); public String fixDescription(String desc) { if (desc == null || desc.equals("")) { return "(no description)"; } return desc; } public String fixValue(Object value) { if (value == null) return null; String s = String.valueOf(value); return xmlOutput.escapeElementEntities(s); } public String fixValueForAttribute(Object value) { if (value == null) return null; String s = String.valueOf(value); return xmlOutput.escapeAttributeEntities(s); } %> MBean Inspector <% ObjectName objectName = mbeanData.getObjectName(); String objectNameString = mbeanData.getName(); MBeanInfo mbeanInfo = mbeanData.getMetaData(); MBeanAttributeInfo[] attributeInfo = mbeanInfo.getAttributes(); MBeanOperationInfo[] operationInfo = mbeanInfo.getOperations(); %>

JMX MBean View

<% Hashtable properties = objectName.getKeyPropertyList(); int size = properties.keySet().size(); %> <% Iterator it = properties.keySet().iterator(); while( it.hasNext() ) { String key = (String) it.next(); String value = (String) properties.get( key ); %> <% } %>
Name Domain <%= objectName.getDomain() %>
<%= key %> <%= value %>
Java Class
Description <%= fixDescription(mbeanInfo.getDescription())%>

Back to Agent ViewRefresh MBean View

<% boolean hasWriteable = false; for(int a = 0; a < attributeInfo.length; a ++) { MBeanAttributeInfo attrInfo = attributeInfo[a]; String attrName = attrInfo.getName(); String attrType = attrInfo.getType(); AttrResultInfo attrResult = Server.getMBeanAttributeResultInfo(objectNameString, attrInfo); String attrValue = attrResult.getAsText(); String access = ""; if( attrInfo.isReadable() ) access += "R"; if( attrInfo.isWritable() ) { access += "W"; hasWriteable = true; } String attrDescription = fixDescription(attrInfo.getDescription()); %> <% } %> <% if( hasWriteable ) { %> <% } %>
Attribute Name (Access)
Type
Description
Attribute Value
<%= attrName %> (<%= access %>)
<%= attrType %>
<%= attrDescription %>
<% if( attrInfo.isWritable() ) { String readonly = attrResult.editor == null ? "readonly='readonly'" : ""; if( attrType.equals("boolean") || attrType.equals("java.lang.Boolean") ) { // Boolean true/false radio boxes Boolean value = Boolean.valueOf(attrValue); String trueChecked = (value == Boolean.TRUE ? "checked='checked'" : ""); String falseChecked = (value == Boolean.FALSE ? "checked='checked'" : ""); %> />True />False <% } else if( attrInfo.isReadable() ) { // Text fields for read-write string values attrValue = fixValueForAttribute(attrValue); if (String.valueOf(attrValue).indexOf(sep) == -1) { %> /> <% } else { %> <% } } else { // Empty text fields for write-only %> /> <% } } else { if( attrType.equals("[Ljavax.management.ObjectName;") ) { // Array of Object Names ObjectName[] names = (ObjectName[]) Server.getMBeanAttributeObject(objectNameString, attrName); if( names != null ) { %> <% for( int i = 0; i < names.length; i++ ) { %> "><%= ( names[ i ] + "" ) %>
<% } } } // Array of some objects else if( attrType.startsWith("[")) { Object arrayObject = Server.getMBeanAttributeObject(objectNameString, attrName); if (arrayObject != null) { out.print("
");
               for (int i = 0; i < Array.getLength(arrayObject); ++i) {
                  out.println(fixValue(Array.get(arrayObject,i)));
               }
               out.print("
"); } } else { // Just the value string %>
<%= fixValue(attrValue) %>
<% } } if( attrType.equals("javax.management.ObjectName") ) { // Add a link to the mbean if( attrValue != null ) { %>
View MBean <% } } %>

<% if (operationInfo.length > 0) { %> <% for(int a = 0; a < operationInfo.length; a ++) { MBeanOperationInfo opInfo = operationInfo[a]; boolean accept = true; if (opInfo instanceof ModelMBeanOperationInfo) { Descriptor desc = ((ModelMBeanOperationInfo)opInfo).getDescriptor(); String role = (String)desc.getFieldValue("role"); if ("getter".equals(role) || "setter".equals(role)) { accept = false; } } if (accept) { MBeanParameterInfo[] sig = opInfo.getSignature(); %> <% } // mbean operation } // all mbean operations %>
Operation Name
Return Type
Description
Parameters
<%= opInfo.getName() %>
<%= opInfo.getReturnType() %>
<%= fixDescription(opInfo.getDescription())%>
<% if( sig.length > 0 ) { %> <% for(int p = 0; p < sig.length; p ++) { MBeanParameterInfo paramInfo = sig[p]; String pname = paramInfo.getName(); String ptype = paramInfo.getType(); if( pname == null || pname.length() == 0 || pname.equals(ptype) ) { pname = "arg"+p; } String pdesc = fixDescription(paramInfo.getDescription()); %> <% } // parameter list %>
<%= pname %>
<%= ptype %>
<%= pdesc %>
<% if( ptype.equals("boolean") || ptype.equals("java.lang.Boolean") ) { // Boolean true/false radio boxes %> True False <% } else { %> <% } %>
<% } // has parameter list %>
<% } // has mbean operation %>