|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object![]()
![]()
![]()
javax.management.StandardMBean

public class StandardMBean


An MBean whose management interface is determined by reflection on a Java interface.
This class brings more flexibility to the notion of Management Interface in the use of Standard MBeans. Straightforward use of the patterns for Standard MBeans described in the JMX Specification means that there is a fixed relationship between the implementation class of an MBean and its management interface (i.e., if the implementation class is Thing, the management interface must be ThingMBean). This class makes it possible to keep the convenience of specifying the management interface with a Java interface, without requiring that there be any naming relationship between the implementation and interface classes.
By making a DynamicMBean out of an MBean, this class makes it possible to select any interface implemented by the MBean as its management interface, provided that it complies with JMX patterns (i.e., attributes defined by getter/setter etc...).
This class also provides hooks that make it possible to supply
custom descriptions and names for the MBeanInfo
returned by
the DynamicMBean interface.
Using this class, an MBean can be created with any implementation class name Impl and with a management interface defined (as for current Standard MBeans) by any interface Intf, in one of two general ways:
StandardMBean(impl,interface)
:
MBeanServer mbs;
...
Impl impl = new Impl(...);
StandardMBean mbean = new StandardMBean(impl, Intf.class);
mbs.registerMBean(mbean, objectName);
public class Impl extends StandardMBean implements Intf {
public Impl() {
super(Intf.class);
}
// implement methods of Intf
}
[...]
MBeanServer mbs;
....
Impl impl = new Impl();
mbs.registerMBean(impl, objectName);
In either case, the class Impl must implement the interface Intf.
Standard MBeans based on the naming relationship between implementation and interface classes are of course still available.
| Constructor Summary | |
|---|---|
protected |
StandardMBean
Make a DynamicMBean out of this, using the specified mbeanInterface class. |
|
StandardMBean
Make a DynamicMBean out of the object implementation, using the specified mbeanInterface class. |
| Method Summary | |
|---|---|
protected void |
cacheMBeanInfo
Customization hook: cache the MBeanInfo built for this object. |
Object |
getAttribute
Obtain the value of a specific attribute of the Dynamic MBean. |
AttributeList |
getAttributes
Get the values of several attributes of the Dynamic MBean. |
protected MBeanInfo |
getCachedMBeanInfo
Customization hook: Return the MBeanInfo cached for this object. |
protected String |
getClassName
Customization hook: Get the className that will be used in the MBeanInfo returned by this MBean. |
protected MBeanConstructorInfo |
getConstructors
Customization hook: Get the MBeanConstructorInfo[] that will be used in the MBeanInfo returned by this MBean. |
protected String |
getDescription
Customization hook: Get the description that will be used in the MBeanAttributeInfo returned by this MBean. |
protected String |
getDescription
Customization hook: Get the description that will be used in the MBeanConstructorInfo returned by this MBean. |
protected String |
getDescription
Customization hook: Get the description that will be used for the sequence MBeanParameterInfo of the MBeanConstructorInfo returned by this MBean. |
protected String |
getDescription
Customization hook: Get the description that will be used in the MBeanFeatureInfo returned by this MBean. |
protected String |
getDescription
Customization hook: Get the description that will be used in the MBeanInfo returned by this MBean. |
protected String |
getDescription
Customization hook: Get the description that will be used in the MBeanOperationInfo returned by this MBean. |
protected String |
getDescription
Customization hook: Get the description that will be used for the sequence MBeanParameterInfo of the MBeanOperationInfo returned by this MBean. |
protected int |
getImpact
Customization hook: Get the impact flag of the operation that will be used in the MBeanOperationInfo returned by this MBean. |
Object |
getImplementation
Get the implementation of this MBean. |
Class |
getImplementationClass
Get the class of the implementation of this MBean. |
MBeanInfo |
getMBeanInfo
Get the MBeanInfo for this MBean. |
Class |
getMBeanInterface
Get the Management Interface of this MBean. |
protected String |
getParameterName
Customization hook: Get the name that will be used for the sequence MBeanParameterInfo of the MBeanConstructorInfo returned by this MBean. |
protected String |
getParameterName
Customization hook: Get the name that will be used for the sequence MBeanParameterInfo of the MBeanOperationInfo returned by this MBean. |
Object |
invoke
Allows an action to be invoked on the Dynamic MBean. |
void |
setAttribute
Set the value of a specific attribute of the Dynamic MBean. |
AttributeList |
setAttributes
Sets the values of several attributes of the Dynamic MBean. |
void |
setImplementation
Replace the implementation object wrapped in this object. |
Methods inherited from class java.lang.Object ![]() |
|---|
clone |
| Constructor Detail |
|---|

