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 AdaptrisConnection
A 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 void
addExceptionListener(StateManagedComponent comp)
Add a component that will be notified upon exception.void
addMessageConsumer(AdaptrisMessageConsumer consumer)
Adds aAdaptrisMessageConsumer
to this connection's internal store of message consumers.void
addMessageProducer(AdaptrisMessageProducer producer)
Adds aAdaptrisMessageProducer
to this connection's internal store of message producers.void
changeState(ComponentState newState)
Updates the state for the componentComponentState
.AdaptrisConnection
cloneForTesting()
Make a copy of this object for test purposes.void
close()
Closes the component.ConnectionErrorHandler
connectionErrorHandler()
Returns the currently activeConnectionErrorHandler
ConnectionErrorHandler
getConnectionErrorHandler()
Returns the configuredConnectionErrorHandler
.java.lang.String
getLookupName()
java.lang.String
getUniqueId()
Get the unique-id that is associated with this component.void
init()
Initialises the component.void
prepare()
Prepare for initialisation.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 recordeComponentState
.<T> T
retrieveConnection(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 aList
of this connection'sAdaptrisMessageConsumer
s.java.util.Set<AdaptrisMessageProducer>
retrieveMessageProducers()
Returns aList
of this connection'sAdaptrisMessageProducer
s.void
setConnectionErrorHandler(ConnectionErrorHandler handler)
Sets theConnectionErrorHandler
to use.void
setLookupName(java.lang.String jndiName)
Set the unique-id of the connection that we will lookup.void
start()
Starts the component.void
stop()
Stop the component-
Methods inherited from class com.adaptris.core.SharedComponent
triggerJndiLookup
-
-
-
-
Method Detail
-
init
public void init() throws CoreException
Description copied from interface:ComponentLifecycle
Initialises the component.Component initialisation includes config verification, creation of connections etc.
- Specified by:
init
in interfaceComponentLifecycle
- Throws:
CoreException
- wrapping any underlyingException
s
-
start
public void start() throws CoreException
Description copied from interface:ComponentLifecycle
Starts 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:
start
in interfaceComponentLifecycle
- Throws:
CoreException
- wrapping any underlyingException
s
-
stop
public void stop()
Description copied from interface:ComponentLifecycle
Stop 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 aRuntimeException
may cause unintended consequences- Specified by:
stop
in interfaceComponentLifecycle
-
close
public void close()
Description copied from interface:ComponentLifecycle
Closes the component.A closed component should release any connections it uses, etc. and clean up completely. Throwing a
RuntimeException
may cause unintended consequences- Specified by:
close
in interfaceComponentLifecycle
-
changeState
public void changeState(ComponentState newState)
Description copied from interface:StateManagedComponent
Updates the state for the component
ComponentState
.- Specified by:
changeState
in interfaceStateManagedComponent
-
retrieveComponentState
public ComponentState retrieveComponentState()
Description copied from interface:StateManagedComponent
Returns the last recorde
ComponentState
.- Specified by:
retrieveComponentState
in interfaceStateManagedComponent
- Returns:
- the current
ComponentState
-
requestInit
public void requestInit() throws CoreException
Description copied from interface:StateManagedComponent
Request this component is init'd.
- Specified by:
requestInit
in interfaceStateManagedComponent
- Throws:
CoreException
- wrapping any underlying Exceptions
-
requestStart
public void requestStart() throws CoreException
Description copied from interface:StateManagedComponent
Request this component is started.
- Specified by:
requestStart
in interfaceStateManagedComponent
- Throws:
CoreException
- wrapping any underlying Exceptions
-
requestStop
public void requestStop()
Description copied from interface:StateManagedComponent
Request this component is stopped.
- Specified by:
requestStop
in interfaceStateManagedComponent
-
requestClose
public void requestClose()
Description copied from interface:StateManagedComponent
Request this component is closed.
- Specified by:
requestClose
in interfaceStateManagedComponent
-
getUniqueId
public java.lang.String getUniqueId()
Description copied from interface:AdaptrisComponent
Get the unique-id that is associated with this component.- Specified by:
getUniqueId
in interfaceAdaptrisComponent
- Returns:
- the unique-id
-
retrieveExceptionListeners
public java.util.Set<StateManagedComponent> retrieveExceptionListeners()
Description copied from interface:AdaptrisConnection
Return a collection of components that need to be restarted on exception.- Specified by:
retrieveExceptionListeners
in 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:AdaptrisConnection
Add a component that will be notified upon exception.- Specified by:
addExceptionListener
in interfaceAdaptrisConnection
- Parameters:
comp
- the component that will be notified.
-
addMessageProducer
public void addMessageProducer(AdaptrisMessageProducer producer) throws CoreException
Description copied from interface:AdaptrisConnection
Adds a
AdaptrisMessageProducer
to this connection's internal store of message producers.- Specified by:
addMessageProducer
in interfaceAdaptrisConnection
- Parameters:
producer
- theAdaptrisMessageProducer
to add- Throws:
CoreException
- wrapping any underlyingException
s
-
retrieveMessageProducers
public java.util.Set<AdaptrisMessageProducer> retrieveMessageProducers()
Description copied from interface:AdaptrisConnection
Returns a
List
of this connection'sAdaptrisMessageProducer
s.- Specified by:
retrieveMessageProducers
in interfaceAdaptrisConnection
- Returns:
- a
List
of this connection'sAdaptrisMessageProducer
s
-
addMessageConsumer
public void addMessageConsumer(AdaptrisMessageConsumer consumer) throws CoreException
Description copied from interface:AdaptrisConnection
Adds a
AdaptrisMessageConsumer
to this connection's internal store of message consumers.- Specified by:
addMessageConsumer
in interfaceAdaptrisConnection
- Parameters:
consumer
- theAdaptrisMessageConsumer
to add- Throws:
CoreException
- wrapping any underlyingException
s
-
retrieveMessageConsumers
public java.util.Set<AdaptrisMessageConsumer> retrieveMessageConsumers()
Description copied from interface:AdaptrisConnection
Returns a
List
of this connection'sAdaptrisMessageConsumer
s.- Specified by:
retrieveMessageConsumers
in interfaceAdaptrisConnection
- Returns:
- a
List
of this connection'sAdaptrisMessageConsumer
s
-
setConnectionErrorHandler
public void setConnectionErrorHandler(ConnectionErrorHandler handler)
Description copied from interface:AdaptrisConnection
Sets theConnectionErrorHandler
to use.- Specified by:
setConnectionErrorHandler
in interfaceAdaptrisConnection
-
getConnectionErrorHandler
public ConnectionErrorHandler getConnectionErrorHandler()
Description copied from interface:AdaptrisConnection
Returns the configuredConnectionErrorHandler
.- Specified by:
getConnectionErrorHandler
in interfaceAdaptrisConnection
-
connectionErrorHandler
public ConnectionErrorHandler connectionErrorHandler()
Description copied from interface:AdaptrisConnection
Returns the currently activeConnectionErrorHandler
- Specified by:
connectionErrorHandler
in 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:AdaptrisConnection
Return the connection as represented by this connection- Specified by:
retrieveConnection
in 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 CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Throws:
CoreException
-
cloneForTesting
public AdaptrisConnection cloneForTesting() throws CoreException
Description copied from interface:AdaptrisConnection
Make a copy of this object for test purposes.- Specified by:
cloneForTesting
in interfaceAdaptrisConnection
- Returns:
- a copy of this object
- Throws:
CoreException
- wrapping any exceptions
-
-