@ComponentProfile(summary="Channels bind two connections together for workflows to do their work", tag="base") public class Channel extends java.lang.Object implements ComponentLifecycleExtension, StateManagedComponentContainer, EventHandlerAware, ConfigComment
Links two AdaptrisConnection
implementations and has a WorkflowList
In the adapter configuration file this class is aliased as channel which is the preferred alternative to the fully qualified classname when building your configuration.
Modifier and Type | Field and Description |
---|---|
protected EventHandler |
eventHandler |
protected org.slf4j.Logger |
log |
protected java.util.Date |
startTime |
protected java.util.Date |
stopTime |
Constructor and Description |
---|
Channel()
Creates a new instance.
|
Channel(java.lang.String uid) |
Modifier and Type | Method and Description |
---|---|
void |
changeState(ComponentState s)
Updates the state for the component
ComponentState . |
void |
close()
Closes the component.
|
java.lang.Boolean |
getAutoStart() |
java.lang.String |
getComments() |
AdaptrisConnection |
getConsumeConnection()
Returns the
AdaptrisConnection used for consuming. |
ProcessingExceptionHandler |
getMessageErrorHandler()
Returns the
MessageErrorHandler to use. |
AdaptrisConnection |
getProduceConnection()
Returns the
AdaptrisConnection used for producing. |
java.lang.String |
getUniqueId()
Get the unique id of this channel.
|
WorkflowList |
getWorkflowList()
Returns the
WorkflowList to use. |
boolean |
hasUniqueId()
Check if this channel has a unique Id.
|
void |
init()
Initialises the component.
|
boolean |
isAvailable()
Returns
true if this Channel is available. |
java.util.Date |
lastStartTime()
Get the last time this channel was started
|
java.util.Date |
lastStopTime()
Get the last time this channel was stopped.
|
void |
prepare()
Prepare for initialisation.
|
void |
registerActiveMsgErrorHandler(ProcessingExceptionHandler m)
Register the active
MessageErrorHandler for this Channel. |
void |
registerEventHandler(EventHandler eh)
Register the current event handler against this component.
|
void |
requestChildClose()
Close any independent sub components.
|
void |
requestChildInit()
Initialise any independent sub-components.
|
void |
requestChildStart()
Start any independent sub components.
|
void |
requestChildStop()
Stop any independent sub components.
|
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.
|
ProcessingExceptionHandler |
retrieveActiveMsgErrorHandler()
Return the active
MessageErrorHandler for this Channel. |
ComponentState |
retrieveComponentState()
This method is not
synchronized and returns the 'last recorded' state of this object. |
void |
setAutoStart(java.lang.Boolean autoStart)
Specify whether or not to auto-start the channel.
|
void |
setComments(java.lang.String s) |
void |
setConsumeConnection(AdaptrisConnection connection)
Sets the
AdaptrisConnection to use for consuming. |
void |
setMessageErrorHandler(ProcessingExceptionHandler errorHandler)
Sets the
MessageErrorHandler to use. |
void |
setProduceConnection(AdaptrisConnection connection)
Sets the
AdaptrisConnection to use for producing. |
void |
setUniqueId(java.lang.String string)
Set the unique id of this channel.
|
void |
setWorkflowList(WorkflowList workflows)
Sets the
WorkflowList to use. |
boolean |
shouldStart() |
void |
start()
Starts the component.
|
void |
stop()
Stop the component
|
void |
toggleAvailability(boolean b)
Set whether this
Channel is available. |
protected transient org.slf4j.Logger log
protected transient EventHandler eventHandler
protected transient java.util.Date startTime
protected transient java.util.Date stopTime
public Channel()
Creates a new instance.
public Channel(java.lang.String uid)
public void prepare() throws CoreException
ComponentLifecycleExtension
prepare
in interface ComponentLifecycleExtension
CoreException
public void registerEventHandler(EventHandler eh)
EventHandlerAware
registerEventHandler
in interface EventHandlerAware
eh
- the event handler currently in use.public void changeState(ComponentState s)
StateManagedComponent
Updates the state for the component ComponentState
.
changeState
in interface StateManagedComponent
public void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
init
in interface ComponentLifecycle
CoreException
- wrapping any underlying Exception
sComponentLifecycle.init()
public 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
sComponentLifecycle.start()
public 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
ComponentLifecycle.stop()
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
ComponentLifecycle.close()
public void setConsumeConnection(AdaptrisConnection connection)
Sets the AdaptrisConnection
to use for consuming.
connection
- the AdaptrisConnection
to use for consuming, may not be nullpublic AdaptrisConnection getConsumeConnection()
Returns the AdaptrisConnection
used for consuming.
AdaptrisConnection
used for consumingpublic void setProduceConnection(AdaptrisConnection connection)
Sets the AdaptrisConnection
to use for producing.
connection
- the AdaptrisConnection
to use for producing, may not be nullpublic AdaptrisConnection getProduceConnection()
Returns the AdaptrisConnection
used for producing.
AdaptrisConnection
used for producingpublic void setWorkflowList(WorkflowList workflows)
Sets the WorkflowList
to use.
workflows
- the WorkflowList
to use, may not be nullpublic WorkflowList getWorkflowList()
Returns the WorkflowList
to use.
WorkflowList
to usepublic void setMessageErrorHandler(ProcessingExceptionHandler errorHandler)
Sets the MessageErrorHandler
to use.
errorHandler
- the MessageErrorHandler
to use, may not be nullpublic ProcessingExceptionHandler getMessageErrorHandler()
Returns the MessageErrorHandler
to use.
MessageErrorHandler
to usepublic boolean isAvailable()
Returns true
if this Channel
is available. A Channel
is available if i) it is not in the
process of being rebooted or ii) it has not failed to reboot.
true
if this Channel
is availablepublic void toggleAvailability(boolean b)
Set whether this Channel
is available.
b
- whether this Channel
is availablepublic void registerActiveMsgErrorHandler(ProcessingExceptionHandler m)
MessageErrorHandler
for this Channel.m
- the active MessageErrorHandler
public ProcessingExceptionHandler retrieveActiveMsgErrorHandler()
MessageErrorHandler
for this Channel.MessageErrorHandler
public java.lang.String getUniqueId()
Get the unique id of this channel.
getUniqueId
in interface AdaptrisComponent
public void setUniqueId(java.lang.String string)
Set the unique id of this channel. The channel's unique id allows it to be individually controlled, either by an event or by the Adapter container.
string
- the unique idpublic boolean hasUniqueId()
Check if this channel has a unique Id.
public void requestInit() throws CoreException
StateManagedComponent
Request this component is init'd.
requestInit
in interface StateManagedComponent
CoreException
- wrapping any underlying ExceptionsStateManagedComponent.requestInit()
public void requestStart() throws CoreException
StateManagedComponent
Request this component is started.
requestStart
in interface StateManagedComponent
CoreException
- wrapping any underlying ExceptionsStateManagedComponent.requestStart()
public void requestStop()
StateManagedComponent
Request this component is stopped.
requestStop
in interface StateManagedComponent
StateManagedComponent.requestStop()
public void requestClose()
StateManagedComponent
Request this component is closed.
requestClose
in interface StateManagedComponent
StateManagedComponent.requestClose()
public ComponentState retrieveComponentState()
This method is not synchronized
and returns the 'last recorded' state of this object.
retrieveComponentState
in interface StateManagedComponent
ComponentState
StateManagedComponent.retrieveComponentState()
public void requestChildInit() throws CoreException
StateManagedComponentContainer
requestChildInit
in interface StateManagedComponentContainer
CoreException
- wrapping any underlying ExceptionsStateManagedComponentContainer.requestChildInit()
public void requestChildStart() throws CoreException
StateManagedComponentContainer
requestChildStart
in interface StateManagedComponentContainer
CoreException
- wrapping any underlying ExceptionsStateManagedComponentContainer.requestChildStart()
public void requestChildStop()
StateManagedComponentContainer
requestChildStop
in interface StateManagedComponentContainer
StateManagedComponentContainer.requestChildStop()
public void requestChildClose()
StateManagedComponentContainer
requestChildClose
in interface StateManagedComponentContainer
StateManagedComponentContainer.requestChildClose()
public java.lang.Boolean getAutoStart()
public void setAutoStart(java.lang.Boolean autoStart)
If auto-start is set to false, then this channel is not started. This behaviour only occurs if the channel has a non-null/empty unique-id as otherwise you will not be able to start the channel through the standard JMX controls
autoStart
- default is true.public boolean shouldStart()
public java.util.Date lastStartTime()
public java.util.Date lastStopTime()
public void setComments(java.lang.String s)
setComments
in interface ConfigComment
public java.lang.String getComments()
getComments
in interface ConfigComment