com.sun.jdmk.remote.cascading
Class MBeanServerConnectionWrapper

java.lang.Object
  extended by com.sun.jdmk.remote.cascading.MBeanServerConnectionWrapper
All Implemented Interfaces:
MBeanServer, MBeanServerConnection

public abstract class MBeanServerConnectionWrapper
extends Object
implements MBeanServer

An object of this class implements the MBeanServer interface and, for each of its methods forwards the request to a wrapped MBeanServerConnection object. Some methods of the MBeanServer interface do not have any equivalent in MBeanServerConnection. In that case, an UnsupportedOperationException will be thrown.

A typical use of this class is to apply a QueryExp object locally, on an MBean that resides in a remote MBeanServer. Since an MBeanServerConnection is not an MBeanServer, it cannot be passed to the setMBeanServer() method of the QueryExp object. However, this object can.

This is an abstract class, and although only getMBeanServerConnection() is declared abstract, implementing this single method will usually not be sufficient in order to substitute an instance of this class to an MBeanServer in the general case: for instance, the methods like getClassLoader(javax.management.ObjectName), getClassLoaderFor(javax.management.ObjectName) etc... which are not part of the MBeanServerConnection interface will throw an UnsupportedOperationException in their default implementation. Therefore, it would not be appropriate to pass an instance of this class to an object that expect these methods to be implemented, unless those methods have been appropriately implemented in a subclass.

Since:
Java DMK 5.1

Constructor Summary
MBeanServerConnectionWrapper()
           
 
Method Summary
 void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)
          Forward this method to the wrapped object.
 void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback)
          Forward this method to the wrapped object.
 ObjectInstance createMBean(String className, ObjectName name)
          Forward this method to the wrapped object.
 ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature)
          Forward this method to the wrapped object.
 ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName)
          Forward this method to the wrapped object.
 ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature)
          Forward this method to the wrapped object.
 ObjectInputStream deserialize(ObjectName name, byte[] data)
          Throws an UnsupportedOperationException.
 ObjectInputStream deserialize(String className, byte[] data)
          Throws an UnsupportedOperationException.
 ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data)
          Throws an UnsupportedOperationException.
 Object getAttribute(ObjectName name, String attribute)
          Forward this method to the wrapped object.
 AttributeList getAttributes(ObjectName name, String[] attributes)
          Forward this method to the wrapped object.
 ClassLoader getClassLoader(ObjectName loaderName)
          Throws an UnsupportedOperationException.
 ClassLoader getClassLoaderFor(ObjectName mbeanName)
          Throws an UnsupportedOperationException.
 ClassLoaderRepository getClassLoaderRepository()
          Throws an UnsupportedOperationException.
 String getDefaultDomain()
          Forward this method to the wrapped object.
 String[] getDomains()
          Forward this method to the wrapped object.
 Integer getMBeanCount()
          Forward this method to the wrapped object.
 MBeanInfo getMBeanInfo(ObjectName name)
          Forward this method to the wrapped object.
protected abstract  MBeanServerConnection getMBeanServerConnection()
          Returns an MBeanServerConnection.
 ObjectInstance getObjectInstance(ObjectName name)
          Forward this method to the wrapped object.
