Top Description Fields Constructors Methods
javax.management.remote.rmi

public abstract Class RMIServerImpl

extends Object
implements Closeable, RMIServer
Class Inheritance
All Implemented Interfaces
javax.management.remote.rmi.RMIServer, java.rmi.Remote, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
javax.management.remote.rmi.RMIJRMPServerImpl
Imports
com.sun.jmx.remote.internal.ArrayNotificationBuffer, .NotificationBuffer, com.sun.jmx.remote.security.JMXPluggableAuthenticator, com.sun.jmx.remote.util.ClassLogger, java.io.Closeable, .IOException, java.lang.ref.WeakReference, java.rmi.Remote, java.rmi.server.RemoteServer, .ServerNotActiveException, java.security.Principal, java.util.ArrayList, .Collections, .Iterator, .List, .Map, .Set, javax.management.MBeanServer, javax.management.remote.JMXAuthenticator, .JMXConnectorServer, javax.security.auth.Subject

An RMI object representing a connector server. Remote clients can make connections using the newClient(Object) method. This method returns an RMI object representing the connection.

User code does not usually reference this class directly. RMI connection servers are usually created with the class RMIConnectorServer. Remote clients usually create connections either with javax.management.remote.JMXConnectorFactory or by instantiating RMIConnector.

This is an abstract class. Concrete subclasses define the details of the client connection objects.

Since
1.5

Field Summary

Modifier and TypeField and Description
private ClassLoader
private final List<WeakReference<RMIConnection>>
clientList

List of WeakReference values.

private static int
private RMIConnectorServer
private final Map<String, ?>
private static final ClassLogger
private MBeanServer
private NotificationBuffer

Constructor Summary

AccessConstructor and Description
public
RMIServerImpl(Map<String, ?>
the environment containing attributes for the new RMIServerImpl. Can be null, which is equivalent to an empty Map.
env
)

Constructs a new RMIServerImpl.

Method Summary

Modifier and TypeMethod and Description
protected void
clientClosed(RMIConnection
the client connection that has been closed.
client
)

Method called when a client connection created by makeClient is closed.

public synchronized void
close()

Implements java.io.Closeable.close.

Closes this connection server.

protected abstract void
closeClient(RMIConnection
a connection previously returned by makeClient on which the closeClient method has not previously been called. The behavior is unspecified if these conditions are violated, including the case where client is null.
client
)

Closes a client connection made by makeClient.

protected abstract void
closeServer()

Called by close() to close the connector server.

pack-priv RMIConnection
doNewClient(Object credentials)

This method could be overridden by subclasses defined in this package to perform additional operations specific to the underlying transport before creating the new client connection.

private void
protected abstract void
export()

Exports this RMI object.

public synchronized ClassLoader

Returns:

the default ClassLoader used by this connector server.
getDefaultClassLoader
()

Gets the default ClassLoader used by this connector server.

public synchronized MBeanServer

Returns:

the MBeanServer to which this connector is attached.
getMBeanServer
()

The MBeanServer to which this connector server is attached.

pack-priv synchronized NotificationBuffer
protected abstract String

Returns:

the protocol string for this object.
getProtocol
()

Returns the protocol string for this object.

public String
getVersion()

Implements javax.management.remote.rmi.RMIServer.getVersion.

The version of the RMI Connector Protocol understood by this connector server.

protected abstract RMIConnection

Returns:

the newly-created RMIConnection.
makeClient
(String
the ID of the new connection. Every connection opened by this connector server will have a different ID. The behavior is unspecified if this parameter is null.
connectionId
,
Subject
the authenticated subject. Can be null.
subject
)

Creates a new client connection.

private static synchronized String
makeConnectionId(String protocol, Subject subject)

public RMIConnection

Returns:

the newly-created RMIConnection. This is usually the object created by makeClient, though an implementation may choose to wrap that object in another object implementing RMIConnection.
newClient
(Object
this object specifies the user-defined credentials to be passed in to the server in order to authenticate the caller before creating the RMIConnection. Can be null.
credentials
)

