com.sun.jdmk
Class MBeanServerForwarder

java.lang.Object
  extended by com.sun.jdmk.MBeanServerForwarder
All Implemented Interfaces:
MBeanServer, MBeanServerConnection
Direct Known Subclasses:
MBeanServerChecker

public class MBeanServerForwarder
extends Object
implements MBeanServer

An object of this class implements the MBeanServer interface and wraps another object that also implements that interface. Every method in MBeanServer is forwarded to the wrapped object.

This class is principally useful as the superclass for other wrapping classes that intercept some of the methods in MBeanServer and perform some action before forwarding to the wrapped object (or do not forward at all).

The wrapped object can be changed at any time. A frequent operation is to insert another MBeanServerForwarder between this one and the wrapped object. The idiom for that is:

 synchronized (mbeanServerForwarder) {
     MBeanServer oldmbs = mbeanServerForwarder.getMBeanServer();
     MBeanServer newmbs = new MyMBeanServerForwarder(oldmbs);
     mbeanServerForwarder.setMBeanServer(newmbs);
 }
 

The synchronized block ensures that information is not lost if two threads try to insert MBeanServerForwarders at the same time.

Since:
Java DMK 5.1

Constructor Summary
MBeanServerForwarder(MBeanServer mbs)
          Make a new MBeanServerForwarder that forwards all requests from the MBeanServer interface to mbs.
 
Method Summary
 void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)
           
 void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback)
           
 ObjectInstance createMBean(String className, ObjectName name)
           
 ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature)
           
 ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName)
           
 ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature)
           
 ObjectInputStream deserialize(ObjectName name, byte[] data)
           
 ObjectInputStream deserialize(String className, byte[] data)
           
 ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data)
           
 Object getAttribute(ObjectName name, String attribute)
           
 AttributeList getAttributes(ObjectName name, String[] attributes)
           
 ClassLoader getClassLoader(ObjectName loaderName)
           
 ClassLoader getClassLoaderFor(ObjectName mbeanName)
           
 ClassLoaderRepository getClassLoaderRepository()
           
 String getDefaultDomain()
           
 String[] getDomains()
           
 Integer getMBeanCount()
           
 MBeanInfo getMBeanInfo(ObjectName name)
           
 MBeanServer getMBeanServer()
          Return the wrapped MBeanServer to which all requests from the MBeanServer interface are forwarded.
 ObjectInstance getObjectInstance(ObjectName name)
           
 Object instantiate(String className)
           
 Object instantiate(String className, Object[] params, String[] signature)
           
 Object instantiate(String className, ObjectName loaderName)
           
 Object instantiate(String className, ObjectName loaderName, Object[] params, String[] signature)
           
 Object invoke(ObjectName name, String operationName, Object[] params, String[] signature)
           
 boolean isInstanceOf(ObjectName name, String className)
           
 boolean isRegistered(ObjectName name)
           
 Set queryMBeans(ObjectName name, QueryExp query)
           
 Set queryNames(ObjectName name, QueryExp query)
           
 ObjectInstance registerMBean(Object object, ObjectName name)
           
 void removeNotificationListener(ObjectName name, NotificationListener listener)
           
 void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)
           
 void removeNotificationListener(ObjectName name, ObjectName listener)
           
 void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback)
           
 void setAttribute(ObjectName name, Attribute attribute)
           
 AttributeList setAttributes(ObjectName name, AttributeList attributes)
           
 void setMBeanServer(MBeanServer mbs)
          Change the wrapped MBeanServer object to which all requests from the MBeanServer interface are forwarded.
 void unregisterMBean(ObjectName name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MBeanServerForwarder

public MBeanServerForwarder(MBeanServer mbs)
Make a new MBeanServerForwarder that forwards all requests from the MBeanServer interface to mbs.

Parameters:
mbs - the wrapped MBeanServer to forward to.
Method Detail

getMBeanServer

public MBeanServer getMBeanServer()
Return the wrapped MBeanServer to which all requests from the MBeanServer interface are forwarded.


setMBeanServer

public void setMBeanServer(MBeanServer mbs)
                    throws IllegalArgumentException

Change the wrapped MBeanServer object to which all requests from the MBeanServer interface are forwarded. The old wrapped object is lost unless it was accessible by other means.

Parameters:
mbs - the new wrapped object.
Throws:
IllegalArgumentException - if mbs is null.

instantiate

public Object instantiate(String className)
                   throws ReflectionException,
                          MBeanException
Specified by:
instantiate in interface MBeanServer
Throws:
ReflectionException
MBeanException

instantiate

public Object instantiate(String className,
                          ObjectName loaderName)
                   throws ReflectionException,
                          MBeanException,
                          InstanceNotFoundException
Specified by:
instantiate in interface MBeanServer
Throws:
ReflectionException
MBeanException
InstanceNotFoundException

instantiate

public Object instantiate(String className,
                          Object[] params,
                          String[] signature)
                   throws ReflectionException,
                          MBeanException
Specified by:
instantiate in interface MBeanServer
Throws:
ReflectionException
MBeanException

instantiate

public Object instantiate(String className,
                          ObjectName loaderName,
                          Object[] params,
                          String[] signature)
                   throws ReflectionException,
                          MBeanException,
                          InstanceNotFoundException
Specified by:
instantiate in interface MBeanServer
Throws:
ReflectionException
MBeanException
InstanceNotFoundException

createMBean

public ObjectInstance createMBean(String className,
                                  ObjectName name)
                           throws ReflectionException,
                                  InstanceAlreadyExistsException,
                                  MBeanRegistrationException,
                                  MBeanException,
                                  NotCompliantMBeanException
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
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,
                                  Object[] params,
                                  String[] signature)
                           throws ReflectionException,
                                  InstanceAlreadyExistsException,
                                  MBeanRegistrationException,
                                  MBeanException,
                                  NotCompliantMBeanException
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,
                                  Object[] params,
                                  String[] signature)
                           throws ReflectionException,
                                  InstanceAlreadyExistsException,
                                  MBeanRegistrationException,
                                  MBeanException,
                                  NotCompliantMBeanException,
                                  InstanceNotFoundException
