public abstract class EventHandlerBase extends java.lang.Object implements EventHandler
Contains behaviour common to implementations of EventHandler
.
Modifier and Type | Class and Description |
---|---|
protected class |
EventHandlerBase.EventEmissary |
Modifier and Type | Field and Description |
---|---|
protected EventHandlerBase.EventEmissary |
eventProducerDelegate |
protected org.slf4j.Logger |
log |
Constructor and Description |
---|
EventHandlerBase()
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
changeState(ComponentState c)
Updates the state for the component
ComponentState . |
void |
close()
Closes the component.
|
protected AdaptrisMarshaller |
currentMarshaller() |
protected AdaptrisMessageFactory |
currentMessageFactory() |
protected abstract void |
eventHandlerClose() |
protected abstract void |
eventHandlerInit() |
protected abstract void |
eventHandlerStart() |
protected abstract void |
eventHandlerStop() |
java.lang.Boolean |
getLogAllExceptions() |
AdaptrisMarshaller |
getMarshaller() |
AdaptrisMessageFactory |
getMessageFactory() |
java.lang.Integer |
getShutdownWaitSeconds() |
java.lang.String |
getUniqueId()
Get the unique-id that is associated with this component.
|
void |
init()
Initialises the component.
|
void |
registerSourceId(java.lang.String s)
Sets the source id for this EventHandler.
|
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 . |
protected abstract AdaptrisMessageSender |
retrieveProducer() |
java.lang.String |
retrieveSourceId()
Retrieve the source id for this EventHandler.
|
void |
send(Event evt)
Send an
Event to the configured default destination. |
void |
send(Event evt,
java.util.Map<java.lang.String,java.lang.String> properties)
Send an
Event to the configured default destination. |
void |
send(Event evt,
ProduceDestination dest)
Send an
Event to the specified destination. |
void |
setLogAllExceptions(java.lang.Boolean logAllExceptions) |
void |
setMarshaller(AdaptrisMarshaller m)
Set the
AdaptrisMarshaller implementation to use when sending events. |
void |
setMessageFactory(AdaptrisMessageFactory f)
Set the message factory used when creating AdaptrisMessage instances.
|
void |
setShutdownWaitSeconds(java.lang.Integer i)
Set the number of seconds to wait when shutting down any internal threads.
|
void |
setUniqueId(java.lang.String s) |
void |
start()
Starts the component.
|
void |
stop()
Stop the component
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
prepare
protected transient org.slf4j.Logger log
protected transient EventHandlerBase.EventEmissary eventProducerDelegate
protected abstract AdaptrisMessageSender retrieveProducer() throws CoreException
CoreException
public void send(Event evt, ProduceDestination dest) throws CoreException
EventHandler
Send an Event
to the specified destination.
send
in interface EventHandler
evt
- the Event
to senddest
- the ProduceDestination
to send toCoreException
- wrapping any underlying Exceptionspublic void send(Event evt) throws CoreException
EventHandler
Send an Event
to the configured default destination.
send
in interface EventHandler
evt
- the Event
to sendCoreException
- wrapping any underlying Exceptionspublic void send(Event evt, java.util.Map<java.lang.String,java.lang.String> properties) throws CoreException
EventHandler
Send an Event
to the configured default destination.
send
in interface EventHandler
evt
- the Event
to sendproperties
- any additional properties that should be sent if possible.CoreException
- wrapping any underlying Exceptionspublic void setMarshaller(AdaptrisMarshaller m)
AdaptrisMarshaller
implementation to use when sending events.m
- the implementation to use, if null then DefaultMarshaller.getDefaultMarshaller()
is used.public AdaptrisMarshaller getMarshaller()
protected AdaptrisMarshaller currentMarshaller()
public void registerSourceId(java.lang.String s)
EventHandler
Sets the source id for this EventHandler. The source id may be used for routing or replying to events and is generally the
unique id of the Adapter
.
registerSourceId
in interface EventHandler
s
- the source id to be sent as part of the Event
EventHandler.registerSourceId(java.lang.String)
public java.lang.String retrieveSourceId()
EventHandler
Retrieve the source id for this EventHandler. The source id may be used for routing or replying to events and is generally the
unique id of the Adapter
.
retrieveSourceId
in interface EventHandler
protected AdaptrisMessageFactory currentMessageFactory() throws CoreException
CoreException
public AdaptrisMessageFactory getMessageFactory()
public void setMessageFactory(AdaptrisMessageFactory f)
f
- the messageFactory to setpublic ComponentState retrieveComponentState()
StateManagedComponent
Returns the last recorde ComponentState
.
retrieveComponentState
in interface StateManagedComponent
ComponentState
StateManagedComponent.retrieveComponentState()
public java.lang.Integer getShutdownWaitSeconds()
public void setShutdownWaitSeconds(java.lang.Integer i)
i
- the number of seconds, default if not specified is 60public java.lang.String getUniqueId()
AdaptrisComponent
getUniqueId
in interface AdaptrisComponent
AdaptrisComponent.getUniqueId()
public void setUniqueId(java.lang.String s)
AdaptrisComponent.getUniqueId()
public void changeState(ComponentState c)
StateManagedComponent
Updates the state for the component ComponentState
.
changeState
in interface StateManagedComponent
public final void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
init
in interface ComponentLifecycle
CoreException
- wrapping any underlying Exception
sprotected abstract void eventHandlerInit() throws CoreException
CoreException
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()
protected abstract void eventHandlerStart() throws CoreException
CoreException
protected abstract void eventHandlerStop()
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()
protected abstract void eventHandlerClose()
public java.lang.Boolean getLogAllExceptions()
public void setLogAllExceptions(java.lang.Boolean logAllExceptions)
logAllExceptions
- the logAllExceptions to setpublic 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()