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:
-
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 org.newsclub.net.unix.AFSocket<?>newConnectedSocket(org.newsclub.net.unix.AFSocketAddress addr) Creates a new socket that is connected to the given socket address.protected intnewPort()Returns a new free port.protected abstract org.newsclub.net.unix.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) Returns a port that was previously returned bynewPort().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) throws IOException Creates a new socket factory.- Parameters:
naming- TheAFNaminginstance to use.defaultClientFactory- The defaultRMIClientSocketFactory.defaultServerFactory- The defaultRMIServerSocketFactory.- Throws:
IOException- on error.
-
-
Method Details
-
newSocketAddress
protected abstract org.newsclub.net.unix.AFSocketAddress newSocketAddress(int port) throws IOException Creates a new socket address for the given RMI port.- Parameters:
port- The port.- Returns:
- The socket address.
- Throws:
IOException- on error.
-
newConnectedSocket
protected abstract org.newsclub.net.unix.AFSocket<?> newConnectedSocket(org.newsclub.net.unix.AFSocketAddress addr) throws IOException 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
Returns a new free port.- Returns:
- The new port.
- Throws:
IOException- on error.- See Also:
-
returnPort
Returns a port that was previously returned bynewPort().- 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
The naming instance.- Returns:
- The instance.
-