public abstract class RMIServerImpl extends Object implements Closeable, RMIServer
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 JMXConnectorFactory
 or by instantiating RMIConnector.
This is an abstract class. Concrete subclasses define the details of the client connection objects, such as whether they use JRMP or IIOP.
| Constructor | Description | 
|---|---|
| RMIServerImpl(Map<String,?> env) | Constructs a new  RMIServerImpl. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| protected void | clientClosed(RMIConnection client) | Method called when a client connection created by  makeClientis closed. | 
| void | close() | Closes this connection server. | 
| protected abstract void | closeClient(RMIConnection client) | Closes a client connection made by  makeClient. | 
| protected abstract void | closeServer() | Called by  close()to close the connector server. | 
| protected abstract void | export() | Exports this RMI object. | 
| ClassLoader | getDefaultClassLoader() | Gets the default  ClassLoaderused by this connector
 server. | 
| MBeanServer | getMBeanServer() | The  MBeanServerto which this connector server
 is attached. | 
| protected abstract String | getProtocol() | Returns the protocol string for this object. | 
| String | getVersion() | The version of the RMI Connector Protocol understood by this
 connector server. | 
| protected abstract RMIConnection | makeClient(String connectionId,
          Subject subject) | Creates a new client connection. | 
| RMIConnection | newClient(Object credentials) | Creates a new client connection. | 
| void | setDefaultClassLoader(ClassLoader cl) | Sets the default  ClassLoaderfor this connector
 server. | 
| void | setMBeanServer(MBeanServer mbs) | Sets the  MBeanServerto which this connector
 server is attached. | 
| abstract Remote | toStub() | Returns a remotable stub for this server object. | 
protected abstract void export()
                        throws IOException
Exports this RMI object.
IOException - if this RMI object cannot be exported.public abstract Remote toStub() throws IOException
IOException - if the stub cannot be obtained - e.g the
            RMIServerImpl has not been exported yet.public void setDefaultClassLoader(ClassLoader cl)
Sets the default ClassLoader for this connector
 server. New client connections will use this classloader.
 Existing client connections are unaffected.
cl - the new ClassLoader to be used by this
 connector server.getDefaultClassLoader()public ClassLoader getDefaultClassLoader()
Gets the default ClassLoader used by this connector
 server.
ClassLoader used by this
 connector server.setDefaultClassLoader(java.lang.ClassLoader)public 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.
mbs - the new MBeanServer.  Can be null, but
 new client connections will be refused as long as it is.getMBeanServer()public MBeanServer getMBeanServer()
The MBeanServer to which this connector server
 is attached.  This is the last value passed to setMBeanServer(javax.management.MBeanServer) on this object, or null if that method has
 never been called.
MBeanServer to which this connector
 is attached.setMBeanServer(javax.management.MBeanServer)public String getVersion()
RMIServerThe 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.
getVersion in interface RMIServerpublic RMIConnection newClient(Object credentials) throws IOException
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.
newClient in interface RMIServercredentials - 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.RMIConnection.  This is
 usually the object created by makeClient, though
 an implementation may choose to wrap that object in another
 object implementing RMIConnection.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.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).
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.subject - the authenticated subject.  Can be null.RMIConnection.IOException - if the new client object cannot be
 created or exported.protected abstract void closeClient(RMIConnection client) throws IOException
Closes a client connection made by makeClient.
client - 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.IOException - if the client connection cannot be
 closed.protected abstract String getProtocol()
Returns the protocol string for this object.  The string is
 rmi for RMI/JRMP and iiop for RMI/IIOP.
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).
client - the client connection that has been closed.IOException - if closeClient(javax.management.remote.rmi.RMIConnection) throws this
 exception.NullPointerException - if client is null.public void close()
           throws IOException
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.
close in interface Closeableclose in interface AutoCloseableIOException - if closeServer() or one of the
 RMIConnection.close() calls threw
 IOException.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.
IOException - if the attempt to close the connector
 server failed. Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2025, Oracle and/or its affiliates.  All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.