java.lang.Object
java.rmi.server.RMISocketFactory
org.newsclub.net.unix.rmi.AFRMISocketFactory
- All Implemented Interfaces:
Closeable
,Externalizable
,Serializable
,AutoCloseable
,RMIClientSocketFactory
,RMIServerSocketFactory
- Direct Known Subclasses:
AFUNIXRMISocketFactory
public abstract class AFRMISocketFactory
extends RMISocketFactory
implements Externalizable, Closeable
An
RMISocketFactory
that supports AFSocket
s.- Author:
- Christian Kohlschütter
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static final class
A lease on a registered port; closing the lease will return the port. -
Constructor Summary
ConstructorDescriptionConstructor required per definition.AFRMISocketFactory
(AFNaming naming, RMIClientSocketFactory defaultClientFactory, RMIServerSocketFactory defaultServerFactory) Creates a new socket factory. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
createServerSocket
(int port) createSocket
(String host, int port) protected AFNaming
The naming instance.boolean
isLocalServer
(int port) Checks if the given port refers to a local server port.protected abstract AFSocket
<?> Creates a new socket that is connected to the given socket address.protected int
newPort()
Deprecated.protected AFRMISocketFactory.PortLease
Returns a new free port.protected abstract AFSocketAddress
newSocketAddress
(int port) Creates a new socket address for the given RMI port.void
protected abstract AFNaming
Deserializes information necessary to instantiate theAFNaming
instance.protected void
returnPort
(int port) Deprecated.usenewPortLease()
void
protected abstract void
writeNamingInstance
(ObjectOutput out, AFNaming namingInstance) Serializes information necessary to instantiate the givenAFNaming
instance.Methods inherited from class java.rmi.server.RMISocketFactory
getDefaultSocketFactory, getFailureHandler, getSocketFactory, setFailureHandler, setSocketFactory
-
Constructor Details
-
AFRMISocketFactory
public AFRMISocketFactory()Constructor required per definition.- See Also:
-
AFRMISocketFactory
public AFRMISocketFactory(AFNaming naming, RMIClientSocketFactory defaultClientFactory, RMIServerSocketFactory defaultServerFactory) Creates a new socket factory.- Parameters:
naming
- TheAFNaming
instance to use.defaultClientFactory
- The defaultRMIClientSocketFactory
.defaultServerFactory
- The defaultRMIServerSocketFactory
.
-
-
Method Details
-
newSocketAddress
Creates a new socket address for the given RMI port.- Parameters:
port
- The port.- Returns:
- The socket address.
- Throws:
IOException
- on error.
-
newConnectedSocket
Creates a new socket that is connected to the given socket address.- Parameters:
addr
- The socket address.- Returns:
- The connected socket.
- Throws:
IOException
- on error.
-
createSocket
- Specified by:
createSocket
in interfaceRMIClientSocketFactory
- Specified by:
createSocket
in classRMISocketFactory
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
newPort
Deprecated.usenewPortLease()
.Returns a new free port.- Returns:
- The new port.
- Throws:
IOException
- on error.- See Also:
-
newPortLease
Returns a new free port.- Returns:
- The new port, wrapped as a
AFRMISocketFactory.PortLease
. Closing the lease will return the port. - Throws:
IOException
- on error.
-
returnPort
Deprecated.usenewPortLease()
Returns a port that was previously returned bynewPort()
. Note that this may call may stall unnecessarily upon shutdown due to locking issues.- Parameters:
port
- The port to return.- Throws:
IOException
- on error.
-
createServerSocket
- Specified by:
createServerSocket
in interfaceRMIServerSocketFactory
- Specified by:
createServerSocket
in classRMISocketFactory
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readNamingInstance
Deserializes information necessary to instantiate theAFNaming
instance.- Parameters:
in
- The stream.- Returns:
- The
AFNaming
instance. - Throws:
IOException
- on error.
-
writeNamingInstance
protected abstract void writeNamingInstance(ObjectOutput out, AFNaming namingInstance) throws IOException Serializes information necessary to instantiate the givenAFNaming
instance.- Parameters:
out
- The stream.namingInstance
- TheAFNaming
instance.- Throws:
IOException
- on error.
-
isLocalServer
public boolean isLocalServer(int port) Checks if the given port refers to a local server port.- Parameters:
port
- The port to check.- Returns:
true
if the given port is a local server.
-
getNaming
-
newPortLease()
.