Implements javax.management.remote.rmi.RMIServer.newClient.

Creates a new client connection.

public synchronized void
setDefaultClassLoader(ClassLoader
the new ClassLoader to be used by this connector server.
cl
)

Sets the default ClassLoader for this connector server.

public synchronized void
setMBeanServer(MBeanServer
the new MBeanServer. Can be null, but new client connections will be refused as long as it is.
mbs
)

Sets the MBeanServer to which this connector server is attached.

pack-priv void
public abstract Remote

Returns:

a remotable stub.
toStub
()

Returns a remotable stub for this server object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clback to summary
private ClassLoader cl
clientListback to summary
private final List<WeakReference<RMIConnection>> clientList

List of WeakReference values. Each one references an RMIConnection created by this object, or null if the RMIConnection has been garbage-collected.

connectionIdNumberback to summary
private static int connectionIdNumber
connServerback to summary
private RMIConnectorServer connServer
envback to summary
private final Map<String, ?> env
loggerback to summary
private static final ClassLogger logger
mbeanServerback to summary
private MBeanServer mbeanServer
notifBufferback to summary
private NotificationBuffer notifBuffer

Constructor Detail

RMIServerImplback to summary
public RMIServerImpl(Map<String, ?> env)

Constructs a new RMIServerImpl.

Parameters
env:Map<String, ?>

the environment containing attributes for the new RMIServerImpl. Can be null, which is equivalent to an empty Map.

Method Detail

clientClosedback to summary
protected void clientClosed(RMIConnection client) throws IOException

Method called when a client connection created by makeClient is closed. A subclass that defines makeClient must arrange for this method to be called when the resultant object's close method is called. This enables it to be removed from the RMIServerImpl's list of connections. It is not an error for client not to be in that list.

After removing client from the list of connections, this method calls closeClient(client).

Parameters
client:RMIConnection

the client connection that has been closed.

Exceptions
IOException:
if closeClient throws this exception.
NullPointerException:
if client is null.
closeback to summary
public synchronized void close() throws IOException

Implements java.io.Closeable.close.

Closes this connection server. This method first calls the closeServer() method so that no new client connections will be accepted. Then, for each remaining RMIConnection object returned by makeClient, its close method is called.

The behavior when this method is called more than once is unspecified.

If closeServer() throws an IOException, the individual connections are nevertheless closed, and then the IOException is thrown from this method.

If closeServer() returns normally but one or more of the individual connections throws an IOException, then, after closing all the connections, one of those IOExceptions is thrown from this method. If more than one connection throws an IOException, it is unspecified which one is thrown from this method.

Exceptions
IOException:
if closeServer() or one of the RMIConnection#close() calls threw IOException.
closeClientback to summary
protected abstract void closeClient(RMIConnection client) throws IOException

Closes a client connection made by makeClient.

Parameters
client:RMIConnection

a connection previously returned by makeClient on which the closeClient method has not previously been called. The behavior is unspecified if these conditions are violated, including the case where client is null.

Exceptions
IOException:
if the client connection cannot be closed.
closeServerback to summary
protected abstract void closeServer() throws IOException

Called by close() to close the connector server. After returning from this method, the connector server must not accept any new connections.

Exceptions
IOException:
if the attempt to close the connector server failed.
doNewClientback to summary
pack-priv RMIConnection doNewClient(Object credentials) throws IOException

This method could be overridden by subclasses defined in this package to perform additional operations specific to the underlying transport before creating the new client connection.

dropDeadReferencesback to summary
private void dropDeadReferences()
exportback to summary
protected abstract void export() throws IOException

Exports this RMI object.

Exceptions
IOException:
if this RMI object cannot be exported.
getDefaultClassLoaderback to summary
public synchronized ClassLoader getDefaultClassLoader()

Gets the default ClassLoader used by this connector server.

