mx4j.server
Class ReflectionMBeanInvoker

java.lang.Object
  extended bymx4j.server.ReflectionMBeanInvoker
All Implemented Interfaces:
MBeanInvoker
Direct Known Subclasses:
CachingReflectionMBeanInvoker

public class ReflectionMBeanInvoker
extends java.lang.Object
implements MBeanInvoker

Stateless MBeanInvoker that uses reflection to invoke on MBean instances.

Version:
$Revision: 1.6 $

Field Summary
protected static java.lang.Object[] EMPTY_ARGS
          A zero-length Object[] that indicates a parameterless argument list of a method
protected static java.lang.String[] EMPTY_PARAMS
          A zero-length String[] that indicates a parameterless signature of a method.
 
Constructor Summary
ReflectionMBeanInvoker()
           
 
Method Summary
protected  java.lang.Object doInvoke(MBeanMetaData metadata, java.lang.String method, java.lang.String[] signature, java.lang.Object[] args)
          Centralizes exception handling necessary to convert exceptions thrown by MBean's methods to JMX exceptions.
 java.lang.Object getAttribute(MBeanMetaData metadata, java.lang.String attribute)
          Returns the value of the specified attribute.
protected  java.lang.String getMethodForAttribute(javax.management.MBeanAttributeInfo attribute, boolean forRead)
          Returns the method name for the given attribute.
protected  javax.management.MBeanAttributeInfo getStandardAttributeInfo(MBeanMetaData metadata, java.lang.String attribute, boolean forWrite)
          Returns the MBeanAttributeInfo for the given attribute, or null if the attribute is not a management attribute.
protected  java.lang.reflect.Method getStandardManagementMethod(MBeanMetaData metadata, java.lang.String name, java.lang.String[] signature)
          Returns a java.lang.reflect.Method object for the given method name and signature.
protected  javax.management.MBeanOperationInfo getStandardOperationInfo(MBeanMetaData metadata, java.lang.String method, java.lang.String[] signature)
          Returns the MBeanOperationInfo for the given operation, or null if the operation is not a management operation.
 java.lang.Object invoke(MBeanMetaData metadata, java.lang.String method, java.lang.String[] params, java.lang.Object[] args)
          Invokes the specified operation on the MBean instance
protected  java.lang.Object invokeImpl(MBeanMetaData metadata, java.lang.String method, java.lang.String[] signature, java.lang.Object[] args)
          Performs the actual invocation of the MBean's method.
 void setAttribute(MBeanMetaData metadata, javax.management.Attribute attribute)
          Sets the value of the specified attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_PARAMS

protected static final java.lang.String[] EMPTY_PARAMS
A zero-length String[] that indicates a parameterless signature of a method.


EMPTY_ARGS

protected static final java.lang.Object[] EMPTY_ARGS
A zero-length Object[] that indicates a parameterless argument list of a method

Constructor Detail

ReflectionMBeanInvoker

public ReflectionMBeanInvoker()
Method Detail

invoke

public java.lang.Object invoke(MBeanMetaData metadata,
                               java.lang.String method,
                               java.lang.String[] params,
                               java.lang.Object[] args)
                        throws javax.management.MBeanException,
                               javax.management.ReflectionException
Description copied from interface: MBeanInvoker
Invokes the specified operation on the MBean instance

Specified by:
invoke in interface MBeanInvoker
Throws:
javax.management.MBeanException
javax.management.ReflectionException

getAttribute

public java.lang.Object getAttribute(MBeanMetaData metadata,
                                     java.lang.String attribute)
                              throws javax.management.MBeanException,
                                     javax.management.AttributeNotFoundException,
                                     javax.management.ReflectionException
Description copied from interface: MBeanInvoker
Returns the value of the specified attribute.

Specified by:
getAttribute in interface MBeanInvoker
Throws:
javax.management.MBeanException
javax.management.AttributeNotFoundException
javax.management.ReflectionException

setAttribute

public void setAttribute(MBeanMetaData metadata,
                         javax.management.Attribute attribute)
                  throws javax.management.MBeanException,
                         javax.management.AttributeNotFoundException,
                         javax.management.InvalidAttributeValueException,
                         javax.management.ReflectionException
Description copied from interface: MBeanInvoker
Sets the value of the specified attribute.

Specified by:
setAttribute in interface MBeanInvoker
Throws:
javax.management.MBeanException
javax.management.AttributeNotFoundException
javax.management.InvalidAttributeValueException
javax.management.ReflectionException

doInvoke

protected java.lang.Object doInvoke(MBeanMetaData metadata,
                                    java.lang.String method,
                                    java.lang.String[] signature,
                                    java.lang.Object[] args)
                             throws javax.management.ReflectionException,
                                    javax.management.MBeanException,
                                    mx4j.server.ReflectionMBeanInvoker.BadArgumentException
Centralizes exception handling necessary to convert exceptions thrown by MBean's methods to JMX exceptions. Delegates the actual invocation to invokeImpl(mx4j.server.MBeanMetaData, java.lang.String, java.lang.String[], java.lang.Object[])

Throws:
javax.management.ReflectionException
javax.management.MBeanException
mx4j.server.ReflectionMBeanInvoker.BadArgumentException

invokeImpl

protected java.lang.Object invokeImpl(MBeanMetaData metadata,
                                      java.lang.String method,
                                      java.lang.String[] signature,
                                      java.lang.Object[] args)
                               throws java.lang.Throwable
Performs the actual invocation of the MBean's method. Exceptions thrown by the MBean's methods should not be catched, since doInvoke(mx4j.server.MBeanMetaData, java.lang.String, java.lang.String[], java.lang.Object[]) takes care of converting them to JMX exceptions.

Throws:
java.lang.Throwable

getStandardOperationInfo

protected javax.management.MBeanOperationInfo getStandardOperationInfo(MBeanMetaData metadata,
                                                                       java.lang.String method,
                                                                       java.lang.String[] signature)
Returns the MBeanOperationInfo for the given operation, or null if the operation is not a management operation.


getStandardAttributeInfo

protected javax.management.MBeanAttributeInfo getStandardAttributeInfo(MBeanMetaData metadata,
                                                                       java.lang.String attribute,
                                                                       boolean forWrite)
Returns the MBeanAttributeInfo for the given attribute, or null if the attribute is not a management attribute.


getMethodForAttribute

protected java.lang.String getMethodForAttribute(javax.management.MBeanAttributeInfo attribute,
                                                 boolean forRead)
Returns the method name for the given attribute.


getStandardManagementMethod

protected java.lang.reflect.Method getStandardManagementMethod(MBeanMetaData metadata,
                                                               java.lang.String name,
                                                               java.lang.String[] signature)
                                                        throws javax.management.ReflectionException
Returns a java.lang.reflect.Method object for the given method name and signature.

Throws:
javax.management.ReflectionException


Copyright © 2001-2005 The MX4J Contributors. All Rights Reserved.