Top Description Inners Constructors Methods
org.newsclub.net.unix

public abstract Class AFUNIXSocketFactory

extends AFSocketFactory<AFUNIXSocketAddress>
Class Inheritance
Known Direct Subclasses
org.newsclub.net.unix.AFUNIXSocketFactory.DefaultSocketHostnameSocketFactory, org.newsclub.net.unix.AFUNIXSocketFactory.URIScheme
Imports
java.io.File, .IOException, java.net.Socket, .SocketException, .URLDecoder, java.util.Objects, javax.net.SocketFactory

The 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.
See Also
AFUNIXSocketFactory.FactoryArg, AFUNIXSocketFactory.SystemProperty, AFUNIXSocketFactory.URIScheme

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class
AFUNIXSocketFactory.DefaultSocketHostnameSocketFactory

A socket factory that handles a custom hostname ("localhost", by default, and configured by the system property "org.newsclub.net.unix.socket.hostname"), forwarding all other requests to the fallback SocketFactory.

public static class
AFUNIXSocketFactory.FactoryArg

A socket factory that handles a custom hostname ("localhost", by default, and configured by the system property "org.newsclub.net.unix.socket.hostname"), forwarding all other requests to the fallback SocketFactory.

public static class
AFUNIXSocketFactory.SystemProperty

A 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 fallback SocketFactory.

public static class
AFUNIXSocketFactory.URIScheme

A socket factory that handles special host names formatted as file:// URIs.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected AFUNIXSocket
connectTo(AFUNIXSocketAddress
The address to connect to.
addr
)

Implements abstract org.newsclub.net.unix.AFSocketFactory.connectTo.

Creates a new AFSocket, connected to the given address.

public Socket
createSocket()

Implements abstract org.newsclub.net.unix.AFSocketFactory.createSocket.

Creates an unconnected socket.

Inherited from org.newsclub.net.unix.AFSocketFactory:
createSocketcreateSocketcreateSocketcreateSocketisInetAddressSupported

Constructor Detail

AFUNIXSocketFactoryback to summary
protected AFUNIXSocketFactory()

Creates a AFUNIXSocketFactory.

Method Detail

connectToback to summary
protected AFUNIXSocket connectTo(AFUNIXSocketAddress addr) throws IOException

Implements abstract org.newsclub.net.unix.AFSocketFactory.connectTo.

Doc from org.newsclub.net.unix.AFSocketFactory.connectTo.

Creates a new AFSocket, connected to the given address.

Parameters
addr:AFUNIXSocketAddress

The address to connect to.

Returns:AFUNIXSocket

The socket instance.

Annotations
@Override
Exceptions
IOException:
on error.
createSocketback to summary
public Socket createSocket() throws SocketException

Implements abstract org.newsclub.net.unix.AFSocketFactory.createSocket.

Doc from javax.net.SocketFactory.createSocket.

Creates an unconnected socket.

Returns:Socket

the unconnected socket

Annotations
@Override
org.newsclub.net.unix back to summary

private abstract Class AFUNIXSocketFactory.DefaultSocketHostnameSocketFactory

extends AFUNIXSocketFactory
Class Inheritance
Known Direct Subclasses
org.newsclub.net.unix.AFUNIXSocketFactory.FactoryArg, org.newsclub.net.unix.AFUNIXSocketFactory.SystemProperty

A socket factory that handles a custom hostname ("localhost", by default, and configured by the system property "org.newsclub.net.unix.socket.hostname"), forwarding all other requests to the fallback SocketFactory.

Field Summary

Modifier and TypeField and Description
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static String
public final boolean
isHostnameSupported(String
The host to check.
host
)

Overrides default org.newsclub.net.unix.AFSocketAddressFromHostname.isHostnameSupported.

Checks whether the given hostname is supported by this socket factory.

Inherited from org.newsclub.net.unix.AFUNIXSocketFactory:
connectTocreateSocket

Field Detail

PROP_SOCKET_HOSTNAMEback to summary
private static final String PROP_SOCKET_HOSTNAME

