org.springframework.jmx.export
Class SpringModelMBean

java.lang.Object
  extended by javax.management.modelmbean.RequiredModelMBean
      extended by org.springframework.jmx.export.SpringModelMBean
All Implemented Interfaces:
javax.management.DynamicMBean, javax.management.MBeanRegistration, javax.management.modelmbean.ModelMBean, javax.management.modelmbean.ModelMBeanNotificationBroadcaster, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, javax.management.PersistentMBean

public class SpringModelMBean
extends javax.management.modelmbean.RequiredModelMBean

Extension of the RequiredModelMBean class that ensures the thread context ClassLoader is switched for the managed resource's ClassLoader before any invocations occur.

Since:
2.0
Author:
Rob Harrop
See Also:
RequiredModelMBean

Field Summary
private  java.lang.ClassLoader managedResourceClassLoader
          Stores the ClassLoader to use for invocations.
 
Constructor Summary
SpringModelMBean()
          Construct a new SpringModelMBean instance with an empty ModelMBeanInfo.
SpringModelMBean(javax.management.modelmbean.ModelMBeanInfo mbi)
          Construct a new SpringModelMBean instance with the given ModelMBeanInfo.
 
Method Summary
 java.lang.Object getAttribute(java.lang.String attrName)
          Switches the context ClassLoader for the managed resources ClassLoader before allowing the invocation to occur.
 javax.management.AttributeList getAttributes(java.lang.String[] attrNames)
          Switches the context ClassLoader for the managed resources ClassLoader before allowing the invocation to occur.
 java.lang.Object invoke(java.lang.String opName, java.lang.Object[] opArgs, java.lang.String[] sig)
          Switches the context ClassLoader for the managed resources ClassLoader before allowing the invocation to occur.
 void setAttribute(javax.management.Attribute attribute)
          Switches the context ClassLoader for the managed resources ClassLoader before allowing the invocation to occur.
 javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
          Switches the context ClassLoader for the managed resources ClassLoader before allowing the invocation to occur.
 void setManagedResource(java.lang.Object managedResource, java.lang.String managedResourceType)
          Sets managed resource to expose and stores its ClassLoader.
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

managedResourceClassLoader

private java.lang.ClassLoader managedResourceClassLoader
Stores the ClassLoader to use for invocations. Defaults to the current thread ClassLoader.

Constructor Detail

SpringModelMBean

public SpringModelMBean()
                 throws javax.management.MBeanException,
                        javax.management.RuntimeOperationsException
Construct a new SpringModelMBean instance with an empty ModelMBeanInfo.

Throws:
javax.management.MBeanException
javax.management.RuntimeOperationsException
See Also:
RequiredModelMBean.RequiredModelMBean()

SpringModelMBean

public SpringModelMBean(javax.management.modelmbean.ModelMBeanInfo mbi)
                 throws javax.management.MBeanException,
                        javax.management.RuntimeOperationsException
Construct a new SpringModelMBean instance with the given ModelMBeanInfo.

Throws:
javax.management.MBeanException
javax.management.RuntimeOperationsException
See Also:
RequiredModelMBean.RequiredModelMBean(ModelMBeanInfo)
Method Detail

setManagedResource

public void setManagedResource(java.lang.Object managedResource,
                               java.lang.String managedResourceType)
                        throws javax.management.MBeanException,
                               javax.management.InstanceNotFoundException,
                               javax.management.modelmbean.InvalidTargetObjectTypeException
Sets managed resource to expose and stores its ClassLoader.

Specified by:
setManagedResource in interface javax.management.modelmbean.ModelMBean
Overrides:
setManagedResource in class javax.management.modelmbean.RequiredModelMBean
Throws:
javax.management.MBeanException
javax.management.InstanceNotFoundException
javax.management.modelmbean.InvalidTargetObjectTypeException

invoke

public java.lang.Object invoke(java.lang.String opName,
                               java.lang.Object[] opArgs,
                               java.lang.String[] sig)
                        throws javax.management.MBeanException,
                               javax.management.ReflectionException
Switches the context ClassLoader for the managed resources ClassLoader before allowing the invocation to occur.

Specified by:
invoke in interface javax.management.DynamicMBean
Overrides:
invoke in class javax.management.modelmbean.RequiredModelMBean
Throws:
javax.management.MBeanException
javax.management.ReflectionException
See Also:
DynamicMBean.invoke(java.lang.String, java.lang.Object[], java.lang.String[])

getAttribute

public java.lang.Object getAttribute(java.lang.String attrName)
                              throws javax.management.AttributeNotFoundException,
                                     javax.management.MBeanException,
                                     javax.management.ReflectionException
Switches the context ClassLoader for the managed resources ClassLoader before allowing the invocation to occur.

Specified by:
getAttribute in interface javax.management.DynamicMBean
Overrides:
getAttribute in class javax.management.modelmbean.RequiredModelMBean
Throws:
javax.management.AttributeNotFoundException
javax.management.MBeanException
javax.management.ReflectionException
See Also:
DynamicMBean.getAttribute(java.lang.String)

getAttributes

public javax.management.AttributeList getAttributes(java.lang.String[] attrNames)
Switches the context ClassLoader for the managed resources ClassLoader before allowing the invocation to occur.

Specified by:
getAttributes in interface javax.management.DynamicMBean
Overrides:
getAttributes in class javax.management.modelmbean.RequiredModelMBean
See Also:
DynamicMBean.getAttributes(java.lang.String[])

setAttribute

public void setAttribute(javax.management.Attribute attribute)
                  throws javax.management.AttributeNotFoundException,
                         javax.management.InvalidAttributeValueException,
                         javax.management.MBeanException,
                         javax.management.ReflectionException
Switches the context ClassLoader for the managed resources ClassLoader before allowing the invocation to occur.

Specified by:
setAttribute in interface javax.management.DynamicMBean
Overrides:
setAttribute in class javax.management.modelmbean.RequiredModelMBean
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)
Switches the context ClassLoader for the managed resources ClassLoader before allowing the invocation to occur.

Specified by:
setAttributes in interface javax.management.DynamicMBean
Overrides:
setAttributes in class javax.management.modelmbean.RequiredModelMBean
See Also:
DynamicMBean.setAttributes(javax.management.AttributeList)