protected  RuntimeException handleIOException(IOException x, String method)
          This method is called each time an IOException is raised when trying to forward an operation to the underlying MBeanServerConnection, as a result of calling getMBeanServerConnection() or as a result of invoking the operation on the returned connection.
 Object instantiate(String className)
          Throws an UnsupportedOperationException.
 Object instantiate(String className, Object[] params, String[] signature)
          Throws an UnsupportedOperationException.
 Object instantiate(String className, ObjectName loaderName)
          Throws an UnsupportedOperationException.
 Object instantiate(String className, ObjectName loaderName, Object[] params, String[] signature)
          Throws an UnsupportedOperationException.
 Object invoke(ObjectName name, String operationName, Object[] params, String[] signature)
          Forward this method to the wrapped object.
 boolean isInstanceOf(ObjectName name, String className)
          Forward this method to the wrapped object.
 boolean isRegistered(ObjectName name)
          Forward this method to the wrapped object.
 Set queryMBeans(ObjectName name, QueryExp query)
          Forward this method to the wrapped object.
 Set queryNames(ObjectName name, QueryExp query)
          Forward this method to the wrapped object.
 ObjectInstance registerMBean(Object object, ObjectName name)
          Throws an UnsupportedOperationException.
 void removeNotificationListener(ObjectName name, NotificationListener listener)
          Forward this method to the wrapped object.
 void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)
          Forward this method to the wrapped object.
 void removeNotificationListener(ObjectName name, ObjectName listener)
          Forward this method to the wrapped object.
 void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback)
          Forward this method to the wrapped object.
 void setAttribute(ObjectName name, Attribute attribute)
          Forward this method to the wrapped object.
 AttributeList setAttributes(ObjectName name, AttributeList attributes)
          Forward this method to the wrapped object.
 void unregisterMBean(ObjectName name)
          Forward this method to the wrapped object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MBeanServerConnectionWrapper

public MBeanServerConnectionWrapper()
Method Detail

getMBeanServerConnection

protected abstract MBeanServerConnection getMBeanServerConnection()
                                                           throws IOException
Returns an MBeanServerConnection. This method is called each time an operation must be invoked on the underlying MBeanServerConnection.

Throws:
IOException

handleIOException

protected RuntimeException handleIOException(IOException x,
                                             String method)
This method is called each time an IOException is raised when trying to forward an operation to the underlying MBeanServerConnection, as a result of calling getMBeanServerConnection() or as a result of invoking the operation on the returned connection. Subclasses may redefine this method if they need to perform any specific handling of IOException (logging etc...).

Parameters:
x - The raised IOException.
method - The name of the method in which the exception was raised. This is one of the methods of the MBeanServer interface.
Returns:
A RuntimeException that should be thrown by the caller. In this default implementation, this is an UndeclaredThrowableException wrapping x.

addNotificationListener

public void addNotificationListener(ObjectName name,
                                    NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback)
                             throws InstanceNotFoundException
Forward this method to the wrapped object.

Specified by:
addNotificationListener in interface MBeanServer
Specified by:
addNotificationListener in interface MBeanServerConnection
Throws:
InstanceNotFoundException

addNotificationListener

public void addNotificationListener(ObjectName name,
                                    ObjectName listener,
                                    NotificationFilter filter,
                                    Object handback)
                             throws InstanceNotFoundException
Forward this method to the wrapped object.

Specified by:
addNotificationListener in interface MBeanServer
Specified by:
addNotificationListener in interface MBeanServerConnection
Throws:
InstanceNotFoundException

createMBean

public ObjectInstance createMBean(String className,
                                  ObjectName name)
                           throws ReflectionException,
                                  InstanceAlreadyExistsException,
                                  MBeanRegistrationException,
                                  MBeanException,
                                  NotCompliantMBeanException
Forward this method to the wrapped object.

Specified by:
createMBean in interface MBeanServer
Specified by:
createMBean in interface MBeanServerConnection
Throws:
ReflectionException
InstanceAlreadyExistsException
MBeanRegistrationException
MBeanException
NotCompliantMBeanException

createMBean

public ObjectInstance createMBean(String className,
                                  ObjectName name,
                                  Object[] params,
                                  String[] signature)
                           throws ReflectionException,
                                  InstanceAlreadyExistsException,
                                  MBeanRegistrationException,
                                  MBeanException,
                                  NotCompliantMBeanException
Forward this method to the wrapped object.

Specified by:
createMBean in interface MBeanServer
Specified by:
createMBean in interface MBeanServerConnection
Throws:
ReflectionException
InstanceAlreadyExistsException
MBeanRegistrationException
MBeanException
NotCompliantMBeanException

