@ComponentProfile(summary="A Connection that refers to another connection configured elsewhere", tag="connections,base") public class SharedConnection extends SharedComponent implements AdaptrisConnection
SharedComponentList
.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 and Description |
---|
SharedConnection() |
SharedConnection(java.lang.String lookupName) |
Modifier and Type | Method and Description |
---|---|
void |
addExceptionListener(StateManagedComponent comp)
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 newState)
Updates the state for the component
ComponentState . |
AdaptrisConnection |
cloneForTesting()
Make a copy of this object for test purposes.
|
void |
close()
Closes the component.
|
ConnectionErrorHandler |
connectionErrorHandler()
Returns the currently active
ConnectionErrorHandler |
ConnectionErrorHandler |
getConnectionErrorHandler()
Returns the configured
ConnectionErrorHandler . |
java.lang.String |
getLookupName()
Returns the exact name to bind this object to our
Context . |
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 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
AdaptrisMessageConsumer s. |
java.util.Set<AdaptrisMessageProducer> |
retrieveMessageProducers()
Returns a
List of this connection's
AdaptrisMessageProducer s. |
void |
setConnectionErrorHandler(ConnectionErrorHandler handler)
Sets the
ConnectionErrorHandler 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
|
triggerJndiLookup
public SharedConnection()
public SharedConnection(java.lang.String lookupName)
public void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
init
in interface ComponentLifecycle
CoreException
- wrapping any underlying Exception
spublic 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 ComponentLifecycle
CoreException
- wrapping any underlying Exception
spublic 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 ComponentLifecycle
public 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 ComponentLifecycle
public void changeState(ComponentState newState)
StateManagedComponent
Updates the state for the component ComponentState
.
changeState
in interface StateManagedComponent
public ComponentState retrieveComponentState()
StateManagedComponent
Returns the last recorde ComponentState
.
retrieveComponentState
in interface StateManagedComponent
ComponentState
public void requestInit() throws CoreException
StateManagedComponent
Request this component is init'd.
requestInit
in interface StateManagedComponent
CoreException
- wrapping any underlying Exceptionspublic void requestStart() throws CoreException
StateManagedComponent
Request this component is started.
requestStart
in interface StateManagedComponent
CoreException
- wrapping any underlying Exceptionspublic void requestStop()
StateManagedComponent
Request this component is stopped.
requestStop
in interface StateManagedComponent
public void requestClose()
StateManagedComponent
Request this component is closed.
requestClose
in interface StateManagedComponent
public java.lang.String getUniqueId()
AdaptrisComponent
getUniqueId
in interface AdaptrisComponent
public java.util.Set<StateManagedComponent> retrieveExceptionListeners()
AdaptrisConnection
retrieveExceptionListeners
in interface AdaptrisConnection
ConnectionErrorHandler
public void addExceptionListener(StateManagedComponent comp)
AdaptrisConnection
addExceptionListener
in interface AdaptrisConnection
comp
- the component that will be notified.public void addMessageProducer(AdaptrisMessageProducer producer) throws CoreException
AdaptrisConnection
Adds a AdaptrisMessageProducer
to this connection's
internal store of message producers.
addMessageProducer
in interface AdaptrisConnection
producer
- the AdaptrisMessageProducer
to addCoreException
- wrapping any underlying Exception
spublic java.util.Set<AdaptrisMessageProducer> retrieveMessageProducers()
AdaptrisConnection
Returns a List
of this connection's
AdaptrisMessageProducer
s.
retrieveMessageProducers
in interface AdaptrisConnection
List
of this connection's
AdaptrisMessageProducer
spublic void addMessageConsumer(AdaptrisMessageConsumer consumer) throws CoreException
AdaptrisConnection
Adds a AdaptrisMessageConsumer
to this connection's
internal store of message consumers.
addMessageConsumer
in interface AdaptrisConnection
consumer
- the AdaptrisMessageConsumer
to addCoreException
- wrapping any underlying Exception
spublic java.util.Set<AdaptrisMessageConsumer> retrieveMessageConsumers()
AdaptrisConnection
Returns a List
of this connection's
AdaptrisMessageConsumer
s.
retrieveMessageConsumers
in interface AdaptrisConnection
List
of this connection's
AdaptrisMessageConsumer
spublic void setConnectionErrorHandler(ConnectionErrorHandler handler)
AdaptrisConnection
ConnectionErrorHandler
to use.setConnectionErrorHandler
in interface AdaptrisConnection
public ConnectionErrorHandler getConnectionErrorHandler()
AdaptrisConnection
ConnectionErrorHandler
.getConnectionErrorHandler
in interface AdaptrisConnection
public ConnectionErrorHandler connectionErrorHandler()
AdaptrisConnection
ConnectionErrorHandler
connectionErrorHandler
in interface AdaptrisConnection
ConnectionErrorHandler
, which may not be the same as the configured...public <T> T retrieveConnection(java.lang.Class<T> type)
AdaptrisConnection
retrieveConnection
in interface AdaptrisConnection
type
- the type of connectionpublic java.lang.String getLookupName()
JndiBindable
Context
.
Specifying a lookupName will not be modified at all when binding to jndi. Therefore you may want to prepend your own chosen subcontexts in this name e.g. "comp/env/"
getLookupName
in interface JndiBindable
public void setLookupName(java.lang.String jndiName)
jndiName
- the namepublic void prepare() throws CoreException
ComponentLifecycleExtension
prepare
in interface ComponentLifecycleExtension
CoreException
public AdaptrisConnection cloneForTesting() throws CoreException
AdaptrisConnection
cloneForTesting
in interface AdaptrisConnection
CoreException
- wrapping any exceptions