Constructor Detail

DefaultSocketHostnameSocketFactoryback to summary
public DefaultSocketHostnameSocketFactory()

Creates a DefaultSocketHostnameSocketFactory.

Method Detail

getDefaultSocketHostnameback to summary
private static String getDefaultSocketHostname()
isHostnameSupportedback to summary
public final boolean isHostnameSupported(String host)

Overrides default org.newsclub.net.unix.AFSocketAddressFromHostname.isHostnameSupported.

Doc from org.newsclub.net.unix.AFSocketAddressFromHostname.isHostnameSupported.

Checks whether the given hostname is supported by this socket factory. If not, calls to createSocket will cause a SocketException.

Parameters
host:String

The host to check.

Returns:boolean

true if supported.

Annotations
@Override
org.newsclub.net.unix back to summary

public final Class AFUNIXSocketFactory.FactoryArg

extends DefaultSocketHostnameSocketFactory
Class Inheritance

A socket factory that handles a custom hostname ("localhost", by default, and configured by the system property "org.newsclub.net.unix.socket.hostname"), forwarding all other requests to the fallback SocketFactory. The socket path is configured through an argument passed by to the constructor. This is particularly useful for JDBC drivers that take a "socketFactory" and a "socketFactoryArg". The latter will be passed as a constructor argument.

Field Summary

Modifier and TypeField and Description
private final File

Constructor Summary

AccessConstructor and Description
public
FactoryArg(String
The path to the socket.
socketPath
)

Constructs a new FactoryArg factory using the given socket path.

public
FactoryArg(File
The path to the socket.
file
)

Constructs a new FactoryArg factory using the given socket path.

Method Summary

Modifier and TypeMethod and Description
public AFUNIXSocketAddress
addressFromHost(String
The hostname
host
,
int
The port, or 0.
port
)

Implements org.newsclub.net.unix.AFSocketAddressFromHostname.addressFromHost.

Translates a "host" string (and port) to an AFSocketAddress.

Inherited from org.newsclub.net.unix.AFUNIXSocketFactory.DefaultSocketHostnameSocketFactory:
isHostnameSupported

Field Detail

socketFileback to summary
private final File socketFile

Constructor Detail

FactoryArgback to summary
public FactoryArg(String socketPath)

Constructs a new FactoryArg factory using the given socket path.

Parameters
socketPath:String

The path to the socket.

FactoryArgback to summary
public FactoryArg(File file)

Constructs a new FactoryArg factory using the given socket path.

Parameters
file:File

The path to the socket.

Method Detail

addressFromHostback to summary
public AFUNIXSocketAddress addressFromHost(String host, int port) throws SocketException

Implements org.newsclub.net.unix.AFSocketAddressFromHostname.addressFromHost.

Doc from org.newsclub.net.unix.AFSocketAddressFromHostname.addressFromHost.

Translates a "host" string (and port) to an AFSocketAddress.

Parameters
host:String

The hostname

port:int

The port, or 0.

Returns:AFUNIXSocketAddress

The AFSocketAddress

Annotations
@Override
Exceptions
SocketException:
If there was a problem converting the hostname
org.newsclub.net.unix back to summary

public final Class AFUNIXSocketFactory.SystemProperty

extends DefaultSocketHostnameSocketFactory
Class Inheritance

A 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 fallback SocketFactory. The socket path is configured through a system property, "org.newsclub.net.unix.socket.default".

Note

While it is technically possible, it is highly discouraged to programmatically change the value of the property as it can lead to concurrency issues and undefined behavior.

Field Summary

Modifier and TypeField and Description
private static final String

Constructor Summary

AccessConstructor and Description
public
SystemProperty()

Creates a SystemProperty socket factory.

Method Summary

Modifier and TypeMethod and Description
public AFUNIXSocketAddress
addressFromHost(String
The hostname
host
,
int
The port, or 0.
port
)

Implements org.newsclub.net.unix.AFSocketAddressFromHostname.addressFromHost.

