Java Code Examples for javax.management.MBeanAttributeInfo#getName()
The following examples show how to use
javax.management.MBeanAttributeInfo#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OldMBeanServerTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private static void printAttrs( MBeanServerConnection mbsc1, Class<? extends Exception> expectX) throws Exception { Set<ObjectName> names = mbsc1.queryNames(null, null); for (ObjectName name : names) { System.out.println(name + ":"); MBeanInfo mbi = mbsc1.getMBeanInfo(name); MBeanAttributeInfo[] mbais = mbi.getAttributes(); for (MBeanAttributeInfo mbai : mbais) { String attr = mbai.getName(); Object value; try { value = mbsc1.getAttribute(name, attr); } catch (Exception e) { if (expectX != null && expectX.isInstance(e)) value = "<" + e + ">"; else throw e; } String s = " " + attr + " = " + value; if (s.length() > 80) s = s.substring(0, 77) + "..."; System.out.println(s); } } }
Example 2
Source File: OldMBeanServerTest.java From hottub with GNU General Public License v2.0 | 6 votes |
private static void printAttrs( MBeanServerConnection mbsc1, Class<? extends Exception> expectX) throws Exception { Set<ObjectName> names = mbsc1.queryNames(null, null); for (ObjectName name : names) { System.out.println(name + ":"); MBeanInfo mbi = mbsc1.getMBeanInfo(name); MBeanAttributeInfo[] mbais = mbi.getAttributes(); for (MBeanAttributeInfo mbai : mbais) { String attr = mbai.getName(); Object value; try { value = mbsc1.getAttribute(name, attr); } catch (Exception e) { if (expectX != null && expectX.isInstance(e)) value = "<" + e + ">"; else throw e; } String s = " " + attr + " = " + value; if (s.length() > 80) s = s.substring(0, 77) + "..."; System.out.println(s); } } }
Example 3
Source File: OldMBeanServerTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static void printAttrs( MBeanServerConnection mbsc1, Class<? extends Exception> expectX) throws Exception { Set<ObjectName> names = mbsc1.queryNames(null, null); for (ObjectName name : names) { System.out.println(name + ":"); MBeanInfo mbi = mbsc1.getMBeanInfo(name); MBeanAttributeInfo[] mbais = mbi.getAttributes(); for (MBeanAttributeInfo mbai : mbais) { String attr = mbai.getName(); Object value; try { value = mbsc1.getAttribute(name, attr); } catch (Exception e) { if (expectX != null && expectX.isInstance(e)) value = "<" + e + ">"; else throw e; } String s = " " + attr + " = " + value; if (s.length() > 80) s = s.substring(0, 77) + "..."; System.out.println(s); } } }
Example 4
Source File: OldMBeanServerTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private static void printAttrs( MBeanServerConnection mbsc1, Class<? extends Exception> expectX) throws Exception { Set<ObjectName> names = mbsc1.queryNames(null, null); for (ObjectName name : names) { System.out.println(name + ":"); MBeanInfo mbi = mbsc1.getMBeanInfo(name); MBeanAttributeInfo[] mbais = mbi.getAttributes(); for (MBeanAttributeInfo mbai : mbais) { String attr = mbai.getName(); Object value; try { value = mbsc1.getAttribute(name, attr); } catch (Exception e) { if (expectX != null && expectX.isInstance(e)) value = "<" + e + ">"; else throw e; } String s = " " + attr + " = " + value; if (s.length() > 80) s = s.substring(0, 77) + "..."; System.out.println(s); } } }
Example 5
Source File: OldMBeanServerTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static void printAttrs( MBeanServerConnection mbsc1, Class<? extends Exception> expectX) throws Exception { Set<ObjectName> names = mbsc1.queryNames(null, null); for (ObjectName name : names) { System.out.println(name + ":"); MBeanInfo mbi = mbsc1.getMBeanInfo(name); MBeanAttributeInfo[] mbais = mbi.getAttributes(); for (MBeanAttributeInfo mbai : mbais) { String attr = mbai.getName(); Object value; try { value = mbsc1.getAttribute(name, attr); } catch (Exception e) { if (expectX != null && expectX.isInstance(e)) value = "<" + e + ">"; else throw e; } String s = " " + attr + " = " + value; if (s.length() > 80) s = s.substring(0, 77) + "..."; System.out.println(s); } } }
Example 6
Source File: OldMBeanServerTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void printAttrs( MBeanServerConnection mbsc1, Class<? extends Exception> expectX) throws Exception { Set<ObjectName> names = mbsc1.queryNames(null, null); for (ObjectName name : names) { System.out.println(name + ":"); MBeanInfo mbi = mbsc1.getMBeanInfo(name); MBeanAttributeInfo[] mbais = mbi.getAttributes(); for (MBeanAttributeInfo mbai : mbais) { String attr = mbai.getName(); Object value; try { value = mbsc1.getAttribute(name, attr); } catch (Exception e) { if (expectX != null && expectX.isInstance(e)) value = "<" + e + ">"; else throw e; } String s = " " + attr + " = " + value; if (s.length() > 80) s = s.substring(0, 77) + "..."; System.out.println(s); } } }
Example 7
Source File: SuppliedMBeanAttribute.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
public SuppliedMBeanAttribute(final MBeanAttributeInfo info, final Supplier supplier) { this.info = checkNotNull(info); this.name = info.getName(); this.supplier = checkNotNull(supplier); }
Example 8
Source File: JmxSupport.java From visualvm with GNU General Public License v2.0 | 5 votes |
boolean hasProcessCPUTimeAttribute() { synchronized (processCPUTimeAttributeLock) { if (processCPUTimeAttribute != null) { return processCPUTimeAttribute.booleanValue(); } processCPUTimeAttribute = Boolean.FALSE; JmxModel jmx = JmxModelFactory.getJmxModelFor(application); if (jmx != null && jmx.getConnectionState().equals(ConnectionState.CONNECTED)) { MBeanServerConnection conn = jmx.getMBeanServerConnection(); if (conn != null) { try { MBeanInfo info = conn.getMBeanInfo(osName); MBeanAttributeInfo[] attrs = info.getAttributes(); processCPUTimeMultiplier = 1; for (MBeanAttributeInfo attr : attrs) { String name = attr.getName(); if (PROCESS_CPU_TIME_ATTR.equals(name)) { processCPUTimeAttribute = Boolean.TRUE; } if (PROCESSING_CAPACITY_ATTR.equals(name)) { Number mul = (Number) conn.getAttribute(osName,PROCESSING_CAPACITY_ATTR); processCPUTimeMultiplier = mul.longValue(); } } } catch (Exception ex) { LOGGER.throwing(JmxSupport.class.getName(), "hasProcessCPUTimeAttribute", ex); // NOI18N } } } return processCPUTimeAttribute.booleanValue(); } }
Example 9
Source File: RRDDataStore.java From scheduling with GNU Affero General Public License v3.0 | 5 votes |
/** * Initializes a new RRD data base if it's not exist. * * @param mbean is the source of chronological data * @param dataBaseFilePath is the path to the file with the rrd data base * @param step is the data base refresh period * @throws IOException is thrown when the data base exists but cannot be read */ public RRDDataStore(StandardMBean mbean, String dataBaseFilePath, int step, Logger logger) throws IOException { this(dataBaseFilePath, step, logger); this.mbean = mbean; for (MBeanAttributeInfo attrInfo : mbean.getMBeanInfo().getAttributes()) { try { if (attrInfo.isReadable() && mbean.getClass().getMethod("get" + attrInfo.getName()).getAnnotation(Chronological.class) != null) { String sourceName = attrInfo.getName(); if (sourceName.length() > 20) { // only 20 symbols allowed in data source name sourceName = sourceName.substring(0, 19); } dataSources.put(sourceName, attrInfo.getName()); } } catch (Exception e) { logger.error(e.getMessage(), e); } } initDatabase(); setName("RRD4J Data Store " + new File(dataBaseFilePath).getName()); setDaemon(true); start(); }
Example 10
Source File: MemoryUsageDeserializer.java From streams with Apache License 2.0 | 5 votes |
@Override public MemoryUsageBroadcast deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { try { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); MemoryUsageBroadcast memoryUsageBroadcast = new MemoryUsageBroadcast(); JsonNode attributes = jsonParser.getCodec().readTree(jsonParser); ObjectName name = new ObjectName(attributes.get("canonicalName").asText()); MBeanInfo info = server.getMBeanInfo(name); memoryUsageBroadcast.setName(name.toString()); for (MBeanAttributeInfo attribute : Arrays.asList(info.getAttributes())) { switch (attribute.getName()) { case "Verbose": memoryUsageBroadcast.setVerbose((boolean) server.getAttribute(name, attribute.getName())); break; case "ObjectPendingFinalizationCount": memoryUsageBroadcast.setObjectPendingFinalizationCount(Long.parseLong(server.getAttribute(name, attribute.getName()).toString())); break; case "HeapMemoryUsage": memoryUsageBroadcast.setHeapMemoryUsage((Long) ((CompositeDataSupport)server.getAttribute(name, attribute.getName())).get("used")); break; case "NonHeapMemoryUsage": memoryUsageBroadcast.setNonHeapMemoryUsage((Long) ((CompositeDataSupport)server.getAttribute(name, attribute.getName())).get("used")); break; default: break; } } return memoryUsageBroadcast; } catch (Exception ex) { LOGGER.error("Exception trying to deserialize MemoryUsageDeserializer object: {}", ex); return null; } }
Example 11
Source File: JMXDataSourceTest.java From tomee with Apache License 2.0 | 5 votes |
private Map<String, Object> getDatasourceJmxMap() throws MalformedObjectNameException, InstanceNotFoundException, IntrospectionException, ReflectionException, MBeanException, AttributeNotFoundException { final ObjectName on = new ObjectName("openejb.management:ObjectType=datasources,DataSource=JMXDataSourceTest"); final MBeanInfo mBeanInfo = ManagementFactory.getPlatformMBeanServer().getMBeanInfo(on); assertNotNull(mBeanInfo); final Map<String, Object> map = new HashMap<>(); for (final MBeanAttributeInfo mBeanAttributeInfo : mBeanInfo.getAttributes()) { final String name = mBeanAttributeInfo.getName(); final Object value = ManagementFactory.getPlatformMBeanServer().getAttribute(on, name); map.put(name, value); } return map; }
Example 12
Source File: TypeNameTest.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { TestMXBean testImpl = (TestMXBean) Proxy.newProxyInstance( TestMXBean.class.getClassLoader(), new Class<?>[] {TestMXBean.class}, nullIH); Object mxbean = new StandardMBean(testImpl, TestMXBean.class, true); MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName name = new ObjectName("a:b=c"); mbs.registerMBean(mxbean, name); MBeanInfo mbi = mbs.getMBeanInfo(name); MBeanAttributeInfo[] mbais = mbi.getAttributes(); boolean sawTabular = false; for (MBeanAttributeInfo mbai : mbais) { String attrName = mbai.getName(); String attrTypeName = (String) mbai.getDescriptor().getFieldValue("originalType"); String fieldName = attrName + "Name"; Field nameField = TestMXBean.class.getField(fieldName); String expectedTypeName = (String) nameField.get(null); if (expectedTypeName.equals(attrTypeName)) { System.out.println("OK: " + attrName + ": " + attrTypeName); } else { fail("For attribute " + attrName + " expected type name \"" + expectedTypeName + "\", found type name \"" + attrTypeName + "\""); } if (mbai.getType().equals(TabularData.class.getName())) { sawTabular = true; TabularType tt = (TabularType) mbai.getDescriptor().getFieldValue("openType"); if (tt.getTypeName().equals(attrTypeName)) { System.out.println("OK: TabularType name for " + attrName); } else { fail("For attribute " + attrName + " expected TabularType " + "name \"" + attrTypeName + "\", found \"" + tt.getTypeName()); } } } if (!sawTabular) fail("Test bug: did not test TabularType name"); if (failure == null) System.out.println("TEST PASSED"); else throw new Exception("TEST FAILED: " + failure); }
Example 13
Source File: TypeNameTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { TestMXBean testImpl = (TestMXBean) Proxy.newProxyInstance( TestMXBean.class.getClassLoader(), new Class<?>[] {TestMXBean.class}, nullIH); Object mxbean = new StandardMBean(testImpl, TestMXBean.class, true); MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName name = new ObjectName("a:b=c"); mbs.registerMBean(mxbean, name); MBeanInfo mbi = mbs.getMBeanInfo(name); MBeanAttributeInfo[] mbais = mbi.getAttributes(); boolean sawTabular = false; for (MBeanAttributeInfo mbai : mbais) { String attrName = mbai.getName(); String attrTypeName = (String) mbai.getDescriptor().getFieldValue("originalType"); String fieldName = attrName + "Name"; Field nameField = TestMXBean.class.getField(fieldName); String expectedTypeName = (String) nameField.get(null); if (expectedTypeName.equals(attrTypeName)) { System.out.println("OK: " + attrName + ": " + attrTypeName); } else { fail("For attribute " + attrName + " expected type name \"" + expectedTypeName + "\", found type name \"" + attrTypeName + "\""); } if (mbai.getType().equals(TabularData.class.getName())) { sawTabular = true; TabularType tt = (TabularType) mbai.getDescriptor().getFieldValue("openType"); if (tt.getTypeName().equals(attrTypeName)) { System.out.println("OK: TabularType name for " + attrName); } else { fail("For attribute " + attrName + " expected TabularType " + "name \"" + attrTypeName + "\", found \"" + tt.getTypeName()); } } } if (!sawTabular) fail("Test bug: did not test TabularType name"); if (failure == null) System.out.println("TEST PASSED"); else throw new Exception("TEST FAILED: " + failure); }
Example 14
Source File: TypeNameTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { TestMXBean testImpl = (TestMXBean) Proxy.newProxyInstance( TestMXBean.class.getClassLoader(), new Class<?>[] {TestMXBean.class}, nullIH); Object mxbean = new StandardMBean(testImpl, TestMXBean.class, true); MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName name = new ObjectName("a:b=c"); mbs.registerMBean(mxbean, name); MBeanInfo mbi = mbs.getMBeanInfo(name); MBeanAttributeInfo[] mbais = mbi.getAttributes(); boolean sawTabular = false; for (MBeanAttributeInfo mbai : mbais) { String attrName = mbai.getName(); String attrTypeName = (String) mbai.getDescriptor().getFieldValue("originalType"); String fieldName = attrName + "Name"; Field nameField = TestMXBean.class.getField(fieldName); String expectedTypeName = (String) nameField.get(null); if (expectedTypeName.equals(attrTypeName)) { System.out.println("OK: " + attrName + ": " + attrTypeName); } else { fail("For attribute " + attrName + " expected type name \"" + expectedTypeName + "\", found type name \"" + attrTypeName + "\""); } if (mbai.getType().equals(TabularData.class.getName())) { sawTabular = true; TabularType tt = (TabularType) mbai.getDescriptor().getFieldValue("openType"); if (tt.getTypeName().equals(attrTypeName)) { System.out.println("OK: TabularType name for " + attrName); } else { fail("For attribute " + attrName + " expected TabularType " + "name \"" + attrTypeName + "\", found \"" + tt.getTypeName()); } } } if (!sawTabular) fail("Test bug: did not test TabularType name"); if (failure == null) System.out.println("TEST PASSED"); else throw new Exception("TEST FAILED: " + failure); }
Example 15
Source File: MBeanCommand.java From arthas with Apache License 2.0 | 4 votes |
@Override public void run() { if (count >= getNumOfExecutions()) { // stop the timer timer.cancel(); timer.purge(); process.write("Process ends after " + getNumOfExecutions() + " time(s).\n"); process.end(); return; } try { MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer(); Set<ObjectName> objectNames = queryObjectNames(); TableElement table = createTable(); for (ObjectName objectName : objectNames) { MBeanInfo mBeanInfo = platformMBeanServer.getMBeanInfo(objectName); MBeanAttributeInfo[] attributes = mBeanInfo.getAttributes(); for (MBeanAttributeInfo attribute : attributes) { String attributeName = attribute.getName(); if (!getAttributeMatcher().matching(attributeName)) { continue; } String value; if (!attribute.isReadable()) { value = RenderUtil.render(new LabelElement("Unavailable").style(Decoration.bold_off.fg(Color.red))); } else { Object attributeObj = platformMBeanServer.getAttribute(objectName, attributeName); value = String.valueOf(attributeObj); } table.row(attributeName, value); } process.write(RenderUtil.render(table, process.width())); process.write("\n"); } } catch (Throwable e) { logger.warn("mbean error", e); } count++; process.times().incrementAndGet(); if (getInterval() <= 0) { stop(); process.end(); } }
Example 16
Source File: Server.java From ironjacamar with Eclipse Public License 1.0 | 4 votes |
/** * Get MBean attribute result info * @param name The bean name * @param attrInfo The attribute information * @return The data * @exception JMException Thrown if an error occurs */ public static AttrResultInfo getMBeanAttributeResultInfo(String name, MBeanAttributeInfo attrInfo) throws JMException { ClassLoader loader = SecurityActions.getThreadContextClassLoader(); MBeanServer server = getMBeanServer(); ObjectName objName = new ObjectName(name); String attrName = attrInfo.getName(); String attrType = attrInfo.getType(); Object value = null; Throwable throwable = null; if (attrInfo.isReadable()) { try { value = server.getAttribute(objName, attrName); } catch (Throwable t) { throwable = t; } } Class typeClass = null; try { typeClass = Classes.getPrimitiveTypeForName(attrType); if (typeClass == null) typeClass = loader.loadClass(attrType); } catch (ClassNotFoundException cnfe) { // Ignore } PropertyEditor editor = null; if (typeClass != null) editor = PropertyEditorManager.findEditor(typeClass); return new AttrResultInfo(attrName, editor, value, throwable); }
Example 17
Source File: TypeNameTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { TestMXBean testImpl = (TestMXBean) Proxy.newProxyInstance( TestMXBean.class.getClassLoader(), new Class<?>[] {TestMXBean.class}, nullIH); Object mxbean = new StandardMBean(testImpl, TestMXBean.class, true); MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName name = new ObjectName("a:b=c"); mbs.registerMBean(mxbean, name); MBeanInfo mbi = mbs.getMBeanInfo(name); MBeanAttributeInfo[] mbais = mbi.getAttributes(); boolean sawTabular = false; for (MBeanAttributeInfo mbai : mbais) { String attrName = mbai.getName(); String attrTypeName = (String) mbai.getDescriptor().getFieldValue("originalType"); String fieldName = attrName + "Name"; Field nameField = TestMXBean.class.getField(fieldName); String expectedTypeName = (String) nameField.get(null); if (expectedTypeName.equals(attrTypeName)) { System.out.println("OK: " + attrName + ": " + attrTypeName); } else { fail("For attribute " + attrName + " expected type name \"" + expectedTypeName + "\", found type name \"" + attrTypeName + "\""); } if (mbai.getType().equals(TabularData.class.getName())) { sawTabular = true; TabularType tt = (TabularType) mbai.getDescriptor().getFieldValue("openType"); if (tt.getTypeName().equals(attrTypeName)) { System.out.println("OK: TabularType name for " + attrName); } else { fail("For attribute " + attrName + " expected TabularType " + "name \"" + attrTypeName + "\", found \"" + tt.getTypeName()); } } } if (!sawTabular) fail("Test bug: did not test TabularType name"); if (failure == null) System.out.println("TEST PASSED"); else throw new Exception("TEST FAILED: " + failure); }
Example 18
Source File: TypeNameTest.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { TestMXBean testImpl = (TestMXBean) Proxy.newProxyInstance( TestMXBean.class.getClassLoader(), new Class<?>[] {TestMXBean.class}, nullIH); Object mxbean = new StandardMBean(testImpl, TestMXBean.class, true); MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName name = new ObjectName("a:b=c"); mbs.registerMBean(mxbean, name); MBeanInfo mbi = mbs.getMBeanInfo(name); MBeanAttributeInfo[] mbais = mbi.getAttributes(); boolean sawTabular = false; for (MBeanAttributeInfo mbai : mbais) { String attrName = mbai.getName(); String attrTypeName = (String) mbai.getDescriptor().getFieldValue("originalType"); String fieldName = attrName + "Name"; Field nameField = TestMXBean.class.getField(fieldName); String expectedTypeName = (String) nameField.get(null); if (expectedTypeName.equals(attrTypeName)) { System.out.println("OK: " + attrName + ": " + attrTypeName); } else { fail("For attribute " + attrName + " expected type name \"" + expectedTypeName + "\", found type name \"" + attrTypeName + "\""); } if (mbai.getType().equals(TabularData.class.getName())) { sawTabular = true; TabularType tt = (TabularType) mbai.getDescriptor().getFieldValue("openType"); if (tt.getTypeName().equals(attrTypeName)) { System.out.println("OK: TabularType name for " + attrName); } else { fail("For attribute " + attrName + " expected TabularType " + "name \"" + attrTypeName + "\", found \"" + tt.getTypeName()); } } } if (!sawTabular) fail("Test bug: did not test TabularType name"); if (failure == null) System.out.println("TEST PASSED"); else throw new Exception("TEST FAILED: " + failure); }
Example 19
Source File: TypeNameTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { TestMXBean testImpl = (TestMXBean) Proxy.newProxyInstance( TestMXBean.class.getClassLoader(), new Class<?>[] {TestMXBean.class}, nullIH); Object mxbean = new StandardMBean(testImpl, TestMXBean.class, true); MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName name = new ObjectName("a:b=c"); mbs.registerMBean(mxbean, name); MBeanInfo mbi = mbs.getMBeanInfo(name); MBeanAttributeInfo[] mbais = mbi.getAttributes(); boolean sawTabular = false; for (MBeanAttributeInfo mbai : mbais) { String attrName = mbai.getName(); String attrTypeName = (String) mbai.getDescriptor().getFieldValue("originalType"); String fieldName = attrName + "Name"; Field nameField = TestMXBean.class.getField(fieldName); String expectedTypeName = (String) nameField.get(null); if (expectedTypeName.equals(attrTypeName)) { System.out.println("OK: " + attrName + ": " + attrTypeName); } else { fail("For attribute " + attrName + " expected type name \"" + expectedTypeName + "\", found type name \"" + attrTypeName + "\""); } if (mbai.getType().equals(TabularData.class.getName())) { sawTabular = true; TabularType tt = (TabularType) mbai.getDescriptor().getFieldValue("openType"); if (tt.getTypeName().equals(attrTypeName)) { System.out.println("OK: TabularType name for " + attrName); } else { fail("For attribute " + attrName + " expected TabularType " + "name \"" + attrTypeName + "\", found \"" + tt.getTypeName()); } } } if (!sawTabular) fail("Test bug: did not test TabularType name"); if (failure == null) System.out.println("TEST PASSED"); else throw new Exception("TEST FAILED: " + failure); }
Example 20
Source File: TypeNameTest.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { TestMXBean testImpl = (TestMXBean) Proxy.newProxyInstance( TestMXBean.class.getClassLoader(), new Class<?>[] {TestMXBean.class}, nullIH); Object mxbean = new StandardMBean(testImpl, TestMXBean.class, true); MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName name = new ObjectName("a:b=c"); mbs.registerMBean(mxbean, name); MBeanInfo mbi = mbs.getMBeanInfo(name); MBeanAttributeInfo[] mbais = mbi.getAttributes(); boolean sawTabular = false; for (MBeanAttributeInfo mbai : mbais) { String attrName = mbai.getName(); String attrTypeName = (String) mbai.getDescriptor().getFieldValue("originalType"); String fieldName = attrName + "Name"; Field nameField = TestMXBean.class.getField(fieldName); String expectedTypeName = (String) nameField.get(null); if (expectedTypeName.equals(attrTypeName)) { System.out.println("OK: " + attrName + ": " + attrTypeName); } else { fail("For attribute " + attrName + " expected type name \"" + expectedTypeName + "\", found type name \"" + attrTypeName + "\""); } if (mbai.getType().equals(TabularData.class.getName())) { sawTabular = true; TabularType tt = (TabularType) mbai.getDescriptor().getFieldValue("openType"); if (tt.getTypeName().equals(attrTypeName)) { System.out.println("OK: TabularType name for " + attrName); } else { fail("For attribute " + attrName + " expected TabularType " + "name \"" + attrTypeName + "\", found \"" + tt.getTypeName()); } } } if (!sawTabular) fail("Test bug: did not test TabularType name"); if (failure == null) System.out.println("TEST PASSED"); else throw new Exception("TEST FAILED: " + failure); }