Please note that this documentation is not final and is subject to change.

Java™ Platform
Standard Ed. 7

DRAFT ea-b76

javax.management.namespace
Class MBeanServerConnectionWrapper

java.lang.Object
  extended by javax.management.namespace.MBeanServerConnectionWrapper
All Implemented Interfaces:
NotificationManager, MBeanServer, MBeanServerConnection

public 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.

Since:
1.7

Constructor Summary
Constructor and Description
MBeanServerConnectionWrapper(MBeanServerConnection wrapped)
          Construct a new object that implements MBeanServer by forwarding its methods to the given MBeanServerConnection.
MBeanServerConnectionWrapper(MBeanServerConnection wrapped, ClassLoader defaultCl)
          Construct a new object that implements MBeanServer by forwarding its methods to the given MBeanServerConnection.
 
Method Summary
Modifier and Type Method and Description
 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)
          Deprecated. see MBeanServer
 ObjectInputStream deserialize(String className, byte[] data)
          Deprecated. see MBeanServer
 ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data)
          Deprecated. see MBeanServer
 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)
          Returns the default class loader.
 ClassLoaderRepository getClassLoaderRepository()
          Returns a ClassLoaderRepository based on the class loader returned by getDefaultClassLoader().
 ClassLoader getDefaultClassLoader()
          Returns the default class loader passed to the constructor.
 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  MBeanServerConnection getMBeanServerConnection()
          Returns an MBeanServerConnection.
 ObjectInstance getObjectInstance(ObjectName name)
          Forward this method to the wrapped object.
 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<ObjectInstance> queryMBeans(ObjectName name, QueryExp query)
          Forward this method to the wrapped object.
 Set<ObjectName> 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.
