javax.management
Class StandardMBean

java.lang.Object
  extended byjavax.management.StandardMBean
All Implemented Interfaces:
DynamicMBean (src)
Direct Known Subclasses:
MBeanRunnable (src) , MyStandardMBean (src) , StandardMBeanExtension (src)

public class StandardMBean
extends java.lang.Object
implements DynamicMBean (src)

A helper class to allow standard mbeans greater control over their management interface.

Extending this class actually makes the mbean a dynamic mbean, but with the convenience of a standard mbean.


Constructor Summary
protected StandardMBean(java.lang.Class mbeanInterface)
          Construct a DynamicMBean from this object and the passed management interface class.
  StandardMBean(java.lang.Object implementation, java.lang.Class mbeanInterface)
          Construct a DynamicMBean from the given implementation object and the passed management interface class.
 
Method Summary
protected  void cacheMBeanInfo(MBeanInfo (src)  info)
          Sets the cached mbean info
 java.lang.Object getAttribute(java.lang.String attribute)
          Returns the value of the attribute with the name matching the passed string.
 AttributeList (src) getAttributes(java.lang.String[] attributes)
          Returns the values of the attributes with names matching the passed string array.
protected  MBeanInfo (src) getCachedMBeanInfo()
          Retrieve the cached mbean info
protected  java.lang.String getClassName(MBeanInfo (src)  info)
          Retrieve the class name of the mbean
protected  MBeanConstructorInfo (src) [] getConstructors(MBeanConstructorInfo (src) [] constructors, java.lang.Object implementation)
          Retrieve the constructors
protected  java.lang.String getDescription(MBeanAttributeInfo (src)  info)
          Retrieve the description of the mbean attribute
protected  java.lang.String getDescription(MBeanConstructorInfo (src)  info)
          Retrieve the description of the mbean constructor
protected  java.lang.String getDescription(MBeanConstructorInfo (src)  info, MBeanParameterInfo (src)  param, int sequence)
          Retrieve the description of the mbean constructor parameter
protected  java.lang.String getDescription(MBeanFeatureInfo (src)  info)
          Retrieve the description of the mbean feature
protected  java.lang.String getDescription(MBeanInfo (src)  info)
          Retrieve the description of the mbean
protected  java.lang.String getDescription(MBeanOperationInfo (src)  info)
          Retrieve the description of the mbean operation
protected  java.lang.String getDescription(MBeanOperationInfo (src)  info, MBeanParameterInfo (src)  param, int sequence)
          Retrieve the description of the mbean operation parameter
protected  int getImpact(MBeanOperationInfo (src)  info)
          Retrieve the impact of the mbean operation
 java.lang.Object getImplementation()
          Retrieve the implementation object
 java.lang.Class getImplementationClass()
          Retrieve the implementation class
 MBeanInfo (src) getMBeanInfo()
          Returns the management interface that describes this dynamic resource.
 java.lang.Class getMBeanInterface()
          Retrieve the management interface
protected  java.lang.String getParameterName(MBeanConstructorInfo (src)  info, MBeanParameterInfo (src)  param, int sequence)
          Retrieve the parameter name for a constructor
protected  java.lang.String getParameterName(MBeanOperationInfo (src)  info, MBeanParameterInfo (src)  param, int sequence)
          Retrieve the parameter name for an operation
 java.lang.Object invoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)
          Invokes a resource operation.
 void setAttribute(Attribute (src)  attribute)
          Sets the value of an attribute.
 AttributeList (src) setAttributes(AttributeList (src)  attributes)
          Sets the values of the attributes passed as an AttributeList (src) of name and new value pairs.
 void setImplementation(java.lang.Object implementation)
          Replace the implementation object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardMBean

public StandardMBean(java.lang.Object implementation,
                     java.lang.Class mbeanInterface)
              throws NotCompliantMBeanException (src) 
Construct a DynamicMBean from the given implementation object and the passed management interface class.

