public abstract class EventProcessor<T extends Event<T,E,S>,E extends Enum<E>,S extends Enum<S>> extends Thread implements Source<T,S>, Handler<T>, Closeable
BlockingQueue.take()
(fetch), Event.getSource()
(see who it's from), Source.getHandler()
(see how the source wishes to process events), and
Handler.handle(Object)
(process the event).Thread.State, Thread.UncaughtExceptionHandler
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
EventProcessor(String name)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
checkCurrentThread()
Checks that
Thread.currentThread() is indeed this thread. |
void |
close()
Stops this thread.
|
protected void |
doCatch(Throwable t)
Runs the exception handler, should anything go awry in the processing loop.
|
protected void |
doFinally()
Runs the finalizer, which executes on termination of the processing loop and possibly exception handler.
|
Handler<T> |
getHandler()
|
void |
onLocal(T evt)
Delivers an
Event to the local manifestation. |
void |
onRemote(T evt)
Delivers an
Event to the remote manifestation. |
void |
run()
Runs the event processing loop.
|
void |
setHandler(Handler<T> handler)
|
String |
toString()
Creates a human-readable representation of this thread.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
public EventProcessor(String name)
public void onLocal(T evt)
SourceLocal
Event
to the local manifestation.public void close()
public String toString()
public void checkCurrentThread()
Thread.currentThread()
is indeed this thread. Helpful for enforcing a serial event processing
model.public void run()
protected void doCatch(Throwable t)
protected void doFinally()
public void onRemote(T evt)
SourceRemote
Event
to the remote manifestation.