Specified by:
createMBean in interface MBeanServer
Specified by:
createMBean in interface MBeanServerConnection
Throws:
ReflectionException
InstanceAlreadyExistsException
MBeanRegistrationException
MBeanException
NotCompliantMBeanException
InstanceNotFoundException

registerMBean

public ObjectInstance registerMBean(Object object,
                                    ObjectName name)
                             throws InstanceAlreadyExistsException,
                                    MBeanRegistrationException,
                                    NotCompliantMBeanException
Specified by:
registerMBean in interface MBeanServer
Throws:
InstanceAlreadyExistsException
MBeanRegistrationException
NotCompliantMBeanException

unregisterMBean

public void unregisterMBean(ObjectName name)
                     throws InstanceNotFoundException,
                            MBeanRegistrationException
Specified by:
unregisterMBean in interface MBeanServer
Specified by:
unregisterMBean in interface MBeanServerConnection
Throws:
InstanceNotFoundException
MBeanRegistrationException

getObjectInstance

public ObjectInstance getObjectInstance(ObjectName name)
                                 throws InstanceNotFoundException
Specified by:
getObjectInstance in interface MBeanServer
Specified by:
getObjectInstance in interface MBeanServerConnection
Throws:
InstanceNotFoundException

queryMBeans

public Set queryMBeans(ObjectName name,
                       QueryExp query)
Specified by:
queryMBeans in interface MBeanServer
Specified by:
queryMBeans in interface MBeanServerConnection

queryNames

public Set queryNames(ObjectName name,
                      QueryExp query)
Specified by:
queryNames in interface MBeanServer
Specified by:
queryNames in interface MBeanServerConnection

isRegistered

public boolean isRegistered(ObjectName name)
Specified by:
isRegistered in interface MBeanServer
Specified by:
isRegistered in interface MBeanServerConnection

getMBeanCount

public Integer getMBeanCount()
Specified by:
getMBeanCount in interface MBeanServer
Specified by:
getMBeanCount in interface MBeanServerConnection

getAttribute