public StandardMBean(Object![]()
![]()
implementation, Class
![]()
![]()
mbeanInterface) throws NotCompliantMBeanException
![]()
![]()
Make a DynamicMBean out of the object implementation, using the specified mbeanInterface class.
implementation - The implementation of this MBean.mbeanInterface - The Management Interface exported by this
MBean's implementation. If null, then this
object will use standard JMX design pattern to determine
the management interface associated with the given
implementation.
IllegalArgumentException

- if the given
implementation is null.
NotCompliantMBeanException

- if the mbeanInterface
does not follow JMX design patterns for Management Interfaces, or
if the given implementation does not implement the
specified interface.

protected StandardMBean(Class![]()
![]()
mbeanInterface) throws NotCompliantMBeanException
![]()
![]()
Make a DynamicMBean out of this, using the specified mbeanInterface class.
Call this(this,mbeanInterface)
.
This constructor is reserved to subclasses.
mbeanInterface - The Management Interface exported by this
MBean.
NotCompliantMBeanException

- if the mbeanInterface
does not follow JMX design patterns for Management Interfaces, or
if this does not implement the specified interface.| Method Detail |
|---|

public void setImplementation(Object![]()
![]()
implementation) throws NotCompliantMBeanException
![]()
![]()
Replace the implementation object wrapped in this object.
implementation - The new implementation of this MBean.
The implementation object must implement the MBean
interface that was supplied when this
StandardMBean was constructed.
IllegalArgumentException

- if the given
implementation is null.
NotCompliantMBeanException

- if the given
implementation does not implement the MBean
interface that was supplied at construction.getImplementation()


public Object![]()
![]()
getImplementation()
setImplementation(java.lang.Object)


public final Class![]()
![]()
getMBeanInterface()

public Class![]()
![]()
getImplementationClass()

public Object![]()
![]()
getAttribute(String
![]()
![]()
attribute) throws AttributeNotFoundException
![]()
![]()
, MBeanException
![]()
![]()
, ReflectionException
![]()
![]()
DynamicMBean

getAttribute

in interface DynamicMBean

attribute - The name of the attribute to be retrieved
AttributeNotFoundException

MBeanException

- Wraps a java.lang.Exception thrown by the MBean's getter.
ReflectionException

- Wraps a java.lang.Exception thrown while trying to invoke the getter.DynamicMBean.setAttribute(javax.management.Attribute)


public void setAttribute(Attribute![]()
![]()
attribute) throws AttributeNotFoundException
![]()
![]()
, InvalidAttributeValueException
![]()
![]()
, MBeanException
![]()
![]()
, ReflectionException
![]()
![]()
DynamicMBean

setAttribute

in interface DynamicMBean

attribute - The identification of the attribute to
be set and the value it is to be set to.
AttributeNotFoundException

InvalidAttributeValueException

MBeanException

- Wraps a java.lang.Exception thrown by the MBean's setter.
ReflectionException

- Wraps a java.lang.Exception thrown while trying to invoke the MBean's setter.DynamicMBean.getAttribute(java.lang.String)


public AttributeList![]()
![]()
getAttributes(String
![]()
![]()
[] attributes)
DynamicMBean

getAttributes

in interface DynamicMBean

attributes - A list of the attributes to be retrieved.
DynamicMBean.setAttributes(javax.management.AttributeList)


public AttributeList