ch.qos.logback.core.net
Interface SocketConnector

All Superinterfaces:
Runnable
All Known Implementing Classes:
SocketConnectorBase

public interface SocketConnector
extends Runnable

A Runnable that (re)connects a socket.

An implementation of this interface is responsible for repeatedly attempting to create a socket connection to a remote host.

Author:
Carl Harris

Nested Class Summary
static interface SocketConnector.ExceptionHandler
          An exception handler that is notified of all exceptions that occur during the (re)connection process.
 
Method Summary
 Socket awaitConnection()
          Blocks the calling thread until a connection is successfully established.
 Socket awaitConnection(long delay)
          Blocks the calling thread until a connection is successfully established or timeout occurs.
 void setExceptionHandler(SocketConnector.ExceptionHandler exceptionHandler)
          Sets the connector's exception handler.
 void setSocketFactory(SocketFactory socketFactory)
          Sets the connector's socket factory.
 
Methods inherited from interface java.lang.Runnable
run
 

Method Detail

awaitConnection

Socket awaitConnection()
                       throws InterruptedException
Blocks the calling thread until a connection is successfully established.

Returns:
the connected socket
Throws:
InterruptedException

awaitConnection

Socket awaitConnection(long delay)
                       throws InterruptedException
Blocks the calling thread until a connection is successfully established or timeout occurs.

Parameters:
the - maximum time to wait (in milliseconds)
Returns:
the connected socket or null if timeout occurs
Throws:
InterruptedException

setExceptionHandler

void setExceptionHandler(SocketConnector.ExceptionHandler exceptionHandler)
Sets the connector's exception handler.

The handler must be set before the Runnable.run() method is invoked.

Parameters:
exceptionHandler - the handler to set

setSocketFactory

void setSocketFactory(SocketFactory socketFactory)
Sets the connector's socket factory.

If no factory is configured that connector will use the platform's default factory.

Parameters:
socketFactory - the factory to set


Copyright © 2005-2013 QOS.ch. All Rights Reserved.