|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object fulmine.AbstractLifeCycle fulmine.event.EventProcessor
public final class EventProcessor
A single-thread execution engine that takes IEvent
objects off a task
queue, finds the IEventListener
instances registered against the
IEventSource
that generated the event, determines if the event is
compatible with the events the listener can accept (see
IEventListener.getEventTypeFilter()
) and calls
IEventListener.update(IEvent)
if the event is compatible.
On shutdown via the AbstractLifeCycle.destroy()
method, a special event (
shutdownEvent
) is added to the processor's #events
. The
processor continues to process its event queue after the destroy method but
when the processor encounters the shutdown event, it shuts down and the
processor thread ceases execution. This technique allows the event queue to
be drained before the processor terminates. There may be some situations
where events that are generated during the context shutdown need to be
processed (e.g. UnsubscribeEvent
s may need to be handled by closing
external resources gracefully) and this delayed shutdown allows this to be
achieved.
Constructor Summary | |
---|---|
EventProcessor(String name,
IFulmineContext context)
Standard constructor for an event processor backed by a standard priority thread. |
|
EventProcessor(String name,
ThreadGroup threadGroup,
IFulmineContext context)
Constructor for an event processor backed by a thread of priority equal to the maximum priority of the thread group argument |
Method Summary | |
---|---|
protected void |
doDestroy()
Destroy the processor. |
protected void |
doStart()
Overridden in subclasses to perform custom logic on activation. |
static IEventFrameExecution |
getCurrentFrame()
Get the frame identifier of the event the processor is currently handling. |
protected AsyncLog |
getLog()
Get the log to use for the object hierarchy |
String |
getStackTrace()
Get the current stack trace for the EventProcessor |
void |
handleTask(IEvent task)
Handle the task. |
void |
queue(IEvent event)
Add the event onto the processor's queue |
String |
toString()
|
Methods inherited from class fulmine.AbstractLifeCycle |
---|
checkActive, destroy, finalize, isActive, start |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface fulmine.ILifeCycle |
---|
isActive, start |
Methods inherited from interface fulmine.IDestroyable |
---|
destroy |
Constructor Detail |
---|
public EventProcessor(String name, IFulmineContext context)
FulmineContext
normal priority
thread group.
name
- the name of the thread for the processorcontext
- the context this processor is associated withpublic EventProcessor(String name, ThreadGroup threadGroup, IFulmineContext context)
name
- the name of the thread for the processorthreadGroup
- the thread group for the thread, this also defines the
priority of the threadcontext
- the context this processor is associated withMethod Detail |
---|
public static final IEventFrameExecution getCurrentFrame()
IEventFrameExecution
of the event that is being
processed.public void handleTask(IEvent task)
ITaskHandler
handleTask
in interface ITaskHandler<IEvent>
task
- the task to processprotected AsyncLog getLog()
AbstractLifeCycle
getLog
in class AbstractLifeCycle
protected void doDestroy()
doDestroy
in class AbstractLifeCycle
protected void doStart()
AbstractLifeCycle
RuntimeException
or subclass
thereof. When this method is called, the AbstractLifeCycle.isActive()
method will
return true
.
doStart
in class AbstractLifeCycle
public void queue(IEvent event)
event
- the event to add the queuepublic String getStackTrace()
EventProcessor
String
of the current stack trace with each
stack call on a new linepublic String toString()
toString
in class AbstractLifeCycle
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |