public class

RMIConnectionImpl

extends Object
implements Unreferenced RMIConnection
java.lang.Object
   ↳ javax.management.remote.rmi.RMIConnectionImpl

Class Overview

Implementation of the RMIConnection interface. User code will not usually reference this class.

Summary

Public Constructors
RMIConnectionImpl(RMIServerImpl rmiServer, String connectionId, ClassLoader defaultClassLoader, Subject subject, Map<String, ?> env)
Constructs a new RMIConnection.
Public Methods
void addNotificationListener(ObjectName name, ObjectName listener, MarshalledObject filter, MarshalledObject handback, Subject delegationSubject)
Integer[] addNotificationListeners(ObjectName[] names, MarshalledObject[] filters, Subject[] delegationSubjects)
void close()

Closes this connection.

ObjectInstance createMBean(String className, ObjectName name, Subject delegationSubject)
ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, MarshalledObject params, String[] signature, Subject delegationSubject)
ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Subject delegationSubject)
ObjectInstance createMBean(String className, ObjectName name, MarshalledObject params, String[] signature, Subject delegationSubject)
NotificationResult fetchNotifications(long clientSequenceNumber, int maxNotifications, long timeout)

Retrieves notifications from the connector server.

Object getAttribute(ObjectName name, String attribute, Subject delegationSubject)
AttributeList getAttributes(ObjectName name, String[] attributes, Subject delegationSubject)
String getConnectionId()

Returns the connection ID.

String getDefaultDomain(Subject delegationSubject)
Handles the method getDefaultDomain().
String[] getDomains(Subject delegationSubject)
Handles the method getDomains().
Integer getMBeanCount(Subject delegationSubject)
Handles the method getMBeanCount().
MBeanInfo getMBeanInfo(ObjectName name, Subject delegationSubject)
Handles the method getMBeanInfo(ObjectName).
ObjectInstance getObjectInstance(ObjectName name, Subject delegationSubject)
Handles the method getObjectInstance(ObjectName).
Object invoke(ObjectName name, String operationName, MarshalledObject params, String[] signature, Subject delegationSubject)
boolean isInstanceOf(ObjectName name, String className, Subject delegationSubject)
boolean isRegistered(ObjectName name, Subject delegationSubject)
Handles the method isRegistered(ObjectName).
Set<ObjectInstance> queryMBeans(ObjectName name, MarshalledObject query, Subject delegationSubject)
Set<ObjectName> queryNames(ObjectName name, MarshalledObject query, Subject delegationSubject)
void removeNotificationListener(ObjectName name, ObjectName listener, MarshalledObject filter, MarshalledObject handback, Subject delegationSubject)
void removeNotificationListener(ObjectName name, ObjectName listener, Subject delegationSubject)
void removeNotificationListeners(ObjectName name, Integer[] listenerIDs, Subject delegationSubject)
void setAttribute(ObjectName name, MarshalledObject attribute, Subject delegationSubject)
AttributeList setAttributes(ObjectName name, MarshalledObject attributes, Subject delegationSubject)
String toString()

Returns a string representation of this object.

void unreferenced()
Called by the RMI runtime sometime after the runtime determines that the reference list, the list of clients referencing the remote object, becomes empty.
void unregisterMBean(ObjectName name, Subject delegationSubject)
Handles the method unregisterMBean(ObjectName).
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.io.Closeable
From interface java.rmi.server.Unreferenced
From interface javax.management.remote.rmi.RMIConnection

Public Constructors

public RMIConnectionImpl (RMIServerImpl rmiServer, String connectionId, ClassLoader defaultClassLoader, Subject subject, Map<String, ?> env)

Constructs a new RMIConnection. This connection can be used with either the JRMP or IIOP transport. This object does not export itself: it is the responsibility of the caller to export it appropriately (see makeClient(String, Subject) and makeClient(String, Subject).

Parameters
rmiServer The RMIServerImpl object for which this connection is created. The behavior is unspecified if this parameter is null.
connectionId The ID for this connection. The behavior is unspecified if this parameter is null.
defaultClassLoader The default ClassLoader to be used when deserializing marshalled objects. Can be null, to signify the bootstrap class loader.
subject the authenticated subject to be used for authorization. Can be null, to signify that no subject has been authenticated.
env the environment containing attributes for the new RMIServerImpl. Can be null, equivalent to an empty map.

Public Methods

public void addNotificationListener (ObjectName name, ObjectName listener, MarshalledObject filter, MarshalledObject handback, Subject delegationSubject)

Handles the method addNotificationListener(ObjectName, ObjectName, NotificationFilter, Object). The NotificationFilter parameter is wrapped in a MarshalledObject. The Object (handback) parameter is also wrapped in a MarshalledObject.

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, encapsulated into a MarshalledObject. If filter encapsulated in the MarshalledObject has a null value, no filtering will be performed before handling notifications.
handback The context to be sent to the listener when a notification is emitted, encapsulated into a MarshalledObject.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.

public Integer[] addNotificationListeners (ObjectName[] names, MarshalledObject[] filters, Subject[] delegationSubjects)

Handles the method addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object).

