Java Code Examples for javax.management.MBeanInfo#getDescriptor()
The following examples show how to use
javax.management.MBeanInfo#getDescriptor() .
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: ImmutableNotificationInfoTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static boolean test(Object mbean, boolean expectImmutable) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName on = new ObjectName("a:b=c"); mbs.registerMBean(mbean, on); MBeanInfo mbi = mbs.getMBeanInfo(on); Descriptor d = mbi.getDescriptor(); String immutableValue = (String) d.getFieldValue("immutableInfo"); boolean immutable = ("true".equals(immutableValue)); if (immutable != expectImmutable) { System.out.println("FAILED: " + mbean.getClass().getName() + " -> " + immutableValue); return false; } else { System.out.println("OK: " + mbean.getClass().getName()); return true; } }
Example 2
Source File: MBeanIntrospector.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Return the MBeanInfo for the given resource, based on the given * per-interface data. */ final MBeanInfo getMBeanInfo(Object resource, PerInterface<M> perInterface) { MBeanInfo mbi = getClassMBeanInfo(resource.getClass(), perInterface); MBeanNotificationInfo[] notifs = findNotifications(resource); if (notifs == null || notifs.length == 0) return mbi; else { return new MBeanInfo(mbi.getClassName(), mbi.getDescription(), mbi.getAttributes(), mbi.getConstructors(), mbi.getOperations(), notifs, mbi.getDescriptor()); } }
Example 3
Source File: MBeanIntrospector.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Return the MBeanInfo for the given resource, based on the given * per-interface data. */ final MBeanInfo getMBeanInfo(Object resource, PerInterface<M> perInterface) { MBeanInfo mbi = getClassMBeanInfo(resource.getClass(), perInterface); MBeanNotificationInfo[] notifs = findNotifications(resource); if (notifs == null || notifs.length == 0) return mbi; else { return new MBeanInfo(mbi.getClassName(), mbi.getDescription(), mbi.getAttributes(), mbi.getConstructors(), mbi.getOperations(), notifs, mbi.getDescriptor()); } }
Example 4
Source File: MBeanIntrospector.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * Return the MBeanInfo for the given resource, based on the given * per-interface data. */ final MBeanInfo getMBeanInfo(Object resource, PerInterface<M> perInterface) { MBeanInfo mbi = getClassMBeanInfo(resource.getClass(), perInterface); MBeanNotificationInfo[] notifs = findNotifications(resource); if (notifs == null || notifs.length == 0) return mbi; else { return new MBeanInfo(mbi.getClassName(), mbi.getDescription(), mbi.getAttributes(), mbi.getConstructors(), mbi.getOperations(), notifs, mbi.getDescriptor()); } }
Example 5
Source File: ImmutableNotificationInfoTest.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private static boolean test(Object mbean, boolean expectImmutable) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName on = new ObjectName("a:b=c"); mbs.registerMBean(mbean, on); MBeanInfo mbi = mbs.getMBeanInfo(on); Descriptor d = mbi.getDescriptor(); String immutableValue = (String) d.getFieldValue("immutableInfo"); boolean immutable = ("true".equals(immutableValue)); if (immutable != expectImmutable) { System.out.println("FAILED: " + mbean.getClass().getName() + " -> " + immutableValue); return false; } else { System.out.println("OK: " + mbean.getClass().getName()); return true; } }
Example 6
Source File: ImmutableNotificationInfoTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static boolean test(Object mbean, boolean expectImmutable) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName on = new ObjectName("a:b=c"); mbs.registerMBean(mbean, on); MBeanInfo mbi = mbs.getMBeanInfo(on); Descriptor d = mbi.getDescriptor(); String immutableValue = (String) d.getFieldValue("immutableInfo"); boolean immutable = ("true".equals(immutableValue)); if (immutable != expectImmutable) { System.out.println("FAILED: " + mbean.getClass().getName() + " -> " + immutableValue); return false; } else { System.out.println("OK: " + mbean.getClass().getName()); return true; } }
Example 7
Source File: MBeanIntrospector.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Return the MBeanInfo for the given resource, based on the given * per-interface data. */ final MBeanInfo getMBeanInfo(Object resource, PerInterface<M> perInterface) { MBeanInfo mbi = getClassMBeanInfo(resource.getClass(), perInterface); MBeanNotificationInfo[] notifs = findNotifications(resource); if (notifs == null || notifs.length == 0) return mbi; else { return new MBeanInfo(mbi.getClassName(), mbi.getDescription(), mbi.getAttributes(), mbi.getConstructors(), mbi.getOperations(), notifs, mbi.getDescriptor()); } }
Example 8
Source File: ImmutableNotificationInfoTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private static boolean test(Object mbean, boolean expectImmutable) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName on = new ObjectName("a:b=c"); mbs.registerMBean(mbean, on); MBeanInfo mbi = mbs.getMBeanInfo(on); Descriptor d = mbi.getDescriptor(); String immutableValue = (String) d.getFieldValue("immutableInfo"); boolean immutable = ("true".equals(immutableValue)); if (immutable != expectImmutable) { System.out.println("FAILED: " + mbean.getClass().getName() + " -> " + immutableValue); return false; } else { System.out.println("OK: " + mbean.getClass().getName()); return true; } }
Example 9
Source File: ImmutableNotificationInfoTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private static boolean test(Object mbean, boolean expectImmutable) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName on = new ObjectName("a:b=c"); mbs.registerMBean(mbean, on); MBeanInfo mbi = mbs.getMBeanInfo(on); Descriptor d = mbi.getDescriptor(); String immutableValue = (String) d.getFieldValue("immutableInfo"); boolean immutable = ("true".equals(immutableValue)); if (immutable != expectImmutable) { System.out.println("FAILED: " + mbean.getClass().getName() + " -> " + immutableValue); return false; } else { System.out.println("OK: " + mbean.getClass().getName()); return true; } }
Example 10
Source File: MBeanIntrospector.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Return the MBeanInfo for the given resource, based on the given * per-interface data. */ final MBeanInfo getMBeanInfo(Object resource, PerInterface<M> perInterface) { MBeanInfo mbi = getClassMBeanInfo(resource.getClass(), perInterface); MBeanNotificationInfo[] notifs = findNotifications(resource); if (notifs == null || notifs.length == 0) return mbi; else { return new MBeanInfo(mbi.getClassName(), mbi.getDescription(), mbi.getAttributes(), mbi.getConstructors(), mbi.getOperations(), notifs, mbi.getDescriptor()); } }
Example 11
Source File: StandardMBeanSupport.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public MBeanInfo getMBeanInfo() { MBeanInfo mbi = super.getMBeanInfo(); Class<?> resourceClass = getResource().getClass(); if (StandardMBeanIntrospector.isDefinitelyImmutableInfo(resourceClass)) return mbi; return new MBeanInfo(mbi.getClassName(), mbi.getDescription(), mbi.getAttributes(), mbi.getConstructors(), mbi.getOperations(), MBeanIntrospector.findNotifications(getResource()), mbi.getDescriptor()); }
Example 12
Source File: StandardMBeanSupport.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override public MBeanInfo getMBeanInfo() { MBeanInfo mbi = super.getMBeanInfo(); Class<?> resourceClass = getResource().getClass(); if (StandardMBeanIntrospector.isDefinitelyImmutableInfo(resourceClass)) return mbi; return new MBeanInfo(mbi.getClassName(), mbi.getDescription(), mbi.getAttributes(), mbi.getConstructors(), mbi.getOperations(), MBeanIntrospector.findNotifications(getResource()), mbi.getDescriptor()); }
Example 13
Source File: StandardMBeanSupport.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override public MBeanInfo getMBeanInfo() { MBeanInfo mbi = super.getMBeanInfo(); Class<?> resourceClass = getResource().getClass(); if (StandardMBeanIntrospector.isDefinitelyImmutableInfo(resourceClass)) return mbi; return new MBeanInfo(mbi.getClassName(), mbi.getDescription(), mbi.getAttributes(), mbi.getConstructors(), mbi.getOperations(), MBeanIntrospector.findNotifications(getResource()), mbi.getDescriptor()); }
Example 14
Source File: StandardMBeanSupport.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public MBeanInfo getMBeanInfo() { MBeanInfo mbi = super.getMBeanInfo(); Class<?> resourceClass = getResource().getClass(); if (StandardMBeanIntrospector.isDefinitelyImmutableInfo(resourceClass)) return mbi; return new MBeanInfo(mbi.getClassName(), mbi.getDescription(), mbi.getAttributes(), mbi.getConstructors(), mbi.getOperations(), MBeanIntrospector.findNotifications(getResource()), mbi.getDescriptor()); }
Example 15
Source File: StandardMBeanSupport.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Override public MBeanInfo getMBeanInfo() { MBeanInfo mbi = super.getMBeanInfo(); Class<?> resourceClass = getResource().getClass(); if (StandardMBeanIntrospector.isDefinitelyImmutableInfo(resourceClass)) return mbi; return new MBeanInfo(mbi.getClassName(), mbi.getDescription(), mbi.getAttributes(), mbi.getConstructors(), mbi.getOperations(), MBeanIntrospector.findNotifications(getResource()), mbi.getDescriptor()); }
Example 16
Source File: TooManyFooTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private static void test(Object child, String name, boolean mxbean) throws Exception { final ObjectName childName = new ObjectName("test:type=Child,name="+name); final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); server.registerMBean(child,childName); try { final MBeanInfo info = server.getMBeanInfo(childName); System.out.println(name+": " + info.getDescriptor()); final int len = info.getOperations().length; if (len == OPCOUNT) { System.out.println(name+": OK, only "+OPCOUNT+ " operations here..."); } else { final String qual = (len>OPCOUNT)?"many":"few"; System.err.println(name+": Too "+qual+" foos! Found "+ len+", expected "+OPCOUNT); for (MBeanOperationInfo op : info.getOperations()) { System.err.println("public "+op.getReturnType()+" "+ op.getName()+"();"); } throw new RuntimeException("Too " + qual + " foos for "+name); } final Descriptor d = info.getDescriptor(); final String mxstr = String.valueOf(d.getFieldValue("mxbean")); final boolean mxb = (mxstr==null)?false:Boolean.valueOf(mxstr).booleanValue(); System.out.println(name+": mxbean="+mxb); if (mxbean && !mxb) throw new AssertionError("MXBean is not OpenMBean?"); for (MBeanOperationInfo mboi : info.getOperations()) { // Sanity check if (mxbean && !mboi.getName().equals("foo")) { // The spec doesn't guarantee that the MBeanOperationInfo // of an MXBean will be an OpenMBeanOperationInfo, and in // some circumstances in our implementation it will not. // However, in thsi tests, for all methods but foo(), // it should. // if (!(mboi instanceof OpenMBeanOperationInfo)) throw new AssertionError("Operation "+mboi.getName()+ "() is not Open?"); } final String exp = EXPECTED_TYPES.get(mboi.getName()); // For MXBeans, we need to compare 'exp' with the original // type - because mboi.getReturnType() returns the OpenType // String type = (String)mboi.getDescriptor(). getFieldValue("originalType"); if (type == null) type = mboi.getReturnType(); if (type.equals(exp)) continue; System.err.println("Bad return type for "+ mboi.getName()+"! Found "+type+ ", expected "+exp); throw new RuntimeException("Bad return type for "+ mboi.getName()); } } finally { server.unregisterMBean(childName); } }
Example 17
Source File: TooManyFooTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private static void test(Object child, String name, boolean mxbean) throws Exception { final ObjectName childName = new ObjectName("test:type=Child,name="+name); final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); server.registerMBean(child,childName); try { final MBeanInfo info = server.getMBeanInfo(childName); System.out.println(name+": " + info.getDescriptor()); final int len = info.getOperations().length; if (len == OPCOUNT) { System.out.println(name+": OK, only "+OPCOUNT+ " operations here..."); } else { final String qual = (len>OPCOUNT)?"many":"few"; System.err.println(name+": Too "+qual+" foos! Found "+ len+", expected "+OPCOUNT); for (MBeanOperationInfo op : info.getOperations()) { System.err.println("public "+op.getReturnType()+" "+ op.getName()+"();"); } throw new RuntimeException("Too " + qual + " foos for "+name); } final Descriptor d = info.getDescriptor(); final String mxstr = String.valueOf(d.getFieldValue("mxbean")); final boolean mxb = (mxstr==null)?false:Boolean.valueOf(mxstr).booleanValue(); System.out.println(name+": mxbean="+mxb); if (mxbean && !mxb) throw new AssertionError("MXBean is not OpenMBean?"); for (MBeanOperationInfo mboi : info.getOperations()) { // Sanity check if (mxbean && !mboi.getName().equals("foo")) { // The spec doesn't guarantee that the MBeanOperationInfo // of an MXBean will be an OpenMBeanOperationInfo, and in // some circumstances in our implementation it will not. // However, in thsi tests, for all methods but foo(), // it should. // if (!(mboi instanceof OpenMBeanOperationInfo)) throw new AssertionError("Operation "+mboi.getName()+ "() is not Open?"); } final String exp = EXPECTED_TYPES.get(mboi.getName()); // For MXBeans, we need to compare 'exp' with the original // type - because mboi.getReturnType() returns the OpenType // String type = (String)mboi.getDescriptor(). getFieldValue("originalType"); if (type == null) type = mboi.getReturnType(); if (type.equals(exp)) continue; System.err.println("Bad return type for "+ mboi.getName()+"! Found "+type+ ", expected "+exp); throw new RuntimeException("Bad return type for "+ mboi.getName()); } } finally { server.unregisterMBean(childName); } }
Example 18
Source File: TooManyFooTest.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
private static void test(Object child, String name, boolean mxbean) throws Exception { final ObjectName childName = new ObjectName("test:type=Child,name="+name); final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); server.registerMBean(child,childName); try { final MBeanInfo info = server.getMBeanInfo(childName); System.out.println(name+": " + info.getDescriptor()); final int len = info.getOperations().length; if (len == OPCOUNT) { System.out.println(name+": OK, only "+OPCOUNT+ " operations here..."); } else { final String qual = (len>OPCOUNT)?"many":"few"; System.err.println(name+": Too "+qual+" foos! Found "+ len+", expected "+OPCOUNT); for (MBeanOperationInfo op : info.getOperations()) { System.err.println("public "+op.getReturnType()+" "+ op.getName()+"();"); } throw new RuntimeException("Too " + qual + " foos for "+name); } final Descriptor d = info.getDescriptor(); final String mxstr = String.valueOf(d.getFieldValue("mxbean")); final boolean mxb = (mxstr==null)?false:Boolean.valueOf(mxstr).booleanValue(); System.out.println(name+": mxbean="+mxb); if (mxbean && !mxb) throw new AssertionError("MXBean is not OpenMBean?"); for (MBeanOperationInfo mboi : info.getOperations()) { // Sanity check if (mxbean && !mboi.getName().equals("foo")) { // The spec doesn't guarantee that the MBeanOperationInfo // of an MXBean will be an OpenMBeanOperationInfo, and in // some circumstances in our implementation it will not. // However, in thsi tests, for all methods but foo(), // it should. // if (!(mboi instanceof OpenMBeanOperationInfo)) throw new AssertionError("Operation "+mboi.getName()+ "() is not Open?"); } final String exp = EXPECTED_TYPES.get(mboi.getName()); // For MXBeans, we need to compare 'exp' with the original // type - because mboi.getReturnType() returns the OpenType // String type = (String)mboi.getDescriptor(). getFieldValue("originalType"); if (type == null) type = mboi.getReturnType(); if (type.equals(exp)) continue; System.err.println("Bad return type for "+ mboi.getName()+"! Found "+type+ ", expected "+exp); throw new RuntimeException("Bad return type for "+ mboi.getName()); } } finally { server.unregisterMBean(childName); } }
Example 19
Source File: TooManyFooTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private static void test(Object child, String name, boolean mxbean) throws Exception { final ObjectName childName = new ObjectName("test:type=Child,name="+name); final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); server.registerMBean(child,childName); try { final MBeanInfo info = server.getMBeanInfo(childName); System.out.println(name+": " + info.getDescriptor()); final int len = info.getOperations().length; if (len == OPCOUNT) { System.out.println(name+": OK, only "+OPCOUNT+ " operations here..."); } else { final String qual = (len>OPCOUNT)?"many":"few"; System.err.println(name+": Too "+qual+" foos! Found "+ len+", expected "+OPCOUNT); for (MBeanOperationInfo op : info.getOperations()) { System.err.println("public "+op.getReturnType()+" "+ op.getName()+"();"); } throw new RuntimeException("Too " + qual + " foos for "+name); } final Descriptor d = info.getDescriptor(); final String mxstr = String.valueOf(d.getFieldValue("mxbean")); final boolean mxb = (mxstr==null)?false:Boolean.valueOf(mxstr).booleanValue(); System.out.println(name+": mxbean="+mxb); if (mxbean && !mxb) throw new AssertionError("MXBean is not OpenMBean?"); for (MBeanOperationInfo mboi : info.getOperations()) { // Sanity check if (mxbean && !mboi.getName().equals("foo")) { // The spec doesn't guarantee that the MBeanOperationInfo // of an MXBean will be an OpenMBeanOperationInfo, and in // some circumstances in our implementation it will not. // However, in thsi tests, for all methods but foo(), // it should. // if (!(mboi instanceof OpenMBeanOperationInfo)) throw new AssertionError("Operation "+mboi.getName()+ "() is not Open?"); } final String exp = EXPECTED_TYPES.get(mboi.getName()); // For MXBeans, we need to compare 'exp' with the original // type - because mboi.getReturnType() returns the OpenType // String type = (String)mboi.getDescriptor(). getFieldValue("originalType"); if (type == null) type = mboi.getReturnType(); if (type.equals(exp)) continue; System.err.println("Bad return type for "+ mboi.getName()+"! Found "+type+ ", expected "+exp); throw new RuntimeException("Bad return type for "+ mboi.getName()); } } finally { server.unregisterMBean(childName); } }
Example 20
Source File: MBeanInfoRenderer.java From text-ui with GNU General Public License v3.0 | 4 votes |
@Override public LineRenderer renderer(Iterator<MBeanInfo> stream) { List<LineRenderer> renderers = new ArrayList<LineRenderer>(); while (stream.hasNext()) { MBeanInfo info = stream.next(); // TreeElement root = new TreeElement(info.getClassName()); // Descriptor TableElement descriptor = new TableElement(). overflow(Overflow.HIDDEN). rightCellPadding(1); Descriptor descriptorInfo = info.getDescriptor(); if (descriptorInfo != null) { for (String fieldName : descriptorInfo.getFieldNames()) { String fieldValue = String.valueOf(descriptorInfo.getFieldValue(fieldName)); descriptor.row(fieldName, fieldValue); } } // Attributes TableElement attributes = new TableElement(). overflow(Overflow.HIDDEN). rightCellPadding(1). add(new RowElement().style(Decoration.bold.fg(Color.black).bg(Color.white)).add("NAME", "TYPE", "DESCRIPTION")); for (MBeanAttributeInfo attributeInfo : info.getAttributes()) { attributes.row(attributeInfo.getName(), attributeInfo.getType(), attributeInfo.getDescription()); } // Operations TreeElement operations = new TreeElement("Operations"); for (MBeanOperationInfo operationInfo : info.getOperations()) { TableElement signature = new TableElement(). overflow(Overflow.HIDDEN). rightCellPadding(1); MBeanParameterInfo[] parameterInfos = operationInfo.getSignature(); for (MBeanParameterInfo parameterInfo : parameterInfos) { signature.row(parameterInfo.getName(), parameterInfo.getType(), parameterInfo.getDescription()); } TreeElement operation = new TreeElement(operationInfo.getName()); String impact; switch (operationInfo.getImpact()) { case MBeanOperationInfo.ACTION: impact = "ACTION"; break; case MBeanOperationInfo.INFO: impact = "INFO"; break; case MBeanOperationInfo.ACTION_INFO: impact = "ACTION_INFO"; break; default: impact = "UNKNOWN"; } operation.addChild(new TableElement(). add( new RowElement().add("Type: ", operationInfo.getReturnType()), new RowElement().add("Description: ", operationInfo.getDescription()), new RowElement().add("Impact: ", impact), new RowElement().add(new LabelElement("Signature: "), signature) ) ); operations.addChild(operation); } // root.addChild( new TableElement().leftCellPadding(1).overflow(Overflow.HIDDEN). row("ClassName", info.getClassName()). row("Description", info.getDescription() ) ); root.addChild(new TreeElement("Descriptor").addChild(descriptor)); root.addChild(new TreeElement("Attributes").addChild(attributes)); root.addChild(operations); // renderers.add(root.renderer()); } return LineRenderer.vertical(renderers); }