- java.lang.Object
- 
- javax.management.remote.rmi.RMIServerImpl
 
- 
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- Remote,- RMIServer
 - Direct Known Subclasses:
- RMIIIOPServerImpl,- RMIJRMPServerImpl
 
 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 withJMXConnectorFactoryor by instantiatingRMIConnector.This is an abstract class. Concrete subclasses define the details of the client connection objects. - Since:
- 1.5
 
- 
- 
Constructor SummaryConstructors Constructor Description RMIServerImpl(Map<String,?> env)Constructs a newRMIServerImpl.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidclientClosed(RMIConnection client)Method called when a client connection created bymakeClientis closed.voidclose()Closes this connection server.protected abstract voidcloseClient(RMIConnection client)Closes a client connection made bymakeClient.protected abstract voidcloseServer()Called byclose()to close the connector server.protected abstract voidexport()Exports this RMI object.ClassLoadergetDefaultClassLoader()Gets the defaultClassLoaderused by this connector server.MBeanServergetMBeanServer()TheMBeanServerto which this connector server is attached.protected abstract StringgetProtocol()Returns the protocol string for this object.protected abstract RMIConnectionmakeClient(String connectionId, Subject subject)Creates a new client connection.RMIConnectionnewClient(Object credentials)Creates a new client connection.voidsetDefaultClassLoader(ClassLoader cl)Sets the defaultClassLoaderfor this connector server.voidsetMBeanServer(MBeanServer mbs)Sets theMBeanServerto which this connector server is attached.abstract RemotetoStub()Returns a remotable stub for this server object.- 
Methods declared in class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods declared in interface javax.management.remote.rmi.RMIServergetVersion
 
- 
 
- 
- 
- 
Method Detail- 
exportprotected abstract void export() throws IOExceptionExports this RMI object. - Throws:
- IOException- if this RMI object cannot be exported.
 
 - 
toStubpublic abstract Remote toStub() throws IOException Returns a remotable stub for this server object.- Returns:
- a remotable stub.
- Throws:
- IOException- if the stub cannot be obtained - e.g the RMIServerImpl has not been exported yet.
 
 - 
setDefaultClassLoaderpublic void setDefaultClassLoader(ClassLoader cl) Sets the default ClassLoaderfor this connector server. New client connections will use this classloader. Existing client connections are unaffected.- Parameters:
- cl- the new- ClassLoaderto be used by this connector server.
- See Also:
- getDefaultClassLoader()
 
 - 
getDefaultClassLoaderpublic ClassLoader getDefaultClassLoader() Gets the default ClassLoaderused by this connector server.- Returns:
- the default ClassLoaderused by this connector server.
- See Also:
- setDefaultClassLoader(java.lang.ClassLoader)
 
 - 
setMBeanServerpublic void setMBeanServer(MBeanServer mbs) Sets the MBeanServerto which this connector server is attached. New client connections will interact with thisMBeanServer. Existing client connections are unaffected.- Parameters:
- mbs- the new- MBeanServer. Can be null, but new client connections will be refused as long as it is.
- See Also:
- getMBeanServer()
 
 - 
getMBeanServerpublic MBeanServer getMBeanServer() The MBeanServerto which this connector server is attached. This is the last value passed tosetMBeanServer(javax.management.MBeanServer)on this object, or null if that method has never been called.- Returns:
- the MBeanServerto which this connector is attached.
- See Also:
- setMBeanServer(javax.management.MBeanServer)
 
 - 
newClientpublic RMIConnection newClient(Object credentials) throws IOException Creates a new client connection. This method calls makeClientand adds the returned client connection object to an internal list. When thisRMIServerImplis shut down via itsclose()method, theclose()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. - Specified by:
- newClientin interface- RMIServer
- Parameters:
- credentials- 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:
- the newly-created RMIConnection. This is usually the object created bymakeClient, though an implementation may choose to wrap that object in another object implementingRMIConnection.
- Throws:
- 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.
 
 - 
makeClientprotected 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- 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 client object cannot be created or exported.
 
 - 
closeClientprotected abstract void closeClient(RMIConnection client) throws IOException Closes a client connection made by makeClient.- Parameters:
- client- a connection previously returned by- makeClienton which the- closeClientmethod has not previously been called. The behavior is unspecified if these conditions are violated, including the case where- clientis null.
- Throws:
- IOException- if the client connection cannot be closed.
 
 - 
getProtocolprotected abstract String getProtocol() Returns the protocol string for this object. The string is rmifor RMI/JRMP.- Returns:
- the protocol string for this object.
 
 - 
clientClosedprotected void clientClosed(RMIConnection client) throws IOException Method called when a client connection created by makeClientis closed. A subclass that definesmakeClientmust arrange for this method to be called when the resultant object'sclosemethod is called. This enables it to be removed from theRMIServerImpl's list of connections. It is not an error forclientnot to be in that list.After removing clientfrom the list of connections, this method callscloseClient(client).- Parameters:
- client- the client connection that has been closed.
- Throws:
- IOException- if- closeClient(javax.management.remote.rmi.RMIConnection)throws this exception.
- NullPointerException- if- clientis null.
 
 - 
closepublic void close() throws IOExceptionCloses this connection server. This method first calls the closeServer()method so that no new client connections will be accepted. Then, for each remainingRMIConnectionobject returned bymakeClient, itsclosemethod is called.The behavior when this method is called more than once is unspecified. If closeServer()throws anIOException, the individual connections are nevertheless closed, and then theIOExceptionis thrown from this method.If closeServer()returns normally but one or more of the individual connections throws anIOException, then, after closing all the connections, one of thoseIOExceptions is thrown from this method. If more than one connection throws anIOException, it is unspecified which one is thrown from this method.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Throws:
- IOException- if- closeServer()or one of the- RMIConnection.close()calls threw- IOException.
 
 - 
closeServerprotected abstract void closeServer() throws IOExceptionCalled by close()to close the connector server. After returning from this method, the connector server must not accept any new connections.- Throws:
- IOException- if the attempt to close the connector server failed.
 
 
- 
 
-