Java EE 5 SDK

com.sun.appserv.management.util.jmx
Class MBeanProxyHandler

java.lang.Object
  extended by javax.management.MBeanServerInvocationHandler
      extended by com.sun.appserv.management.util.jmx.MBeanProxyHandler
All Implemented Interfaces:
InvocationHandler

public class MBeanProxyHandler
extends MBeanServerInvocationHandler

Implementation of a proxy handler that supports Attribute names which are not legal Java identifiers. It does so by mapping illegal Java identifiers into legal names. Any interface supplied needs to take mapped names into account.

Allows specification of either an AttributeNameMangler or AttributeNameMapper for maximum flexibility in how illegal Attribute names are mapped.


Field Summary
protected static String DEBUG_ID
           
protected static String GET
           
protected static int GET_PREFIX_LENGTH
           
protected static String IS
           
protected static int IS_PREFIX_LENGTH
           
protected static String LOGGER_NAME
           
protected  ConnectionSource mConnectionSource
           
protected  Output mDebug
           
protected  AttributeNameMangler mMangler
           
protected static String SET
           
 
Constructor Summary
MBeanProxyHandler(ConnectionSource connectionSource, ObjectName objectName)
          Normally created through MBeanProxyFactory.newProxyInstance().
MBeanProxyHandler(ConnectionSource connectionSource, ObjectName objectName, AttributeNameMangler mangler)
          Same as MBeanProxyHandler( connection, objectName ), but can take a name mangler.
MBeanProxyHandler(ConnectionSource connectionSource, ObjectName objectName, AttributeNameMapper mapper)
          Same as MBeanProxyHandler( connection, objectName ), but can take a supplied mapper for illegal Attribute names.
 
Method Summary
protected  void cacheMBeanInfo(boolean cacheIt)
           
 boolean checkValid()
           
 void connectionBad()
           
protected  void debug(Object... args)
           
protected  void debug(Object o)
           
protected  void debugMethod(String methodName, Object... args)
           
protected  void debugMethod(String msg, String methodName, Object... args)
           
 boolean equals(Object rhs)
           
protected  String extractAttributeNameFromMethod(String methodName)
           
static String[] getAllAttributeNames(MBeanAttributeInfo[] infos)
           
 Object getAttribute(String attributeName)
          Same as XAttributesAccess.getAttribute, but with exceptions
 AttributeList getAttributes(String[] attrNames)
          Same as XAttributesAccess.getAttributes, but with exceptions
protected  boolean getCacheMBeanInfo()
           
protected  MBeanServerConnection getConnection()
           
 ConnectionSource getConnectionSource()
           
protected  boolean getDebug()
           
protected  String getDebugID()
           
protected  MBeanInfo getMBeanInfo(boolean refresh)
          Same as XAttributesAccess.getAttributes, but with exceptions
 boolean getMBeanInfoIsInvariant()
           
 Logger getProxyLogger()
           
protected  ObjectName getTargetObjectName()
           
 int hashCode()
           
protected  void initMapper()
          Initialize a mapper based on the supplied attributeInfos.
 Object invoke(Object proxy, Method method, Object[] args)
          Invoke the specified method.
protected  boolean isMappedAttributeMethod(String attributeName)
           
protected  void postGetAttributeHook(String name, Object value)
           
protected  void postGetAttributesHook(String[] requested, AttributeList actual)
           
protected  void postSetAttributeHook(Attribute attr)
           
protected  void postSetAttributesHook(AttributeList requested, AttributeList actual)
           
 void setAttribute(Attribute attr)
          Same as XAttributesAccess.setAttribute, but with exceptions
 AttributeList setAttributes(AttributeList requested)
          Same as XAttributesAccess.setAttributes, but with exceptions
protected  void setMBeanInfoIsInvariant(boolean isInvariant)
           
 void setProxyLogger(Logger logger)
           
protected  boolean targetIsValid()
           
 void targetUnregistered()
           
 
Methods inherited from class javax.management.MBeanServerInvocationHandler
newProxyInstance
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GET

protected static final String GET
See Also:
Constant Field Values

SET

protected static final String SET
See Also:
Constant Field Values

IS

protected static final String IS
See Also:
Constant Field Values

GET_PREFIX_LENGTH

protected static final int GET_PREFIX_LENGTH

IS_PREFIX_LENGTH

protected static final int IS_PREFIX_LENGTH

mConnectionSource

protected final ConnectionSource mConnectionSource

mMangler

protected AttributeNameMangler mMangler

mDebug

protected Output mDebug

DEBUG_ID

protected static final String DEBUG_ID
See Also:
Constant Field Values

LOGGER_NAME

protected static final String LOGGER_NAME
See Also:
Constant Field Values
Constructor Detail

MBeanProxyHandler

public MBeanProxyHandler(ConnectionSource connectionSource,
                         ObjectName objectName)
                  throws IOException
Normally created through MBeanProxyFactory.newProxyInstance(). Creates a new instance to be used as a handler object for Proxy.newProxyInstance.

Parameters:
connectionSource - the connection
objectName - the ObjectName of the proxied MBean
Throws:
IOException

MBeanProxyHandler

public MBeanProxyHandler(ConnectionSource connectionSource,
                         ObjectName objectName,
                         AttributeNameMangler mangler)
                  throws IOException
