Õ¾ÄÚËÑË÷: ÇëÊäÈëËÑË÷¹Ø¼ü´Ê
µ±Ç°Ò³Ãæ: ÔÚÏßÎĵµÊ×Ò³ > JBoss 4.0.1 sp1 jmx API Documentation Ó¢ÎÄ°æÎĵµ

OptimizedMBeanDispatcher (JBoss/JMX API) - JBoss 4.0.1 sp1 jmx API Documentation Ó¢ÎÄ°æÎĵµ


org.jboss.mx.capability
Class OptimizedMBeanDispatcher

java.lang.Object
  extended byorg.jboss.mx.capability.OptimizedMBeanDispatcher
All Implemented Interfaces:
ServerConstants

public class OptimizedMBeanDispatcher
extends Object
implements ServerConstants

Byte code optimized dispatcher for Standard MBeans. This dispatcher generates an invoke implementation that handles the operation dispatching without Java reflection.

The use of this dispatcher may be controlled by setting a OPTIMIZE_REFLECTED_DISPATCHER property to either "true" or "false" string value.

Version:
$Revision: 1.12 $
Author:
Juha Lindfors.
See Also:
ReflectedMBeanDispatcher, DispatchClassLoader

Field Summary
 
Fields inherited from interface org.jboss.mx.server.ServerConstants
CLASS_REMOVED, CLASSLOADER, CLASSLOADER_ADDED, CLASSLOADER_REMOVED, DEFAULT_DOMAIN, DEFAULT_LOADER_NAME, DEFAULT_LOADER_REPOSITORY_CLASS, DEFAULT_MBEAN_REGISTRY_CLASS, DEFAULT_MBEAN_SERVER_BUILDER_CLASS, DEFAULT_REQUIRED_MODELMBEAN_CLASS, DEFAULT_SCOPED_REPOSITORY_CLASS, DEFAULT_SCOPED_REPOSITORY_PARSER_CLASS, IMPLEMENTATION_NAME, IMPLEMENTATION_VENDOR, IMPLEMENTATION_VERSION, JMI_DOMAIN, LOADER_REPOSITORY_CLASS_PROPERTY, MBEAN_REGISTRY, MBEAN_REGISTRY_CLASS_PROPERTY, MBEAN_SERVER_BUILDER_CLASS_PROPERTY, MBEAN_SERVER_CONFIGURATION, MBEAN_SERVER_DELEGATE, OPTIMIZE_REFLECTED_DISPATCHER, REQUIRED_MODELMBEAN_CLASS_PROPERTY, SPECIFICATION_NAME, SPECIFICATION_VENDOR, SPECIFICATION_VERSION, UNIFIED_LOADER_REPOSITORY_CLASS
 
Constructor Summary
OptimizedMBeanDispatcher()
           
 
Method Summary
protected static org.apache.bcel.generic.InstructionList convertObjectToPrimitive(org.apache.bcel.generic.ConstantPoolGen cp, String type)
          Converts a reference of a primitve wrapper object into a primite value type.
protected static org.apache.bcel.generic.InstructionList convertPrimitiveToObject(org.apache.bcel.generic.ConstantPoolGen cp, String type)
          Converts a primitive into its corresponding object wrapper reference.
static ReflectedMBeanDispatcher create(MBeanInfo info, Object resource)
           
protected static org.apache.bcel.generic.MethodGen createConstructor(org.apache.bcel.generic.ConstantPoolGen cp, String className)
          creates constructor <init>(MBeanInfo info, AttributeOperationResolver resolver, Object resource) that calls super(info, resolver, resource) in its implementation
protected static org.apache.bcel.generic.MethodGen createInvoke(org.apache.bcel.generic.ConstantPoolGen cp, MBeanInfo info, String className, String resourceClassName)
          Creates the implementation of the invoke(String actionName, Object[] args, String[] signature) method.
static String getDescriptorForType(String name)
          Returns a descriptor for a given Java type.
static String getMethodDescriptor(MBeanParameterInfo[] signature, String returnType)
          Returns the signature of a MBean operation using the grammar required by the class file format, excluding the method name.
protected static org.jboss.mx.capability.OptimizedMBeanDispatcher.MethodEntry[] getOperations(MBeanInfo info)
          Returns a subset of MBean's operations.
static boolean isPrimitive(String name)
          Checks if a given name matches the TYPE name of a primitive wrapper class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OptimizedMBeanDispatcher

public OptimizedMBeanDispatcher()
Method Detail

create

public static ReflectedMBeanDispatcher create(MBeanInfo info,
                                              Object resource)

getMethodDescriptor

public static String getMethodDescriptor(MBeanParameterInfo[] signature,
                                         String returnType)
Returns the signature of a MBean operation using the grammar required by the class file format, excluding the method name.

The Java Virtual Machine Specification: 4.3.3 Method Descriptors