Parameters:
implementation - the object implementing the mbean
mbeanInterface - the management interface of the mbean
Throws:
java.lang.IllegalArgumentException - for a null implementation
NotCompliantMBeanException (src) - if the management interface does not follow the JMX design patterns or the implementation does not implement the interface

StandardMBean

protected StandardMBean(java.lang.Class mbeanInterface)
                 throws NotCompliantMBeanException (src) 
Construct a DynamicMBean from this object and the passed management interface class.

Used in subclassing

Parameters:
mbeanInterface - the management interface of the mbean
Throws:
NotCompliantMBeanException (src) - if the management interface does not follow the JMX design patterns or this does not implement the interface
Method Detail

getImplementation

public java.lang.Object getImplementation()
Retrieve the implementation object

Returns:
the implementation

setImplementation

public void setImplementation(java.lang.Object implementation)
                       throws NotCompliantMBeanException (src) 
Replace the implementation object

Parameters:
implementation - the new implementation
Throws:
java.lang.IllegalArgumentException - for a null parameter
NotCompliantMBeanException (src) - if the new implementation does not implement the interface supplied at construction

getImplementationClass

public java.lang.Class getImplementationClass()
Retrieve the implementation class

Returns:
the class of the implementation

getMBeanInterface

public final java.lang.Class getMBeanInterface()
Retrieve the management interface

Returns:
the management interface

getAttribute

public java.lang.Object getAttribute(java.lang.String attribute)
                              throws AttributeNotFoundException (src) ,
                                     MBeanException (src) ,
                                     ReflectionException (src) 
Description copied from interface: DynamicMBean (src)
Returns the value of the attribute with the name matching the passed string.

Specified by:
getAttribute in interface DynamicMBean (src)
Parameters:
attribute - the name of the attribute.
Returns:
the value of the attribute.
Throws:
MBeanException (src) - wraps any error thrown by the resource when getting the attribute.
AttributeNotFoundException (src) - when there is no such attribute.
ReflectionException (src) - wraps any error invoking the resource.

setAttribute

public void setAttribute(Attribute (src)  attribute)
                  throws AttributeNotFoundException (src) ,
                         InvalidAttributeValueException (src) ,
                         MBeanException (src) ,
                         ReflectionException (src) 
Description copied from interface: DynamicMBean (src)
Sets the value of an attribute. The attribute and new value are passed in the name value pair Attribute (src) .

Specified by:
setAttribute in interface DynamicMBean (src)
Parameters:
attribute - the name and new value of the attribute.
Throws:
InvalidAttributeValueException (src) - when the new value cannot be converted to the type of the attribute.
AttributeNotFoundException (src) - when there is no such attribute.
MBeanException (src) - wraps any error thrown by the resource when setting the new value.
ReflectionException (src) - wraps any error invoking the resource.
See Also:
Attribute (src)

getAttributes

public AttributeList (src)  getAttributes(java.lang.String[] attributes)
Description copied from interface: DynamicMBean (src)
Returns the values of the attributes with names matching the passed string array.

Specified by:
getAttributes in interface DynamicMBean (src)
Parameters:
attributes - the names of the attribute.
Returns:
an AttributeList (src) of name and value pairs.

setAttributes

public AttributeList (src)  setAttributes(AttributeList (src)  attributes)
Description copied from interface: DynamicMBean (src)
Sets the values of the attributes passed as an AttributeList (src) of name and new value pairs.

Specified by:
setAttributes in interface DynamicMBean (src)
Parameters:
attributes - the name an new value pairs.
Returns:
an AttributeList (src) of name and value pairs that were actually set.

invoke

public java.lang.Object invoke(java.lang.String actionName,
                               java.lang.Object[] params,
                               java.lang.String[] signature)
                        throws MBeanException (src) ,
                               ReflectionException (src) 
Description copied from interface: DynamicMBean (src)
Invokes a resource operation.

Specified by:
invoke in interface DynamicMBean (src)
Parameters:
actionName - the name of the operation to perform.
params - the parameters to pass to the operation.
signature - the signartures of the parameters.
Returns:
the result of the operation.
Throws:
MBeanException (src) - wraps any error thrown by the resource when performing the operation.
ReflectionException (src) - wraps any error invoking the resource.

