RMIJRMPServerImpl (Java SE 26 & JDK 26)
Description: declaration: module: java.management.rmi, package: javax.management.remote.rmi, class: RMIJRMPServerImpl
Keywords: javax.management.remote.rmi.RMIJRMPServerImpl class

# Class RMIJRMPServerImpl

java.lang.Object
javax.management.remote.rmi.RMIServerImpl
javax.management.remote.rmi.RMIJRMPServerImpl

All Implemented Interfaces:
  `Closeable, AutoCloseable, Remote, RMIServer`

public class RMIJRMPServerImpl extends RMIServerImpl

An `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.

Since:
  1.5
See Also:
  - `RMIServerImpl`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RMIJRMPServerImpl(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf, Map<String,?> env)`
  Creates a new `RMIServer` object that will be exported on the given port using the given socket factories.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `closeClient(RMIConnection client)`
  Closes a client connection made by `makeClient`.
  `protected void`
  `closeServer()`
  Called by `RMIServerImpl.close()` to close the connector server by unexporting this object.
  `protected void`
  `export()`
  Exports this RMI object.
  `protected String`
  `getProtocol()`
  Returns the protocol string for this object.
  `protected RMIConnection`
  `makeClient(String connectionId, Subject subject)`
  Creates a new client connection as an RMI object exported through JRMP.
  `Remote`
  `toStub()`
  Returns a serializable stub for this `RMIServer` object.

  ### Methods declared in class RMIServerImpl

  `clientClosed, close, getDefaultClassLoader, getMBeanServer, getVersion, newClient, setDefaultClassLoader, setMBeanServer`
  Modifier and Type
  Method
  Description
  `protected void`
  `clientClosed(RMIConnection client)`
  Method called when a client connection created by `makeClient` is closed.
  `void`
  `close()`
  Closes this connection server.
  `ClassLoader`
  `getDefaultClassLoader()`
  Gets the default `ClassLoader` used by this connector server.
  `MBeanServer`
  `getMBeanServer()`
  The `MBeanServer` to which this connector server is attached.
  `String`
  `getVersion()`
  The version of the RMI Connector Protocol understood by this connector server.
  `RMIConnection`
  `newClient(Object credentials)`
  Creates a new client connection.
  `void`
  `setDefaultClassLoader(ClassLoader cl)`
  Sets the default `ClassLoader` for this connector server.
  `void`
  `setMBeanServer(MBeanServer mbs)`
  Sets the `MBeanServer` to which this connector server is attached.

  ### Methods declared in class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  Creates and returns a copy of this object.
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `protected void`
  `finalize()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Finalization is deprecated and subject to removal in a future release.
  `final Class<?>`
  `getClass()`
  Returns the runtime class of this `Object`.
  `int`
  `hashCode()`
  Returns a hash code value for this object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `String`
  `toString()`
  Returns a string representation of the object.
  `final void`
  `wait()`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
  `final void`
  `wait(long timeoutMillis)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
  `final void`
  `wait(long timeoutMillis, int nanos)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

- ## Constructor Details

  - ### RMIJRMPServerImpl

    public RMIJRMPServerImpl(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf, Map<String,?> env) throws IOException

    Creates a new `RMIServer` object that will be exported on the given port using the given socket factories.

    Parameters:
      `port` - the port on which this object and the `RMIConnectionImpl` objects it creates will be exported. Can be zero, to indicate any available port.
      `csf` - the client socket factory for the created RMI objects. Can be null.
      `ssf` - the server socket factory for the created RMI objects. Can be null.
      `env` - the environment map. Can be null.
    Throws:
      `IOException` - if the `RMIServer` object cannot be created.
      `IllegalArgumentException` - if `port` is negative.

- ## Method Details

  - ### export

    protected void export() throws IOException
    Description copied from class: `RMIServerImpl`

    Exports this RMI object.

    Specified by:
      `export` in class `RMIServerImpl`
    Throws:
      `IOException` - if this RMI object cannot be exported.

  - ### getProtocol

    protected String getProtocol()
    Description copied from class: `RMIServerImpl`

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

    Specified by:
      `getProtocol` in class `RMIServerImpl`
    Returns:
      the protocol string for this object.

  - ### toStub

    public Remote toStub() throws IOException

    Returns a serializable stub for this `RMIServer` object.

    Specified by:
      `toStub` in class `RMIServerImpl`
    Returns:
      a serializable stub.
    Throws:
      `IOException` - if the stub cannot be obtained - e.g the RMIJRMPServerImpl has not been exported yet.

  - ### makeClient

    protected RMIConnection makeClient(String connectionId, Subject subject) throws IOException

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

    Specified by:
      `makeClient` in class `RMIServerImpl`
    Parameters:
      `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.
    Returns:
      the newly-created `RMIConnection`.
    Throws:
      `IOException` - if the new `RMIConnection` object cannot be created or exported.

  - ### closeClient

    protected void closeClient(RMIConnection client) throws IOException
    Description copied from class: `RMIServerImpl`

    Closes a client connection made by `makeClient`.

    Specified by:
      `closeClient` in class `RMIServerImpl`
    Parameters:
      `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.
    Throws:
      `IOException` - if the client connection cannot be closed.

  - ### closeServer

    protected void closeServer() throws IOException

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

    Specified by:
      `closeServer` in class `RMIServerImpl`
    Throws:
      `IOException` - if the attempt to close the connector server failed.