javax.management
public interface MBeanServer extends MBeanServerConnection
This interface represents a server for management beans,
providing facilities for the creation, registration and
removal of such beans. This interface is central to the
Java management architecture. Users do not usually implement
this class. Instead, implementations of this class
may be obtained using an MBeanServerFactory
.
Registering a bean with the server makes its attributes and
operations accessible via the server. Only JMX compliant
beans may be registered with the server. When a bean
is registered or unregistered, an MBeanServerNotification
is emitted by the server's MBeanServerDelegate
.
Listeners may be registered with this bean in order to
obtain such notifications. It has the ObjectName
JMImplementation:type=MBeanServerDelegate
.
Security checks are applied on the methods of the server,
as detailed below, if it is obtained using the
MBeanServerFactory.createMBeanServer()
or
MBeanServerFactory.newMBeanServer()
methods and
System.getSecurityManager()
returns a non-null
value. If a check fails, a SecurityException
is thrown. Note than the class name used in the exception
is that of the bean, and thus, as a result, an
InstanceNotFoundException
precludes these security checks, due to the class name
that would be used in the exception being unavailable.
Modifier and Type | Method and Description |
---|---|
void |
addNotificationListener(ObjectName name,
NotificationListener listener,
NotificationFilter filter,
Object passback)
Registers the supplied listener with the specified management
bean.
|
void |
addNotificationListener(ObjectName name,
ObjectName listener,
NotificationFilter filter,
Object passback)
Registers the supplied listener with the specified management
bean.
|
ObjectInstance |
createMBean(String className,
ObjectName name)
Instantiates a new instance of the specified management bean
using the default constructor and registers it with the server
under the supplied name.
|
ObjectInstance |
createMBean(String className,
ObjectName name,
Object[] params,
String[] sig)
Instantiates a new instance of the specified management bean
using the given constructor and registers it with the server
under the supplied name.
|
ObjectInstance |
createMBean(String className,
ObjectName name,
ObjectName loaderName)
Instantiates a new instance of the specified management bean
using the default constructor and registers it with the server
under the supplied name.
|
ObjectInstance |
createMBean(String className,
ObjectName name,
ObjectName loaderName,
Object[] params,
String[] sig)
Instantiates a new instance of the specified management bean
using the given constructor and registers it with the server
under the supplied name.
|
ObjectInputStream |
deserialize(ObjectName name,
byte[] data)
Deprecated.
getClassLoaderFor(ObjectName) should be used
to obtain the class loader of the bean, which can then
be used to perform deserialization in the user's code. |
ObjectInputStream |
deserialize(String name,
byte[] data)
Deprecated.
getClassLoaderRepository() should be used
to obtain the class loading repository, which can then
be used to obtain the Class instance and deserialize
the array using its class loader. |
ObjectInputStream |
deserialize(String name,
ObjectName loader,
byte[] data)
Deprecated.
#getClassLoader(ObjectName can be used to obtain
the named class loader and deserialize the array. |
Object |
getAttribute(ObjectName bean,
String name)
Returns the value of the supplied attribute from the specified
management bean.
|
AttributeList |
getAttributes(ObjectName bean,
String[] names)
Returns the values of the named attributes from the specified
management bean.
|
ClassLoader |
getClassLoader(ObjectName name)
Returns the specified class loader.
|
ClassLoader |
getClassLoaderFor(ObjectName name)
Returns the class loader of the specified management bean.
|
ClassLoaderRepository |
getClassLoaderRepository()
Returns the class loader repository used by this server.
|
String |
getDefaultDomain()
Returns the default domain this server applies to beans that have
no specified domain.
|
String[] |
getDomains()
Returns an array containing all the domains used by beans registered
with this server.
|
Integer |
getMBeanCount()
Returns the number of management beans registered with this server.
|
MBeanInfo |
getMBeanInfo(ObjectName name)
Returns information on the given management bean.
|
ObjectInstance |
getObjectInstance(ObjectName name)
Returns the
ObjectInstance created for the specified
management bean on registration. |
Object |
instantiate(String name)
Creates an instance of the specified class using the list of
class loaders from the
Class Loader
Repository . |
Object |
instantiate(String name,
Object[] params,
String[] sig)
Creates an instance of the specified class using the list of
class loaders from the
Class Loader
Repository . |
Object |
instantiate(String name,
ObjectName loaderName)
Creates an instance of the specified class using the supplied
class loader.
|
Object |
instantiate(String name,
ObjectName loaderName,
Object[] params,
String[] sig)
Creates an instance of the specified class using the supplied
class loader.
|
Object |
invoke(ObjectName bean,
String name,
Object[] params,
String[] sig)
Invokes the supplied operation on the specified management
bean.
|
boolean |
isInstanceOf(ObjectName name,
String className)
Returns true if the specified management bean is an instance
of the supplied class.
|
boolean |
isRegistered(ObjectName name)
Returns true if the specified management bean is registered with
the server.
|
Set<ObjectInstance> |
queryMBeans(ObjectName name,
QueryExp query)
Returns a set of
ObjectInstance s matching the specified
criteria. |
Set<ObjectName> |
queryNames(ObjectName name,
QueryExp query)
Returns a set of
ObjectName s matching the specified
criteria. |
ObjectInstance |
registerMBean(Object obj,
ObjectName name)
Registers the supplied instance with the server, using the specified
ObjectName . |
void |
removeNotificationListener(ObjectName name,
NotificationListener listener)
Removes the specified listener from the list of recipients
of notifications from the supplied bean.
|
void |
removeNotificationListener(ObjectName name,
NotificationListener listener,
NotificationFilter filter,
Object passback)
Removes the specified listener from the list of recipients
of notifications from the supplied bean.
|
void |
removeNotificationListener(ObjectName name,
ObjectName listener)
Removes the specified listener from the list of recipients
of notifications from the supplied bean.
|
void |
removeNotificationListener(ObjectName name,
ObjectName listener,
NotificationFilter filter,
Object passback)
Removes the specified listener from the list of recipients
of notifications from the supplied bean.
|
void |
setAttribute(ObjectName name,
Attribute attribute)
Sets the value of the specified attribute of the supplied
management bean.
|
AttributeList |
setAttributes(ObjectName name,
AttributeList attributes)
Sets the value of each of the specified attributes
of the supplied management bean to that specified by
the
Attribute object. |
void |
unregisterMBean(ObjectName name)
Unregisters the specified management bean.
|
void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object passback) throws InstanceNotFoundException
ObjectName
instances. The notification is otherwise unchanged.addNotificationListener
in interface MBeanServerConnection
name
- the name of the management bean with which the listener
should be registered.listener
- the listener which will handle notifications from
the bean.filter
- the filter to apply to incoming notifications, or
null
if no filtering should be applied.passback
- an object to be passed to the listener when a
notification is emitted.InstanceNotFoundException
- if the name of the management bean
could not be resolved.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, null, name,
"addNotificationListener")
.removeNotificationListener(ObjectName, NotificationListener)
,
removeNotificationListener(ObjectName, NotificationListener,
NotificationFilter, Object)
,
NotificationBroadcaster.addNotificationListener(NotificationListener,
NotificationFilter,
Object)
void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object passback) throws InstanceNotFoundException
Registers the supplied listener with the specified management
bean. Notifications emitted by the management bean are forwarded
to the listener via the server, which will convert any MBean
references in the source to portable ObjectName
instances. The notification is otherwise unchanged.
The listener that receives notifications will be the one that is registered with the given name at the time this method is called. Even if it later unregisters and ceases to use that name, it will still receive notifications.
addNotificationListener
in interface MBeanServerConnection
name
- the name of the management bean with which the listener
should be registered.listener
- the name of the listener which will handle
notifications from the bean.filter
- the filter to apply to incoming notifications, or
null
if no filtering should be applied.passback
- an object to be passed to the listener when a
notification is emitted.InstanceNotFoundException
- if the name of the management bean
could not be resolved.RuntimeOperationsException
- if the bean associated with the given
object name is not a
NotificationListener
. This
exception wraps an
IllegalArgumentException
.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, null, name,
"addNotificationListener")
.removeNotificationListener(ObjectName, NotificationListener)
,
removeNotificationListener(ObjectName, NotificationListener,
NotificationFilter, Object)
,
NotificationBroadcaster.addNotificationListener(NotificationListener,
NotificationFilter,
Object)
ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException
Instantiates a new instance of the specified management bean
using the default constructor and registers it with the server
under the supplied name. The class is loaded using the
default
loader repository
of the server.
If the name supplied is null
, then the bean is
expected to implement the MBeanRegistration
interface.
The preRegister
method
of this interface will be used to obtain the name in this case.
This method is equivalent to calling
with createMBean(className, name, (Object[]) null,
(String[]) null)
null
parameters
and signature.
createMBean
in interface MBeanServerConnection
className
- the class of the management bean, of which
an instance should be created.name
- the name to register the new bean with.ObjectInstance
containing the ObjectName
and Java class name of the created instance.ReflectionException
- if an exception occurs in creating
an instance of the bean.InstanceAlreadyExistsException
- if a matching instance
already exists.MBeanRegistrationException
- if an exception occurs in
calling the preRegister
method.MBeanException
- if the bean's constructor throws an exception.NotCompliantMBeanException
- if the created bean is not
compliant with the JMX specification.RuntimeOperationsException
- if an IllegalArgumentException
is thrown by the server due to a
null
class name or object
name or if the object name is a pattern.SecurityException
- if a security manager exists and the
caller's permissions don't imply the
use of the instantiate
and registerMBean
methods.createMBean(String, ObjectName, Object[], String[])
ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] sig) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException
Instantiates a new instance of the specified management bean
using the given constructor and registers it with the server
under the supplied name. The class is loaded using the
default
loader repository
of the server.
If the name supplied is null
, then the bean is
expected to implement the MBeanRegistration
interface.
The preRegister
method
of this interface will be used to obtain the name in this case.
createMBean
in interface MBeanServerConnection
className
- the class of the management bean, of which
an instance should be created.name
- the name to register the new bean with.params
- the parameters for the bean's constructor.sig
- the signature of the constructor to use.ObjectInstance
containing the ObjectName
and Java class name of the created instance.ReflectionException
- if an exception occurs in creating
an instance of the bean.InstanceAlreadyExistsException
- if a matching instance
already exists.MBeanRegistrationException
- if an exception occurs in
calling the preRegister
method.MBeanException
- if the bean's constructor throws an exception.NotCompliantMBeanException
- if the created bean is not
compliant with the JMX specification.RuntimeOperationsException
- if an IllegalArgumentException
is thrown by the server due to a
null
class name or object
name or if the object name is a pattern.SecurityException
- if a security manager exists and the
caller's permissions don't imply the
use of the instantiate
and registerMBean
methods.ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
Instantiates a new instance of the specified management bean
using the default constructor and registers it with the server
under the supplied name. The class is loaded using the
given class loader. If this argument is null
,
then the same class loader as was used to load the server
is used.
If the name supplied is null
, then the bean is
expected to implement the MBeanRegistration
interface.
The preRegister
method
of this interface will be used to obtain the name in this case.
This method is equivalent to calling
with createMBean(className, name, loaderName, (Object[]) null,
(String) null)
null
parameters
and signature.
createMBean
in interface MBeanServerConnection
className
- the class of the management bean, of which
an instance should be created.name
- the name to register the new bean with.loaderName
- the name of the class loader.ObjectInstance
containing the ObjectName
and Java class name of the created instance.ReflectionException
- if an exception occurs in creating
an instance of the bean.InstanceAlreadyExistsException
- if a matching instance
already exists.MBeanRegistrationException
- if an exception occurs in
calling the preRegister
method.MBeanException
- if the bean's constructor throws an exception.NotCompliantMBeanException
- if the created bean is not
compliant with the JMX specification.InstanceNotFoundException
- if the specified class loader is not
registered with the server.RuntimeOperationsException
- if an IllegalArgumentException
is thrown by the server due to a
null
class name or object
name or if the object name is a pattern.SecurityException
- if a security manager exists and the
caller's permissions don't imply the
use of the instantiate
and registerMBean
methods.createMBean(String, ObjectName, ObjectName, Object[], String[])
ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] sig) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
Instantiates a new instance of the specified management bean
using the given constructor and registers it with the server
under the supplied name. The class is loaded using the
given class loader. If this argument is null
,
then the same class loader as was used to load the server
is used.
If the name supplied is null
, then the bean is
expected to implement the MBeanRegistration
interface.
The preRegister
method
of this interface will be used to obtain the name in this case.
createMBean
in interface MBeanServerConnection
className
- the class of the management bean, of which
an instance should be created.name
- the name to register the new bean with.loaderName
- the name of the class loader.params
- the parameters for the bean's constructor.sig
- the signature of the constructor to use.ObjectInstance
containing the ObjectName
and Java class name of the created instance.ReflectionException
- if an exception occurs in creating
an instance of the bean.InstanceAlreadyExistsException
- if a matching instance
already exists.MBeanRegistrationException
- if an exception occurs in
calling the preRegister
method.MBeanException
- if the bean's constructor throws an exception.NotCompliantMBeanException
- if the created bean is not
compliant with the JMX specification.InstanceNotFoundException
- if the specified class loader is not
registered with the server.RuntimeOperationsException
- if an IllegalArgumentException
is thrown by the server due to a
null
class name or object
name or if the object name is a pattern.SecurityException
- if a security manager exists and the
caller's permissions don't imply the
use of the instantiate
and registerMBean
methods.ObjectInputStream deserialize(ObjectName name, byte[] data) throws InstanceNotFoundException, OperationsException
getClassLoaderFor(ObjectName)
should be used
to obtain the class loader of the bean, which can then
be used to perform deserialization in the user's code.name
- the name of the bean whose class loader should be used.data
- the byte array to be deserialized.InstanceNotFoundException
- if the specified bean is not
registered with the server.OperationsException
- if any I/O error is thrown by the
deserialization process.SecurityException
- if a security manager exists and the
caller's permissions don't imply {@link
MBeanPermission(String,String,ObjectName,String)
MBeanPermission(className, null, name,
"getClassLoaderFor")
ObjectInputStream deserialize(String name, byte[] data) throws OperationsException, ReflectionException
getClassLoaderRepository()
should be used
to obtain the class loading repository, which can then
be used to obtain the Class
instance and deserialize
the array using its class loader.Class Loader Repository
and then using the class loader of the resulting Class
instance.name
- the name of the class which should be loaded to obtain the
class loader.data
- the byte array to be deserialized.OperationsException
- if any I/O error is thrown by the
deserialization process.ReflectionException
- if an error occurs in obtaining the
Class
instance.SecurityException
- if a security manager exists and the
caller's permissions don't imply {@link
MBeanPermission(String,String,ObjectName,String)
MBeanPermission(null, null, null,
"getClassLoaderRepository")
ObjectInputStream deserialize(String name, ObjectName loader, byte[] data) throws InstanceNotFoundException, ReflectionException, OperationsException
#getClassLoader(ObjectName
can be used to obtain
the named class loader and deserialize the array.null
if the server's
class loader should be used instead.name
- the name of the class which should be loaded to obtain the
class loader.loader
- the name of the class loader to use, or null
if the class loader of the server should be used.data
- the byte array to be deserialized.InstanceNotFoundException
- if the specified class loader is not
registered with the server.OperationsException
- if any I/O error is thrown by the
deserialization process.ReflectionException
- if an error occurs in obtaining the
Class
instance.SecurityException
- if a security manager exists and the
caller's permissions don't imply {@link
MBeanPermission(String,String,ObjectName,String)
MBeanPermission(className, null, loader,
"getClassLoader")
Object getAttribute(ObjectName bean, String name) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException
getAttribute
in interface MBeanServerConnection
bean
- the bean to retrieve the value from.name
- the name of the attribute to retrieve.AttributeNotFoundException
- if the attribute could not be
accessed from the bean.MBeanException
- if the management bean's accessor throws
an exception.InstanceNotFoundException
- if the bean can not be found.ReflectionException
- if an exception was thrown in trying
to invoke the bean's accessor.RuntimeOperationsException
- if an IllegalArgumentException
is thrown by the server due to a
null
bean or attribute
name.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, name, bean,
"getAttribute")
.DynamicMBean.getAttribute(String)
AttributeList getAttributes(ObjectName bean, String[] names) throws InstanceNotFoundException, ReflectionException
getAttributes
in interface MBeanServerConnection
bean
- the bean to retrieve the value from.names
- the names of the attributes to retrieve.InstanceNotFoundException
- if the bean can not be found.ReflectionException
- if an exception was thrown in trying
to invoke the bean's accessor.RuntimeOperationsException
- if an IllegalArgumentException
is thrown by the server due to a
null
bean or attribute
name.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, null, bean,
"getAttribute")
. Additionally,
for an attribute name, n
, the
caller's permission must imply MBeanPermission(className, n, bean,
"getAttribute")
or that attribute will
not be included.DynamicMBean.getAttributes(String[])
ClassLoader getClassLoader(ObjectName name) throws InstanceNotFoundException
null
, then the class loader of the server will be
returned. If l
is the requested class loader,
and r
is the actual class loader returned, then
either l
and r
will be identical,
or they will at least return the same class from
ClassLoader.loadClass(String)
for any given string.
They may not be identical due to one or the other
being wrapped in another class loader (e.g. for security).name
- the name of the class loader to return.InstanceNotFoundException
- if the class loader can not
be found.SecurityException
- if a security manager exists and the
caller's permissions don't imply {@link
MBeanPermission(String,String,ObjectName,String)
MBeanPermission(className, null, name,
"getClassLoader")
ClassLoader getClassLoaderFor(ObjectName name) throws InstanceNotFoundException
l
is the requested class loader, and r
is the actual class loader returned, then either l
and r
will be identical, or they will at least
return the same class from ClassLoader.loadClass(String)
for any given string. They may not be identical due to one or
the other being wrapped in another class loader (e.g. for
security).name
- the name of the bean whose class loader should be
returned.InstanceNotFoundException
- if the bean is not registered
with the server.SecurityException
- if a security manager exists and the
caller's permissions don't imply {@link
MBeanPermission(String,String,ObjectName,String)
MBeanPermission(className, null, name,
"getClassLoaderFor")
ClassLoaderRepository getClassLoaderRepository()
SecurityException
- if a security manager exists and the
caller's permissions don't imply {@link
MBeanPermission(String,String,ObjectName,String)
MBeanPermission(null, null, null,
"getClassLoaderRepository")
String getDefaultDomain()
getDefaultDomain
in interface MBeanServerConnection
String[] getDomains()
getDomains
in interface MBeanServerConnection
SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(null, null, name,
"getDomains")
. Additionally,
for an domain, d
, the
caller's permission must imply MBeanPermission(null, null,
new ObjectName("d:x=x"), "getDomains")
or that domain will not be included. Note
that "x=x" is an arbitrary key-value pair
provided to satisfy the constructor.ObjectName.getDomain()
Integer getMBeanCount()
getMBeanCount
in interface MBeanServerConnection
MBeanInfo getMBeanInfo(ObjectName name) throws InstanceNotFoundException, IntrospectionException, ReflectionException
getMBeanInfo
in interface MBeanServerConnection
name
- the name of the management bean.MBeanInfo
for the bean.IntrospectionException
- if an exception occurs in examining
the bean.InstanceNotFoundException
- if the bean can not be found.ReflectionException
- if an exception occurs when trying
to invoke DynamicMBean.getMBeanInfo()
on the bean.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, null, name,
"getMBeanInfo")
.DynamicMBean.getMBeanInfo()
ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException
ObjectInstance
created for the specified
management bean on registration.getObjectInstance
in interface MBeanServerConnection
name
- the name of the bean.ObjectInstance
instance.InstanceNotFoundException
- if the bean can not be found.SecurityException
- if a security manager exists and the
caller's permissions don't imply {@link
MBeanPermission(String,String,ObjectName,String)
MBeanPermission(className, null, name,
"getObjectInstance")
createMBean(String, ObjectName)
Object instantiate(String name) throws ReflectionException, MBeanException
Creates an instance of the specified class using the list of
class loaders from the Class Loader
Repository
. The class should have a public constructor
with no arguments. A reference to the new instance is returned,
but the instance is not yet registered with the server.
This method is equivalent to calling
with instantiate(name, (Object[]) null, (String[]) null)
null
parameters and signature.
name
- the name of the class of bean to be instantiated.ReflectionException
- if an exception is thrown during
loading the class or calling the
constructor.MBeanException
- if the constructor throws an exception.RuntimeOperationsException
- if an IllegalArgumentException
is thrown by the server due to a
null
name.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, null, null,
"instantiate")
.instantiate(String, Object[], String[])
Object instantiate(String name, Object[] params, String[] sig) throws ReflectionException, MBeanException
Class Loader
Repository
. The class should have a public constructor
matching the supplied signature. A reference to the new
instance is returned, but the instance is not yet
registered with the server.name
- the name of the class of bean to be instantiated.params
- the parameters for the constructor.sig
- the signature of the constructor.ReflectionException
- if an exception is thrown during
loading the class or calling the
constructor.MBeanException
- if the constructor throws an exception.RuntimeOperationsException
- if an IllegalArgumentException
is thrown by the server due to a
null
name.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, null, null,
"instantiate")
.Object instantiate(String name, ObjectName loaderName) throws InstanceNotFoundException, ReflectionException, MBeanException
Creates an instance of the specified class using the supplied
class loader. If the class loader given is null
,
then the class loader of the server will be used. The class
should have a public constructor with no arguments. A reference
to the new instance is returned, but the instance is not yet
registered with the server.
This method is equivalent to calling
with instantiate(name, loaderName, (Object[]) null,
(String[]) null)
null
parameters
and signature.
name
- the name of the class of bean to be instantiated.loaderName
- the name of the class loader to use.InstanceNotFoundException
- if the class loader is not
registered with the server.ReflectionException
- if an exception is thrown during
loading the class or calling the
constructor.MBeanException
- if the constructor throws an exception.RuntimeOperationsException
- if an IllegalArgumentException
is thrown by the server due to a
null
name.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, null, null,
"instantiate")
.instantiate(String, Object[], String[])
Object instantiate(String name, ObjectName loaderName, Object[] params, String[] sig) throws InstanceNotFoundException, ReflectionException, MBeanException
null
,
then the class loader of the server will be used. The class
should have a public constructor matching the supplied
signature. A reference to the new instance is returned,
but the instance is not yet registered with the server.name
- the name of the class of bean to be instantiated.loaderName
- the name of the class loader to use.params
- the parameters for the constructor.sig
- the signature of the constructor.InstanceNotFoundException
- if the class loader is not
registered with the server.ReflectionException
- if an exception is thrown during
loading the class or calling the
constructor.MBeanException
- if the constructor throws an exception.RuntimeOperationsException
- if an IllegalArgumentException
is thrown by the server due to a
null
name.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, null, null,
"instantiate")
.Object invoke(ObjectName bean, String name, Object[] params, String[] sig) throws InstanceNotFoundException, MBeanException, ReflectionException
invoke
in interface MBeanServerConnection
bean
- the management bean whose operation should be invoked.name
- the name of the operation to invoke.params
- the parameters of the operation.sig
- the signature of the operation.InstanceNotFoundException
- if the bean can not be found.MBeanException
- if the method invoked throws an exception.ReflectionException
- if an exception is thrown in invoking the
method.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, name, bean,
"invoke")
.DynamicMBean.invoke(String, Object[], String[])
boolean isInstanceOf(ObjectName name, String className) throws InstanceNotFoundException
Returns true if the specified management bean is an instance of the supplied class.
A bean, B, is an instance of a class, C, if either of the following conditions holds:
MBeanInfo
is equal to the supplied
name.isInstanceOf
in interface MBeanServerConnection
name
- the name of the management bean.className
- the name of the class to test if name
is
an instance of.InstanceNotFoundException
- if the bean can not be found.SecurityException
- if a security manager exists and the
caller's permissions don't imply {@link
MBeanPermission(String,String,ObjectName,String)
MBeanPermission(className, null, name,
"isInstanceOf")
boolean isRegistered(ObjectName name)
isRegistered
in interface MBeanServerConnection
name
- the name of the management bean.RuntimeOperationsException
- if an IllegalArgumentException
is thrown by the server due to a
null
bean name.Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query)
Returns a set of ObjectInstance
s matching the specified
criteria. The full set of beans registered with the server
are passed through two filters:
ObjectName
.
If both the object name and the query expression are null
,
or the object name has no domain and no key properties,
no filtering will be performed and all beans are returned.
queryMBeans
in interface MBeanServerConnection
name
- an ObjectName
to use as a filter.query
- a query expression to apply to each of the beans that match
the given object name.ObjectInstance
s matching the filtered beans.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(null, null, name,
"queryMBeans")
. Additionally,
for an bean, b
, the
caller's permission must imply MBeanPermission(className, b, name,
"queryMBeans")
or that bean will
not be included. Such an exception may also
arise from the execution of the query, in which
case that particular bean will again be excluded.Set<ObjectName> queryNames(ObjectName name, QueryExp query)
Returns a set of ObjectName
s matching the specified
criteria. The full set of beans registered with the server
are passed through two filters:
ObjectName
.
If both the object name and the query expression are null
,
or the object name has no domain and no key properties,
no filtering will be performed and all beans are returned.
queryNames
in interface MBeanServerConnection
name
- an ObjectName
to use as a filter.query
- a query expression to apply to each of the beans that match
the given object name.ObjectName
s matching the filtered beans.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(null, null, name,
"queryNames")
. Additionally,
for an name, n
, the
caller's permission must imply MBeanPermission(className, n, name,
"queryNames")
or that name will
not be included. Such an exception may also
arise from the execution of the query, in which
case that particular bean will again be excluded.
Note that these permissions are implied if the
queryMBeans
permissions are available.ObjectInstance registerMBean(Object obj, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException
ObjectName
. If the name given is null
, then
the bean supplied is expected to implement the MBeanRegistration
interface and provide the name via the
preRegister
method
of this interface.obj
- the object to register with the server.name
- the name under which to register the object,
or null
if the MBeanRegistration
interface should be used.InstanceAlreadyExistsException
- if a matching instance
already exists.MBeanRegistrationException
- if an exception occurs in
calling the preRegister
method.NotCompliantMBeanException
- if the created bean is not
compliant with the JMX specification.RuntimeOperationsException
- if an IllegalArgumentException
is thrown by the server due to a
null
object.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, null, name,
"registerMBean")
. className
here corresponds to the result of
MBeanInfo.getClassName()
for objects of
this class. If this check succeeds, a check
is also made on its
ProtectionDomain
to ensure
it implies MBeanTrustPermission("register")
.
The use of the MBeanRegistration
interface
results in another MBeanPermission
check
being made on the returned ObjectName
.void removeNotificationListener(ObjectName name, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException
removeNotificationListener(ObjectName,
NotificationListener,NotificationFilter,Object)
removeNotificationListener
in interface MBeanServerConnection
name
- the name of the management bean from which the
listener should be removed.listener
- the listener to remove.InstanceNotFoundException
- if the bean can not be found.ListenerNotFoundException
- if the specified listener
is not registered with the bean.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, null, name,
"removeNotificationListener")
.#addNotificationListener(NotificationListener, NotificationFilter,
java.lang.Object)
,
NotificationBroadcaster.removeNotificationListener(NotificationListener)
void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object passback) throws InstanceNotFoundException, ListenerNotFoundException
null
is used as a valid value for these parameters,
rather than as a way to remove all registration instances for
the specified listener; for this behaviour instead, see
removeNotificationListener(ObjectName, NotificationListener)
.removeNotificationListener
in interface MBeanServerConnection
name
- the name of the management bean from which the
listener should be removed.listener
- the listener to remove.filter
- the filter of the listener to remove.passback
- the passback object of the listener to remove.InstanceNotFoundException
- if the bean can not be found.ListenerNotFoundException
- if the specified listener
is not registered with the bean.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, null, name,
"removeNotificationListener")
.addNotificationListener(ObjectName, NotificationListener,
NotificationFilter, Object)
,
NotificationEmitter.removeNotificationListener(NotificationListener,
NotificationFilter,
Object)
void removeNotificationListener(ObjectName name, ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException
removeNotificationListener(ObjectName,
ObjectName,NotificationFilter,Object)
removeNotificationListener
in interface MBeanServerConnection
name
- the name of the management bean from which the
listener should be removed.listener
- the name of the listener to remove.InstanceNotFoundException
- if a name doesn't match a registered
bean.ListenerNotFoundException
- if the specified listener
is not registered with the bean.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, null, name,
"removeNotificationListener")
.#addNotificationListener(NotificationListener, NotificationFilter,
java.lang.Object)
,
NotificationBroadcaster.removeNotificationListener(NotificationListener)
void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object passback) throws InstanceNotFoundException, ListenerNotFoundException
null
is used as a valid value for these parameters,
rather than as a way to remove all registration instances for
the specified listener; for this behaviour instead, see
removeNotificationListener(ObjectName, ObjectName)
.removeNotificationListener
in interface MBeanServerConnection
name
- the name of the management bean from which the
listener should be removed.listener
- the name of the listener to remove.filter
- the filter of the listener to remove.passback
- the passback object of the listener to remove.InstanceNotFoundException
- if a name doesn't match a registered
bean.ListenerNotFoundException
- if the specified listener
is not registered with the bean.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, null, name,
"removeNotificationListener")
.addNotificationListener(ObjectName, NotificationListener,
NotificationFilter, Object)
,
NotificationEmitter.removeNotificationListener(NotificationListener,
NotificationFilter,
Object)
void setAttribute(ObjectName name, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
setAttribute
in interface MBeanServerConnection
name
- the name of the management bean.attribute
- the attribute to set.InstanceNotFoundException
- if the bean can not be found.AttributeNotFoundException
- if the attribute does not
correspond to an attribute
of the bean.InvalidAttributeValueException
- if the value is invalid
for this particular
attribute of the bean.MBeanException
- if setting the attribute causes
the bean to throw an exception (which
becomes the cause of this exception).ReflectionException
- if an exception occurred in trying
to use the reflection interface
to lookup the attribute. The
thrown exception is the cause of
this exception.RuntimeOperationsException
- if an IllegalArgumentException
is thrown by the server due to a
null
bean or attribute
name.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, name, bean,
"setAttribute")
.getAttribute(ObjectName, String)
,
DynamicMBean.setAttribute(Attribute)
AttributeList setAttributes(ObjectName name, AttributeList attributes) throws InstanceNotFoundException, ReflectionException
Attribute
object. The returned list contains
the attributes that were set and their new values.setAttributes
in interface MBeanServerConnection
name
- the name of the management bean.attributes
- the attributes to set.InstanceNotFoundException
- if the bean can not be found.ReflectionException
- if an exception occurred in trying
to use the reflection interface
to lookup the attribute. The
thrown exception is the cause of
this exception.RuntimeOperationsException
- if an IllegalArgumentException
is thrown by the server due to a
null
bean or attribute
list.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, null, bean,
"setAttribute")
. Additionally,
for an attribute name, n
, the
caller's permission must imply MBeanPermission(className, n, bean,
"setAttribute")
or that attribute will
not be included.getAttributes(ObjectName, String[])
,
DynamicMBean.setAttributes(AttributeList)
void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException
MBeanRegistration.preDeregister()
method will be called if
the bean implements the MBeanRegistration
interface.unregisterMBean
in interface MBeanServerConnection
name
- the name of the management bean.InstanceNotFoundException
- if the bean can not be found.MBeanRegistrationException
- if an exception occurs in
calling the preDeregister
method.RuntimeOperationsException
- if an IllegalArgumentException
is thrown by the server due to a
null
bean name or a
request being made to unregister the
MBeanServerDelegate
bean.SecurityException
- if a security manager exists and the
caller's permissions don't imply MBeanPermission(className, null, name,
"unregisterMBean")
.