The Spring Framework

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:
DynamicMBean, MBeanRegistration, ModelMBean, ModelMBeanNotificationBroadcaster, NotificationBroadcaster, NotificationEmitter, PersistentMBean

public class SpringModelMBean
extends 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

Constructor Summary
SpringModelMBean()
          Construct a new SpringModelMBean instance with an empty ModelMBeanInfo.
SpringModelMBean(ModelMBeanInfo mbi)
          Construct a new SpringModelMBean instance with the given ModelMBeanInfo.
 
Method Summary
 Object getAttribute(String attrName)
          Switches the context ClassLoader for the managed resources ClassLoader before allowing the invocation to occur.
 AttributeList getAttributes(String[] attrNames)
          Switches the context ClassLoader for the managed resources ClassLoader before allowing the invocation to occur.
 Object invoke(String opName, Object[] opArgs, String[] sig)
          Switches the context ClassLoader for the managed resources ClassLoader before allowing the invocation to occur.
 void setAttribute(Attribute attribute)
          Switches the context ClassLoader for the managed resources ClassLoader before allowing the invocation to occur.
 AttributeList setAttributes(AttributeList attributes)
          Switches the context ClassLoader for the managed resources ClassLoader before allowing the invocation to occur.
 void setManagedResource(Object managedResource, 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
 

Constructor Detail

SpringModelMBean

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

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

SpringModelMBean

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

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

setManagedResource

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

Specified by:
setManagedResource in interface ModelMBean
Overrides:
setManagedResource in class RequiredModelMBean
Throws:
MBeanException
InstanceNotFoundException
InvalidTargetObjectTypeException

invoke

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

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

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

getAttributes

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

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

setAttribute

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

Specified by:
setAttribute in interface DynamicMBean
Overrides:
setAttribute in class RequiredModelMBean
Throws:
AttributeNotFoundException
InvalidAttributeValueException
MBeanException
ReflectionException
See Also:
DynamicMBean.setAttribute(javax.management.Attribute)

setAttributes

public AttributeList setAttributes(AttributeList attributes)
Switches the context ClassLoader for the managed resources ClassLoader before allowing the invocation to occur.

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

The Spring Framework

Copyright © 2002-2008 The Spring Framework.