Class AdaptrisConnectionImp
- All Implemented Interfaces:
AdaptrisComponent,AdaptrisConnection,ComponentLifecycle,ComponentLifecycleExtension,StateManagedComponent
- Direct Known Subclasses:
AllowsRetriesConnection,CacheConnection,EmbeddedConnection,JettyConnection,NoOpConnection
Contains behaviour common to implementations of AdaptrisConnection.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a component that will be notified upon exception.voidaddMessageConsumer(AdaptrisMessageConsumer consumer) Adds aAdaptrisMessageConsumerto this connection's internal store of message consumers.voidaddMessageProducer(AdaptrisMessageProducer producer) Adds aAdaptrisMessageProducerto this connection's internal store of message producers.voidUpdates the state for the componentComponentState.Make a copy of this object for test purposes.final voidclose()Closes the component.protected abstract voidClose the underlying connection.Returns the currently activeConnectionErrorHandlerReturns the configuredConnectionErrorHandler.Get the unique-id that is associated with this component.final voidinit()Initialises the component.protected abstract voidInitialise the underlying connection.final voidprepare()Prepare for initialisation.protected abstract voidvoidRequest this component is closed.voidRequest this component is init'd.voidRequest this component is started.voidRequest this component is stopped.Returns the last recordeComponentState.<T> TretrieveConnection(Class<T> type) Return the connection as represented by this connectionReturn a collection of components that need to be restarted on exception.Returns aListof this connection'sAdaptrisMessageConsumers.Returns aListof this connection'sAdaptrisMessageProducers.voidSets theConnectionErrorHandlerto use.voidvoidPerform consumer and producer lifecycle shutdown prior to connection shutdown.final voidstart()Starts the component.protected abstract voidStart the underlying connection.final voidstop()Stop the componentprotected abstract voidStop the underlying connection.boolean
-
Field Details
-
log
protected transient org.slf4j.Logger log
-
-
Constructor Details
-
AdaptrisConnectionImp
public AdaptrisConnectionImp()Created a new instance.
-
-
Method Details
-
init
Description copied from interface:ComponentLifecycleInitialises the component.Component initialisation includes config verification, creation of connections etc.
- Specified by:
initin interfaceComponentLifecycle- Throws:
CoreException- wrapping any underlyingExceptions- See Also:
-
prepare
Description copied from interface:ComponentLifecycleExtensionPrepare for initialisation.- Specified by:
preparein interfaceComponentLifecycleExtension- Throws:
CoreException
-
prepareConnection
- Throws:
CoreException
-
start
Description copied from interface:ComponentLifecycleStarts the component.Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer, calling start will begin message delivery.- Specified by:
startin interfaceComponentLifecycle- Throws:
CoreException- wrapping any underlyingExceptions- See Also:
-
close
public final void close()Description copied from interface:ComponentLifecycleCloses the component.A closed component should release any connections it uses, etc. and clean up completely. Throwing a
RuntimeExceptionmay cause unintended consequences- Specified by:
closein interfaceComponentLifecycle- See Also:
-
stop
public final void stop()Description copied from interface:ComponentLifecycleStop the componentA stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer, calling stop will pause message delivery. Throwing aRuntimeExceptionmay cause unintended consequences- Specified by:
stopin interfaceComponentLifecycle- See Also:
-
initConnection
Initialise the underlying connection.- Throws:
CoreException- wrapping any exception.
-
startConnection
Start the underlying connection.- Throws:
CoreException- wrapping any exception.
-
stopConnection
protected abstract void stopConnection()Stop the underlying connection. -
closeConnection
protected abstract void closeConnection()Close the underlying connection. -
addExceptionListener
Description copied from interface:AdaptrisConnectionAdd a component that will be notified upon exception.- Specified by:
addExceptionListenerin interfaceAdaptrisConnection- Parameters:
c- the component that will be notified.
-
retrieveExceptionListeners
Description copied from interface:AdaptrisConnectionReturn a collection of components that need to be restarted on exception.- Specified by:
retrieveExceptionListenersin interfaceAdaptrisConnection- Returns:
- a list of Components that need to be restarted of any exceptions.
- See Also:
-
addMessageProducer
Description copied from interface:AdaptrisConnectionAdds a
AdaptrisMessageProducerto this connection's internal store of message producers.- Specified by:
addMessageProducerin interfaceAdaptrisConnection- Parameters:
producer- theAdaptrisMessageProducerto add- Throws:
CoreException- wrapping any underlyingExceptions- See Also:
-
retrieveMessageProducers
Description copied from interface:AdaptrisConnectionReturns a
Listof this connection'sAdaptrisMessageProducers.- Specified by:
retrieveMessageProducersin interfaceAdaptrisConnection- Returns:
- a
Listof this connection'sAdaptrisMessageProducers - See Also:
-
addMessageConsumer
Description copied from interface:AdaptrisConnectionAdds a
AdaptrisMessageConsumerto this connection's internal store of message consumers.- Specified by:
addMessageConsumerin interfaceAdaptrisConnection- Parameters:
consumer- theAdaptrisMessageConsumerto add- Throws:
CoreException- wrapping any underlyingExceptions- See Also:
-
retrieveMessageConsumers
Description copied from interface:AdaptrisConnectionReturns a
Listof this connection'sAdaptrisMessageConsumers.- Specified by:
retrieveMessageConsumersin interfaceAdaptrisConnection- Returns:
- a
Listof this connection'sAdaptrisMessageConsumers - See Also:
-
setConnectionErrorHandler
Description copied from interface:AdaptrisConnectionSets theConnectionErrorHandlerto use.- Specified by:
setConnectionErrorHandlerin interfaceAdaptrisConnection- See Also:
-
getConnectionErrorHandler
Description copied from interface:AdaptrisConnectionReturns the configuredConnectionErrorHandler.- Specified by:
getConnectionErrorHandlerin interfaceAdaptrisConnection- See Also:
-
connectionErrorHandler
Description copied from interface:AdaptrisConnectionReturns the currently activeConnectionErrorHandler- Specified by:
connectionErrorHandlerin interfaceAdaptrisConnection- Returns:
- the active
ConnectionErrorHandler, which may not be the same as the configured...
-
getWorkersFirstOnShutdown
- Returns:
- the workerLifecycleFirstOnShutdown
-
workersFirstOnShutdown
public boolean workersFirstOnShutdown()- Returns:
- the workerLifecycleFirstOnShutdown
-
setWorkersFirstOnShutdown
Perform consumer and producer lifecycle shutdown prior to connection shutdown.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.
- Parameters:
b- true to shutdown workers prior to connection shutdown, default is false.
-
retrieveConnection
Return the connection as represented by this connection- Specified by:
retrieveConnectionin interfaceAdaptrisConnection- Parameters:
type- the type of connection- Returns:
- the connection
-
getUniqueId
Description copied from interface:AdaptrisComponentGet the unique-id that is associated with this component.- Specified by:
getUniqueIdin interfaceAdaptrisComponent- Returns:
- the unique-id
-
setUniqueId
-
changeState
Description copied from interface:StateManagedComponentUpdates the state for the component
ComponentState.- Specified by:
changeStatein interfaceStateManagedComponent
-
requestInit
Description copied from interface:StateManagedComponentRequest this component is init'd.
- Specified by:
requestInitin interfaceStateManagedComponent- Throws:
CoreException- wrapping any underlying Exceptions- See Also:
-
requestStart
Description copied from interface:StateManagedComponentRequest this component is started.
- Specified by:
requestStartin interfaceStateManagedComponent- Throws:
CoreException- wrapping any underlying Exceptions- See Also:
-
requestStop
public void requestStop()Description copied from interface:StateManagedComponentRequest this component is stopped.
- Specified by:
requestStopin interfaceStateManagedComponent- See Also:
-
requestClose
public void requestClose()Description copied from interface:StateManagedComponentRequest this component is closed.
- Specified by:
requestClosein interfaceStateManagedComponent- See Also:
-
retrieveComponentState
Description copied from interface:StateManagedComponentReturns the last recorde
ComponentState.- Specified by:
retrieveComponentStatein interfaceStateManagedComponent- Returns:
- the current
ComponentState
-
cloneForTesting
Description copied from interface:AdaptrisConnectionMake a copy of this object for test purposes.- Specified by:
cloneForTestingin interfaceAdaptrisConnection- Returns:
- a copy of this object
- Throws:
CoreException- wrapping any exceptions
-