Class SharedConnection
- java.lang.Object
-
- com.adaptris.core.SharedComponent
-
- com.adaptris.core.SharedConnection
-
- All Implemented Interfaces:
AdaptrisComponent,AdaptrisConnection,ComponentLifecycle,ComponentLifecycleExtension,StateManagedComponent
@ComponentProfile(summary="A Connection that refers to another connection configured elsewhere", tag="connections,base") public class SharedConnection extends SharedComponent implements AdaptrisConnectionA connection instance that references a connection made available viaSharedComponentList.In the adapter configuration file this class is aliased as shared-connection which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Constructor Summary
Constructors Constructor Description SharedConnection()SharedConnection(java.lang.String lookupName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddExceptionListener(StateManagedComponent comp)Add 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.voidchangeState(ComponentState newState)Updates the state for the componentComponentState.AdaptrisConnectioncloneForTesting()Make a copy of this object for test purposes.voidclose()Closes the component.ConnectionErrorHandlerconnectionErrorHandler()Returns the currently activeConnectionErrorHandlerConnectionErrorHandlergetConnectionErrorHandler()Returns the configuredConnectionErrorHandler.java.lang.StringgetLookupName()java.lang.StringgetUniqueId()Get the unique-id that is associated with this component.voidinit()Initialises the component.voidprepare()Prepare for initialisation.voidrequestClose()Request this component is closed.voidrequestInit()Request this component is init'd.voidrequestStart()Request this component is started.voidrequestStop()Request this component is stopped.ComponentStateretrieveComponentState()Returns the last recordeComponentState.<T> TretrieveConnection(java.lang.Class<T> type)Return the connection as represented by this connectionjava.util.Set<StateManagedComponent>retrieveExceptionListeners()Return a collection of components that need to be restarted on exception.java.util.Set<AdaptrisMessageConsumer>retrieveMessageConsumers()Returns aListof this connection'sAdaptrisMessageConsumers.java.util.Set<AdaptrisMessageProducer>retrieveMessageProducers()Returns aListof this connection'sAdaptrisMessageProducers.voidsetConnectionErrorHandler(ConnectionErrorHandler handler)Sets theConnectionErrorHandlerto use.voidsetLookupName(java.lang.String jndiName)Set the unique-id of the connection that we will lookup.voidstart()Starts the component.voidstop()Stop the component-
Methods inherited from class com.adaptris.core.SharedComponent
triggerJndiLookup
-
-
-
-
Method Detail
-
init
public void init() throws CoreExceptionDescription copied from interface:ComponentLifecycleInitialises the component.Component initialisation includes config verification, creation of connections etc.
- Specified by:
initin interfaceComponentLifecycle- Throws:
CoreException- wrapping any underlyingExceptions
-
start
public void start() throws CoreExceptionDescription 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
-
stop
public 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
-
close
public 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
-
changeState
public void changeState(ComponentState newState)
Description copied from interface:StateManagedComponentUpdates the state for the component
ComponentState.- Specified by:
changeStatein interfaceStateManagedComponent
-
retrieveComponentState
public ComponentState retrieveComponentState()
Description copied from interface:StateManagedComponentReturns the last recorde
ComponentState.- Specified by:
retrieveComponentStatein interfaceStateManagedComponent- Returns:
- the current
ComponentState
-
requestInit
public void requestInit() throws CoreExceptionDescription copied from interface:StateManagedComponentRequest this component is init'd.
- Specified by:
requestInitin interfaceStateManagedComponent- Throws:
CoreException- wrapping any underlying Exceptions
-
requestStart
public void requestStart() throws CoreExceptionDescription copied from interface:StateManagedComponentRequest this component is started.
- Specified by:
requestStartin interfaceStateManagedComponent- Throws:
CoreException- wrapping any underlying Exceptions
-
requestStop
public void requestStop()
Description copied from interface:StateManagedComponentRequest this component is stopped.
- Specified by:
requestStopin interfaceStateManagedComponent
-
requestClose
public void requestClose()
Description copied from interface:StateManagedComponentRequest this component is closed.
- Specified by:
requestClosein interfaceStateManagedComponent
-
getUniqueId
public java.lang.String getUniqueId()
Description copied from interface:AdaptrisComponentGet the unique-id that is associated with this component.- Specified by:
getUniqueIdin interfaceAdaptrisComponent- Returns:
- the unique-id
-
retrieveExceptionListeners
public java.util.Set<StateManagedComponent> 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:
ConnectionErrorHandler
-
addExceptionListener
public void addExceptionListener(StateManagedComponent comp)
Description copied from interface:AdaptrisConnectionAdd a component that will be notified upon exception.- Specified by:
addExceptionListenerin interfaceAdaptrisConnection- Parameters:
comp- the component that will be notified.
-
addMessageProducer
public void addMessageProducer(AdaptrisMessageProducer producer) throws CoreException
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
-
retrieveMessageProducers
public java.util.Set<AdaptrisMessageProducer> retrieveMessageProducers()
Description copied from interface:AdaptrisConnectionReturns a
Listof this connection'sAdaptrisMessageProducers.- Specified by:
retrieveMessageProducersin interfaceAdaptrisConnection- Returns:
- a
Listof this connection'sAdaptrisMessageProducers
-
addMessageConsumer
public void addMessageConsumer(AdaptrisMessageConsumer consumer) throws CoreException
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
-
retrieveMessageConsumers
public java.util.Set<AdaptrisMessageConsumer> retrieveMessageConsumers()
Description copied from interface:AdaptrisConnectionReturns a
Listof this connection'sAdaptrisMessageConsumers.- Specified by:
retrieveMessageConsumersin interfaceAdaptrisConnection- Returns:
- a
Listof this connection'sAdaptrisMessageConsumers
-
setConnectionErrorHandler
public void setConnectionErrorHandler(ConnectionErrorHandler handler)
Description copied from interface:AdaptrisConnectionSets theConnectionErrorHandlerto use.- Specified by:
setConnectionErrorHandlerin interfaceAdaptrisConnection
-
getConnectionErrorHandler
public ConnectionErrorHandler getConnectionErrorHandler()
Description copied from interface:AdaptrisConnectionReturns the configuredConnectionErrorHandler.- Specified by:
getConnectionErrorHandlerin interfaceAdaptrisConnection
-
connectionErrorHandler
public ConnectionErrorHandler 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...
-
retrieveConnection
public <T> T retrieveConnection(java.lang.Class<T> type)
Description copied from interface:AdaptrisConnectionReturn the connection as represented by this connection- Specified by:
retrieveConnectionin interfaceAdaptrisConnection- Parameters:
type- the type of connection- Returns:
- the connection
-
getLookupName
public java.lang.String getLookupName()
-
setLookupName
public void setLookupName(java.lang.String jndiName)
Set the unique-id of the connection that we will lookup.- Parameters:
jndiName- the name
-
prepare
public void prepare() throws CoreExceptionDescription copied from interface:ComponentLifecycleExtensionPrepare for initialisation.- Specified by:
preparein interfaceComponentLifecycleExtension- Throws:
CoreException
-
cloneForTesting
public AdaptrisConnection cloneForTesting() throws CoreException
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
-
-