org.jboss.mx.mxbean
Class MXBeanDelegate

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.jboss.mx.mxbean.MXBeanDelegate
All Implemented Interfaces:
DynamicMBean, MBeanRegistration, NotificationBroadcaster, NotificationEmitter

public class MXBeanDelegate
extends NotificationBroadcasterSupport
implements DynamicMBean, MBeanRegistration, NotificationEmitter

MXBeanDelegate. FIXME: Reflection madness

Version:
$Revision: 85945 $
Author:
Adrian Brock

Constructor Summary
protected MXBeanDelegate(Class mbeanInterface)
          Construct a DynamicMBean from this object and the passed management interface class.
  MXBeanDelegate(Object implementation, Class mbeanInterface)
          Construct a DynamicMBean from the given implementation object and the passed management interface class.
 
Method Summary
 OpenMBeanInfo buildMBeanInfo()
          Builds a default MBeanInfo for this MBean, using the Management Interface specified for this MBean.
 void cacheMBeanInfo(OpenMBeanInfo info)
          Sets the cached mbean info
 Object getAttribute(String attribute)
           
 AttributeList getAttributes(String[] attributes)
           
 OpenMBeanInfo 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 postDeregister()
           
 void postRegister(Boolean registrationDone)
           
 void preDeregister()
           
 ObjectName preRegister(MBeanServer server, ObjectName name)
           
 void setAttribute(Attribute attribute)
           
 AttributeList setAttributes(AttributeList attributes)
           
 void setImplementation(Object implementation)
          Replace the implementation object
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.management.NotificationEmitter
removeNotificationListener
 
Methods inherited from interface javax.management.NotificationBroadcaster
addNotificationListener, getNotificationInfo, removeNotificationListener
 

Constructor Detail

MXBeanDelegate

public MXBeanDelegate(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

MXBeanDelegate

protected MXBeanDelegate(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

Returns:
the implementation

setImplementation

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

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

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

preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
                       throws Exception
Specified by:
preRegister in interface MBeanRegistration
Throws:
Exception

postRegister

public void postRegister(Boolean registrationDone)
Specified by:
postRegister in interface MBeanRegistration

preDeregister

public void preDeregister()
                   throws Exception
Specified by:
preDeregister in interface MBeanRegistration
Throws:
Exception

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface MBeanRegistration

getMBeanInfo

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

getCachedMBeanInfo

public OpenMBeanInfo getCachedMBeanInfo()
Retrieve the cached mbean info

Returns:
the cached mbean info

cacheMBeanInfo

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

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

buildMBeanInfo

public OpenMBeanInfo 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...

Returns:
the mbean info
Throws:
NotCompliantMBeanException - when not a valid mbean


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