public Object getAttribute(ObjectName name,
                           String attribute)
                    throws MBeanException,
                           AttributeNotFoundException,
                           InstanceNotFoundException,
                           ReflectionException
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
Specified by:
getAttributes in interface MBeanServer
Specified by:
getAttributes in interface MBeanServerConnection
Throws:
InstanceNotFoundException
ReflectionException

setAttribute

public void setAttribute(ObjectName name,
                         Attribute attribute)
                  throws InstanceNotFoundException,
                         AttributeNotFoundException,
                         InvalidAttributeValueException,
                         MBeanException,
                         ReflectionException
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
Specified by:
setAttributes in interface MBeanServer
Specified by:
setAttributes in interface MBeanServerConnection
Throws:
InstanceNotFoundException
ReflectionException

invoke

public Object invoke(ObjectName name,
                     String operationName,
                     Object[] params,
                     String[] signature)
              throws InstanceNotFoundException,
                     MBeanException,
                     ReflectionException
Specified by:
invoke in interface MBeanServer
Specified by:
invoke in interface MBeanServerConnection
Throws:
InstanceNotFoundException
MBeanException
ReflectionException

getDefaultDomain

public String getDefaultDomain()
Specified by:
getDefaultDomain in interface MBeanServer
Specified by:
getDefaultDomain in interface MBeanServerConnection

getDomains

public String[] getDomains()
Specified by:
getDomains in interface MBeanServer
Specified by:
getDomains in interface MBeanServerConnection

addNotificationListener

public void addNotificationListener(ObjectName name,
                                    NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback)
                             throws InstanceNotFoundException
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
Specified by:
addNotificationListener in interface MBeanServer
Specified by:
addNotificationListener in interface MBeanServerConnection
Throws:
InstanceNotFoundException

removeNotificationListener

public void removeNotificationListener(ObjectName name,
                                       NotificationListener listener)
                                throws InstanceNotFoundException,
                                       ListenerNotFoundException
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
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
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
Specified by:
removeNotificationListener in interface MBeanServer
Specified by:
removeNotificationListener in interface MBeanServerConnection
Throws:
InstanceNotFoundException
ListenerNotFoundException

getMBeanInfo

public MBeanInfo getMBeanInfo(ObjectName name)
                       throws InstanceNotFoundException,
                              IntrospectionException,
                              ReflectionException
Specified by:
getMBeanInfo in interface MBeanServer
Specified by:
getMBeanInfo in interface MBeanServerConnection
Throws:
InstanceNotFoundException
IntrospectionException
ReflectionException

isInstanceOf

public boolean isInstanceOf(ObjectName name,
                            String className)
                     throws InstanceNotFoundException
Specified by:
isInstanceOf in interface MBeanServer
Specified by:
isInstanceOf in interface MBeanServerConnection
Throws:
InstanceNotFoundException

deserialize

public ObjectInputStream deserialize(ObjectName name,
                                     byte[] data)
                              throws InstanceNotFoundException,
                                     OperationsException
Specified by:
deserialize in interface MBeanServer
Throws:
InstanceNotFoundException
OperationsException

deserialize

public ObjectInputStream deserialize(String className,
                                     byte[] data)
                              throws OperationsException,
                                     ReflectionException
Specified by:
deserialize in interface MBeanServer
Throws:
OperationsException
ReflectionException

deserialize

public ObjectInputStream deserialize(String className,
                                     ObjectName loaderName,
                                     byte[] data)
                              throws InstanceNotFoundException,
                                     OperationsException,
                                     ReflectionException
Specified by:
deserialize in interface MBeanServer
Throws:
InstanceNotFoundException
OperationsException
ReflectionException

getClassLoaderFor

public ClassLoader getClassLoaderFor(ObjectName mbeanName)
                              throws InstanceNotFoundException
Specified by:
getClassLoaderFor in interface MBeanServer
Throws:
InstanceNotFoundException

getClassLoader

public ClassLoader getClassLoader(ObjectName loaderName)
                           throws InstanceNotFoundException
Specified by:
getClassLoader in interface MBeanServer
Throws:
InstanceNotFoundException

getClassLoaderRepository

public ClassLoaderRepository getClassLoaderRepository()
Specified by:
getClassLoaderRepository in interface MBeanServer

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.