createMBean

public ObjectInstance createMBean(String className,
                                  ObjectName name,
                                  ObjectName loaderName)
                           throws ReflectionException,
                                  InstanceAlreadyExistsException,
                                  MBeanRegistrationException,
                                  MBeanException,
                                  NotCompliantMBeanException,
                                  InstanceNotFoundException
Forward this method to the wrapped object.

Specified by:
createMBean in interface MBeanServer
Specified by:
createMBean in interface MBeanServerConnection
Throws:
ReflectionException
InstanceAlreadyExistsException
MBeanRegistrationException
MBeanException
NotCompliantMBeanException
InstanceNotFoundException

createMBean

public ObjectInstance createMBean(String className,
                                  ObjectName name,
                                  ObjectName loaderName,
                                  Object[] params,
                                  String[] signature)
                           throws ReflectionException,
                                  InstanceAlreadyExistsException,
                                  MBeanRegistrationException,
                                  MBeanException,
                                  NotCompliantMBeanException,
                                  InstanceNotFoundException
Forward this method to the wrapped object.

Specified by:
createMBean in interface MBeanServer
Specified by:
createMBean in interface MBeanServerConnection
Throws:
ReflectionException
InstanceAlreadyExistsException
MBeanRegistrationException
MBeanException
NotCompliantMBeanException
InstanceNotFoundException

deserialize

public ObjectInputStream deserialize(ObjectName name,
                                     byte[] data)
                              throws InstanceNotFoundException,
                                     OperationsException
Throws an UnsupportedOperationException. This behavior can be changed by subclasses.

Specified by:
deserialize in interface MBeanServer
Throws:
InstanceNotFoundException
OperationsException

deserialize

public ObjectInputStream deserialize(String className,
                                     byte[] data)
                              throws OperationsException,
                                     ReflectionException
Throws an UnsupportedOperationException. This behavior can be changed by subclasses.

Specified by:
deserialize in interface MBeanServer
Throws:
OperationsException
ReflectionException

deserialize

public ObjectInputStream deserialize(String className,
                                     ObjectName loaderName,
                                     byte[] data)
                              throws InstanceNotFoundException,
                                     OperationsException,
                                     ReflectionException
Throws an UnsupportedOperationException. This behavior can be changed by subclasses.

Specified by:
deserialize in interface MBeanServer
Throws:
InstanceNotFoundException
OperationsException
ReflectionException

getAttribute

public Object getAttribute(ObjectName name,
                           String attribute)
                    throws MBeanException,
                           AttributeNotFoundException,
                           InstanceNotFoundException,
                           ReflectionException
Forward this method to the wrapped object.

Specified by:
getAttribute in interface MBeanServer
Specified by:
getAttribute in interface MBeanServerConnection
Throws:
MBeanException
AttributeNotFoundException
InstanceNotFoundException
ReflectionException

getAttributes

public AttributeList getAttributes(ObjectName name,
                                   String[] attributes)
                            throws InstanceNotFoundException,
                                   ReflectionException
Forward this method to the wrapped object.

Specified by:
getAttributes in interface MBeanServer
Specified by:
getAttributes in interface MBeanServerConnection
Throws:
InstanceNotFoundException
ReflectionException

getClassLoader

public ClassLoader getClassLoader(ObjectName loaderName)
                           throws InstanceNotFoundException
Throws an UnsupportedOperationException. This behavior can be changed by subclasses.

Specified by:
getClassLoader in interface MBeanServer
Throws:
InstanceNotFoundException

getClassLoaderFor

public ClassLoader getClassLoaderFor(ObjectName mbeanName)
                              throws InstanceNotFoundException
Throws an UnsupportedOperationException. This behavior can be changed by subclasses.

Specified by:
getClassLoaderFor in interface MBeanServer
Throws:
InstanceNotFoundException

getClassLoaderRepository

public ClassLoaderRepository getClassLoaderRepository()
Throws an UnsupportedOperationException. This behavior can be changed by subclasses.

