gnu.java.lang.management

Class BeanImpl

Implemented Interfaces:
DynamicMBean
Known Direct Subclasses:
ClassLoadingMXBeanImpl, CompilationMXBeanImpl, MemoryManagerMXBeanImpl, MemoryMXBeanImpl, MemoryPoolMXBeanImpl, OperatingSystemMXBeanImpl, RuntimeMXBeanImpl, ThreadMXBeanImpl

public class BeanImpl
extends StandardMBean

A common superclass for bean implementations.
Since:
1.5

Constructor Summary

BeanImpl(Class<T> iface)
Constructs a new BeanImpl.

Method Summary

protected void
cacheMBeanInfo(MBeanInfo info)
Caches the MBeanInfo instance for this object.
protected void
checkControlPermissions()
protected void
checkMonitorPermissions()
Object
getAttribute(String attribute)
Obtains the value of the specified attribute of the management bean.
protected MBeanInfo
getCachedMBeanInfo()
Returns the cached MBeanInfo instance for this object.
MBeanInfo
getMBeanInfo()
Returns an information object which lists the attributes and actions associated with the management bean.

Methods inherited from class javax.management.StandardMBean

cacheMBeanInfo, getAttribute, getAttributes, getCachedMBeanInfo, getClassName, getConstructors, getDescription, getDescription, getDescription, getDescription, getDescription, getDescription, getDescription, getImpact, getImplementation, getImplementationClass, getMBeanInfo, getMBeanInterface, getParameterName, getParameterName, invoke, setAttribute, setAttributes, setImplementation

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

BeanImpl

protected BeanImpl(Class<T> iface)
            throws NotCompliantMBeanException
Constructs a new BeanImpl.
Parameters:
iface - the bean interface being implemented.
Throws:
NotCompliantMBeanException - if this class doesn't implement the interface or a method appears in the interface that doesn't comply with the naming conventions.

Method Details

cacheMBeanInfo

protected void cacheMBeanInfo(MBeanInfo info)
Caches the MBeanInfo instance for this object. This is a customization hook, so that subclasses can choose the caching policy used. The default implementation caches the value in the instance itself. Subclasses may override this so as to not cache the data at all, or so as to use a cache shared between multiple beans.
Overrides:
cacheMBeanInfo in interface StandardMBean
Parameters:
info - the MBeanInfo instance to cache, or null if there is no new value to cache. When the value is not null, the cache should replace the current value with the value supplied here.

checkControlPermissions

protected void checkControlPermissions()

checkMonitorPermissions

protected void checkMonitorPermissions()

getAttribute

public Object getAttribute(String attribute)
            throws AttributeNotFoundException,
                   MBeanException,
                   ReflectionException
Obtains the value of the specified attribute of the management bean. The management bean should perform a lookup for the named attribute, and return its value by calling the appropriate getter method, if possible.
Specified by:
getAttribute in interface DynamicMBean
Overrides:
getAttribute in interface StandardMBean
Parameters:
Returns:
the value of the specified attribute.
Throws:
AttributeNotFoundException - if the name does not correspond to an attribute of the bean.
MBeanException - if retrieving the attribute causes the bean to throw an exception (which becomes the cause of this exception).
ReflectionException - if an exception occurred in trying to use the reflection interface to lookup the attribute. The thrown exception is the cause of this exception.
See Also:
setAttribute(String)

getCachedMBeanInfo

protected MBeanInfo getCachedMBeanInfo()
Returns the cached MBeanInfo instance for this object. This is a customization hook, so that subclasses can choose the caching policy used. The default implementation caches the value in the instance itself, and returns this value on calls to this method.
Overrides:
getCachedMBeanInfo in interface StandardMBean
Returns:
the cached MBeanInfo instance, or null if no value is cached.

getMBeanInfo

public MBeanInfo getMBeanInfo()
Returns an information object which lists the attributes and actions associated with the management bean. This implementation proceeds as follows:
  1. StandardMBean.getCachedMBeanInfo() is called to obtain the cached instance. If this returns a non-null value, this value is returned.
  2. If there is no cached value, then the method proceeds to create one. During this process, the customization hooks detailed in this class are called to allow the values used to be overrided:
    • For each attribute, StandardMBean.getDescription(MBeanAttributeInfo) is called.
    • For each constructor, StandardMBean.getDescription(MBeanConstructorInfo) is called, along with StandardMBean.getDescription(MBeanConstructorInfo,MBeanParameterInfo,int) and StandardMBean.getParameterName(MBeanConstructorInfo,MBeanParameterInfo,int) for each parameter.
    • The constructors may be replaced as a whole by a call to StandardMBean.getConstructors(MBeanConstructorInfo[],Object).
    • For each operation, StandardMBean.getDescription(MBeanOperationInfo) and StandardMBean.getImpact(MBeanOperationInfo) are called, along with StandardMBean.getDescription(MBeanOperationInfo,MBeanParameterInfo,int) and StandardMBean.getParameterName(MBeanOperationInfo,MBeanParameterInfo,int) for each parameter.
    • StandardMBean.getClassName(MBeanInfo) and StandardMBean.getDescription(MBeanInfo) are called to customise the basic information about the class.
    • Finally, StandardMBean.cacheMBeanInfo(MBeanInfo) is called with the created instance before it is returned.
    Specified by:
    getMBeanInfo in interface DynamicMBean
    Overrides:
    getMBeanInfo in interface StandardMBean
    Returns:
    a description of the management bean, including all exposed attributes and actions.

    BeanImpl.java - A common superclass for bean implementations. Copyright (C) 2006 Free Software Foundation This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.