Package ch.qos.logback.core.net
Class DefaultSocketConnector
- java.lang.Object
-
- ch.qos.logback.core.net.DefaultSocketConnector
-
- All Implemented Interfaces:
SocketConnector
,java.util.concurrent.Callable<java.net.Socket>
public class DefaultSocketConnector extends java.lang.Object implements SocketConnector
Default implementation ofSocketConnector
.- Since:
- 1.0.12
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
DefaultSocketConnector.ConsoleExceptionHandler
A defaultSocketConnector.ExceptionHandler
that writes toSystem.out
-
Nested classes/interfaces inherited from interface ch.qos.logback.core.net.SocketConnector
SocketConnector.ExceptionHandler
-
-
Field Summary
Fields Modifier and Type Field Description private java.net.InetAddress
address
private DelayStrategy
delayStrategy
private SocketConnector.ExceptionHandler
exceptionHandler
private int
port
private javax.net.SocketFactory
socketFactory
-
Constructor Summary
Constructors Constructor Description DefaultSocketConnector(java.net.InetAddress address, int port, long initialDelay, long retryDelay)
Constructs a new connector.DefaultSocketConnector(java.net.InetAddress address, int port, DelayStrategy delayStrategy)
Constructs a new connector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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()
-
-
-
Field Detail
-
address
private final java.net.InetAddress address
-
port
private final int port
-
delayStrategy
private final DelayStrategy delayStrategy
-
exceptionHandler
private SocketConnector.ExceptionHandler exceptionHandler
-
socketFactory
private javax.net.SocketFactory socketFactory
-
-
Constructor Detail
-
DefaultSocketConnector
public DefaultSocketConnector(java.net.InetAddress address, int port, long initialDelay, long retryDelay)
Constructs a new connector.- Parameters:
address
- address of remote listenerport
- port of remote listenerinitialDelay
- delay before initial connection attemptretryDelay
- delay after failed connection attempt
-
DefaultSocketConnector
public DefaultSocketConnector(java.net.InetAddress address, int port, DelayStrategy delayStrategy)
Constructs a new connector.- Parameters:
address
- address of remote listenerport
- port of remote listenerdelayStrategy
- strategy for choosing the delay to impose before each connection attempt
-
-
Method Detail
-
call
public java.net.Socket call() throws java.lang.InterruptedException
Loops until the desired connection is established and returns the resulting connector.- Specified by:
call
in interfacejava.util.concurrent.Callable<java.net.Socket>
- Specified by:
call
in interfaceSocketConnector
- Returns:
- the connected socket
- Throws:
java.lang.InterruptedException
-
createSocket
private java.net.Socket createSocket()
-
useDefaultsForMissingFields
private void useDefaultsForMissingFields()
-
setExceptionHandler
public void setExceptionHandler(SocketConnector.ExceptionHandler exceptionHandler)
Sets the connector's exception handler.The handler must be set before the
SocketConnector.call()
method is invoked.- Specified by:
setExceptionHandler
in interfaceSocketConnector
- Parameters:
exceptionHandler
- the handler to set
-
setSocketFactory
public void setSocketFactory(javax.net.SocketFactory socketFactory)
Sets the connector's socket factory.If no factory is configured that connector will use the platform's default factory.
- Specified by:
setSocketFactory
in interfaceSocketConnector
- Parameters:
socketFactory
- the factory to set
-
-