Specified by:
getClassLoaderRepository in interface MBeanServer

getDefaultDomain

public String getDefaultDomain()
Forward this method to the wrapped object.

Specified by:
getDefaultDomain in interface MBeanServer
Specified by:
getDefaultDomain in interface MBeanServerConnection

getDomains

public String[] getDomains()
Forward this method to the wrapped object.

Specified by:
getDomains in interface MBeanServer
Specified by:
getDomains in interface MBeanServerConnection

getMBeanCount

public Integer getMBeanCount()
Forward this method to the wrapped object.

Specified by:
getMBeanCount in interface MBeanServer
Specified by:
getMBeanCount in interface MBeanServerConnection

getMBeanInfo

public MBeanInfo getMBeanInfo(ObjectName name)
                       throws InstanceNotFoundException,
                              IntrospectionException,
                              ReflectionException
Forward this method to the wrapped object.

Specified by:
getMBeanInfo in interface MBeanServer
Specified by:
getMBeanInfo in interface MBeanServerConnection
Throws:
InstanceNotFoundException
IntrospectionException
ReflectionException

getObjectInstance

public ObjectInstance getObjectInstance(ObjectName name)
                                 throws InstanceNotFoundException
Forward this method to the wrapped object.

Specified by:
getObjectInstance in interface MBeanServer
Specified by:
getObjectInstance in interface MBeanServerConnection
Throws:
InstanceNotFoundException

instantiate

public Object instantiate(String className)
                   throws ReflectionException,
                          MBeanException
Throws an UnsupportedOperationException. This behavior can be changed by subclasses.

Specified by:
instantiate in interface MBeanServer
Throws:
ReflectionException
MBeanException

instantiate

public Object instantiate(String className,
                          Object[] params,
                          String[] signature)
                   throws ReflectionException,
                          MBeanException
Throws an UnsupportedOperationException. This behavior can be changed by subclasses.

Specified by:
instantiate in interface MBeanServer
Throws:
ReflectionException
MBeanException

instantiate

public Object instantiate(String className,
                          ObjectName loaderName)
                   throws ReflectionException,
                          MBeanException,
                          InstanceNotFoundException
Throws an UnsupportedOperationException. This behavior can be changed by subclasses.

Specified by:
instantiate in interface MBeanServer
Throws:
ReflectionException
MBeanException
InstanceNotFoundException

instantiate

public Object instantiate(String className,
                          ObjectName loaderName,
                          Object[] params,
                          String[] signature)
                   throws ReflectionException,
                          MBeanException,
                          InstanceNotFoundException
Throws an UnsupportedOperationException. This behavior can be changed by subclasses.

Specified by:
instantiate in interface MBeanServer
Throws:
ReflectionException
MBeanException
InstanceNotFoundException

invoke

public Object invoke(ObjectName name,
                     String operationName,
                     Object[] params,
                     String[] signature)
              throws InstanceNotFoundException,
                     MBeanException,
                     ReflectionException
Forward this method to the wrapped object.

Specified by:
invoke in interface MBeanServer
Specified by:
invoke in interface MBeanServerConnection
Throws:
InstanceNotFoundException
MBeanException
ReflectionException

isInstanceOf

public boolean isInstanceOf(ObjectName name,
                            String className)
                     throws InstanceNotFoundException
Forward this method to the wrapped object.

Specified by:
isInstanceOf in interface MBeanServer
Specified by:
isInstanceOf in interface MBeanServerConnection
Throws:
InstanceNotFoundException

isRegistered

public boolean isRegistered(ObjectName name)
Forward this method to the wrapped object.

Specified by:
isRegistered in interface MBeanServer
Specified by:
isRegistered in interface MBeanServerConnection

queryMBeans

public Set queryMBeans(ObjectName name,
                       QueryExp query)
Forward this method to the wrapped object. If an IOException is raised, returns an empty Set.