Register for notifications from the given MBeans that match the given filters. The remote client can subsequently retrieve the notifications using the fetchNotifications method.

For each listener, the original NotificationListener and handback are kept on the client side; in order for the client to be able to identify them, the server generates and returns a unique listenerID. This listenerID is forwarded with the Notifications to the remote client.

If any one of the given (name, filter) pairs cannot be registered, then the operation fails with an exception, and no names or filters are registered.

Parameters
names the ObjectNames identifying the MBeans emitting the Notifications.
filters an array of marshalled representations of the NotificationFilters. Elements of this array can be null.
delegationSubjects the Subjects on behalf of which the listeners are being added. Elements of this array can be null. Also, the delegationSubjects parameter itself can be null, which is equivalent to an array of null values with the same size as the names and filters arrays.
Returns
  • an array of listenerIDs identifying the local listeners. This array has the same number of elements as the parameters.

public void close ()

Closes this connection. On return from this method, the RMI object implementing this interface is unexported, so further remote calls to it will fail.

Throws
IOException

public ObjectInstance createMBean (String className, ObjectName name, Subject delegationSubject)

Parameters
className The class name of the MBean to be instantiated.
name The object name of the MBean. May be null.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.
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().

public ObjectInstance createMBean (String className, ObjectName name, ObjectName loaderName, MarshalledObject params, String[] signature, Subject delegationSubject)

Handles the method createMBean(String, ObjectName, ObjectName, Object[], String[]). The Object[] parameter is wrapped in a MarshalledObject.

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, encapsulated into a MarshalledObject. The encapsulated array can be null, equivalent to an empty array.
signature An array containing the signature of the constructor to be invoked. Can be null, equivalent to an empty array.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.
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().

public ObjectInstance createMBean (String className, ObjectName name, ObjectName loaderName, Subject delegationSubject)

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.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.
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().

public ObjectInstance createMBean (String className, ObjectName name, MarshalledObject params, String[] signature, Subject delegationSubject)

Handles the method createMBean(String, ObjectName, Object[], String[]). The Object[] parameter is wrapped in a MarshalledObject.

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, encapsulated into a MarshalledObject. The encapsulated array can be null, equivalent to an empty array.
signature An array containing the signature of the constructor to be invoked. Can be null, equivalent to an empty array.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.
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().

public NotificationResult fetchNotifications (long clientSequenceNumber, int maxNotifications, long timeout)

Retrieves notifications from the connector server. This method can block until there is at least one notification or until the specified timeout is reached. The method can also return at any time with zero notifications.

A notification can be included in the result if its sequence number is no less than clientSequenceNumber and this client has registered at least one listener for the MBean generating the notification, with a filter that accepts the notification. Each listener that is interested in the notification is identified by an Integer ID that was returned by addNotificationListeners(ObjectName[], MarshalledObject[], Subject[]).

Parameters
clientSequenceNumber the first sequence number that the client is interested in. If negative, it is interpreted as meaning the sequence number that the next notification will have.
maxNotifications the maximum number of different notifications to return. The TargetedNotification array in the returned NotificationResult can have more elements than this if the same notification appears more than once. The behavior is unspecified if this parameter is negative.
timeout the maximum time in milliseconds to wait for a notification to arrive. This can be 0 to indicate that the method should not wait if there are no notifications, but should return at once. It can be Long.MAX_VALUE to indicate that there is no timeout. The behavior is unspecified if this parameter is negative.
Returns
  • A NotificationResult.
Throws
IOException

public Object getAttribute (ObjectName name, String attribute, Subject delegationSubject)

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.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.
Returns
  • The value of the retrieved attribute.

public AttributeList getAttributes (ObjectName name, String[] attributes, Subject delegationSubject)

Parameters
name The object name of the MBean from which the attributes are retrieved.
attributes A list of the attributes to be retrieved.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.
Returns
  • The list of the retrieved attributes.

public String getConnectionId ()

Returns the connection ID. This string is different for every open connection to a given RMI connector server.

Returns
  • the connection ID
Throws
IOException

public String getDefaultDomain (Subject delegationSubject)

Handles the method getDefaultDomain().

Parameters
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.
Returns
  • the default domain.
Throws
IOException

public String[] getDomains (Subject delegationSubject)

Handles the method getDomains().

Parameters
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.
Returns
  • the list of domains.
Throws
IOException

public Integer getMBeanCount (Subject delegationSubject)

Handles the method getMBeanCount().

Parameters
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.
Returns
  • the number of MBeans registered.
Throws
IOException

public MBeanInfo getMBeanInfo (ObjectName name, Subject delegationSubject)

Handles the method getMBeanInfo(ObjectName).

