org.jboss.mx.server
Class AbstractMBeanInvoker

java.lang.Object
  extended by org.jboss.mx.server.AbstractMBeanInvoker
All Implemented Interfaces:
DynamicMBean, MBeanRegistration, NotificationBroadcaster, NotificationEmitter, Interceptable, MBeanInvoker, Suspendable
Direct Known Subclasses:
ModelMBeanInvoker, RawDynamicInvoker

public abstract class AbstractMBeanInvoker
extends Object
implements MBeanInvoker

A base MBeanInvoker class that provides common state

Version:
$Revision: 81026 $
Author:
Juha Lindfors., Scott Stark., Dimitris Andreadis.

Nested Class Summary
protected  class AbstractMBeanInvoker.OperationKey
           
 
Field Summary
protected  Map attributeContextMap
           
protected  Map constructorContextMap
           
protected  boolean dynamicResource
          Whether this is a dynamic resource
protected  InvocationContext getMBeanInfoCtx
           
protected  MBeanInfo info
          The metadata describing this MBean.
protected  org.jboss.logging.Logger log
           
protected  Map operationContextMap
           
protected  InvocationContext postDeregisterCtx
           
protected  InvocationContext postRegisterCtx
           
protected  InvocationContext preDeregisterCtx
           
protected  InvocationContext preRegisterCtx
           
protected  MBeanEntry resourceEntry
          The mbean server register entry used for the TCL
 
Constructor Summary
AbstractMBeanInvoker()
          Constructs a new invoker.
AbstractMBeanInvoker(MBeanEntry resourceEntry)
          Constructs an invoker with the target resource entry.
AbstractMBeanInvoker(Object resource)
          Constructs a new invoker with a given target resource.
 
Method Summary
 void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
           
protected  void addNotificationListenerToResource(NotificationListener listener, NotificationFilter filter, Object handback)
           
 void addOperationInterceptor(Interceptor interceptor)
          Add dynamically an operation interceptor, first in the chain.
 Object getAttribute(String attribute)
          Returns an attribte value.
 AttributeList getAttributes(String[] attributes)
           
 long getInvocationTimeout()
           
static MBeanEntry getMBeanEntry()
          An accessor for the MBeanEntry thread local
 MBeanInfo getMBeanInfo()
           
 MBeanInfo getMetaData()
           
 MBeanNotificationInfo[] getNotificationInfo()
           
protected  MBeanNotificationInfo[] getNotificationInfoFromResource()
           
 ObjectName getObjectName()
           
 Object getResource()
           
 MBeanServer getServer()
           
protected  String getSignatureString(String[] signature)
           
protected  void initAttributeContexts(MBeanAttributeInfo[] attributes)
           
protected  void initDispatchers()
           
protected  void initOperationContexts(MBeanOperationInfo[] operations)
           
protected  void inject(String type, String name, Class argType, Object value)
          Inject context from the xmbean layer to the resource
 Object invoke(String operationName, Object[] args, String[] signature)
          Invokes the target resource.
protected  void invokePostDeregister()
           
protected  void invokePostRegister(Boolean b)
           
protected  void invokePreDeregister()
           
protected  ObjectName invokePreRegister(MBeanServer server, ObjectName name)
           
 boolean isSuspended()
           
protected  void override(Invocation invocation)
          Placeholder to allow subclasses to override the invocation
 void postDeregister()
           
 void postRegister(Boolean registrationSuccessful)
           
 void preDeregister()
           
 ObjectName preRegister(MBeanServer server, ObjectName name)
          Initializes this invoker.
 void removeNotificationListener(NotificationListener listener)
           
 void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
           
protected  void removeNotificationListenerFromResource(NotificationListener listener)
           
protected  void removeNotificationListenerFromResource(NotificationListener listener, NotificationFilter filter, Object handback)
           
 void removeOperationInterceptor(Interceptor interceptor)
          Remove the specified operation interceptor
 void resume()
           
 void setAttribute(Attribute attribute)
          Sets an attribute value.
 AttributeList setAttributes(AttributeList attributes)
           
 void setInvocationTimeout(long time)
           
static void setMBeanEntry(MBeanEntry entry)
          Set the MBeanEntry thread local value.
 void setResource(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 attrDesc)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resourceEntry

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


dynamicResource

protected boolean dynamicResource
Whether this is a dynamic resource


info

protected MBeanInfo info
The metadata describing this MBean.


attributeContextMap

protected Map attributeContextMap

operationContextMap

protected Map operationContextMap

constructorContextMap

protected Map constructorContextMap

getMBeanInfoCtx

protected InvocationContext getMBeanInfoCtx

preRegisterCtx

protected InvocationContext preRegisterCtx

postRegisterCtx

protected InvocationContext postRegisterCtx

preDeregisterCtx

protected InvocationContext preDeregisterCtx

postDeregisterCtx

protected InvocationContext postDeregisterCtx

log

protected org.jboss.logging.Logger log
Constructor Detail

AbstractMBeanInvoker

