org.baswell.easybeans
Class EasyBeanWrapper

java.lang.Object
  extended by org.baswell.easybeans.EasyBeanWrapper
All Implemented Interfaces:
javax.management.DynamicMBean
Direct Known Subclasses:
EasyBeanNotificationWrapper

public class EasyBeanWrapper
extends java.lang.Object
implements javax.management.DynamicMBean

Wraps a Java object to exposure their attributes and operations as a DynamicMBean. If you want to broadcast JMX notifications use EasyBeanNotificationWrapper


Constructor Summary
EasyBeanWrapper(java.lang.Object bean)
           
EasyBeanWrapper(java.lang.Object bean, EasyBeanExposure exposure)
           
 
Method Summary
 java.lang.Object getAttribute(java.lang.String attribute)
           
 javax.management.AttributeList getAttributes(java.lang.String[] attributes)
           
 javax.management.MBeanInfo getMBeanInfo()
           
 java.lang.Object invoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)
           
 void register()
          Registers this MBean with the platform MBeanServer
 void register(javax.management.MBeanServer mBeanServer)
          Registers this MBean with the given MBeanServer.
 void setAttribute(javax.management.Attribute attribute)
           
 javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
           
 void unregister()
          Unregisters this MBean from the platform MBeanServer
 void unregister(javax.management.MBeanServer mBeanServer)
          Unregisters this MBean from the given MBeanServer *
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EasyBeanWrapper

public EasyBeanWrapper(java.lang.Object bean)
                throws InvalidEasyBeanNameException,
                       InvalidEasyBeanAnnotation,
                       InvalidEasyBeanOpenType
Parameters:
bean - The bean to wrap as a DynamicMBean.
Throws:
InvalidEasyBeanNameException - If the ObjectName used for this bean in invalid.
InvalidEasyBeanAnnotation - If an EasyBean annotation is used incorrectly.
InvalidEasyBeanOpenType - If the given object (or a descendant of this object) cannot be mapped to an OpenType.

EasyBeanWrapper

public EasyBeanWrapper(java.lang.Object bean,
                       EasyBeanExposure exposure)
                throws InvalidEasyBeanNameException,
                       InvalidEasyBeanAnnotation,
                       InvalidEasyBeanOpenType
Parameters:
bean - The bean to wrap as a DynamicMBean.
exposure - Overrides the EasyBeanExposure annotated by the given bean object.
Throws:
InvalidEasyBeanNameException - If the ObjectName used for this bean in invalid.
InvalidEasyBeanAnnotation - If an EasyBean annotation is used incorrectly.
InvalidEasyBeanOpenType - If the given object (or a descendant of this object) cannot be mapped to an OpenType.
Method Detail

register

public void register()
              throws ObjectNameAlreadyRegistered,
                     UnexpectedEasyBeanException
Registers this MBean with the platform MBeanServer

Throws:
ObjectNameAlreadyRegistered - If the object name of this MBean has already been registered.
UnexpectedEasyBeanException - If the registration could not occur from some other unexpected reason.
See Also:
ManagementFactory.getPlatformMBeanServer()

register

public void register(javax.management.MBeanServer mBeanServer)
              throws ObjectNameAlreadyRegistered,
                     UnexpectedEasyBeanException
Registers this MBean with the given MBeanServer.

Parameters:
mBeanServer - The server to register this MBean with.
Throws:
ObjectNameAlreadyRegistered - If the object name of this MBean has already been registered.
UnexpectedEasyBeanException - If the registration could not occur from some other unexpected reason.

unregister

public void unregister()
                throws UnexpectedEasyBeanException
Unregisters this MBean from the platform MBeanServer

Throws:
UnexpectedEasyBeanException - If the unregister action could not occur from some other unexpected reason.
See Also:
ManagementFactory.getPlatformMBeanServer()

unregister

public void unregister(javax.management.MBeanServer mBeanServer)
                throws UnexpectedEasyBeanException
Unregisters this MBean from the given MBeanServer *

Parameters:
mBeanServer - The server to unregister this MBean from.
Throws:
UnexpectedEasyBeanException - If the unregister action could not occur from some other unexpected reason.

getAttribute

public java.lang.Object getAttribute(java.lang.String attribute)
                              throws javax.management.AttributeNotFoundException,
                                     javax.management.MBeanException,
                                     javax.management.ReflectionException
Specified by:
getAttribute in interface javax.management.DynamicMBean
Throws:
javax.management.AttributeNotFoundException
javax.management.MBeanException
javax.management.ReflectionException

getAttributes

public javax.management.AttributeList getAttributes(java.lang.String[] attributes)
Specified by:
getAttributes in interface javax.management.DynamicMBean

getMBeanInfo

public javax.management.MBeanInfo getMBeanInfo()
Specified by:
getMBeanInfo in interface javax.management.DynamicMBean
See Also:
DynamicMBean.getMBeanInfo()

invoke

public java.lang.Object invoke(java.lang.String actionName,
                               java.lang.Object[] params,
                               java.lang.String[] signature)
                        throws javax.management.MBeanException,
                               javax.management.ReflectionException
Specified by:
invoke in interface javax.management.DynamicMBean
Throws:
javax.management.MBeanException
javax.management.ReflectionException
See Also:
DynamicMBean.invoke(String, Object[], String[])

setAttribute

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

setAttributes

public javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
Specified by:
setAttributes in interface javax.management.DynamicMBean
See Also:
DynamicMBean.setAttributes(javax.management.AttributeList)