FileDocCategorySizeDatePackage
RMIJRMPServerImpl.javaAPI DocJava SE 5 API5123Fri Aug 26 14:57:38 BST 2005javax.management.remote.rmi

RMIJRMPServerImpl

public class RMIJRMPServerImpl extends RMIServerImpl

An {@link RMIServer} object that is exported through JRMP and that creates client connections as RMI objects exported through JRMP. User code does not usually reference this class directly.

see
RMIServerImpl
since
1.5
since.unbundled
1.0

Fields Summary
private final int
port
private final RMIClientSocketFactory
csf
private final RMIServerSocketFactory
ssf
private final Map
env
Constructors Summary
public RMIJRMPServerImpl(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf, Map env)

Creates a new {@link RMIServer} object that will be exported on the given port using the given socket factories.

param
port the port on which this object and the {@link RMIConnectionImpl} objects it creates will be exported. Can be zero, to indicate any available port.
param
csf the client socket factory for the created RMI objects. Can be null.
param
ssf the server socket factory for the created RMI objects. Can be null.
param
env the environment map. Can be null.
exception
IOException if the {@link RMIServer} object cannot be created.
exception
IllegalArgumentException if port is negative.


        super(env);

	if (port < 0)
	    throw new IllegalArgumentException("Negative port: " + port);

        this.port = port;
        this.csf = csf;
        this.ssf = ssf;
	this.env = (env == null) ? Collections.EMPTY_MAP : env;
    
Methods Summary
protected voidcloseClient(javax.management.remote.rmi.RMIConnection client)

        unexport(client, true);
    
protected voidcloseServer()

Called by {@link #close()} to close the connector server by unexporting this object. After returning from this method, the connector server must not accept any new connections.

exception
IOException if the attempt to close the connector server failed.

        unexport(this, true);
    
protected voidexport()

	export(this);
    
private voidexport(java.rmi.Remote obj)

	RMIExporter exporter =
	    (RMIExporter) env.get(RMIExporter.EXPORTER_ATTRIBUTE);
	if (exporter == null)
	    UnicastRemoteObject.exportObject(obj, port, csf, ssf);
	else
	    exporter.exportObject(obj, port, csf, ssf);
    
protected java.lang.StringgetProtocol()

	return "rmi";
    
protected javax.management.remote.rmi.RMIConnectionmakeClient(java.lang.String connectionId, javax.security.auth.Subject subject)

Creates a new client connection as an RMI object exported through JRMP. The port and socket factories for the new {@link RMIConnection} object are the ones supplied to the RMIJRMPServerImpl constructor.

param
connectionId 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.
param
subject the authenticated subject. Can be null.
return
the newly-created RMIConnection.
exception
IOException if the new {@link RMIConnection} object cannot be created or exported.


	if (connectionId == null)
	    throw new NullPointerException("Null connectionId");

        RMIConnection client =
            new RMIConnectionImpl(this, connectionId, getDefaultClassLoader(),
				  subject, env);
	export(client);
        return client;
    
public java.rmi.RemotetoStub()

Returns a serializable stub for this {@link RMIServer} object.

return
a serializable stub.
exception
IOException if the stub cannot be obtained - e.g the RMIJRMPServerImpl has not been exported yet.

        return RemoteObject.toStub(this);
    
private voidunexport(java.rmi.Remote obj, boolean force)

	RMIExporter exporter =
	    (RMIExporter) env.get(RMIExporter.EXPORTER_ATTRIBUTE);
	if (exporter == null)
	    UnicastRemoteObject.unexportObject(obj, force);
	else
	    exporter.unexportObject(obj, force);