protected  RuntimeException wrapIOException(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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MBeanServerConnectionWrapper

public MBeanServerConnectionWrapper(MBeanServerConnection wrapped)
Construct a new object that implements MBeanServer by forwarding its methods to the given MBeanServerConnection. This constructor is equivalent to MBeanServerConnectionWrapper(wrapped, null).

Parameters:
wrapped - the MBeanServerConnection to which methods are to be forwarded. This parameter can be null, in which case the MBeanServerConnection will typically be supplied by overriding getMBeanServerConnection().

MBeanServerConnectionWrapper

public MBeanServerConnectionWrapper(MBeanServerConnection wrapped,
                                    ClassLoader defaultCl)
Construct a new object that implements MBeanServer by forwarding its methods to the given MBeanServerConnection. The defaultCl parameter specifies the value to be returned by getDefaultClassLoader(). A null value is equivalent to Thread.getContextClassLoader().

Parameters:
wrapped - the MBeanServerConnection to which methods are to be forwarded. This parameter can be null, in which case the MBeanServerConnection will typically be supplied by overriding getMBeanServerConnection().
defaultCl - the value to be returned by getDefaultClassLoader(). A null value is equivalent to the current thread's Thread.getContextClassLoader().
Method Detail

getMBeanServerConnection

protected MBeanServerConnection getMBeanServerConnection()
Returns an MBeanServerConnection. This method is called each time an operation must be invoked on the underlying MBeanServerConnection. The default implementation returns the MBeanServerConnection that was supplied to the constructor of this MBeanServerConnectionWrapper.


getDefaultClassLoader

public ClassLoader getDefaultClassLoader()
Returns the default class loader passed to the constructor. If the value passed was null, then the returned value will be the context class loader at the time this object was constructed.

Returns:
the ClassLoader that was passed to the constructor.

wrapIOException

protected RuntimeException wrapIOException(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. Since the methods in MBeanServer are not declared to throw IOException, this method must return a RuntimeException to be thrown instead. Typically, the original IOException will be in the cause chain of the RuntimeException.

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 a RuntimeException 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 NotificationManager
Specified by:
addNotificationListener in interface MBeanServer
Specified by:
addNotificationListener in interface MBeanServerConnection
Parameters:
name - The name of the MBean on which the listener should be added.
listener - The listener object which will handle the notifications emitted by the registered MBean.
filter - The filter object. If filter is null, no filtering will be performed before handling notifications.
handback - The context to be sent to the listener when a notification is emitted.
Throws:
InstanceNotFoundException - The MBean name provided does not match any of the registered MBeans.
See Also:
NotificationManager.removeNotificationListener(ObjectName, NotificationListener), NotificationManager.removeNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object)

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
Parameters:
name - The name of the MBean on which the listener should be added.
listener - The object name of the listener which will handle the notifications emitted by the registered MBean.
filter - The filter object. If filter is null, no filtering will be performed before handling notifications.
handback - The context to be sent to the listener when a notification is emitted.
Throws:
InstanceNotFoundException - The MBean name of the notification listener or of the notification broadcaster does not match any of the registered MBeans.
See Also:
MBeanServerConnection.removeNotificationListener(ObjectName, ObjectName), MBeanServerConnection.removeNotificationListener(ObjectName, ObjectName, NotificationFilter, Object)

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
Parameters:
className - The class name of the MBean to be instantiated.
name - The object name of the MBean. May be null.
Returns:
An ObjectInstance, containing the ObjectName and the Java class name of the newly instantiated MBean. If the contained ObjectName is n, the contained Java class name is getMBeanInfo(n).getClassName().
Throws:
ReflectionException - Wraps a java.lang.ClassNotFoundException or a java.lang.Exception that occurred when trying to invoke the MBean's constructor.
InstanceAlreadyExistsException - The MBean is already under the control of the MBean server.
MBeanRegistrationException - The preRegister (MBeanRegistration interface) method of the MBean has thrown an exception. The MBean will not be registered.
MBeanException - The constructor of the MBean has thrown an exception
NotCompliantMBeanException - This class is not a JMX compliant MBean
See Also:
MBeanRegistration

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
Parameters:
className - The class name of the MBean to be instantiated.
name - The object name of the MBean. May be null.
params - An array containing the parameters of the constructor to be invoked.
signature - An array containing the signature of the constructor to be invoked.
Returns:
An ObjectInstance, containing the ObjectName and the Java class name of the newly instantiated MBean. If the contained ObjectName is n, the contained Java class name is getMBeanInfo(n).getClassName().
Throws:
ReflectionException - Wraps a java.lang.ClassNotFoundException or a java.lang.Exception that occurred when trying to invoke the MBean's constructor.
InstanceAlreadyExistsException - The MBean is already under the control of the MBean server.
MBeanRegistrationException - The preRegister (MBeanRegistration interface) method of the MBean has thrown an exception. The MBean will not be registered.
MBeanException - The constructor of the MBean has thrown an exception
NotCompliantMBeanException - This class is not a JMX compliant MBean
See Also:
MBeanRegistration

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
Parameters:
className - The class name of the MBean to be instantiated.
name - The object name of the MBean. May be null.
loaderName - The object name of the class loader to be used.
Returns:
An ObjectInstance, containing the ObjectName and the Java class name of the newly instantiated MBean. If the contained ObjectName is n, the contained Java class name is getMBeanInfo(n).getClassName().
Throws:
ReflectionException - Wraps a java.lang.ClassNotFoundException or a java.lang.Exception that occurred when trying to invoke the MBean's constructor.
InstanceAlreadyExistsException - The MBean is already under the control of the MBean server.
MBeanRegistrationException - The preRegister (MBeanRegistration interface) method of the MBean has thrown an exception. The MBean will not be registered.
MBeanException - The constructor of the MBean has thrown an exception
NotCompliantMBeanException - This class is not a JMX compliant MBean
InstanceNotFoundException - The specified class loader is not registered in the MBean server.
See Also:
MBeanRegistration

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
Parameters:
className - The class name of the MBean to be instantiated.
name - The object name of the MBean. May be null.
loaderName - The object name of the class loader to be used.
params - An array containing the parameters of the constructor to be invoked.
signature - An array containing the signature of the constructor to be invoked.
Returns:
An ObjectInstance, containing the ObjectName and the Java class name of the newly instantiated MBean. If the contained ObjectName is n, the contained Java class name is getMBeanInfo(n).getClassName().
Throws:
ReflectionException - Wraps a java.lang.ClassNotFoundException or a java.lang.Exception that occurred when trying to invoke the MBean's constructor.
InstanceAlreadyExistsException - The MBean is already under the control of the MBean server.
MBeanRegistrationException - The preRegister (MBeanRegistration interface) method of the MBean has thrown an exception. The MBean will not be registered.
MBeanException - The constructor of the MBean has thrown an exception
NotCompliantMBeanException - This class is not a JMX compliant MBean
InstanceNotFoundException - The specified class loader is not registered in the MBean server.
See Also:
MBeanRegistration

deserialize

@Deprecated
public ObjectInputStream deserialize(ObjectName name,
                                                byte[] data)
                              throws InstanceNotFoundException,
                                     OperationsException
Deprecated. see MBeanServer

Throws an UnsupportedOperationException. This behavior can be changed by subclasses.

Specified by:
deserialize in interface MBeanServer
Parameters:
name - The name of the MBean whose class loader should be used for the de-serialization.
data - The byte array to be de-sererialized.
Returns:
The de-serialized object stream.
Throws:
InstanceNotFoundException - The MBean specified is not found.
OperationsException - Any of the usual Input/Output related exceptions.

deserialize

@Deprecated
public ObjectInputStream deserialize(String className,
                                                byte[] data)
                              throws OperationsException,
                                     ReflectionException
Deprecated. see MBeanServer

Throws an UnsupportedOperationException. This behavior can be changed by subclasses.

Specified by:
deserialize in interface MBeanServer
Parameters:
className - The name of the class whose class loader should be used for the de-serialization.
data - The byte array to be de-sererialized.
Returns:
The de-serialized object stream.
Throws:
OperationsException - Any of the usual Input/Output related exceptions.
ReflectionException - The specified class could not be loaded by the class loader repository

deserialize

@Deprecated
public ObjectInputStream deserialize(String className,
                                                ObjectName loaderName,
                                                byte[] data)
                              throws InstanceNotFoundException,
                                     OperationsException,
                                     ReflectionException
Deprecated. see MBeanServer

Throws an UnsupportedOperationException. This behavior can be changed by subclasses.

Specified by:
deserialize in interface MBeanServer
Parameters:
className - The name of the class whose class loader should be used for the de-serialization.
loaderName - The name of the class loader to be used for loading the specified class. If null, the MBean Server's class loader will be used.
data - The byte array to be de-sererialized.
Returns:
The de-serialized object stream.
Throws:
InstanceNotFoundException - The specified class loader MBean is not found.
OperationsException - Any of the usual Input/Output related exceptions.
ReflectionException - The specified class could not be loaded by the specified class loader.

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
Parameters:
name - The object name of the MBean from which the attribute is to be retrieved.
attribute - A String specifying the name of the attribute to be retrieved.
Returns:
The value of the retrieved attribute.
Throws:
MBeanException - Wraps an exception thrown by the MBean's getter.
AttributeNotFoundException - The attribute specified is not accessible in the MBean.
InstanceNotFoundException - The MBean specified is not registered in the MBean server.
ReflectionException - Wraps a java.lang.Exception thrown when trying to invoke the setter.
See Also:
MBeanServerConnection.setAttribute(javax.management.ObjectName, javax.management.Attribute)

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
Parameters:
name - The object name of the MBean from which the attributes are retrieved.
attributes - A list of the attributes to be retrieved.
Returns:
The list of the retrieved attributes.
Throws:
InstanceNotFoundException - The MBean specified is not registered in the MBean server.
ReflectionException - An exception occurred when trying to invoke the getAttributes method of a Dynamic MBean.
See Also:
MBeanServerConnection.setAttributes(javax.management.ObjectName, javax.management.AttributeList)

getClassLoader

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

Specified by:
getClassLoader in interface MBeanServer
Parameters:
loaderName - The ObjectName of the ClassLoader. May be null, in which case the MBean server's own ClassLoader is returned.
Returns:
The named ClassLoader. If l is the actual ClassLoader with that name, and r is the returned value, then either: What this means is that the ClassLoader may be wrapped in another ClassLoader for security or other reasons.
Throws:
InstanceNotFoundException - if the named ClassLoader is not found.

getClassLoaderFor

public ClassLoader getClassLoaderFor(ObjectName mbeanName)
                              throws InstanceNotFoundException
Returns the default class loader. This behavior can be changed by subclasses.

Specified by:
getClassLoaderFor in interface MBeanServer
Parameters:
mbeanName - The ObjectName of the MBean.
Returns:
The ClassLoader used for that MBean. If l is the value specified by the rules above, and r is the returned value, then either: What this means is that the ClassLoader may be wrapped in another ClassLoader for security or other reasons.
Throws:
InstanceNotFoundException - if the named MBean is not found.

getClassLoaderRepository

public ClassLoaderRepository getClassLoaderRepository()

Returns a ClassLoaderRepository based on the class loader returned by getDefaultClassLoader().

Specified by:
getClassLoaderRepository in interface MBeanServer
Returns:
a ClassLoaderRepository that contains a single class loader, returned by getDefaultClassLoader().

getDefaultDomain

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

Specified by:
getDefaultDomain in interface MBeanServer
Specified by:
getDefaultDomain in interface MBeanServerConnection
Returns:
the default domain.

getDomains

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

Specified by:
getDomains in interface MBeanServer
Specified by:
getDomains in interface MBeanServerConnection
Returns:
the list of domains.

getMBeanCount

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

Specified by:
getMBeanCount in interface MBeanServer
Specified by:
getMBeanCount in interface MBeanServerConnection
Returns:
the number of registered MBeans, wrapped in an Integer. If the caller's permissions are restricted, this number may be greater than the number of MBeans the caller can access.

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
Parameters:
name - The name of the MBean to analyze
Returns:
An instance of MBeanInfo allowing the retrieval of all attributes and operations of this MBean.
Throws:
InstanceNotFoundException - The MBean specified was not found.
IntrospectionException - An exception occurred during introspection.
ReflectionException - An exception occurred when trying to invoke the getMBeanInfo of a Dynamic MBean.

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
Parameters:
name - The object name of the MBean.
Returns:
The ObjectInstance associated with the MBean specified by name. The contained ObjectName is name and the contained class name is getMBeanInfo(name).getClassName().
Throws:
InstanceNotFoundException - The MBean specified is not registered in the MBean server.

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
Parameters:
className - The class name of the object to be instantiated.
Returns:
The newly instantiated object.
Throws:
ReflectionException - Wraps a java.lang.ClassNotFoundException or the java.lang.Exception that occurred when trying to invoke the object's constructor.
MBeanException - The constructor of the object has thrown an exception

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
Parameters:
className - The class name of the object to be instantiated.
params - An array containing the parameters of the constructor to be invoked.
signature - An array containing the signature of the constructor to be invoked.
Returns:
The newly instantiated object.
Throws:
ReflectionException - Wraps a java.lang.ClassNotFoundException or the java.lang.Exception that occurred when trying to invoke the object's constructor.
MBeanException - The constructor of the object has thrown an exception

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
Parameters:
className - The class name of the MBean to be instantiated.
loaderName - The object name of the class loader to be used.
Returns:
The newly instantiated object.
Throws:
ReflectionException - Wraps a java.lang.ClassNotFoundException or the java.lang.Exception that occurred when trying to invoke the object's constructor.
MBeanException - The constructor of the object has thrown an exception.
InstanceNotFoundException - The specified class loader is not registered in the MBeanServer.

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
Parameters:
className - The class name of the object to be instantiated.
loaderName - The object name of the class loader to be used.
params - An array containing the parameters of the constructor to be invoked.
signature - An array containing the signature of the constructor to be invoked.
Returns:
The newly instantiated object.
Throws:
ReflectionException - Wraps a java.lang.ClassNotFoundException or the java.lang.Exception that occurred when trying to invoke the object's constructor.
MBeanException - The constructor of the object has thrown an exception
InstanceNotFoundException - The specified class loader is not registered in the MBean server.

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
Parameters:
name - The object name of the MBean on which the method is to be invoked.
operationName - The name of the operation to be invoked.
params - An array containing the parameters to be set when the operation is invoked
signature - An array containing the signature of the operation, an array of class names in the format returned by Class.getName(). The class objects will be loaded using the same class loader as the one used for loading the MBean on which the operation was invoked.
Returns:
The object returned by the operation, which represents the result of invoking the operation on the MBean specified.
Throws:
InstanceNotFoundException - The MBean specified is not registered in the MBean server.
MBeanException - Wraps an exception thrown by the MBean's invoked method.
ReflectionException - Wraps a java.lang.Exception thrown while trying to invoke the method.

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
Parameters:
name - The ObjectName of the MBean.
className - The name of the class.
Returns:
true if the MBean specified is an instance of the specified class according to the rules above, false otherwise.
Throws:
InstanceNotFoundException - The MBean specified is not registered in the MBean server.
See Also:
Class.isInstance(java.lang.Object)

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
Parameters:
name - The object name of the MBean to be checked.
Returns:
True if the MBean is already registered in the MBean server, false otherwise.

queryMBeans

public Set<ObjectInstance> 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
Parameters:
name - The object name pattern identifying the MBeans to be retrieved. If null or no domain and key properties are specified, all the MBeans registered will be retrieved.
query - The query expression to be applied for selecting MBeans. If null no query expression will be applied for selecting MBeans. ObjectName patterns that may be contained in the query expression will be evaluated in the context of the namespace in which the MBeans selected by name are registered. Thus, in the query parameter, no ObjectName pattern containing a namespace path can match any of the MBean names selected by name. See the namespaces documentation for more details.
Returns:
A set containing the ObjectInstance objects for the selected MBeans. If no MBean satisfies the query an empty list is returned.

queryNames

public Set<ObjectName> 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
Parameters:
name - The object name pattern identifying the MBean names to be retrieved. If null or no domain and key properties are specified, the name of all registered MBeans will be retrieved.
query - The query expression to be applied for selecting MBeans. If null no query expression will be applied for selecting MBeans. ObjectName patterns that may be contained in the query expression will be evaluated in the context of the namespace in which the MBeans slected by name are registered. Thus, in the query parameter, no ObjectName pattern containing a namespace path can match any of the MBean names selected by name. See the namespaces documentation for more details.
Returns:
A set containing the ObjectNames for the MBeans selected. If no MBean satisfies the query, an empty list is returned.

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
Parameters:
object - The MBean to be registered as an MBean.
name - The object name of the MBean. May be null.
Returns:
An ObjectInstance, containing the ObjectName and the Java class name of the newly registered MBean. If the contained ObjectName is n, the contained Java class name is getMBeanInfo(n).getClassName().
Throws:
InstanceAlreadyExistsException - The MBean is already under the control of the MBean server.
MBeanRegistrationException - The preRegister (MBeanRegistration interface) method of the MBean has thrown an exception. The MBean will not be registered.
NotCompliantMBeanException - This object is not a JMX compliant MBean
See Also:
MBeanRegistration

removeNotificationListener

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

Specified by:
removeNotificationListener in interface NotificationManager
Specified by:
removeNotificationListener in interface MBeanServer
Specified by:
removeNotificationListener in interface MBeanServerConnection
Parameters:
name - The name of the MBean on which the listener should be removed.
listener - The listener to be removed.
Throws:
InstanceNotFoundException - The MBean name provided does not match any of the registered MBeans.
ListenerNotFoundException - The listener is not registered in the MBean.
See Also:
NotificationManager.addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object)

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 NotificationManager
Specified by:
removeNotificationListener in interface MBeanServer
Specified by:
removeNotificationListener in interface MBeanServerConnection
Parameters:
name - The name of the MBean on which the listener should be removed.
listener - The listener to be removed.
filter - The filter that was specified when the listener was added.
handback - The handback that was specified when the listener was added.
Throws:
InstanceNotFoundException - The MBean name provided does not match any of the registered MBeans.
ListenerNotFoundException - The listener is not registered in the MBean, or it is not registered with the given filter and handback.
See Also:
NotificationManager.addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object)

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
Parameters:
name - The name of the MBean on which the listener should be removed.
listener - The object name of the listener to be removed.
Throws:
InstanceNotFoundException - The MBean name provided does not match any of the registered MBeans.
ListenerNotFoundException - The listener is not registered in the MBean.
See Also:
MBeanServerConnection.addNotificationListener(ObjectName, ObjectName, NotificationFilter, Object)

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
Parameters:
name - The name of the MBean on which the listener should be removed.
listener - The object name of the listener to be removed.
filter - The filter that was specified when the listener was added.
handback - The handback that was specified when the listener was added.
Throws:
InstanceNotFoundException - The MBean name provided does not match any of the registered MBeans.
ListenerNotFoundException - The listener is not registered in the MBean, or it is not registered with the given filter and handback.
See Also:
MBeanServerConnection.addNotificationListener(ObjectName, ObjectName, NotificationFilter, Object)

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
Parameters:
name - The name of the MBean within which the attribute is to be set.
attribute - The identification of the attribute to be set and the value it is to be set to.
Throws:
InstanceNotFoundException - The MBean specified is not registered in the MBean server.
AttributeNotFoundException - The attribute specified is not accessible in the MBean.
InvalidAttributeValueException - The value specified for the attribute is not valid.
MBeanException - Wraps an exception thrown by the MBean's setter.
ReflectionException - Wraps a java.lang.Exception thrown when trying to invoke the setter.
See Also:
MBeanServerConnection.getAttribute(javax.management.ObjectName, java.lang.String)

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
Parameters:
name - The object name of the MBean within which the attributes are to be set.
attributes - A list of attributes: The identification of the attributes to be set and the values they are to be set to.
Returns:
The list of attributes that were set, with their new values.
Throws:
InstanceNotFoundException - The MBean specified is not registered in the MBean server.
ReflectionException - An exception occurred when trying to invoke the getAttributes method of a Dynamic MBean.
See Also:
MBeanServerConnection.getAttributes(javax.management.ObjectName, java.lang.String[])

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
Parameters:
name - The object name of the MBean to be unregistered.
Throws:
InstanceNotFoundException - The MBean specified is not registered in the MBean server.
MBeanRegistrationException - The preDeregister ((MBeanRegistration interface) method of the MBean has thrown an exception.
See Also:
MBeanRegistration

Java™ Platform
Standard Ed. 7

DRAFT ea-b76

Submit a bug or feature

Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.