mx4j.server

Class ReflectionMBeanInvoker

Implemented Interfaces:
MBeanInvoker
Known Direct 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 Object[]
EMPTY_ARGS
A zero-length Object[] that indicates a parameterless argument list of a method
protected static String[]
EMPTY_PARAMS
A zero-length String[] that indicates a parameterless signature of a method.

Method Summary

protected Object
doInvoke(MBeanMetaData metadata, String method, String[] signature, Object[] args)
Centralizes exception handling necessary to convert exceptions thrown by MBean's methods to JMX exceptions.
Object
getAttribute(MBeanMetaData metadata, String attribute)
Returns the value of the specified attribute.
protected String
getMethodForAttribute(javax.management.MBeanAttributeInfo attribute, boolean forRead)
Returns the method name for the given attribute.
protected javax.management.MBeanAttributeInfo
getStandardAttributeInfo(MBeanMetaData metadata, String attribute, boolean forWrite)
Returns the MBeanAttributeInfo for the given attribute, or null if the attribute is not a management attribute.
protected Method
getStandardManagementMethod(MBeanMetaData metadata, String name, String[] signature)
Returns a java.lang.reflect.Method object for the given method name and signature.
protected javax.management.MBeanOperationInfo
getStandardOperationInfo(MBeanMetaData metadata, String method, String[] signature)
Returns the MBeanOperationInfo for the given operation, or null if the operation is not a management operation.
Object
invoke(MBeanMetaData metadata, String method, String[] params, Object[] args)
Invokes the specified operation on the MBean instance
protected Object
invokeImpl(MBeanMetaData metadata, String method, String[] signature, 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.

Field Details

EMPTY_ARGS

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

EMPTY_PARAMS

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

Method Details

doInvoke

protected Object doInvoke(MBeanMetaData metadata,
                          String method,
                          String[] signature,
                          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(MBeanMetaData,String,String[],Object[])

getAttribute

public Object getAttribute(MBeanMetaData metadata,
                           String attribute)
            throws javax.management.MBeanException,
                   javax.management.AttributeNotFoundException,
                   javax.management.ReflectionException
Returns the value of the specified attribute.
Specified by:
getAttribute in interface MBeanInvoker

getMethodForAttribute

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

getStandardAttributeInfo

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

getStandardManagementMethod

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

getStandardOperationInfo

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

invoke

public Object invoke(MBeanMetaData metadata,
                     String method,
                     String[] params,
                     Object[] args)
            throws javax.management.MBeanException,
                   javax.management.ReflectionException
Invokes the specified operation on the MBean instance
Specified by:
invoke in interface MBeanInvoker

invokeImpl

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

setAttribute

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

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