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 theRequiredModelMBean
class that ensures thethread context ClassLoader
is switched for the managed resource'sClassLoader
before 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 Object
getAttribute(String attrName)
Switches thecontext ClassLoader
for the managed resourcesClassLoader
before allowing the invocation to occur.AttributeList
getAttributes(String[] attrNames)
Switches thecontext ClassLoader
for the managed resourcesClassLoader
before allowing the invocation to occur.Object
invoke(String opName, Object[] opArgs, String[] sig)
Switches thecontext ClassLoader
for the managed resourcesClassLoader
before allowing the invocation to occur.void
setAttribute(Attribute attribute)
Switches thecontext ClassLoader
for the managed resourcesClassLoader
before allowing the invocation to occur.AttributeList
setAttributes(AttributeList attributes)
Switches thecontext ClassLoader
for the managed resourcesClassLoader
before allowing the invocation to occur.void
setManagedResource(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:
MBeanException
RuntimeOperationsException
- 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:
setManagedResource
in interfaceModelMBean
- Overrides:
setManagedResource
in classRequiredModelMBean
- Throws:
MBeanException
InstanceNotFoundException
InvalidTargetObjectTypeException
invoke
public Object invoke(String opName, Object[] opArgs, String[] sig) throws MBeanException, ReflectionException
Switches thecontext ClassLoader
for the managed resourcesClassLoader
before allowing the invocation to occur.- Specified by:
invoke
in interfaceDynamicMBean
- Overrides:
invoke
in classRequiredModelMBean
- Throws:
MBeanException
ReflectionException
- 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 ClassLoader
for the managed resourcesClassLoader
before allowing the invocation to occur.- Specified by:
getAttribute
in interfaceDynamicMBean
- Overrides:
getAttribute
in classRequiredModelMBean
- Throws:
AttributeNotFoundException
MBeanException
ReflectionException
- See Also:
DynamicMBean.getAttribute(java.lang.String)
getAttributes
public AttributeList getAttributes(String[] attrNames)
Switches thecontext ClassLoader
for the managed resourcesClassLoader
before allowing the invocation to occur.- Specified by:
getAttributes
in interfaceDynamicMBean
- Overrides:
getAttributes
in classRequiredModelMBean
- See Also:
DynamicMBean.getAttributes(java.lang.String[])
setAttribute
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
Switches thecontext ClassLoader
for the managed resourcesClassLoader
before allowing the invocation to occur.- Specified by:
setAttribute
in interfaceDynamicMBean
- Overrides:
setAttribute
in classRequiredModelMBean
- Throws:
AttributeNotFoundException
InvalidAttributeValueException
MBeanException
ReflectionException
- See Also:
DynamicMBean.setAttribute(javax.management.Attribute)
setAttributes
public AttributeList setAttributes(AttributeList attributes)
Switches thecontext ClassLoader
for the managed resourcesClassLoader
before allowing the invocation to occur.- Specified by:
setAttributes
in interfaceDynamicMBean
- Overrides:
setAttributes
in classRequiredModelMBean
- See Also:
DynamicMBean.setAttributes(javax.management.AttributeList)