RMI interface for forwarding requests to a remote
MBeanServer. This interface
parallels the
MBeanServerConnection
interface, providing a way of invoking those methods using
the RMI protocol. When a client wishes to call a method
of an MBean server using RMI, the method is called on the stub
on the client side, which serializes the object parameters
and sends them to the server where they are deserialized and
an implementation of this interface forwards them to the
appropriate MBean server. Return values follow the same
process, only in reverse. Each client obtains its own
implementation of this interface from an
RMIServer
instance.
Implementations of this interface do more than simply
forward requests directly to the server. The arguments
of the server methods are wrapped in
MarshalledObject
instances, so that the correct classloader can be used to
deserialize the arguments. When a method is called, the
implementation must first retrieve the appropriate classloader
and then use it to deserialize the marshalled object. Unless
explicitly specified in the documentation for the method,
a parameter of the type
MarshalledObject or an array
of that type should not be
null.
Security is also handled by this interface, as the methods
use an additional
Subject parameter
for role delegation.
addNotificationListener
public void addNotificationListener(ObjectName name,
ObjectName listener,
MarshalledObject<T> filter,
MarshalledObject<T> passback,
Subject delegationSubject)
throws InstanceNotFoundException,
IOException Handles
MBeanServerConnection.addNotificationListener(ObjectName,
ObjectName, NotificationFilter, Object) by
registering 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 filter
and handback object are wrapped in a
MarshalledObject
so that they are deserialised using the bean's classloader.
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 - a wrapper containing a filter to apply to incoming
notifications, or null if no filtering
should be applied.passback - a wrapper containing an object to be passed to the
listener when a notification is emitted.delegationSubject - a Subject instance
containing the delegation principles or
null if authentication is used.
InstanceNotFoundException - if the name of the management bean
could not be resolved.SecurityException - if the client or delegated subject (if any)
does not have permission to invoke this operation.IOException - if an I/O error occurred in communicating with
the bean server.
removeNotificationListener(ObjectName,ObjectName,Subject), removeNotificationListener(ObjectName,ObjectName,MarshalledObject,MarshalledObject,Subject), removeNotificationListeners(ObjectName,Integer[],Subject), NotificationBroadcaster.addNotificationListener(NotificationListener,
NotificationFilter,
Object)
addNotificationListeners
public Integer[] addNotificationListeners(ObjectName[] names,
MarshalledObject<T>[] filters,
Subject[] delegationSubjects)
throws InstanceNotFoundException,
IOExceptionnames - the names of the management bean whose notifications
should be recorded.filters - an array of wrappers containing filters to apply to
incoming notifications. An element may be null
if no filtering should be applied to a bean's notifications.delegationSubjects - an array of Subject
instances containing the delegation principles for
each listener. An element may be null if
authentication is used instead, or the entire
argument itself may be null. In the latter
case, this is treated as an array of null
values.
IllegalArgumentException - if the names or filters array
is null, the names array contains
a null value or the three arrays are not
of the same size.ClassCastException - if an element of the filters array unmarshalls
as a non-null object that is not a NotificationFilter.InstanceNotFoundException - if the name of one of the management beans
could not be resolved.SecurityException - if, for one of the beans, the client or delegated subject
(if any) does not have permission to invoke this operation.IOException - if an I/O error occurred in communicating with
the bean server.
removeNotificationListener(ObjectName,ObjectName,Subject), removeNotificationListener(ObjectName,ObjectName,MarshalledObject,MarshalledObject,Subject), removeNotificationListeners(ObjectName,Integer[],Subject), NotificationBroadcaster.addNotificationListener(NotificationListener,
NotificationFilter,
Object)
close
public void close()
throws IOException Closes the connection and unexports the RMI object implementing this
interface. Following this call, future method calls to this instance
will fail.
- close in interface Closeable
IOException - if there is an I/O error in transmitting the close
request via RMI, closing the connection, or unexporting
the RMI object.
createMBean
public ObjectInstance createMBean(String className,
ObjectName name,
MarshalledObject<T> params,
String[] sig,
Subject delegationSubject)
throws ReflectionException,
InstanceAlreadyExistsException,
MBeanRegistrationException,
MBeanException,
NotCompliantMBeanException,
IOException
Handles
MBeanServerConnection.createMBean(String, ObjectName,
Object[], String[]). The array of parameters is wrapped in
a
MarshalledObject so that it is deserialised using the
bean's classloader.
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.
className - the class of the management bean, of which
an instance should be created.name - the name to register the new bean with. This may
be null.params - the parameters for the bean's constructor, encapsulated
in a MarshalledObject. If this parameter is
null, it will be judged equivalent to an
empty array.sig - the signature of the constructor to use. If this parameter
is null, it will be judged equivalent to an
empty array.delegationSubject - an instance of Subject
containing the delegation principles. This may be
null is authentication is used instead.
createMBean
public ObjectInstance createMBean(String className,
ObjectName name,
ObjectName loaderName,
MarshalledObject<T> params,
String[] sig,
Subject delegationSubject)
throws ReflectionException,
InstanceAlreadyExistsException,
MBeanRegistrationException,
MBeanException,
NotCompliantMBeanException,
InstanceNotFoundException,
IOException
Handles
MBeanServerConnection.createMBean(String, ObjectName,
ObjectName, Object[], String[]). The array of parameters is
wrapped in a
MarshalledObject so that it is deserialised
using the bean's classloader.
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.
className - the class of the management bean, of which
an instance should be created.name - the name to register the new bean with. This may
be null.loaderName - the name of the class loader.params - the parameters for the bean's constructor, encapsulated
in a MarshalledObject. If this parameter is
null, it will be judged equivalent to an
empty array.sig - the signature of the constructor to use. If this parameter
is null, it will be judged equivalent to an
empty array.delegationSubject - an instance of Subject
containing the delegation principles. This may be
null is authentication is used instead.
createMBean
public ObjectInstance createMBean(String className,
ObjectName name,
ObjectName loaderName,
Subject delegationSubject)
throws ReflectionException,
InstanceAlreadyExistsException,
MBeanRegistrationException,
MBeanException,
NotCompliantMBeanException,
InstanceNotFoundException,
IOException
Handles
MBeanServerConnection.createMBean(String, ObjectName,
ObjectName) by instantiating a new instance of the specified
management bean using the default constructor and registering
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
createMBean(className, name, loaderName, (Object[]) null,
(String) null) with
null parameters
and signature.
className - the class of the management bean, of which
an instance should be created.name - the name to register the new bean with. This may
be null.loaderName - the name of the class loader.delegationSubject - an instance of Subject
containing the delegation principles. This may be
null is authentication is used instead.
createMBean
public ObjectInstance createMBean(String className,
ObjectName name,
Subject delegationSubject)
throws ReflectionException,
InstanceAlreadyExistsException,
MBeanRegistrationException,
MBeanException,
NotCompliantMBeanException,
IOException
Handles
MBeanServerConnection.createMBean(String, ObjectName) by
instantiating a new instance of the specified management bean
using the default constructor and registering 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
createMBean(className, name, (Object[]) null,
(String[]) null) with
null parameters
and signature.
className - the class of the management bean, of which
an instance should be created.name - the name to register the new bean with. This may
be null.delegationSubject - an instance of Subject
containing the delegation principles. This may be
null is authentication is used instead.
fetchNotifications
public NotificationResult fetchNotifications(long sequenceNumber,
int maxNotifications,
long timeout)
throws IOException
Retrieves any waiting notifications from the server. When notifications
are requested using the
addNotificationListeners(ObjectName[],MarshalledObject[],Subject[]) method, the server sets up an internal
listener to receive notifications from the bean and buffer them. When
this method is called, these buffered notifications can be retrieved.
The blocking behaviour of this method depends on the timeout value specified.
If there are no waiting notifications in the buffer, a value of 0 will cause
the method to return immediately. Conversely, if the value is
Long.MAX_VALUE, then it will wait indefinitely until a notification
arrives. For any other value, it waits until a notification arrives or the
number of milliseconds specified by the timeout value is exceeded. The
behaviour for a negative timeout value is undefined.
For a notification to be returned, the following criteria must be fulfilled:
- the client must have previously requested notifications from at least
one bean
- a bean from which notifications have been requested must have emitted
a notification since the last call to this method
- the emitted notification must pass through any filters established
when notifications were requested
- the sequence number of the notification must be greater than or equal
to the specified sequence number (if non-negative)
sequenceNumber - the sequence number of each notification returned
must be greater than or equal to this value. If
the number is negative, this is interpreted as
meaning the sequence number of the next notification
and so all notifications are allowed through.maxNotifications - the maximum number of notifications to return.
This does not include any duplicates so the
number of actual notifications returned may
be larger.timeout - the number of milliseconds to wait for a notification
if the buffer is empty. 0 causes the
method to return immediately even if there are no
notifications available (non-blocking behaviour) while
a value of Long.MAX_VALUE causes it to wait
indefinitely (blocking behaviour). The response to
a negative value is undefined.
getAttributes
public AttributeList getAttributes(ObjectName bean,
String[] names,
Subject delegationSubject)
throws InstanceNotFoundException,
ReflectionException,
IOException Handles MBeanServerConnection.getAttribute(ObjectName, String),
returning the values of the named attributes from the specified
management bean.
bean - the bean to retrieve the value from.names - the names of the attributes to retrieve.delegationSubject - an instance of Subject
containing the delegation principles. This may be
null is authentication is used instead.
- the values of the attributes.
DynamicMBean.getAttributes(String[])
getDefaultDomain
public String getDefaultDomain(Subject delegationSubject)
throws IOException Handles MBeanServerConnection.getDefaultDomain() by returning the default
domain this server applies to beans that have no specified domain.
delegationSubject - an instance of Subject
containing the delegation principles. This may be
null is authentication is used instead.
SecurityException - if the client or delegated subject (if any) does
not have permission to invoke this operation.IOException - if an I/O error occurred in communicating with
the bean server.
getDomains
public String[] getDomains(Subject delegationSubject)
throws IOException Handles MBeanServerConnection.getDomains() by returning an array
containing all the domains used by beans registered with
this server. The ordering of the array is undefined.
delegationSubject - an instance of Subject
containing the delegation principles. This may be
null is authentication is used instead.
SecurityException - if the client or delegated subject (if any) does
not have permission to invoke this operation.IOException - if an I/O error occurred in communicating with
the bean server.
getMBeanCount
public Integer getMBeanCount(Subject delegationSubject)
throws IOException Handles MBeanServerConnection.getMBeanCount() by returning the number of
management beans registered with this server.
delegationSubject - an instance of Subject
containing the delegation principles. This may be
null is authentication is used instead.
- the number of registered beans.
SecurityException - if the client or delegated subject (if any) does
not have permission to invoke this operation.IOException - if an I/O error occurred in communicating with
the bean server.
invoke
public Object invoke(ObjectName bean,
String name,
MarshalledObject<T> params,
String[] sig,
Subject delegationSubject)
throws InstanceNotFoundException,
MBeanException,
ReflectionException,
IOException
Handles
MBeanServerConnection.invoke(ObjectName, String, Object[],
String[]). The array of parameters is wrapped in a
MarshalledObject so that it is deserialised
using the bean's classloader.
Invokes the supplied operation on the specified management
bean. The class objects specified in the signature are loaded
using the same class loader as was used for the management bean.
bean - the management bean whose operation should be invoked.name - the name of the operation to invoke.params - the parameters for the bean's constructor, encapsulated
in a MarshalledObject. If this parameter is
null, it will be judged equivalent to an
empty array.sig - the signature of the constructor to use. If this parameter
is null, it will be judged equivalent to an
empty array. The class objects will be loaded using the
bean's classloader.delegationSubject - an instance of Subject
containing the delegation principles. This may be
null is authentication is used instead.
- the return value of the method.
DynamicMBean.invoke(String, Object[], String[])
isInstanceOf
public boolean isInstanceOf(ObjectName name,
String className,
Subject delegationSubject)
throws InstanceNotFoundException,
IOException
Handles
by
returning 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:
- The class name in B's {@link MBeanInfo
is equal to the supplied
name.
Both the class of B and C were loaded by the same class loader,
and B is assignable to C.
name - the name of the management bean.className - the name of the class to test if name is
an instance of.delegationSubject - an instance of Subject
containing the delegation principles. This may be
null is authentication is used instead.
- true if either B is directly an instance of the named class,
or B is assignable to the class, given that both it and B's
current class were loaded using the same class loader.
isRegistered
public boolean isRegistered(ObjectName name,
Subject delegationSubject)
throws IOException Handles by returning
true if the specified management bean is registered with
the server.
@param name the name of the management bean.
@param delegationSubject an instance of {@link javax.security.auth.Subject
containing the delegation principles. This may be
null is authentication is used instead.
- true if the bean is registered.
SecurityException - if the client or delegated subject (if any) does
not have permission to invoke this operation.IOException - if an I/O error occurred in communicating with
the bean server.
queryMBeans
public Set queryMBeans(ObjectName name,
MarshalledObject<T> query,
Subject delegationSubject)
throws IOException
Handles
MBeanServerConnection.queryMBeans(ObjectName, QueryExp).
The query expression is wrapped in a
MarshalledObject
so that it is deserialised using the bean's classloader.
Returns a set of
ObjectInstances matching the specified
criteria. The full set of beans registered with the server
are passed through two filters:
- Pattern matching is performed using the supplied
ObjectName. - The supplied query expression is applied.
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.
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, encapsulated in a
MarshalledObject. If a null value is
encapsulated, then the beans will only be filtered using
pattern matching on the supplied ObjectName.delegationSubject - an instance of Subject
containing the delegation principles. This may be
null is authentication is used instead.
- a set of
ObjectInstances matching the filtered beans.
This is empty if no beans survived the filters.
IOException - if an I/O error occurred in communicating with
the bean server.SecurityException - if the client or delegated subject (if any) does
not have permission to invoke this operation.
queryNames
public Set queryNames(ObjectName name,
MarshalledObject<T> query,
Subject delegationSubject)
throws IOException
Handles
MBeanServerConnection.queryNames(ObjectName, QueryExp).
The query expression is wrapped in a
MarshalledObject
so that it is deserialised using the bean's classloader.
Returns a set of
ObjectNames matching the specified
criteria. The full set of beans registered with the server
are passed through two filters:
- Pattern matching is performed using the supplied
ObjectName. - The supplied query expression is applied.
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.
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, encapsulated in a
MarshalledObject. If a null value is
encapsulated, then the beans will only be filtered using
pattern matching on the supplied ObjectName.delegationSubject - an instance of Subject
containing the delegation principles. This may be
null is authentication is used instead.
SecurityException - if the client or delegated subject (if any) does
not have permission to invoke this operation.IOException - if an I/O error occurred in communicating with
the bean server.
removeNotificationListener
public void removeNotificationListener(ObjectName name,
ObjectName listener,
MarshalledObject<T> filter,
MarshalledObject<T> passback,
Subject delegationSubject)
throws InstanceNotFoundException,
ListenerNotFoundException,
IOException
Handles
MBeanServerConnection.removeNotificationListener(ObjectName,
ObjectName, NotificationFilter, Object). Both the filter and
the handback object are wrapped in a
MarshalledObject
so that they are deserialised using the bean's classloader.
Removes the specified listener from the list of recipients
of notifications from the supplied bean. Only the first instance with
the supplied filter and passback object is removed.
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).
name - the name of the management bean from which the
listener should be removed.listener - the listener to remove.filter - a wrapper containing the filter of the listener
to remove.passback - a wrapper containing the handback object of the
listener to remove.delegationSubject - a Subject instance
containing the delegation principles or
null if authentication is used.
addNotificationListener(ObjectName, NotificationListener,
MarshalledObject, MarshalledObject, Subject), NotificationEmitter.removeNotificationListener(NotificationListener,
NotificationFilter,
Object)
removeNotificationListener
public void removeNotificationListener(ObjectName name,
ObjectName listener,
Subject delegationSubject)
throws InstanceNotFoundException,
ListenerNotFoundException,
IOExceptionname - the name of the management bean from which the
listener should be removed.listener - the name of the listener to remove.delegationSubject - a Subject instance
containing the delegation principles or
null if authentication is used.
addNotificationListener(ObjectName, NotificationListener,
MarshalledObject, MarshalledObject, Subject), NotificationBroadcaster.removeNotificationListener(NotificationListener)