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.
@SuppressWarnings
public @SuppressWarnings("rawtypes" )
throws name,
listener,
filter,
passback,
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.
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,
java.rmi.MarshalledObject,
java.rmi.MarshalledObject,
javax.security.auth.Subject)
, removeNotificationListeners(ObjectName,Integer[],Subject)
, NotificationBroadcaster.addNotificationListener(NotificationListener,
NotificationFilter,
Object)
@SuppressWarnings
public [][][][] @SuppressWarnings("rawtypes" )
throws names,
filters,
InstanceNotFoundException,
IOException
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,
java.rmi.MarshalledObject,
java.rmi.MarshalledObject,
javax.security.auth.Subject)
, removeNotificationListeners(ObjectName,Integer[],Subject)
, NotificationBroadcaster.addNotificationListener(NotificationListener,
NotificationFilter,
Object)
@SuppressWarnings
public [] @SuppressWarnings("rawtypes" )
throws className,
name,
params,
sig,
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.
@SuppressWarnings
public [] @SuppressWarnings("rawtypes" )
throws className,
name,
loaderName,
params,
sig,
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.
@SuppressWarnings
public [] @SuppressWarnings("rawtypes" )
throws bean,
name,
params,
sig,
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.
- the return value of the method.
DynamicMBean.invoke(String, Object[], String[])
@SuppressWarnings
public @SuppressWarnings("rawtypes" )
throws name,
query,
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
ObjectInstance
s 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.
- a set of
ObjectInstance
s 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.
@SuppressWarnings
public @SuppressWarnings("rawtypes" )
throws name,
query,
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
ObjectName
s 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.
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.
@SuppressWarnings
public @SuppressWarnings("rawtypes" )
throws name,
listener,
filter,
passback,
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)
.
addNotificationListener(ObjectName, NotificationListener,
MarshalledObject, MarshalledObject, Subject)
, NotificationEmitter.removeNotificationListener(NotificationListener,
NotificationFilter,
Object)
@SuppressWarnings
public @SuppressWarnings("rawtypes" )
throws name,
attributes,
InstanceNotFoundException,
ReflectionException,
IOException
Handles
MBeanServerConnection.setAttributes(ObjectName, AttributeList)
by setting the value of each of the specified attributes
of the supplied management bean to that specified by
the
Attribute
object. The returned list contains
the attributes that were set and their new values.
The attribute list is wrapped in a
MarshalledObject
so
that it is deserialised using the bean's classloader.
- a list of the changed attributes.
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.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.
getAttributes(ObjectName, String[])
, DynamicMBean.setAttributes(AttributeList)
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
- close in interface AutoCloseable
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,
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(String, ObjectName, ObjectName, MarshalledObject,
String[], Subject)
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.
createMBean(String, ObjectName, MarshalledObject, String[], Subject)
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.
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.
removeNotificationListener
public void removeNotificationListener(ObjectName name,
ObjectName listener,
Subject delegationSubject)
throws InstanceNotFoundException,
ListenerNotFoundException,
IOException
Handles MBeanServerConnection.removeNotificationListener(ObjectName,
ObjectName)
by removing the specified listener from the list
of recipients of notifications from the supplied bean. This
includes all combinations of filters and passback objects
registered for this listener. For more specific removal of
listeners, see removeNotificationListener(ObjectName,
ObjectName,MarshalledObject,MarshalledObject,Subject)
name
- 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)
removeNotificationListeners
public void removeNotificationListeners(ObjectName name,
Integer[] listenerIds,
Subject delegationSubject)
throws InstanceNotFoundException,
ListenerNotFoundException,
IOException
Removes one or more NotificationListener
s from the specified
management bean. This method corresponds to
addNotificationListeners(ObjectName[], MarshalledObject[],
Subject)
and provides a different way of handling
MBeanServerConnection#removeNotificationListener(ObjectName,
ObjectName)} and
MBeanServerConnection.removeNotificationListener(ObjectName,
ObjectName, NotificationFilter, Object)
by using the integer
identifiers provided by the
addNotificationListeners(ObjectName[], MarshalledObject[],
Subject)
method to select the listeners to remove.
name
- the name of the management bean from which the
listeners should be removed.listenerIds
- the identifiers of the listeners to remove.delegationSubject
- a Subject
instance
containing the delegation principles or
null
if authentication is used.
addNotificationListeners(ObjectName[], MarshalledObject[], Subject)
unregisterMBean
public void unregisterMBean(ObjectName name,
Subject delegationSubject)
throws InstanceNotFoundException,
MBeanRegistrationException,
IOException
Handles MBeanServerConnection.unregisterMBean(ObjectName)
by unregistering
the specified management bean. Following this operation,
the bean instance is no longer accessible from the server via this
name. Prior to unregistering the bean, the
MBeanRegistration.preDeregister()
method will be called if
the bean implements the MBeanRegistration
interface.
name
- the name of the management bean.delegationSubject
- a Subject
instance
containing the delegation principles or
null
if authentication is used.
RMIConnection.java -- RMI object representing a MBean server connection.
Copyright (C) 2007, 2008 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.