org.jboss.mx.standardmbean
Class StandardMBeanImpl

java.lang.Object
  extended by org.jboss.mx.standardmbean.StandardMBeanImpl
All Implemented Interfaces:
DynamicMBean, StandardMBeanDelegate

public class StandardMBeanImpl
extends Object
implements StandardMBeanDelegate

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.

Version:
$Revision: 81022 $
Author:
Adrian Brock., Thomas Diesler.

Constructor Summary
protected StandardMBeanImpl(Class mbeanInterface)
          Construct a DynamicMBean from this object and the passed management interface class.
  StandardMBeanImpl(Object implementation, Class mbeanInterface)
          Construct a DynamicMBean from the given implementation object and the passed management interface class.
 
Method Summary
 MBeanInfo buildMBeanInfo()
          Builds a default MBeanInfo for this MBean, using the Management Interface specified for this MBean.
 void cacheMBeanInfo(MBeanInfo info)
          Sets the cached mbean info
 Object getAttribute(String attribute)
           
 AttributeList getAttributes(String[] attributes)
           
 MBeanInfo getCachedMBeanInfo()
          Retrieve the cached mbean info
 Object getImplementation()
          Retrieve the implementation object
 Class getImplementationClass()
          Retrieve the implementation class
 MBeanInfo getMBeanInfo()
           
 Class getMBeanInterface()
          Retrieve the management interface
 Object invoke(String actionName, Object[] params, String[] signature)
           
 void setAttribute(Attribute attribute)
           
 AttributeList setAttributes(AttributeList attributes)
           
 void setImplementation(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

StandardMBeanImpl

public StandardMBeanImpl(Object implementation,
                         Class mbeanInterface)
                  throws NotCompliantMBeanException
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:
IllegalArgumentException - for a null implementation
NotCompliantMBeanException - if the management interface does not follow the JMX design patterns or the implementation does not implement the interface

StandardMBeanImpl

protected StandardMBeanImpl(Class mbeanInterface)
                     throws NotCompliantMBeanException
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 - if the management interface does not follow the JMX design patterns or this does not implement the interface
Method Detail

getImplementation

public Object getImplementation()
Retrieve the implementation object

Specified by:
getImplementation in interface StandardMBeanDelegate
Returns:
the implementation

setImplementation

public void setImplementation(Object implementation)
                       throws NotCompliantMBeanException
Replace the implementation object

Specified by:
setImplementation in interface StandardMBeanDelegate
Parameters:
implementation - the new implementation
Throws:
IllegalArgumentException - for a null parameter
NotCompliantMBeanException - if the new implementation does not implement the interface supplied at construction

getImplementationClass

public Class getImplementationClass()
Retrieve the implementation class

Returns:
the class of the implementation

getMBeanInterface

public final Class getMBeanInterface()
Retrieve the management interface

Specified by:
getMBeanInterface in interface StandardMBeanDelegate
Returns:
the management interface

getAttribute

public Object getAttribute(String attribute)
                    throws AttributeNotFoundException,
                           MBeanException,
                           ReflectionException
Specified by:
getAttribute in interface DynamicMBean
Throws:
AttributeNotFoundException
MBeanException
ReflectionException

setAttribute

public void setAttribute(Attribute attribute)
                  throws AttributeNotFoundException,
                         InvalidAttributeValueException,
                         MBeanException,
                         ReflectionException
Specified by:
setAttribute in interface DynamicMBean
Throws:
AttributeNotFoundException
InvalidAttributeValueException
MBeanException
ReflectionException

getAttributes

public AttributeList getAttributes(String[] attributes)
Specified by:
getAttributes in interface DynamicMBean

setAttributes

public AttributeList setAttributes(AttributeList attributes)
Specified by:
setAttributes in interface DynamicMBean

invoke

public Object invoke(String actionName,
                     Object[] params,
                     String[] signature)
              throws MBeanException,
                     ReflectionException
Specified by:
invoke in interface DynamicMBean
Throws:
MBeanException
ReflectionException

getMBeanInfo

public MBeanInfo getMBeanInfo()
Specified by:
getMBeanInfo in interface DynamicMBean

getCachedMBeanInfo

public MBeanInfo getCachedMBeanInfo()
Retrieve the cached mbean info

Specified by:
getCachedMBeanInfo in interface StandardMBeanDelegate
Returns:
the cached mbean info

cacheMBeanInfo

public void cacheMBeanInfo(MBeanInfo info)
Sets the cached mbean info

Specified by:
cacheMBeanInfo in interface StandardMBeanDelegate
Parameters:
info - the mbeaninfo to cache, can be null to erase the cache

buildMBeanInfo

public MBeanInfo buildMBeanInfo()
                         throws NotCompliantMBeanException
Builds a default MBeanInfo for this MBean, using the Management Interface specified for this MBean. While building the MBeanInfo, this method calls the customization hooks that make it possible for subclasses to supply their custom descriptions, parameter names, etc...

Specified by:
buildMBeanInfo in interface StandardMBeanDelegate
Throws:
NotCompliantMBeanException


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.