Same as MBeanProxyHandler( connection, objectName ), but can take a name mangler.

Parameters:
connectionSource - the connection
objectName - the ObjectName of the proxied MBean
mangler - optional name mangler for illegal Attribute names
Throws:
IOException

MBeanProxyHandler

public MBeanProxyHandler(ConnectionSource connectionSource,
                         ObjectName objectName,
                         AttributeNameMapper mapper)
                  throws IOException
Same as MBeanProxyHandler( connection, objectName ), but can take a supplied mapper for illegal Attribute names.

Parameters:
connectionSource - the connection
objectName - the ObjectName of the proxied MBean
mapper - optional name mapper for illegal Attribute names
Throws:
IOException
Method Detail

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object rhs)
Overrides:
equals in class Object

getDebugID

protected String getDebugID()

targetUnregistered

public final void targetUnregistered()

connectionBad

public final void connectionBad()

targetIsValid

protected final boolean targetIsValid()

checkValid

public final boolean checkValid()

setProxyLogger

public void setProxyLogger(Logger logger)

getProxyLogger

public Logger getProxyLogger()

getConnectionSource

public final ConnectionSource getConnectionSource()

getConnection

protected final MBeanServerConnection getConnection()
                                             throws IOException
Throws:
IOException

getTargetObjectName

protected final ObjectName getTargetObjectName()

getAllAttributeNames

public static String[] getAllAttributeNames(MBeanAttributeInfo[] infos)

initMapper

protected void initMapper()
                   throws IOException,
                          IntrospectionException,
                          ReflectionException,
                          InstanceNotFoundException
Initialize a mapper based on the supplied attributeInfos. Does nothing if already initialized.

Throws:
IOException
IntrospectionException
ReflectionException
InstanceNotFoundException

extractAttributeNameFromMethod

protected String extractAttributeNameFromMethod(String methodName)

isMappedAttributeMethod

protected boolean isMappedAttributeMethod(String attributeName)

cacheMBeanInfo

protected void cacheMBeanInfo(boolean cacheIt)

getMBeanInfoIsInvariant

public final boolean getMBeanInfoIsInvariant()

setMBeanInfoIsInvariant

protected final void setMBeanInfoIsInvariant(boolean isInvariant)

getCacheMBeanInfo

protected final boolean getCacheMBeanInfo()

getMBeanInfo

protected MBeanInfo getMBeanInfo(boolean refresh)
                          throws IOException,
                                 InstanceNotFoundException,
                                 IntrospectionException,
                                 ReflectionException
Same as XAttributesAccess.getAttributes, but with exceptions

Parameters:
refresh - whether to get a fresh copy
Throws:
IOException
InstanceNotFoundException
IntrospectionException
ReflectionException

getAttribute

public Object getAttribute(String attributeName)
                    throws InstanceNotFoundException,
                           ReflectionException,
                           MBeanException,
                           AttributeNotFoundException,
                           IOException
Same as XAttributesAccess.getAttribute, but with exceptions

Throws:
InstanceNotFoundException
ReflectionException
MBeanException
AttributeNotFoundException
IOException

getAttributes

public AttributeList getAttributes(String[] attrNames)
                            throws IOException,
                                   InstanceNotFoundException,
                                   ReflectionException
Same as XAttributesAccess.getAttributes, but with exceptions

Throws:
IOException
InstanceNotFoundException
ReflectionException

setAttribute

public void setAttribute(Attribute attr)
                  throws IOException,
                         InstanceNotFoundException,
                         ReflectionException,
                         AttributeNotFoundException,
                         MBeanException,
                         InvalidAttributeValueException
Same as XAttributesAccess.setAttribute, but with exceptions

Throws:
IOException
InstanceNotFoundException
ReflectionException
AttributeNotFoundException
MBeanException
InvalidAttributeValueException

setAttributes

public AttributeList setAttributes(AttributeList requested)
                            throws IOException,
                                   InstanceNotFoundException,
                                   ReflectionException
Same as XAttributesAccess.setAttributes, but with exceptions

Throws:
IOException
InstanceNotFoundException
ReflectionException

postGetAttributeHook

protected void postGetAttributeHook(String name,
                                    Object value)

postGetAttributesHook

protected void postGetAttributesHook(String[] requested,
                                     AttributeList actual)

postSetAttributeHook

protected void postSetAttributeHook(Attribute attr)

postSetAttributesHook

protected void postSetAttributesHook(AttributeList requested,
                                     AttributeList actual)

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Invoke the specified method. This implementation supports additional functionality over the JMX MBeanServerInvocationHandler: (1) It supports mapped Attribute names (ones that are not legal Java names) (2) it supports XAttributesAccess, which otherwise does not work correctly

For anything else, the behavior of MBeanServerInvocationHandler is used.

Specified by:
invoke in interface InvocationHandler
Overrides:
invoke in class MBeanServerInvocationHandler
Throws:
Throwable

getDebug

protected boolean getDebug()

debugMethod

protected void debugMethod(String methodName,
                           Object... args)

debugMethod

protected void debugMethod(String msg,
                           String methodName,
                           Object... args)

debug

protected void debug(Object... args)

debug

protected void debug(Object o)

Java EE 5 SDK

Submit a bug or feature

Copyright 2006 Sun Microsystems, Inc. All rights reserved.