public AbstractMBeanInvoker()
Constructs a new invoker.


AbstractMBeanInvoker

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


AbstractMBeanInvoker

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

Parameters:
resourceEntry -
Method Detail

setMBeanEntry

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

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

getMBeanEntry

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

Returns:

invoke

public Object invoke(String operationName,
                     Object[] args,
                     String[] signature)
              throws MBeanException,
                     ReflectionException
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
Parameters:
operationName - name of the target method
args - argumetns for the target method
signature - signature of the target method
Throws:
MBeanException - if the target method raised a hecked exception
ReflectionException - if there was an error trying to resolve or invoke the target method
RuntimeMBeanException - if the target method raised an unchecked exception

getAttribute

public Object getAttribute(String attribute)
                    throws AttributeNotFoundException,
                           MBeanException,
                           ReflectionException
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
Parameters:
attribute - attribute name
Returns:
attribute value
Throws:
AttributeNotFoundException - if the requested attribute is not part of the MBean's management interface
MBeanException - if retrieving the attribute value causes an application exception
ReflectionException - if there was an error trying to retrieve the attribute value

setAttribute

public void setAttribute(Attribute attribute)
                  throws AttributeNotFoundException,
                         InvalidAttributeValueException,
                         MBeanException,
                         ReflectionException
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
Parameters:
attribute - new attribute value
Throws:
AttributeNotFoundException - if the requested attribute is not part of the MBean's management interface
InvalidAttributeValueException - if the attribute contains a value not suitable for the attribute
MBeanException - if setting the attribute value causes an application exception
ReflectionException - if there was an error trying to set the attribute value.

getMBeanInfo

public MBeanInfo getMBeanInfo()
Specified by:
getMBeanInfo in interface DynamicMBean

getAttributes

public AttributeList getAttributes(String[] attributes)
Specified by:
getAttributes in interface DynamicMBean

setAttributes

public AttributeList setAttributes(AttributeList attributes)
Specified by:
setAttributes in interface DynamicMBean

preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
                       throws 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
Throws:
Exception

postRegister

public void postRegister(Boolean registrationSuccessful)
Specified by:
postRegister in interface MBeanRegistration

preDeregister

public void preDeregister()
                   throws Exception
Specified by:
preDeregister in interface MBeanRegistration
Throws:
Exception

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface MBeanRegistration

addNotificationListener

public void addNotificationListener(NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback)
Specified by:
addNotificationListener in interface NotificationBroadcaster

addNotificationListenerToResource

protected void addNotificationListenerToResource(NotificationListener listener,
                                                 NotificationFilter filter,
                                                 Object handback)

removeNotificationListener

public void removeNotificationListener(NotificationListener listener)
                                throws ListenerNotFoundException
Specified by:
removeNotificationListener in interface NotificationBroadcaster
Throws:
ListenerNotFoundException

removeNotificationListenerFromResource

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

removeNotificationListener

public void removeNotificationListener(NotificationListener listener,
                                       NotificationFilter filter,
                                       Object handback)
                                throws ListenerNotFoundException
Specified by:
removeNotificationListener in interface NotificationEmitter
Throws:
ListenerNotFoundException

removeNotificationListenerFromResource

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

getNotificationInfo

public MBeanNotificationInfo[] getNotificationInfo()
Specified by:
getNotificationInfo in interface NotificationBroadcaster

getNotificationInfoFromResource

protected MBeanNotificationInfo[] getNotificationInfoFromResource()

getMetaData

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

getResource

public Object getResource()
Specified by:
getResource in interface MBeanInvoker

setResource

public void setResource(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
Parameters:
resource - - the model mbean resource

getObjectName

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

updateAttributeInfo

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

addOperationInterceptor

public void addOperationInterceptor(Interceptor interceptor)
Add dynamically an operation interceptor, first in the chain.

Specified by:
addOperationInterceptor in interface Interceptable

removeOperationInterceptor

public void removeOperationInterceptor(Interceptor interceptor)
Remove the specified operation interceptor

Specified by:
removeOperationInterceptor in interface Interceptable

suspend

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

suspend

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

suspend

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

isSuspended

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

setInvocationTimeout

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

getInvocationTimeout

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

resume

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

getServer

public MBeanServer getServer()

inject

protected void inject(String type,
                      String name,
                      Class argType,
                      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 invokePreRegister(MBeanServer server,
                                       ObjectName name)
                                throws Exception
Throws:
Exception

invokePostRegister

protected void invokePostRegister(Boolean b)

invokePreDeregister

protected void invokePreDeregister()
                            throws Exception
Throws:
Exception

invokePostDeregister

protected void invokePostDeregister()

initAttributeContexts

protected void initAttributeContexts(MBeanAttributeInfo[] attributes)

initOperationContexts

protected void initOperationContexts(MBeanOperationInfo[] operations)

initDispatchers

protected void initDispatchers()

override

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

Parameters:
invocation - the invocation
Throws:
MBeanException - for any error

getSignatureString

protected String getSignatureString(String[] signature)


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.