|
BEA Systems, Inc. | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.connecterra.util.event.AbstractEventProcessor
public class AbstractEventProcessor
This class encapsulates a common pattern of use of EventReceiver and EventProcessor. This class optionally
creates and then holds an EventReceiver instance, and implements
the EventProcessor interface. It provides a set of
protected methods for queueing Event instances on the
receiver which are then handled, either one at a time and in order,
or scheduled for the future, on threads in the Scheduler.
| Nested Class Summary | |
|---|---|
protected static class |
AbstractEventProcessor.PeriodicEventHandle
This class contains the state for a periodic event. |
| Method Summary | |
|---|---|
protected void |
doASAP(Event task)
Queues an Event immediately. |
protected void |
doASAPOrBlock(Event task)
Queues an Event immediately. |
protected void |
doASAPOrDrop(Event task)
Queues an Event immediately. |
protected void |
doASAPOrThrow(Event task)
Queues an Event immediately. |
protected void |
doLater(long delay,
Event task)
Queues an event to be handled after delay |
protected void |
doPeriodic(AbstractEventProcessor.PeriodicEventHandle handle,
long interval,
PeriodicEvent task)
Queues an event whose handler will be invoked every interval milliseconds until cancelled, by calling
the PeriodicEvent.stop() method on the event or by
calling doPeriodic again with the same
handle. |
protected EventReceiver |
getEventReceiver()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.connecterra.util.event.EventProcessor |
|---|
handleEvent |
| Method Detail |
|---|
protected EventReceiver getEventReceiver()
EventReceiver which handles queued
events.protected void doASAP(Event task)
Event immediately. Because this method
queues the event event if the queue is over the high water
mark, it should be avoided except when necessary. Instead,
AbstractEventProcessor.doASAPOrBlock(com.connecterra.util.event.Event), AbstractEventProcessor.doASAPOrThrow(com.connecterra.util.event.Event), or AbstractEventProcessor.doASAPOrDrop(com.connecterra.util.event.Event) should be used, depending on the appropriate
behavior for that event.
task - the Event to be queued
protected void doASAPOrBlock(Event task)
throws InterruptedException
Event immediately. If the queue is at or
above the high water mark, then the method blocks until the
queue shrinks below the high water mark.
task - the Event to be queued
InterruptedException - if the thread is interrupted
while the call is blocked waiting for the queue to shrink below
the high water mark.protected void doASAPOrDrop(Event task)
Event immediately. If the queue is at or
above the high water mark, then the event is silently dropped.
task - the Event to be queued
protected void doASAPOrThrow(Event task)
throws QueueFullException
Event immediately. If the queue is at or
above the high water mark, then QueueFullException is
thrown.
task - the Event to be queued
QueueFullException - if the queue is at or above the
high water mark
protected void doLater(long delay,
Event task)
delay
milliseconds. The AlarmClock instance passed to the
constructor or AbstractEventProcessor.initialize(com.connecterra.util.event.EventReceiver, com.connecterra.util.event.AlarmClock) method is used to perform
the delay.
- Parameters:
delay - the number of milliseconds in the future after
which the event will be queued.task - the Event to be handled later
- Throws:
IllegalStateException - if the AbstractEventProcessor was
created with no AlarmClock.
protected void doPeriodic(AbstractEventProcessor.PeriodicEventHandle handle,
long interval,
PeriodicEvent task)
interval milliseconds until cancelled, by calling
the PeriodicEvent.stop() method on the event or by
calling doPeriodic again with the same
handle.
The interval specifies the time between the start
of each successive invocation. For example, if the interval is
100 ms and the handler takes 12 ms to run, then the next
invocation will occur 88 ms after the previous one finishes.
If an invocation takes longer than the interval, then the next
invocation is queued immediately.
handle - a PeriodicEventHandle instanceinterval - the time in milliseconds between invocations of
the event handler.task - a PeriodicEvent value
|
Documentation is available at ${DOCSWEBROOT} Copyright 2007 BEA Systems Inc. |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||