Package org.springframework.jmx.export
Class SpringModelMBean
- java.lang.Object
- javax.management.modelmbean.RequiredModelMBean
- org.springframework.jmx.export.SpringModelMBean
- All Implemented Interfaces:
DynamicMBean,MBeanRegistration,ModelMBean,ModelMBeanNotificationBroadcaster,NotificationBroadcaster,NotificationEmitter,PersistentMBean
public class SpringModelMBean extends RequiredModelMBean
Extension of theRequiredModelMBeanclass that ensures thethread context ClassLoaderis switched for the managed resource'sClassLoaderbefore any invocations occur.- Since:
- 2.0
- Author:
- Rob Harrop
- See Also:
RequiredModelMBean
Constructor Summary
Constructors Constructor Description SpringModelMBean()Construct a new SpringModelMBean instance with an emptyModelMBeanInfo.SpringModelMBean(ModelMBeanInfo mbi)Construct a new SpringModelMBean instance with the givenModelMBeanInfo.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectgetAttribute(String attrName)Switches thecontext ClassLoaderfor the managed resourcesClassLoaderbefore allowing the invocation to occur.AttributeListgetAttributes(String[] attrNames)Switches thecontext ClassLoaderfor the managed resourcesClassLoaderbefore allowing the invocation to occur.Objectinvoke(String opName, Object[] opArgs, String[] sig)Switches thecontext ClassLoaderfor the managed resourcesClassLoaderbefore allowing the invocation to occur.voidsetAttribute(Attribute attribute)Switches thecontext ClassLoaderfor the managed resourcesClassLoaderbefore allowing the invocation to occur.AttributeListsetAttributes(AttributeList attributes)Switches thecontext ClassLoaderfor the managed resourcesClassLoaderbefore allowing the invocation to occur.voidsetManagedResource(Object managedResource, String managedResourceType)Sets managed resource to expose and stores itsClassLoader.Methods inherited from class javax.management.modelmbean.RequiredModelMBean
addAttributeChangeNotificationListener, addNotificationListener, getClassLoaderRepository, getMBeanInfo, getNotificationInfo, load, postDeregister, postRegister, preDeregister, preRegister, removeAttributeChangeNotificationListener, removeNotificationListener, removeNotificationListener, sendAttributeChangeNotification, sendAttributeChangeNotification, sendNotification, sendNotification, setModelMBeanInfo, store
Constructor Detail
SpringModelMBean
public SpringModelMBean() throws MBeanException, RuntimeOperationsException
Construct a new SpringModelMBean instance with an emptyModelMBeanInfo.- Throws:
MBeanExceptionRuntimeOperationsException- See Also:
RequiredModelMBean()
SpringModelMBean
public SpringModelMBean(ModelMBeanInfo mbi) throws MBeanException, RuntimeOperationsException
Construct a new SpringModelMBean instance with the givenModelMBeanInfo.
Method Detail
setManagedResource
public void setManagedResource(Object managedResource, String managedResourceType) throws MBeanException, InstanceNotFoundException, InvalidTargetObjectTypeException
Sets managed resource to expose and stores itsClassLoader.- Specified by:
setManagedResourcein interfaceModelMBean- Overrides:
setManagedResourcein classRequiredModelMBean- Throws:
MBeanExceptionInstanceNotFoundExceptionInvalidTargetObjectTypeException
invoke
public Object invoke(String opName, Object[] opArgs, String[] sig) throws MBeanException, ReflectionException
Switches thecontext ClassLoaderfor the managed resourcesClassLoaderbefore allowing the invocation to occur.- Specified by:
invokein interfaceDynamicMBean- Overrides:
invokein classRequiredModelMBean- Throws:
MBeanExceptionReflectionException- See Also:
DynamicMBean.invoke(java.lang.String, java.lang.Object[], java.lang.String[])
getAttribute
public Object getAttribute(String attrName) throws AttributeNotFoundException, MBeanException, ReflectionException
Switches thecontext ClassLoaderfor the managed resourcesClassLoaderbefore allowing the invocation to occur.- Specified by:
getAttributein interfaceDynamicMBean- Overrides:
getAttributein classRequiredModelMBean- Throws:
AttributeNotFoundExceptionMBeanExceptionReflectionException- See Also:
DynamicMBean.getAttribute(java.lang.String)
getAttributes
public AttributeList getAttributes(String[] attrNames)
Switches thecontext ClassLoaderfor the managed resourcesClassLoaderbefore allowing the invocation to occur.- Specified by:
getAttributesin interfaceDynamicMBean- Overrides:
getAttributesin classRequiredModelMBean- See Also:
DynamicMBean.getAttributes(java.lang.String[])
setAttribute
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
Switches thecontext ClassLoaderfor the managed resourcesClassLoaderbefore allowing the invocation to occur.- Specified by:
setAttributein interfaceDynamicMBean- Overrides:
setAttributein classRequiredModelMBean- Throws:
AttributeNotFoundExceptionInvalidAttributeValueExceptionMBeanExceptionReflectionException- See Also:
DynamicMBean.setAttribute(javax.management.Attribute)
setAttributes
public AttributeList setAttributes(AttributeList attributes)
Switches thecontext ClassLoaderfor the managed resourcesClassLoaderbefore allowing the invocation to occur.- Specified by:
setAttributesin interfaceDynamicMBean- Overrides:
setAttributesin classRequiredModelMBean- See Also:
DynamicMBean.setAttributes(javax.management.AttributeList)