Translates a "host" string (and port) to an AFSocketAddress.

Inherited from org.newsclub.net.unix.AFUNIXSocketFactory.DefaultSocketHostnameSocketFactory:
isHostnameSupported

Field Detail

PROP_SOCKET_DEFAULTback to summary
private static final String PROP_SOCKET_DEFAULT

Constructor Detail

SystemPropertyback to summary
public SystemProperty()

Creates a SystemProperty socket factory.

Method Detail

addressFromHostback to summary
public AFUNIXSocketAddress addressFromHost(String host, int port) throws SocketException

Implements org.newsclub.net.unix.AFSocketAddressFromHostname.addressFromHost.

Doc from org.newsclub.net.unix.AFSocketAddressFromHostname.addressFromHost.

Translates a "host" string (and port) to an AFSocketAddress.

Parameters
host:String

The hostname

port:int

The port, or 0.

Returns:AFUNIXSocketAddress

The AFSocketAddress

Annotations
@Override
Exceptions
SocketException:
If there was a problem converting the hostname
org.newsclub.net.unix back to summary

public final Class AFUNIXSocketFactory.URIScheme

extends AFUNIXSocketFactory
Class Inheritance

A socket factory that handles special host names formatted as file:// URIs. The file:// URI may also be specified in URL-encoded format, i.e., file:%3A%2F%2F etc. You may also surround the URL with square brackets ("[" and "]"), whereas the closing bracket may be omitted.

Note

In some circumstances it is recommended to use "[file:%3A%2F%2F(...)", i.e. encoded and without the closing bracket. Since this is an invalid hostname, it will not trigger a DNS lookup, but can still be used within a JDBC Connection URL.

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
public
URIScheme()

Creates a URIScheme socket factory.

Method Summary

Modifier and TypeMethod and Description
public AFUNIXSocketAddress
addressFromHost(String
The hostname
host
,
int
The port, or 0.
port
)

Implements org.newsclub.net.unix.AFSocketAddressFromHostname.addressFromHost.

Translates a "host" string (and port) to an AFSocketAddress.

public boolean
isHostnameSupported(String
The host to check.
host
)

Overrides default org.newsclub.net.unix.AFSocketAddressFromHostname.isHostnameSupported.

Checks whether the given hostname is supported by this socket factory.

private static String
Inherited from org.newsclub.net.unix.AFUNIXSocketFactory:
connectTocreateSocket

Field Detail

FILE_SCHEME_LOCALHOSTback to summary
private static final String FILE_SCHEME_LOCALHOST
FILE_SCHEME_PREFIXback to summary
private static final String FILE_SCHEME_PREFIX
FILE_SCHEME_PREFIX_ENCODEDback to summary
private static final String FILE_SCHEME_PREFIX_ENCODED

Constructor Detail

URISchemeback to summary
public URIScheme()

Creates a URIScheme socket factory.

Method Detail

addressFromHostback to summary
public AFUNIXSocketAddress addressFromHost(String host, int port) throws SocketException

Implements org.newsclub.net.unix.AFSocketAddressFromHostname.addressFromHost.

Doc from org.newsclub.net.unix.AFSocketAddressFromHostname.addressFromHost.

Translates a "host" string (and port) to an AFSocketAddress.

Parameters
host:String

The hostname

port:int

The port, or 0.

Returns:AFUNIXSocketAddress

The AFSocketAddress

Annotations
@Override
Exceptions
SocketException:
If there was a problem converting the hostname
isHostnameSupportedback to summary
public boolean isHostnameSupported(String host)

Overrides default org.newsclub.net.unix.AFSocketAddressFromHostname.isHostnameSupported.

Doc from org.newsclub.net.unix.AFSocketAddressFromHostname.isHostnameSupported.

Checks whether the given hostname is supported by this socket factory. If not, calls to createSocket will cause a SocketException.

Parameters
host:String

The host to check.

Returns:boolean

true if supported.

Annotations
@Override
stripBracketsback to summary
private static String stripBrackets(String host)