public abstract class AdaptrisConnectionImp extends java.lang.Object implements AdaptrisConnection, StateManagedComponent
Contains behaviour common to implementations of AdaptrisConnection.
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
log |
| Constructor and Description |
|---|
AdaptrisConnectionImp()
Created a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addExceptionListener(StateManagedComponent c)
Add a component that will be notified upon exception.
|
void |
addMessageConsumer(AdaptrisMessageConsumer consumer)
Adds a
AdaptrisMessageConsumer to this connection's
internal store of message consumers. |
void |
addMessageProducer(AdaptrisMessageProducer producer)
Adds a
AdaptrisMessageProducer to this connection's
internal store of message producers. |
void |
changeState(ComponentState s)
Updates the state for the component
ComponentState. |
AdaptrisConnection |
cloneForTesting()
Make a copy of this object for test purposes.
|
void |
close()
Closes the component.
|
protected abstract void |
closeConnection()
Close the underlying connection.
|
ConnectionErrorHandler |
connectionErrorHandler()
Returns the currently active
ConnectionErrorHandler |
ConnectionErrorHandler |
getConnectionErrorHandler()
Returns the configured
ConnectionErrorHandler. |
java.lang.String |
getUniqueId()
Get the unique-id that is associated with this component.
|
java.lang.Boolean |
getWorkersFirstOnShutdown() |
void |
init()
Initialises the component.
|
protected abstract void |
initConnection()
Initialise the underlying connection.
|
void |
prepare()
Prepare for initialisation.
|
protected abstract void |
prepareConnection() |
void |
requestClose()
Request this component is closed.
|
void |
requestInit()
Request this component is init'd.
|
void |
requestStart()
Request this component is started.
|
void |
requestStop()
Request this component is stopped.
|
ComponentState |
retrieveComponentState()
Returns the last recorde
ComponentState. |
<T> T |
retrieveConnection(java.lang.Class<T> type)
Return the connection as represented by this connection
|
java.util.Set<StateManagedComponent> |
retrieveExceptionListeners()
Return a collection of components that need to be restarted on exception.
|
java.util.Set<AdaptrisMessageConsumer> |
retrieveMessageConsumers()
Returns a
List of this connection's
AdaptrisMessageConsumers. |
java.util.Set<AdaptrisMessageProducer> |
retrieveMessageProducers()
Returns a
List of this connection's
AdaptrisMessageProducers. |
void |
setConnectionErrorHandler(ConnectionErrorHandler handler)
Sets the
ConnectionErrorHandler to use. |
void |
setUniqueId(java.lang.String s) |
void |
setWorkersFirstOnShutdown(java.lang.Boolean b)
Perform consumer and producer lifecycle shutdown prior to connection shutdown.
|
void |
start()
Starts the component.
|
protected abstract void |
startConnection()
Start the underlying connection.
|
void |
stop()
Stop the component
|
protected abstract void |
stopConnection()
Stop the underlying connection.
|
boolean |
workersFirstOnShutdown() |
public final void init()
throws CoreException
ComponentLifecycleComponent initialisation includes config verification, creation of connections etc.
init in interface ComponentLifecycleCoreException - wrapping any underlying ExceptionsComponentLifecycle.init()public final void prepare()
throws CoreException
ComponentLifecycleExtensionprepare in interface ComponentLifecycleExtensionCoreExceptionprotected abstract void prepareConnection()
throws CoreException
CoreExceptionpublic final void start()
throws CoreException
ComponentLifecycle
Once a component is started it should be ready to process messages. In the case of AdaptrisMessageConsumer, calling start
will begin message delivery.
start in interface ComponentLifecycleCoreException - wrapping any underlying ExceptionsComponentLifecycle.start()public final void close()
ComponentLifecycle
A closed component should release any connections it uses, etc. and clean up completely. Throwing a RuntimeException may
cause unintended consequences
close in interface ComponentLifecycleComponentLifecycle.close()public final void stop()
ComponentLifecycle
A stopped component is not expected to be ready to process messages. In the case of AdaptrisMessageConsumer, calling stop
will pause message delivery. Throwing a RuntimeException may cause unintended consequences
stop in interface ComponentLifecycleComponentLifecycle.stop()protected abstract void initConnection()
throws CoreException
CoreException - wrapping any exception.protected abstract void startConnection()
throws CoreException
CoreException - wrapping any exception.protected abstract void stopConnection()
protected abstract void closeConnection()
public void addExceptionListener(StateManagedComponent c)
AdaptrisConnectionaddExceptionListener in interface AdaptrisConnectionc - the component that will be notified.public java.util.Set<StateManagedComponent> retrieveExceptionListeners()
AdaptrisConnectionretrieveExceptionListeners in interface AdaptrisConnectionConnectionErrorHandlerpublic void addMessageProducer(AdaptrisMessageProducer producer) throws CoreException
AdaptrisConnection
Adds a AdaptrisMessageProducer to this connection's
internal store of message producers.
addMessageProducer in interface AdaptrisConnectionproducer - the AdaptrisMessageProducer to addCoreException - wrapping any underlying Exceptions#addMessageProducer(com.adaptris.core.AdaptrisMessageProducer)public java.util.Set<AdaptrisMessageProducer> retrieveMessageProducers()
AdaptrisConnection
Returns a List of this connection's
AdaptrisMessageProducers.
retrieveMessageProducers in interface AdaptrisConnectionList of this connection's
AdaptrisMessageProducersAdaptrisConnection.retrieveMessageProducers()public void addMessageConsumer(AdaptrisMessageConsumer consumer) throws CoreException
AdaptrisConnection
Adds a AdaptrisMessageConsumer to this connection's
internal store of message consumers.
addMessageConsumer in interface AdaptrisConnectionconsumer - the AdaptrisMessageConsumer to addCoreException - wrapping any underlying Exceptions#addMessageConsumer(com.adaptris.core.AdaptrisMessageConsumer)public java.util.Set<AdaptrisMessageConsumer> retrieveMessageConsumers()
AdaptrisConnection
Returns a List of this connection's
AdaptrisMessageConsumers.
retrieveMessageConsumers in interface AdaptrisConnectionList of this connection's
AdaptrisMessageConsumersAdaptrisConnection.retrieveMessageConsumers()public void setConnectionErrorHandler(ConnectionErrorHandler handler)
AdaptrisConnectionConnectionErrorHandler to use.setConnectionErrorHandler in interface AdaptrisConnection#setConnectionErrorHandler(com.adaptris.core.ConnectionErrorHandler)public ConnectionErrorHandler getConnectionErrorHandler()
AdaptrisConnectionConnectionErrorHandler.getConnectionErrorHandler in interface AdaptrisConnectionAdaptrisConnection.getConnectionErrorHandler()public ConnectionErrorHandler connectionErrorHandler()
AdaptrisConnectionConnectionErrorHandlerconnectionErrorHandler in interface AdaptrisConnectionConnectionErrorHandler, which may not be the same as the configured...public java.lang.Boolean getWorkersFirstOnShutdown()
public boolean workersFirstOnShutdown()
public void setWorkersFirstOnShutdown(java.lang.Boolean b)
When set to true, this method forces the AdaptrisConnection to stop and close any registered MessageConsumer and MessageProducer implementations before attempting to stop and close the underlying Connection. This is useful in cases where shutting down the Connection blocks until all attached workers are manually closed (WebsphereMQ)
When set to false, existing behaviour is preserved, and the consumers and producers are shutdown as part of the normal workflow lifecycle.
b - true to shutdown workers prior to connection shutdown, default is false.public <T> T retrieveConnection(java.lang.Class<T> type)
retrieveConnection in interface AdaptrisConnectiontype - the type of connectionpublic java.lang.String getUniqueId()
AdaptrisComponentgetUniqueId in interface AdaptrisComponentpublic void setUniqueId(java.lang.String s)
public void changeState(ComponentState s)
StateManagedComponent
Updates the state for the component ComponentState.
changeState in interface StateManagedComponentpublic void requestInit()
throws CoreException
StateManagedComponentRequest this component is init'd.
requestInit in interface StateManagedComponentCoreException - wrapping any underlying ExceptionsStateManagedComponent.requestInit()public void requestStart()
throws CoreException
StateManagedComponentRequest this component is started.
requestStart in interface StateManagedComponentCoreException - wrapping any underlying ExceptionsStateManagedComponent.requestStart()public void requestStop()
StateManagedComponentRequest this component is stopped.
requestStop in interface StateManagedComponentStateManagedComponent.requestStop()public void requestClose()
StateManagedComponentRequest this component is closed.
requestClose in interface StateManagedComponentStateManagedComponent.requestClose()public ComponentState retrieveComponentState()
StateManagedComponent
Returns the last recorde ComponentState.
retrieveComponentState in interface StateManagedComponentComponentStatepublic AdaptrisConnection cloneForTesting() throws CoreException
AdaptrisConnectioncloneForTesting in interface AdaptrisConnectionCoreException - wrapping any exceptions