2362N/A * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This class contains the methods for performing all the tests needed to verify 0N/A * that a class represents a JMX compliant MBean. 0N/A * ------------------------------------------ 0N/A * PRIVATE CONSTRUCTORS 0N/A * ------------------------------------------ 0N/A // private constructor defined to "hide" the default public constructor 0N/A // ------------------------------ 0N/A // ------------------------------ 0N/A * ------------------------------------------ 0N/A * ------------------------------------------ 0N/A * Tell whether a MBean of the given class is a Dynamic MBean. 0N/A * This method does nothing more than returning 0N/A * javax.management.DynamicMBean.class.isAssignableFrom(c) 0N/A * This method does not check for any JMX MBean compliance: 0N/A * <ul><li>If <code>true</code> is returned, then instances of 0N/A * <code>c</code> are DynamicMBean.</li> 0N/A * <li>If <code>false</code> is returned, then no further 0N/A * assumption can be made on instances of <code>c</code>. 0N/A * In particular, instances of <code>c</code> may, or may not 0N/A * be JMX standard MBeans.</li> 0N/A * @param c The class of the MBean under examination. 0N/A * @return <code>true</code> if instances of <code>c</code> are 0N/A * Dynamic MBeans, <code>false</code> otherwise. 0N/A // Check if the MBean implements the DynamicMBean interface 0N/A * Basic method for testing that a MBean of a given class can be 0N/A * instantiated by the MBean server.<p> 0N/A * This method checks that: 0N/A * <ul><li>The given class is a concrete class.</li> 0N/A * <li>The given class exposes at least one public constructor.</li> 0N/A * If these conditions are not met, throws a NotCompliantMBeanException. 0N/A * @param c The class of the MBean we want to create. 0N/A * @exception NotCompliantMBeanException if the MBean class makes it 0N/A * impossible to instantiate the MBean from within the 0N/A // Check if the class is a concrete class 0N/A // Check if the MBean has a public constructor 0N/A // Is Standard MBean? 1790N/A "DynamicMBean, and neither follows the Standard MBean conventions (" +
0N/A // Ignore exception - we need to check whether 0N/A // mbean is an MXBean first. 0N/A // Ignore exception - we cannot decide whether mbean was supposed 0N/A // to be an MBean or an MXBean. We will call checkCompliance() 0N/A // to generate the appropriate exception. 0N/A * Basic method for testing if a given class is a JMX compliant MBean. 0N/A * @param baseClass The class to be tested 0N/A * @return <code>null</code> if the MBean is a DynamicMBean, 0N/A * the computed {@link javax.management.MBeanInfo} otherwise. 0N/A * @exception NotCompliantMBeanException The specified class is not a 0N/A * JMX compliant MBean 0N/A // ------------------------------ 0N/A // ------------------------------ 0N/A // Check if the MBean implements the MBean or the Dynamic 0N/A * Basic method for testing if a given class is a JMX compliant 0N/A * Standard MBean. This method is only called by the legacy code 0N/A * in com.sun.management.jmx. 0N/A * @param baseClass The class to be tested. 0N/A * @param mbeanInterface the MBean interface that the class implements, 0N/A * or null if the interface must be determined by introspection. 0N/A * @return the computed {@link javax.management.MBeanInfo}. 0N/A * @exception NotCompliantMBeanException The specified class is not a 0N/A * JMX compliant Standard MBean 0N/A * Get the MBean interface implemented by a JMX Standard 0N/A * MBean class. This method is only called by the legacy 0N/A * code in "com.sun.management.jmx". 0N/A * @param baseClass The class to be tested. 0N/A * @return The MBean interface implemented by the MBean. 0N/A * Return <code>null</code> if the MBean is a DynamicMBean, 0N/A * or if no MBean interface is found. 0N/A // Check if the given class implements the MBean interface 0N/A // or the Dynamic MBean interface 0N/A * Get the MBean interface implemented by a JMX Standard MBean class. 0N/A * @param baseClass The class to be tested. 0N/A * @return The MBean interface implemented by the Standard MBean. 0N/A * @throws NotCompliantMBeanException The specified class is 0N/A * not a JMX compliant Standard MBean. 0N/A " is not a JMX compliant Standard MBean";
0N/A * Get the MXBean interface implemented by a JMX MXBean class. 0N/A * @param baseClass The class to be tested. 0N/A * @return The MXBean interface implemented by the MXBean. 0N/A * @throws NotCompliantMBeanException The specified class is 0N/A * not a JMX compliant MXBean. 0N/A * ------------------------------------------ 0N/A * ------------------------------------------ 0N/A * Try to find the MBean interface corresponding to the class aName 0N/A * - i.e. <i>aName</i>MBean, from within aClass and its superclasses. 6296N/A // Avoid checking access more than once per annotation 1790N/A // we don't expect this - except for possibly 1790N/A // RuntimeExceptions shouldn't be "UndeclaredThrowable". 1790N/A "Inconsistent values for descriptor field " +
name +
0N/A * Throws a NotCompliantMBeanException or a SecurityException. 0N/A * @param notCompliant the class which was under examination 0N/A * @param cause the raeson why NotCompliantMBeanException should 0N/A * @return nothing - this method always throw an exception. 0N/A * The return type makes it possible to write 0N/A * <pre> throw throwException(clazz,cause); </pre> 0N/A * @throws SecurityException - if cause is a SecurityException 0N/A * @throws NotCompliantMBeanException otherwise. 0N/A // Convert a value from an annotation element to a descriptor field value 0N/A // E.g. with @interface Foo {class value()} an annotation @Foo(String.class) 0N/A // will produce a Descriptor field value "java.lang.String" 0N/A // An annotation element cannot have a null value but never mind 0N/A // Remaining possibilities: array of primitive (e.g. int[]), 0N/A // enum, class, array of enum or class. 0N/A // The only other possibility is that the value is another 0N/A // annotation, or that the language has evolved since this code 0N/A // was written. We don't allow for either of those currently. 406N/A // If it is indeed another annotation, then x will be a proxy 406N/A // with an unhelpful name like $Proxy2. So we extract the 406N/A // proxy's interface to use that in the exception message. 0N/A // This must be consistent with the check for duplicate field values in 0N/A // ImmutableDescriptor.union. But we don't expect to be called very 0N/A // often so this inefficient check should be enough. 0N/A * Returns the XXMBean interface or null if no such interface exists 0N/A * @param c The interface to be tested 0N/A * @param clName The name of the class implementing this interface 11N/A // Java Beans introspection 1933N/A // Java Beans not available so use simple introspection 11N/A "Could not find the getter method for the property " +
1933N/A * A simple introspector that uses reflection to analyze a class and 1933N/A * identify its "getter" methods. This class is intended for use only when 1933N/A * Java Beans is not present (which implies that there isn't explicit 1933N/A * information about the bean available). 1933N/A // cache to avoid repeated lookups 1933N/A * Returns the list of methods cached for the given class, or {@code null} 1933N/A // return cached methods if possible 1933N/A * Returns {@code true} if the given method is a "getter" method (where 1933N/A * "getter" method is a public method of the form getXXX or "boolean 1933N/A * Returns the list of "getter" methods for the given class. The list 1933N/A * is ordered so that isXXX methods appear before getXXX methods - this 1933N/A * is for compatability with the JavaBeans Introspector. 1933N/A // return cached result if available 1933N/A // get list of public methods, filtering out methods that have 1933N/A // been overridden to return a more specific type. 1933N/A // filter out the non-getter methods 1933N/A * Returns the "getter" to read the given property from the given class or 1933N/A * {@code null} if no method is found. 1933N/A // first character in uppercase (compatability with JavaBeans) 1933N/A * A class that provides access to the JavaBeans Introspector and 1933N/A * PropertyDescriptors without creating a static dependency on java.beans. 1933N/A * Returns {@code true} if java.beans is available. 1933N/A * Invokes java.beans.Introspector.getBeanInfo(Class) 1933N/A * Invokes java.beans.BeanInfo.getPropertyDescriptors() 1933N/A * Invokes java.beans.PropertyDescriptor.getName() 1933N/A * Invokes java.beans.PropertyDescriptor.getReadMethod()