public class DefaultSocketConnector extends java.lang.Object implements SocketConnector
SocketConnector.| Modifier and Type | Class and Description |
|---|---|
private static class |
DefaultSocketConnector.ConsoleExceptionHandler
A default
ExceptionHandler that writes to System.out |
SocketConnector.ExceptionHandler| Modifier and Type | Field and Description |
|---|---|
private java.net.InetAddress |
address |
private DelayStrategy |
delayStrategy |
private SocketConnector.ExceptionHandler |
exceptionHandler |
private int |
port |
private javax.net.SocketFactory |
socketFactory |
| Constructor and Description |
|---|
DefaultSocketConnector(java.net.InetAddress address,
int port,
DelayStrategy delayStrategy)
Constructs a new connector.
|
DefaultSocketConnector(java.net.InetAddress address,
int port,
long initialDelay,
long retryDelay)
Constructs a new connector.
|
| Modifier and Type | Method and Description |
|---|---|
java.net.Socket |
call()
Loops until the desired connection is established and returns the resulting connector.
|
private java.net.Socket |
createSocket() |
void |
setExceptionHandler(SocketConnector.ExceptionHandler exceptionHandler)
Sets the connector's exception handler.
|
void |
setSocketFactory(javax.net.SocketFactory socketFactory)
Sets the connector's socket factory.
|
private void |
useDefaultsForMissingFields() |
private final java.net.InetAddress address
private final int port
private final DelayStrategy delayStrategy
private SocketConnector.ExceptionHandler exceptionHandler
private javax.net.SocketFactory socketFactory
public DefaultSocketConnector(java.net.InetAddress address,
int port,
long initialDelay,
long retryDelay)
address - address of remote listenerport - port of remote listenerinitialDelay - delay before initial connection attemptretryDelay - delay after failed connection attemptpublic DefaultSocketConnector(java.net.InetAddress address,
int port,
DelayStrategy delayStrategy)
address - address of remote listenerport - port of remote listenerdelayStrategy - strategy for choosing the delay to impose before
each connection attemptpublic java.net.Socket call()
throws java.lang.InterruptedException
call in interface SocketConnectorcall in interface java.util.concurrent.Callable<java.net.Socket>java.lang.InterruptedExceptionprivate java.net.Socket createSocket()
private void useDefaultsForMissingFields()
public void setExceptionHandler(SocketConnector.ExceptionHandler exceptionHandler)
The handler must be set before the SocketConnector.call() method is invoked.
setExceptionHandler in interface SocketConnectorexceptionHandler - the handler to setpublic void setSocketFactory(javax.net.SocketFactory socketFactory)
If no factory is configured that connector will use the platform's default factory.
setSocketFactory in interface SocketConnectorsocketFactory - the factory to set