A method descriptor represents the parameters that the method takes and the value that it returns:

 MethodDescriptor:
    ( ParameterDescriptor* ) ReturnDescriptor
 
A parameter descriptor represents a parameter passed to a method:

 ParameterDescriptor:
    FieldType
 
A return descriptor represents the type of the value returned from a method. It is a series of characters generated by the grammar:

 ReturnDescriptor:
    FieldType
    V
 
The character V indicates that the method returns no value (its return type is void).

For example, the method descriptor for the method

  Object mymethod(int i, double d, Thread t)  
is
  (IDLjava/lang/Thread;)Ljava/lang/Object;  
Note that internal forms of the fully qualified names of Thread and Object are used in the method descriptor.


getDescriptorForType

public static String getDescriptorForType(String name)
Returns a descriptor for a given Java type. See Class.getName() for details on the grammar for arrays and primitive types. Note that the internal form of the fully qualified name for class Object is used, so for example, the returned descriptor for java.lang.Object is
Ljava/lang/Object;
See JVM spec �4.2 and �4.3 for detailed description of the internal class name format and grammar notation.

Parameters:
name - fully qualified name of the Java type
Returns:
descriptor string using the JVM grammar

isPrimitive

public static boolean isPrimitive(String name)
Checks if a given name matches the TYPE name of a primitive wrapper class.

Parameters:
name - TYPE.getName()
Returns:
true if is a primitive type name; false otherwise
See Also:
Integer.TYPE

createConstructor

protected static org.apache.bcel.generic.MethodGen createConstructor(org.apache.bcel.generic.ConstantPoolGen cp,
                                                                     String className)
creates constructor <init>(MBeanInfo info, AttributeOperationResolver resolver, Object resource) that calls super(info, resolver, resource) in its implementation

Parameters:
cp - constant pool
className - name of the class being generated

createInvoke

protected static org.apache.bcel.generic.MethodGen createInvoke(org.apache.bcel.generic.ConstantPoolGen cp,
                                                                MBeanInfo info,
                                                                String className,
                                                                String resourceClassName)
Creates the implementation of the invoke(String actionName, Object[] args, String[] signature) method. This implementation currently handles all non overloaded MBean operation invocations. Overloaded operations still fall back to the default reflected invocations.

The Java equivalent of the implementation looks roughly as follows:


 public void invoke(String actionName, Object[] args, String[] signature)
 {
    if (actionName != null)
    {
       try
       {
          if (actionName.equals(<operName1>))
             return ((<resource type>)super.getResourceObject()).<operName1>((<arg1 type>)arg1, (<arg2 type>)arg2, ...);
          else if (actionName.equals(<operName2>))
             return ((<resource type>)super.getResourceObject()).<operName2>((<arg1 type>)arg1, (<arg2 type>)arg2, ...);

          ...

          else
             super.invoke(actionName, args, signature);
      }
      catch (Throwable t)
      {
          super.invoke(actionName, args, signature);
      }
    }
 }
 

Parameters:
cp - constant pool of the class being generated
info - metadata of the MBean
className - name of the class being generated
resourceClassName - name of the resource class being invoked

convertObjectToPrimitive

protected static org.apache.bcel.generic.InstructionList convertObjectToPrimitive(org.apache.bcel.generic.ConstantPoolGen cp,
                                                                                  String type)
Converts a reference of a primitve wrapper object into a primite value type. This method assumes that the wrapper object reference is already loaded at the top of the operand stack. The stack is modified so that the object reference to a primitive wrapper is replaced by the corresponding value in the stack.

Parameters:
cp - constant pool
type - class name of the primitive wrapper object to convert
Returns:
an instruction list that replaces an object reference of a primitive wrapper object to its corresponding value in the operand stack

convertPrimitiveToObject

protected static org.apache.bcel.generic.InstructionList convertPrimitiveToObject(org.apache.bcel.generic.ConstantPoolGen cp,
                                                                                  String type)
Converts a primitive into its corresponding object wrapper reference. This method assumes the primitve is already pushed to the top of the operand stack. The stack is modified so that the primitive value is replaced by a reference to its corresponding wrapper object that has been initialized to contain the same value.

Parameters:
cp - constant pool
type - type string of the primitive, for example Integer.TYPE.getName()
Returns:
an instruction list that replaces the primitive type at the top of the operand stack with its corresponding, initialized, wrapper object

getOperations

protected static org.jboss.mx.capability.OptimizedMBeanDispatcher.MethodEntry[] getOperations(MBeanInfo info)
Returns a subset of MBean's operations. Overloaded operations are not supported yet, so they're left out of the list and their invocations are delegated to the reflection based super class.

Overloaded operations that differ in their arg list length may be able to gain in performance if implemented directly with byte code. Overloaded operations with equal arg list length may not show much difference compared to ternary search tree based resolver.



Copyright © 2002 JBoss Group, LLC. All Rights Reserved.