- java.lang.Object
-
- javax.net.SocketFactory
-
- org.newsclub.net.unix.AFUNIXSocketFactory
-
- Direct Known Subclasses:
AFUNIXSocketFactory.FactoryArg,AFUNIXSocketFactory.SystemProperty,AFUNIXSocketFactory.URIScheme
public abstract class AFUNIXSocketFactory extends javax.net.SocketFactoryThe base for a SocketFactory that connects to UNIX sockets. Typically, the "hostname" is used as a reference to a socketFile on the file system. The actual mapping is left to the implementor. Three default implementations are provided.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAFUNIXSocketFactory.FactoryArgA socket factory that handles a custom hostname ("junixsocket.localhost", by default, and configured by the system property "org.newsclub.net.unix.socket.hostname"), forwarding all other requests to the fallbackSocketFactory.static classAFUNIXSocketFactory.SystemPropertyA socket factory that handles a custom hostname ("junixsocket.localhost", by default, and configured by the system property "org.newsclub.net.unix.socket.hostname"), forwarding all other requests to the fallbackSocketFactory.static classAFUNIXSocketFactory.URISchemeA socket factory that handles special host names formatted as file:// URIs.
-
Constructor Summary
Constructors Constructor Description AFUNIXSocketFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract AFUNIXSocketAddressaddressFromHost(java.lang.String host, int port)Translates a "host" string (and port) to anAFUNIXSocketAddress.java.net.SocketcreateSocket()java.net.SocketcreateSocket(java.lang.String host, int port)java.net.SocketcreateSocket(java.lang.String host, int port, java.net.InetAddress localHost, int localPort)java.net.SocketcreateSocket(java.net.InetAddress address, int port)java.net.SocketcreateSocket(java.net.InetAddress address, int port, java.net.InetAddress localAddress, int localPort)protected booleanisHostnameSupported(java.lang.String host)Checks whether the given hostname is supported by this socket factory.protected booleanisInetAddressSupported(java.net.InetAddress address)Checks whether the givenInetAddressis supported by this socket factory.
-
-
-
Method Detail
-
addressFromHost
protected abstract AFUNIXSocketAddress addressFromHost(java.lang.String host, int port) throws java.io.IOException
Translates a "host" string (and port) to anAFUNIXSocketAddress.- Parameters:
host- The hostnameport- The port, or 0.- Returns:
- The
AFUNIXSocketAddress - Throws:
java.io.IOException- If there was a problem converting the hostnamejava.lang.NullPointerException- If host wasnull.
-
isHostnameSupported
protected boolean isHostnameSupported(java.lang.String host)
Checks whether the given hostname is supported by this socket factory. If not, calls to createSocket will cause an UnknownHostException.- Parameters:
host- The host to check.- Returns:
trueif supported.
-
isInetAddressSupported
protected boolean isInetAddressSupported(java.net.InetAddress address)
Checks whether the givenInetAddressis supported by this socket factory. If not, calls to createSocket will cause an UnknownHostException. By default, this only checks the hostname part of the address viaisHostnameSupported(String).- Parameters:
address- The address to check.- Returns:
trueif supported.
-
createSocket
public java.net.Socket createSocket() throws java.io.IOException- Overrides:
createSocketin classjavax.net.SocketFactory- Throws:
java.io.IOException
-
createSocket
public java.net.Socket createSocket(java.lang.String host, int port) throws java.io.IOException, java.net.UnknownHostException- Specified by:
createSocketin classjavax.net.SocketFactory- Throws:
java.io.IOExceptionjava.net.UnknownHostException
-
createSocket
public java.net.Socket createSocket(java.lang.String host, int port, java.net.InetAddress localHost, int localPort) throws java.io.IOException, java.net.UnknownHostException- Specified by:
createSocketin classjavax.net.SocketFactory- Throws:
java.io.IOExceptionjava.net.UnknownHostException
-
createSocket
public java.net.Socket createSocket(java.net.InetAddress address, int port) throws java.io.IOException- Specified by:
createSocketin classjavax.net.SocketFactory- Throws:
java.io.IOException
-
createSocket
public java.net.Socket createSocket(java.net.InetAddress address, int port, java.net.InetAddress localAddress, int localPort) throws java.io.IOException- Specified by:
createSocketin classjavax.net.SocketFactory- Throws:
java.io.IOException
-
-