Parameters
name The name of the MBean to analyze
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.
Returns
  • An instance of MBeanInfo allowing the retrieval of all attributes and operations of this MBean.

public ObjectInstance getObjectInstance (ObjectName name, Subject delegationSubject)

Handles the method getObjectInstance(ObjectName).

Parameters
name The object name of the MBean.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.
Returns
  • The ObjectInstance associated with the MBean specified by name. The contained ObjectName is name and the contained class name is getMBeanInfo(name).getClassName().

public Object invoke (ObjectName name, String operationName, MarshalledObject params, String[] signature, Subject delegationSubject)

Handles the method invoke(ObjectName, String, Object[], String[]). The Object[] parameter is wrapped in a MarshalledObject.

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, encapsulated into a MarshalledObject. The encapsulated array can be null, equivalent to an empty array.
signature An array containing the signature of the operation. 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. Can be null, equivalent to an empty array.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.
Returns
  • The object returned by the operation, which represents the result of invoking the operation on the MBean specified.

public boolean isInstanceOf (ObjectName name, String className, Subject delegationSubject)

Parameters
name The ObjectName of the MBean.
className The name of the class.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.
Returns
  • true if the MBean specified is an instance of the specified class according to the rules above, false otherwise.

public boolean isRegistered (ObjectName name, Subject delegationSubject)

Handles the method isRegistered(ObjectName).

Parameters
name The object name of the MBean to be checked.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.
Returns
  • True if the MBean is already registered in the MBean server, false otherwise.
Throws
IOException

public Set<ObjectInstance> queryMBeans (ObjectName name, MarshalledObject query, Subject delegationSubject)

Handles the method queryMBeans(ObjectName, QueryExp). The QueryExp is wrapped in a MarshalledObject.

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, encapsulated into a MarshalledObject. If the MarshalledObject encapsulates a null value no query expression will be applied for selecting MBeans.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.
Returns
  • A set containing the ObjectInstance objects for the selected MBeans. If no MBean satisfies the query an empty list is returned.
Throws
IOException

public Set<ObjectName> queryNames (ObjectName name, MarshalledObject query, Subject delegationSubject)

Handles the method queryNames(ObjectName, QueryExp). The QueryExp is wrapped in a MarshalledObject.

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, encapsulated into a MarshalledObject. If the MarshalledObject encapsulates a null value no query expression will be applied for selecting MBeans.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.
Returns
  • A set containing the ObjectNames for the MBeans selected. If no MBean satisfies the query, an empty list is returned.
Throws
IOException

public void removeNotificationListener (ObjectName name, ObjectName listener, MarshalledObject filter, MarshalledObject handback, Subject delegationSubject)

Handles the method removeNotificationListener(ObjectName, ObjectName, NotificationFilter, Object). The NotificationFilter parameter is wrapped in a MarshalledObject. The Object parameter is also wrapped in a MarshalledObject.

Parameters
name The name of the MBean on which the listener should be removed.
listener A listener that was previously added to this MBean.
filter The filter that was specified when the listener was added, encapsulated into a MarshalledObject.
handback The handback that was specified when the listener was added, encapsulated into a MarshalledObject.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.

public void removeNotificationListener (ObjectName name, ObjectName listener, Subject delegationSubject)

Parameters
name The name of the MBean on which the listener should be removed.
listener The object name of the listener to be removed.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.

public void removeNotificationListeners (ObjectName name, Integer[] listenerIDs, Subject delegationSubject)

Handles the removeNotificationListener(ObjectName, NotificationListener) and removeNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object) methods.

This method removes one or more NotificationListeners from a given MBean in the MBean server.

The NotificationListeners are identified by the IDs which were returned by the addNotificationListeners(ObjectName[], MarshalledObject[], Subject[]) method.

Parameters
name the ObjectName identifying the MBean emitting the Notifications.
listenerIDs the list of the IDs corresponding to the listeners to remove.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.

public void setAttribute (ObjectName name, MarshalledObject attribute, Subject delegationSubject)

Handles the method setAttribute(ObjectName, Attribute). The Attribute parameter is wrapped in a MarshalledObject.

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, encapsulated into a MarshalledObject.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.

public AttributeList setAttributes (ObjectName name, MarshalledObject attributes, Subject delegationSubject)

Handles the method setAttributes(ObjectName, AttributeList). The AttributeList parameter is wrapped in a MarshalledObject.

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, encapsulated into a MarshalledObject.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.
Returns
  • The list of attributes that were set, with their new values.

public String toString ()

Returns a string representation of this object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read.

Returns
  • a String representation of this object.

public void unreferenced ()

Called by the RMI runtime sometime after the runtime determines that the reference list, the list of clients referencing the remote object, becomes empty.

public void unregisterMBean (ObjectName name, Subject delegationSubject)

Handles the method unregisterMBean(ObjectName).

Parameters
name The object name of the MBean to be unregistered.
delegationSubject The Subject containing the delegation principals or null if the authentication principal is used instead.