org.jboss.mx.server
Class AbstractMBeanInvoker

java.lang.Object
  extended byorg.jboss.mx.server.AbstractMBeanInvoker
All Implemented Interfaces:
DynamicMBean (src) , MBeanInvoker (src) , MBeanRegistration (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , Suspendable (src)
Direct Known Subclasses:
ModelMBeanInvoker (src) , RawDynamicInvoker (src)

public abstract class AbstractMBeanInvoker
extends java.lang.Object
implements MBeanInvoker (src)

A base MBeanInvoker class that provides common state as well as


Nested Class Summary
protected  class AbstractMBeanInvoker.OperationKey (src)
           
 
Field Summary
protected  java.util.Map attributeContextMap
           
protected  java.util.Map constructorContextMap
           
protected  boolean dynamicResource
          Whether this is a dynamic resource
protected  InvocationContext (src) getMBeanInfoCtx
           
protected  MBeanInfo (src) info
          The metadata describing this MBean.
protected  Logger (src) log
           
protected  java.util.Map operationContextMap
           
protected  InvocationContext (src) postDeregisterCtx
           
protected  InvocationContext (src) postRegisterCtx
           
protected  InvocationContext (src) preDeregisterCtx
           
protected  InvocationContext (src) preRegisterCtx
           
protected  MBeanEntry (src) resourceEntry
          The mbean server register entry used for the TCL
 
Constructor Summary
AbstractMBeanInvoker()
          Constructs a new invoker.
AbstractMBeanInvoker(MBeanEntry (src)  resourceEntry)
          Constructs an invoker with the target resource entry.
AbstractMBeanInvoker(java.lang.Object resource)
          Constructs a new invoker with a given target resource.
 
Method Summary
 void addNotificationListener(NotificationListener (src)  listener, NotificationFilter (src)  filter, java.lang.Object handback)
          Add a listener to an MBean.
protected  void addNotificationListenerToResource(NotificationListener (src)  listener, NotificationFilter (src)  filter, java.lang.Object handback)
           
 java.lang.Object getAttribute(java.lang.String attribute)
          Returns an attribte value.
 AttributeList (src) getAttributes(java.lang.String[] attributes)
          Returns the values of the attributes with names matching the passed string array.
 long getInvocationTimeout()
           
static MBeanEntry (src) getMBeanEntry()
          An accessor for the MBeanEntry thread local
 MBeanInfo (src) getMBeanInfo()
          Returns the management interface that describes this dynamic resource.
 MBeanInfo (src) getMetaData()
           
 MBeanNotificationInfo (src) [] getNotificationInfo()
          Returns the notification metadata associated with the MBean.
protected  MBeanNotificationInfo (src) [] getNotificationInfoFromResource()
           
 ObjectName (src) getObjectName()
           
 java.lang.Object getResource()
           
 MBeanServer (src) getServer()
           
protected  java.lang.String getSignatureString(java.lang.String[] signature)
           
protected  void initAttributeContexts(MBeanAttributeInfo (src) [] attributes)
           
protected  void initDispatchers()
           
protected  void initOperationContexts(MBeanOperationInfo (src) [] operations)
           
protected  void inject(java.lang.String type, java.lang.String name, java.lang.Class argType, java.lang.Object value)
          Inject context from the xmbean layer to the resource
 java.lang.Object invoke(java.lang.String operationName, java.lang.Object[] args, java.lang.String[] signature)
          Invokes the target resource.
protected  void invokePostDeregister()
           
protected  void invokePostRegister(java.lang.Boolean b)
           
protected  void invokePreDeregister()
           
protected  ObjectName (src) invokePreRegister(MBeanServer (src)  server, ObjectName (src)  name)
           
 boolean isSuspended()
           
protected  void override(Invocation (src)  invocation)
          Placeholder to allow subclasses to override the invocation
 void postDeregister()
          This method is called by the MBeanServer after deregistration takes place.
 void postRegister(java.lang.Boolean registrationSuccessful)
          This method is called by the MBeanServer after registration takes place or when registration fails.
 void preDeregister()
          This method is called by the MBeanServer before deregistration takes place.
 ObjectName (src) preRegister(MBeanServer (src)  server, ObjectName (src)  name)
          Initializes this invoker.
 void removeNotificationListener(NotificationListener (src)  listener)
          Removes a listener from an MBean.
 void removeNotificationListener(NotificationListener (src)  listener, NotificationFilter (src)  filter, java.lang.Object handback)
          Removes a listener from the Emitter.
protected  void removeNotificationListenerFromResource(NotificationListener (src)  listener)
           
protected  void removeNotificationListenerFromResource(NotificationListener (src)  listener, NotificationFilter (src)  filter, java.lang.Object handback)
           
 void resume()
           
 void setAttribute(Attribute (src)  attribute)
          Sets an attribute value.
 AttributeList (src) setAttributes(AttributeList (src)  attributes)
          Sets the values of the attributes passed as an AttributeList (src) of name and new value pairs.
 void setInvocationTimeout(long time)
           
static void setMBeanEntry(MBeanEntry (src)  entry)
          Set the MBeanEntry thread local value.
 void setResource(java.lang.Object resource)
          Sets the XMBean resource and optionally allows the resource to interact with the jmx microkernel via the following injection points: #ModelMBeanConstants.MBEAN_SERVER_INJECTION_TYPE #ModelMBeanConstants.MBEAN_INFO_INJECTION_TYPE #ModelMBeanConstants.OBJECT_NAME_INJECTION_TYPE
 void suspend()
           
 void suspend(boolean force)
           
 void suspend(long wait)
           
 void updateAttributeInfo(Descriptor (src)  attrDesc)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resourceEntry

protected MBeanEntry (src)  resourceEntry
The mbean server register entry used for the TCL


dynamicResource

protected boolean dynamicResource
Whether this is a dynamic resource


info

protected MBeanInfo (src)  info
The metadata describing this MBean.


attributeContextMap

protected java.util.Map attributeContextMap

operationContextMap

protected java.util.Map operationContextMap

constructorContextMap

protected java.util.Map constructorContextMap

getMBeanInfoCtx

protected InvocationContext (src)  getMBeanInfoCtx

preRegisterCtx

protected InvocationContext (src)  preRegisterCtx

postRegisterCtx

protected InvocationContext (src)  postRegisterCtx

preDeregisterCtx

protected InvocationContext (src)  preDeregisterCtx

postDeregisterCtx

protected InvocationContext (src)  postDeregisterCtx

log

protected Logger (src)  log
Constructor Detail

AbstractMBeanInvoker

public AbstractMBeanInvoker()
Constructs a new invoker.


AbstractMBeanInvoker

public AbstractMBeanInvoker(java.lang.Object resource)
Constructs a new invoker with a given target resource.


AbstractMBeanInvoker

public AbstractMBeanInvoker(MBeanEntry (src)  resourceEntry)
Constructs an invoker with the target resource entry.

Parameters:
resourceEntry -
Method Detail

setMBeanEntry

public static void setMBeanEntry(MBeanEntry (src)  entry)
Set the MBeanEntry thread local value.

Parameters:
entry - - the entry that will be used on successful registration

getMBeanEntry

public static MBeanEntry (src)  getMBeanEntry()
An accessor for the MBeanEntry thread local

Returns:

updateAttributeInfo

public void updateAttributeInfo(Descriptor (src)  attrDesc)
                         throws MBeanException (src) 
Specified by:
updateAttributeInfo in interface MBeanInvoker (src)
Throws:
MBeanException (src)

invoke

public java.lang.Object invoke(java.lang.String operationName,
                               java.lang.Object[] args,
                               java.lang.String[] signature)
                        throws MBeanException (src) ,
                               ReflectionException (src) 
Invokes the target resource. The default invocation used by this invoker implement sends the invocation through a stack of interceptors before reaching the target method.

Specified by:
invoke in interface DynamicMBean (src)
Parameters:
operationName - name of the target method
args - argumetns for the target method
signature - signature of the target method
Returns:
the result of the operation.
Throws:
MBeanException (src) - if the target method raised a hecked exception
ReflectionException (src) - if there was an error trying to resolve or invoke the target method
RuntimeMBeanException (src) - if the target method raised an unchecked exception

getAttribute

public java.lang.Object getAttribute(java.lang.String attribute)
                              throws AttributeNotFoundException (src) ,
                                     MBeanException (src) ,
                                     ReflectionException (src) 
Returns an attribte value. The request for the value is forced through a set of interceptors before the value is returned.

Specified by:
getAttribute in interface DynamicMBean (src)
Parameters:
attribute - attribute name
Returns:
attribute value
Throws:
AttributeNotFoundException (src) - if the requested attribute is not part of the MBean's management interface
MBeanException (src) - if retrieving the attribute value causes an application exception
ReflectionException (src) - if there was an error trying to retrieve the attribute value

setAttribute

public void setAttribute(Attribute (src)  attribute)
                  throws AttributeNotFoundException (src) ,
                         InvalidAttributeValueException (src) ,
                         MBeanException (src) ,
                         ReflectionException (src) 
Sets an attribute value. The operation is forced through a set of interceptors before the new value for the attribute is set.

Specified by:
setAttribute in interface DynamicMBean (src)
Parameters:
attribute - new attribute value
Throws:
AttributeNotFoundException (src) - if the requested attribute is not part of the MBean's management interface
InvalidAttributeValueException (src) - if the attribute contains a value not suitable for the attribute
MBeanException (src) - if setting the attribute value causes an application exception
ReflectionException (src) - if there was an error trying to set the attribute value.
See Also:
Attribute (src)

getMBeanInfo

public MBeanInfo (src)  getMBeanInfo()
Description copied from interface: DynamicMBean (src)
Returns the management interface that describes this dynamic resource. It is the responsibility of the implementation to make sure the description is accurate.

Specified by:
getMBeanInfo in interface DynamicMBean (src)
Returns:
the management interface.

getAttributes

public AttributeList (src)  getAttributes(java.lang.String[] attributes)
Description copied from interface: DynamicMBean (src)
Returns the values of the attributes with names matching the passed string array.

Specified by:
getAttributes in interface DynamicMBean (src)
Parameters:
attributes - the names of the attribute.
Returns:
an AttributeList (src) of name and value pairs.

setAttributes

public AttributeList (src)  setAttributes(AttributeList (src)  attributes)
Description copied from interface: DynamicMBean (src)
Sets the values of the attributes passed as an AttributeList (src) of name and new value pairs.

Specified by:
setAttributes in interface DynamicMBean (src)
Parameters:
attributes - the name an new value pairs.
Returns:
an AttributeList (src) of name and value pairs that were actually set.

preRegister

public ObjectName (src)  preRegister(MBeanServer (src)  server,
                              ObjectName (src)  name)
                       throws java.lang.Exception
Initializes this invoker. At the registration time we can be sure that all of the metadata is available and initialize the invoker and cache the data accordingly.

Subclasses that override the preRegister method must make sure they call super.preRegister() in their implementation to ensure proper initialization of the invoker.

Specified by:
preRegister in interface MBeanRegistration (src)
Returns:
the actual ObjectName to register this MBean with.
Throws:
java.lang.Exception - for any error, the MBean is not registered.

postRegister

public void postRegister(java.lang.Boolean registrationSuccessful)
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer after registration takes place or when registration fails.

Specified by:
postRegister in interface MBeanRegistration (src)
Parameters:
registrationSuccessful - the MBeanServer passes true when the MBean was registered, false otherwise.

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer before deregistration takes place.

The MBean can throw an exception, this will stop the deregistration. The exception is forwarded to the invoker wrapped in an MBeanRegistrationException.

Specified by:
preDeregister in interface MBeanRegistration (src)
Throws:
java.lang.Exception

postDeregister

public void postDeregister()
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer after deregistration takes place.

Specified by:
postDeregister in interface MBeanRegistration (src)

addNotificationListener

public void addNotificationListener(NotificationListener (src)  listener,
                                    NotificationFilter (src)  filter,
                                    java.lang.Object handback)
Description copied from interface: NotificationBroadcaster (src)
Add a listener to an MBean.

Specified by:
addNotificationListener in interface NotificationBroadcaster (src)
Parameters:
listener - implementation of the listener object
filter - implementation of the filter object or null if no filtering is required
handback - A handback object associated with each notification sent by this notification broadcaster.

addNotificationListenerToResource

protected void addNotificationListenerToResource(NotificationListener (src)  listener,
                                                 NotificationFilter (src)  filter,
                                                 java.lang.Object handback)

removeNotificationListener

public void removeNotificationListener(NotificationListener (src)  listener)
                                throws ListenerNotFoundException (src) 
Description copied from interface: NotificationBroadcaster (src)
Removes a listener from an MBean.

Specified by:
removeNotificationListener in interface NotificationBroadcaster (src)
Parameters:
listener - the listener object to remove
Throws:
ListenerNotFoundException (src) - if the listener was not found

removeNotificationListenerFromResource

protected void removeNotificationListenerFromResource(NotificationListener (src)  listener)
                                               throws ListenerNotFoundException (src) 
Throws:
ListenerNotFoundException (src)

removeNotificationListener

public void removeNotificationListener(NotificationListener (src)  listener,
                                       NotificationFilter (src)  filter,
                                       java.lang.Object handback)
                                throws ListenerNotFoundException (src) 
Description copied from interface: NotificationEmitter (src)
Removes a listener from the Emitter.

Only the listener, filter, handback triplet is removed

Specified by:
removeNotificationListener in interface NotificationEmitter (src)
Parameters:
listener - the listener object to remove
filter - the filter registered with the listener
handback - the handback object associated with the registered listener
Throws:
ListenerNotFoundException (src) - if the listener was not found

removeNotificationListenerFromResource

protected void removeNotificationListenerFromResource(NotificationListener (src)  listener,
                                                      NotificationFilter (src)  filter,
                                                      java.lang.Object handback)
                                               throws ListenerNotFoundException (src) 
Throws:
ListenerNotFoundException (src)

getNotificationInfo

public MBeanNotificationInfo (src) [] getNotificationInfo()
Description copied from interface: NotificationBroadcaster (src)
Returns the notification metadata associated with the MBean.

Specified by:
getNotificationInfo in interface NotificationBroadcaster (src)
Returns:
MBean's notification metadata
See Also:
MBeanNotificationInfo (src)

getNotificationInfoFromResource

protected MBeanNotificationInfo (src) [] getNotificationInfoFromResource()

getResource

public java.lang.Object getResource()
Specified by:
getResource in interface MBeanInvoker (src)

setResource

public void setResource(java.lang.Object resource)
Sets the XMBean resource and optionally allows the resource to interact with the jmx microkernel via the following injection points: #ModelMBeanConstants.MBEAN_SERVER_INJECTION_TYPE #ModelMBeanConstants.MBEAN_INFO_INJECTION_TYPE #ModelMBeanConstants.OBJECT_NAME_INJECTION_TYPE

Specified by:
setResource in interface MBeanInvoker (src)
Parameters:
resource - - the model mbean resource

getMetaData

public MBeanInfo (src)  getMetaData()
Specified by:
getMetaData in interface MBeanInvoker (src)

getObjectName

public ObjectName (src)  getObjectName()
Specified by:
getObjectName in interface MBeanInvoker (src)

suspend

public void suspend()
Specified by:
suspend in interface Suspendable (src)

suspend

public void suspend(long wait)
             throws TimeoutException (src) 
Specified by:
suspend in interface Suspendable (src)
Throws:
TimeoutException (src)

suspend

public void suspend(boolean force)
Specified by:
suspend in interface Suspendable (src)

isSuspended

public boolean isSuspended()
Specified by:
isSuspended in interface Suspendable (src)

setInvocationTimeout

public void setInvocationTimeout(long time)
Specified by:
setInvocationTimeout in interface Suspendable (src)

getInvocationTimeout

public long getInvocationTimeout()
Specified by:
getInvocationTimeout in interface Suspendable (src)

resume

public void resume()
Specified by:
resume in interface Suspendable (src)

getServer

public MBeanServer (src)  getServer()

inject

protected void inject(java.lang.String type,
                      java.lang.String name,
                      java.lang.Class argType,
                      java.lang.Object value)
Inject context from the xmbean layer to the resource

Parameters:
type - - the type of injection
name - - the setter method name of the resource
argType - - the injection data type
value - - the injection data value to pass to the setter

invokePreRegister

protected ObjectName (src)  invokePreRegister(MBeanServer (src)  server,
                                       ObjectName (src)  name)
                                throws java.lang.Exception
Throws:
java.lang.Exception

invokePostRegister

protected void invokePostRegister(java.lang.Boolean b)

invokePreDeregister

protected void invokePreDeregister()
                            throws java.lang.Exception
Throws:
java.lang.Exception

invokePostDeregister

protected void invokePostDeregister()

initAttributeContexts

protected void initAttributeContexts(MBeanAttributeInfo (src) [] attributes)

initOperationContexts

protected void initOperationContexts(MBeanOperationInfo (src) [] operations)

initDispatchers

protected void initDispatchers()

override

protected void override(Invocation (src)  invocation)
                 throws MBeanException (src) 
Placeholder to allow subclasses to override the invocation

Parameters:
invocation - the invocation
Throws:
MBeanException (src) - for any error

getSignatureString

protected java.lang.String getSignatureString(java.lang.String[] signature)