List of utility methods to do MBean
void | dumpOperations(MBeanOperationInfo[] operations) dump Operations System.out.println(""); System.out.println("Operations:"); for (int i = 0; i < operations.length; i++) { StringBuffer dump = new StringBuffer(); MBeanOperationInfo operation = operations[i]; dump.append("name=").append(operation.getName()); dump.append(",impact=").append(decodeImpact(operation.getImpact())); dump.append(",returnType=").append(operation.getReturnType()); ... |
MBeanAttributeInfo | findAttribute(MBeanAttributeInfo[] attributes, String name) find Attribute for (int i = 0; i < attributes.length; i++) { if (attributes[i].getName().equals(name)) { return attributes[i]; return null; |
MBeanServer | findFirstMBeanServer() Retrieve the first MBeanServer found. return findMBeanServerForAgentId(null);
|
ObjectName | findMBean(MBeanServer mbs, ObjectName queryName) find M Bean Iterator<ObjectName> it = mbs.queryNames(queryName, null).iterator(); if (it.hasNext()) { ObjectName name = it.next(); if (it.hasNext()) { throw new JMException("Found more than one MBean matching " + queryName); } else { return name; } else { throw new JMException("Failed to locate " + queryName); |
ArrayList | findMBeanServer(String agentId) Return a list of registered MBeanServers. return MBeanServerFactory.findMBeanServer(agentId);
|
MBeanServer | findMBeanServerForAgentId(String agentId) Find a MBeanServer given an agent id. List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(agentId); if (servers == null || servers.isEmpty()) { return null; return servers.get(0); |
MBeanAttributeInfo | getAttribute(MBeanInfo info, String attrName) Returns the attribute with the specified name. MBeanAttributeInfo[] attrs = info.getAttributes(); for (int i = 0; i < attrs.length; i++) { if (attrs[i].getName().equals(attrName)) return attrs[i]; return null; |
Object | getAttribute(MBeanServer mbeanServer, ObjectName objectName, String attributeName) get Attribute try { return mbeanServer.getAttribute(objectName, attributeName); } catch (AttributeNotFoundException nsa) { return null; } catch (Exception ex) { throw new RuntimeException(String.format("failed to retrieve attribute '%s' from objectName '%s'", attributeName, objectName), ex); |
T | getAttribute(MBeanServerConnection connection, ObjectName objectName, String attribute) get Attribute return (T) connection.getAttribute(objectName, attribute);
|
Object | getAttribute(ObjectName on, MBeanServerConnection server, String name) Gets an attribute value from an mbean. try { return server.getAttribute(on, name); } catch (Exception e) { throw new RuntimeException("Failed to get attribute", e); |