Specified by:
queryMBeans in interface MBeanServer
Specified by:
queryMBeans in interface MBeanServerConnection

queryNames

public Set queryNames(ObjectName name,
                      QueryExp query)
Forward this method to the wrapped object. If an IOException is raised, returns an empty Set.

Specified by:
queryNames in interface MBeanServer
Specified by:
queryNames in interface MBeanServerConnection

registerMBean

public ObjectInstance registerMBean(Object object,
                                    ObjectName name)
                             throws InstanceAlreadyExistsException,
                                    MBeanRegistrationException,
                                    NotCompliantMBeanException
Throws an UnsupportedOperationException. This behavior can be changed by subclasses.

Specified by:
registerMBean in interface MBeanServer
Throws:
InstanceAlreadyExistsException
MBeanRegistrationException
NotCompliantMBeanException

removeNotificationListener

public void removeNotificationListener(ObjectName name,
                                       NotificationListener listener)
                                throws InstanceNotFoundException,
                                       ListenerNotFoundException
Forward this method to the wrapped object.

Specified by:
removeNotificationListener in interface MBeanServer
Specified by:
removeNotificationListener in interface MBeanServerConnection
Throws:
InstanceNotFoundException
ListenerNotFoundException

removeNotificationListener

public void removeNotificationListener(ObjectName name,
                                       NotificationListener listener,
                                       NotificationFilter filter,
                                       Object handback)
                                throws InstanceNotFoundException,
                                       ListenerNotFoundException
Forward this method to the wrapped object.

Specified by:
removeNotificationListener in interface MBeanServer
Specified by:
removeNotificationListener in interface MBeanServerConnection
Throws:
InstanceNotFoundException
ListenerNotFoundException

removeNotificationListener

public void removeNotificationListener(ObjectName name,
                                       ObjectName listener)
                                throws InstanceNotFoundException,
                                       ListenerNotFoundException
Forward this method to the wrapped object.

Specified by:
removeNotificationListener in interface MBeanServer
Specified by:
removeNotificationListener in interface MBeanServerConnection
Throws:
InstanceNotFoundException
ListenerNotFoundException

removeNotificationListener

public void removeNotificationListener(ObjectName name,
                                       ObjectName listener,
                                       NotificationFilter filter,
                                       Object handback)
                                throws InstanceNotFoundException,
                                       ListenerNotFoundException
Forward this method to the wrapped object.

Specified by:
removeNotificationListener in interface MBeanServer
Specified by:
removeNotificationListener in interface MBeanServerConnection
Throws:
InstanceNotFoundException
ListenerNotFoundException

setAttribute

public void setAttribute(ObjectName name,
                         Attribute attribute)
                  throws InstanceNotFoundException,
                         AttributeNotFoundException,
                         InvalidAttributeValueException,
                         MBeanException,
                         ReflectionException
Forward this method to the wrapped object.

Specified by:
setAttribute in interface MBeanServer
Specified by:
setAttribute in interface MBeanServerConnection
Throws:
InstanceNotFoundException
AttributeNotFoundException
InvalidAttributeValueException
MBeanException
ReflectionException

setAttributes

public AttributeList setAttributes(ObjectName name,
                                   AttributeList attributes)
                            throws InstanceNotFoundException,
                                   ReflectionException
Forward this method to the wrapped object.

Specified by:
setAttributes in interface MBeanServer
Specified by:
setAttributes in interface MBeanServerConnection
Throws:
InstanceNotFoundException
ReflectionException

unregisterMBean

public void unregisterMBean(ObjectName name)
                     throws InstanceNotFoundException,
                            MBeanRegistrationException
Forward this method to the wrapped object.

Specified by:
unregisterMBean in interface MBeanServer
Specified by:
unregisterMBean in interface MBeanServerConnection
Throws:
InstanceNotFoundException
MBeanRegistrationException

Open Source build 02
opendmk-1.0-b02 2007.10.01_19:17:46_MEST

Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.