FileDocCategorySizeDatePackage
StandardMBeanMetaDataImpl.javaAPI DocJava SE 5 API3961Fri Aug 26 14:55:00 BST 2005com.sun.jmx.mbeanserver

StandardMBeanMetaDataImpl

public final class StandardMBeanMetaDataImpl extends StandardMetaDataImpl
Override StandardMetaDataImpl in order to redefine the caching of MBean Information in StandardMBean.
since
1.6

Fields Summary
private final StandardMBean
mbean
Constructors Summary
public StandardMBeanMetaDataImpl(StandardMBean mbean)
Constructor.

        super(false);
        this.mbean = mbean;
    
Methods Summary
voidcacheMBeanInfo(java.lang.Class c, java.lang.Class mbeanInterface, javax.management.MBeanInfo mbeanInfo)
Need to override this method because default caching implemented in StandardMetaDataImpl will not work if two instances of class c can have different mbeanInterface.

The default caching mechanism in StandardMetaDataImpl uses class static {@link java.util.WeakHashMap WeakHashMaps} - and is common to all instance of StandardMetaData - hence to all MBeanServer.

As this default mechanism might not always work for StandardMBean objects (may have several instances of class c with different MBean interfaces), we disable this default caching by defining an empty cacheMBeanInfo() method.

Caching in our case is no longer performed by the MetaData object, but by the StandardMBean object.

    
javax.management.MBeanInfogetCachedMBeanInfo(java.lang.Class beanClass)
We need to override this method because some methods from BaseMetaDataImpl rely on MetaData#getMBeanInfo().

The default caching implemented in StandardMetaDataImpl will not work if two instances of class c can have different management interfaces, which is made possible by {@link javax.management.StandardMBean}.

return
mbean.getMBeanInfo();


        if (beanClass == null) return null;

        // Need the synchronized block as long as implementation
        // and mbeanInterface are not final.
        //
        synchronized (mbean) {
            // Consistency checking: beanClass must be equal
            // to mbean.getImplementationClass().
            //
            final Class implementationClass =
                mbean.getImplementationClass();
            if (implementationClass == null) return null;
            if (!beanClass.equals(implementationClass)) return null;

            // Should always come here (null cases excepted)...
            //
            return mbean.getMBeanInfo();
        }
    
java.lang.ClassgetCachedMBeanInterface(java.lang.Class beanClass)
We need to override this method because some methods from StandardMetaDataImpl rely on it.

The default caching implemented in StandardMetaDataImpl will not work if two instances of class c can have different management interfaces, which is made possible by {@link javax.management.StandardMBean}.

return
mbean.getMBeanInterface();

        // Need the synchronized block as long as implementation
        // and mbeanInterface are not final.
        //
        synchronized (mbean) {
            // Consistency checking: beanClass must be equal
            // to mbean.getImplementationClass().
            //
            final Class implementationClass =
                mbean.getImplementationClass();
            if (implementationClass == null) return null;
            if (!beanClass.equals(implementationClass)) return null;

            // Should always come here (null cases excepted)...
            //
            return mbean.getMBeanInterface();
        }