getMBeanInfo

public MBeanInfo (src)  getMBeanInfo()
Description copied from interface: DynamicMBean (src)
Returns the management interface that describes this dynamic resource. It is the responsibility of the implementation to make sure the description is accurate.

Specified by:
getMBeanInfo in interface DynamicMBean (src)
Returns:
the management interface.

getClassName

protected java.lang.String getClassName(MBeanInfo (src)  info)
Retrieve the class name of the mbean

Parameters:
info - the default mbeaninfo derived by reflection
Returns:
the class name

getDescription

protected java.lang.String getDescription(MBeanInfo (src)  info)
Retrieve the description of the mbean

Parameters:
info - the default mbeaninfo derived by reflection
Returns:
the description

getDescription

protected java.lang.String getDescription(MBeanFeatureInfo (src)  info)
Retrieve the description of the mbean feature

Parameters:
info - the default mbeanfeatureinfo derived by reflection
Returns:
the description

getDescription

protected java.lang.String getDescription(MBeanAttributeInfo (src)  info)
Retrieve the description of the mbean attribute

Parameters:
info - the default mbeanattributeinfo derived by reflection
Returns:
the description

getDescription

protected java.lang.String getDescription(MBeanConstructorInfo (src)  info)
Retrieve the description of the mbean constructor

Parameters:
info - the default mbeanconstructorinfo derived by reflection
Returns:
the description

getDescription

protected java.lang.String getDescription(MBeanOperationInfo (src)  info)
Retrieve the description of the mbean operation

Parameters:
info - the default mbeanoperationinfo derived by reflection
Returns:
the description

getDescription

protected java.lang.String getDescription(MBeanConstructorInfo (src)  info,
                                          MBeanParameterInfo (src)  param,
                                          int sequence)
Retrieve the description of the mbean constructor parameter

Parameters:
info - the default mbeanconstructorinfo derived by reflection
param - the parameter information
sequence - the parameter index, starting with zero
Returns:
the description

getDescription

protected java.lang.String getDescription(MBeanOperationInfo (src)  info,
                                          MBeanParameterInfo (src)  param,
                                          int sequence)
Retrieve the description of the mbean operation parameter

Parameters:
info - the default mbeanoperationinfo derived by reflection
param - the parameter information
sequence - the parameter index, starting with zero
Returns:
the description

getParameterName

protected java.lang.String getParameterName(MBeanConstructorInfo (src)  info,
                                            MBeanParameterInfo (src)  param,
                                            int sequence)
Retrieve the parameter name for a constructor

Parameters:
info - the default mbeanconstructorinfo derived by reflection
param - the parameter information
sequence - the parameter index, starting with zero
Returns:
the parameter name

getParameterName

protected java.lang.String getParameterName(MBeanOperationInfo (src)  info,
                                            MBeanParameterInfo (src)  param,
                                            int sequence)
Retrieve the parameter name for an operation

Parameters:
info - the default mbeanoperationinfo derived by reflection
param - the parameter information
sequence - the parameter index, starting with zero
Returns:
the parameter name

getImpact

protected int getImpact(MBeanOperationInfo (src)  info)
Retrieve the impact of the mbean operation

Parameters:
info - the default mbeanoperationinfo derived by reflection
Returns:
the impact

getConstructors

protected MBeanConstructorInfo (src) [] getConstructors(MBeanConstructorInfo (src) [] constructors,
                                                 java.lang.Object implementation)
Retrieve the constructors

Parameters:
constructors - the default constructors derived by reflection
implementation - the implementation
Returns:
the constructors if the implementation is this, otherwise null

getCachedMBeanInfo

protected MBeanInfo (src)  getCachedMBeanInfo()
Retrieve the cached mbean info

Returns:
the cached mbean info

cacheMBeanInfo

protected void cacheMBeanInfo(MBeanInfo (src)  info)
Sets the cached mbean info

Parameters:
info - the mbeaninfo to cache, can be null to erase the cache