Package com.adaptris.core
Class AllowsRetriesConnection
- java.lang.Object
-
- com.adaptris.core.AdaptrisConnectionImp
-
- com.adaptris.core.AllowsRetriesConnection
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisConnection
,ComponentLifecycle
,ComponentLifecycleExtension
,StateManagedComponent
- Direct Known Subclasses:
DatabaseConnection
,JmsConnection
,JmxConnection
public abstract class AllowsRetriesConnection extends AdaptrisConnectionImp
Abstract class for connections that have the ability to retry connections.Generally speaking for connections that physically require initialisation such as a connection to a JMS Broker or a Database, it should be possible to configure the connection to retry the connection if it initially fails. For other types of connection such as binding on a socket, this isn't so valid.
Previously AdaptrisConnectionImp exposed connectionAttemps and connectionWait however, this class was introduced reduce the number of un-used fields in the connection hierarchy.
- See Also:
JmsConnection
,DatabaseConnection
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.AdaptrisConnectionImp
log
-
-
Constructor Summary
Constructors Constructor Description AllowsRetriesConnection()
Default Constructor with the following default values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
connectionAttempts()
long
connectionRetryInterval()
Returns the wait between connection attempts in milliseconds.protected java.lang.String
createLoggingStatement(int attempt)
java.lang.Integer
getConnectionAttempts()
Returns the number of connection attempts to make.TimeInterval
getConnectionRetryInterval()
protected boolean
logWarning(int attemptCount)
void
setConnectionAttempts(java.lang.Integer i)
Sets the number of connection attempts to make.void
setConnectionRetryInterval(TimeInterval interval)
Set the interval between each retry attempt.-
Methods inherited from class com.adaptris.core.AdaptrisConnectionImp
addExceptionListener, addMessageConsumer, addMessageProducer, changeState, cloneForTesting, close, closeConnection, connectionErrorHandler, getConnectionErrorHandler, getUniqueId, getWorkersFirstOnShutdown, init, initConnection, prepare, prepareConnection, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, retrieveConnection, retrieveExceptionListeners, retrieveMessageConsumers, retrieveMessageProducers, setConnectionErrorHandler, setUniqueId, setWorkersFirstOnShutdown, start, startConnection, stop, stopConnection, workersFirstOnShutdown
-
-
-
-
Method Detail
-
setConnectionAttempts
public void setConnectionAttempts(java.lang.Integer i)
Sets the number of connection attempts to make. -1 means keep trying indefinitely.
- Parameters:
i
- the number of connection attempts to make
-
getConnectionAttempts
public java.lang.Integer getConnectionAttempts()
Returns the number of connection attempts to make.
- Returns:
- the number of connection attempts to make
-
connectionAttempts
public int connectionAttempts()
-
connectionRetryInterval
public long connectionRetryInterval()
Returns the wait between connection attempts in milliseconds.- Returns:
- the connection retry interval in ms.
-
logWarning
protected boolean logWarning(int attemptCount)
-
createLoggingStatement
protected java.lang.String createLoggingStatement(int attempt)
-
getConnectionRetryInterval
public TimeInterval getConnectionRetryInterval()
-
setConnectionRetryInterval
public void setConnectionRetryInterval(TimeInterval interval)
Set the interval between each retry attempt.- Parameters:
interval
- the interval between each retry attempt.
-
-