Returns:ClassLoader

the default ClassLoader used by this connector server.

See Also
setDefaultClassLoader
getMBeanServerback to summary
public synchronized MBeanServer getMBeanServer()

The MBeanServer to which this connector server is attached. This is the last value passed to setMBeanServer on this object, or null if that method has never been called.

Returns:MBeanServer

the MBeanServer to which this connector is attached.

See Also
setMBeanServer
getNotifBufferback to summary
pack-priv synchronized NotificationBuffer getNotifBuffer()
getProtocolback to summary
protected abstract String getProtocol()

Returns the protocol string for this object. The string is rmi for RMI/JRMP.

Returns:String

the protocol string for this object.

getVersionback to summary
public String getVersion()

Implements javax.management.remote.rmi.RMIServer.getVersion.

Doc from javax.management.remote.rmi.RMIServer.getVersion.

The version of the RMI Connector Protocol understood by this connector server. This is a string with the following format:

protocol-version implementation-name

The protocol-version is a series of two or more non-negative integers separated by periods (.). An implementation of the version described by this documentation must use the string 1.0 here.

After the protocol version there must be a space, followed by the implementation name. The format of the implementation name is unspecified. It is recommended that it include an implementation version number. An implementation can use an empty string as its implementation name, for example for security reasons.

Returns:String

a string with the format described here.

makeClientback to summary
protected abstract RMIConnection makeClient(String connectionId, Subject subject) throws IOException

Creates a new client connection. This method is called by the public method newClient(Object).

Parameters
connectionId:String

the ID of the new connection. Every connection opened by this connector server will have a different ID. The behavior is unspecified if this parameter is null.

subject:Subject

the authenticated subject. Can be null.

Returns:RMIConnection

the newly-created RMIConnection.

Exceptions
IOException:
if the new client object cannot be created or exported.
makeConnectionIdback to summary
private static synchronized String makeConnectionId(String protocol, Subject subject)
newClientback to summary
public RMIConnection newClient(Object credentials) throws IOException

Implements javax.management.remote.rmi.RMIServer.newClient.

Creates a new client connection. This method calls makeClient and adds the returned client connection object to an internal list. When this RMIServerImpl is shut down via its close() method, the close() method of each object remaining in the list is called.

The fact that a client connection object is in this internal list does not prevent it from being garbage collected.

Parameters
credentials:Object

this object specifies the user-defined credentials to be passed in to the server in order to authenticate the caller before creating the RMIConnection. Can be null.

Returns:RMIConnection

the newly-created RMIConnection. This is usually the object created by makeClient, though an implementation may choose to wrap that object in another object implementing RMIConnection.

Exceptions
IOException:
if the new client object cannot be created or exported.
SecurityException:
if the given credentials do not allow the server to authenticate the user successfully.
IllegalStateException:
if getMBeanServer() is null.
setDefaultClassLoaderback to summary
public synchronized void setDefaultClassLoader(ClassLoader cl)

Sets the default ClassLoader for this connector server. New client connections will use this classloader. Existing client connections are unaffected.

Parameters
cl:ClassLoader

the new ClassLoader to be used by this connector server.

See Also
getDefaultClassLoader
setMBeanServerback to summary
public synchronized void setMBeanServer(MBeanServer mbs)

Sets the MBeanServer to which this connector server is attached. New client connections will interact with this MBeanServer. Existing client connections are unaffected.

Parameters
mbs:MBeanServer

the new MBeanServer. Can be null, but new client connections will be refused as long as it is.

See Also
getMBeanServer
setRMIConnectorServerback to summary
pack-priv void setRMIConnectorServer(RMIConnectorServer connServer) throws IOException
toStubback to summary
public abstract Remote toStub() throws IOException

Returns a remotable stub for this server object.

Returns:Remote

a remotable stub.

Exceptions
IOException:
if the stub cannot be obtained - e.g the RMIServerImpl has not been exported yet.