org.pfsw.reflect
Class DynamicMBeanDelegator<TRECEIVER>

java.lang.Object
  extended by org.pfsw.reflect.DynamicMBeanDelegator<TRECEIVER>
All Implemented Interfaces:
javax.management.DynamicMBean

public class DynamicMBeanDelegator<TRECEIVER>
extends java.lang.Object
implements javax.management.DynamicMBean

An generic reflection based implementation for applying a DynamicMBean interface on a another object that actually does not need to implement the DynamicMBean interface.

The dynamic method invocations and attribute access will be delegated on the internally held receiver object.

The generic type TRECEIVER represents the type of the internal object that is the target for all method invocations and attribute access.


Constructor Summary
DynamicMBeanDelegator(TRECEIVER receiver)
          Initialize the new instance with the target object.
 
Method Summary
 java.lang.Object getAttribute(java.lang.String attrName)
          Returns the value of the attribute with the given name.
 javax.management.AttributeList getAttributes(java.lang.String[] attrNames)
          Returns all the attributes with the specified names.
protected  javax.management.MBeanInfo getManagedBeanInfo()
           
 javax.management.MBeanInfo getMBeanInfo()
          Returns the meta data describing the supported attributes and methods.
 TRECEIVER getReceiver()
           
 java.lang.Object invoke(java.lang.String methodName, java.lang.Object[] params, java.lang.String[] signature)
          Executes the methods that are supported via JMX.
 void setAttribute(javax.management.Attribute attr)
          Sets the specified attribute.
 javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
          Sets all specified attributes.
 void setManagedBeanInfo(javax.management.MBeanInfo newValue)
           
 void setReceiver(TRECEIVER newValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicMBeanDelegator

public DynamicMBeanDelegator(TRECEIVER receiver)
Initialize the new instance with the target object.

Method Detail

getReceiver

public TRECEIVER getReceiver()

setReceiver

public void setReceiver(TRECEIVER newValue)

getManagedBeanInfo

protected javax.management.MBeanInfo getManagedBeanInfo()

setManagedBeanInfo

public void setManagedBeanInfo(javax.management.MBeanInfo newValue)

invoke

public java.lang.Object invoke(java.lang.String methodName,
                               java.lang.Object[] params,
                               java.lang.String[] signature)
                        throws javax.management.MBeanException,
                               javax.management.ReflectionException
Executes the methods that are supported via JMX.

Specified by:
invoke in interface javax.management.DynamicMBean
Throws:
javax.management.MBeanException
javax.management.ReflectionException

getAttribute

public java.lang.Object getAttribute(java.lang.String attrName)
                              throws javax.management.AttributeNotFoundException,
                                     javax.management.MBeanException,
                                     ReflectionException
Returns the value of the attribute with the given name.

Specified by:
getAttribute in interface javax.management.DynamicMBean
Parameters:
attrName - The name of the attribute to be returned
Throws:
javax.management.AttributeNotFoundException - if the attribute with the given name cannot be found.
javax.management.MBeanException
ReflectionException

setAttribute

public void setAttribute(javax.management.Attribute attr)
                  throws javax.management.AttributeNotFoundException,
                         javax.management.InvalidAttributeValueException,
                         javax.management.MBeanException,
                         ReflectionException
Sets the specified attribute.

Specified by:
setAttribute in interface javax.management.DynamicMBean
Parameters:
attr - The attribute with name and value.
Throws:
javax.management.AttributeNotFoundException - if the attribute with the given name cannot be found.
javax.management.InvalidAttributeValueException
javax.management.MBeanException
ReflectionException

getAttributes

public javax.management.AttributeList getAttributes(java.lang.String[] attrNames)
Returns all the attributes with the specified names.

Specified by:
getAttributes in interface javax.management.DynamicMBean
Throws:
IllegalArgument - In any case of problem setting one of the attributes. The original exception will be available via getCause().

setAttributes

public javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
Sets all specified attributes.

Specified by:
setAttributes in interface javax.management.DynamicMBean
Throws:
IllegalArgument - In any case of problem setting one of the attributes. The original exception will be available via getCause().

getMBeanInfo

public javax.management.MBeanInfo getMBeanInfo()
Returns the meta data describing the supported attributes and methods. Subclasses may override this method if necessary, otherwise the setManagedBeanInfo(MBeanInfo) method can be used to set the meta data.

Specified by:
getMBeanInfo in interface javax.management.DynamicMBean