public abstract class AbstractEventProcessor extends Object implements EventProcessor, org.springframework.beans.factory.BeanNameAware
event processor
implementations
Read 'good practice'
notes for documenting behaviour.Modifier and Type | Field and Description |
---|---|
protected static boolean |
DEFAULT_CHART |
protected static boolean |
DEFAULT_PROPAGATE_SESSION_ID |
protected static long |
DEFAULT_WARN_DELAY |
protected org.apache.commons.logging.Log |
logger
Resource for derived classes to use for logging
|
Constructor and Description |
---|
AbstractEventProcessor()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
long |
getWarnDelay()
Provide a hint for the processing framework on how much time should elapse before
the warnings need to be issued over the delay
|
boolean |
isChart()
Hint whether the result should be included in charts
|
protected abstract EventResult |
processEvent(Event event)
Process an event.
|
EventResult |
processEvent(Event event,
org.apache.commons.lang3.time.StopWatch stopWatch)
Process an event.
|
void |
propagateSessionId(Event event,
Event nextEvent)
Called by the framework after
event processing
and just prior to publishing an event to the event queue. |
void |
register()
Register this instance for the event names that are handled.
|
protected long |
resumeTimer()
Continue timing the event processing
|
void |
setBeanName(String beanName) |
void |
setChart(boolean chart) |
void |
setEventName(String eventName)
Set the single event name that this processor can handle
|
void |
setEventNames(List<String> eventNames)
Set the names of the events that this processor can handle
|
void |
setPropagateSessionId(boolean propagateSessionId)
Change the
default session ID propagation
behaviour |
void |
setRegistry(EventProcessorRegistry registry)
Inject the registry that this instance will
register with. |
void |
setWarnDelay(long warnDelay) |
protected long |
stopTimer()
Stop timing the event processing.
|
protected long |
suspendTimer()
Suspend the event processing timer.
|
String |
toString() |
protected static final long DEFAULT_WARN_DELAY
protected static final boolean DEFAULT_CHART
protected static final boolean DEFAULT_PROPAGATE_SESSION_ID
protected org.apache.commons.logging.Log logger
public void setBeanName(String beanName)
setBeanName
in interface org.springframework.beans.factory.BeanNameAware
public void setEventName(String eventName)
public void setEventNames(List<String> eventNames)
public void setRegistry(EventProcessorRegistry registry)
register
with.public long getWarnDelay()
EventProcessor
getWarnDelay
in interface EventProcessor
DEFAULT_WARN_DELAY
)public void setWarnDelay(long warnDelay)
warnDelay
- the time allowed for processing before a warning is loggedgetWarnDelay()
public boolean isChart()
EventProcessor
isChart
in interface EventProcessor
public void setChart(boolean chart)
chart
- true to tag results for chartingisChart()
public void setPropagateSessionId(boolean propagateSessionId)
default
session ID propagation
behaviourpropagateSessionId
- true to propagate session IDs to all new events
otherwise falsepublic void propagateSessionId(Event event, Event nextEvent)
event processing
and just prior to publishing an event to the event queue.
The default behaviour is determined by the
session propagation flag
but implementations
can override the behaviour on a case-by-case basis.
Implementations can make use of the SessionService
for creating new sessions,
the details of which can then be attached to the next event(s).propagateSessionId
in interface EventProcessor
event
- the original eventnextEvent
- a new event (possibly one of many)public void register()
protected long suspendTimer()
IllegalStateException
- if the timer is not runningprotected long resumeTimer()
IllegalStateException
- if the timer is is not suspendedprotected long stopTimer()
IllegalStateException
- if the timer is is not running or suspendedpublic final EventResult processEvent(Event event, org.apache.commons.lang3.time.StopWatch stopWatch) throws Exception
StopWatch.start()
and StopWatch.stop()
the timer to better reflect actual event processing.
The implementation overrides this method to store the StopWatch
in a thread-local.processEvent
in interface EventProcessor
event
- the event (along with associated data)stopWatch
- the timer that will be used or null to have one
created and attached to the process automaticallyException
protected abstract EventResult processEvent(Event event) throws Exception
event
- the event (along with associated data)Exception
suspendTimer()
,
resumeTimer()
,
stopTimer()
Copyright © 2014. All rights reserved.