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 AFSockets.- Author:
- Christian Kohlschütter
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classA lease on a registered port; closing the lease will return the port. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor required per definition.AFRMISocketFactory(AFNaming naming, RMIClientSocketFactory defaultClientFactory, RMIServerSocketFactory defaultServerFactory) Creates a new socket factory. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()createServerSocket(int port) createSocket(String host, int port) protected AFNamingThe naming instance.booleanisLocalServer(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 intnewPort()Deprecated.protected AFRMISocketFactory.PortLeaseReturns a new free port.protected abstract AFSocketAddressnewSocketAddress(int port) Creates a new socket address for the given RMI port.voidprotected abstract AFNamingDeserializes information necessary to instantiate theAFNaminginstance.protected voidreturnPort(int port) Deprecated.usenewPortLease()voidprotected abstract voidwriteNamingInstance(ObjectOutput out, AFNaming namingInstance) Serializes information necessary to instantiate the givenAFNaminginstance.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- TheAFNaminginstance 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:
createSocketin interfaceRMIClientSocketFactory- Specified by:
createSocketin classRMISocketFactory- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein 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:
createServerSocketin interfaceRMIServerSocketFactory- Specified by:
createServerSocketin classRMISocketFactory- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readNamingInstance
Deserializes information necessary to instantiate theAFNaminginstance.- Parameters:
in- The stream.- Returns:
- The
AFNaminginstance. - Throws:
IOException- on error.
-
writeNamingInstance
protected abstract void writeNamingInstance(ObjectOutput out, AFNaming namingInstance) throws IOException Serializes information necessary to instantiate the givenAFNaminginstance.- Parameters:
out- The stream.namingInstance- TheAFNaminginstance.- 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:
trueif the given port is a local server.
-
getNaming
-
newPortLease().