|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enhydra.barracuda.core.event.DefaultDispatchQueue
The DispatchQueue as a relatively shortlived structure...the Queue would be created by the dispatcher, and it would be discarded when the events have been delivered. It should be made available to the listeners, however, so that they can add events to the queue if they'd like.
While the DispatchQueue interface views the queue as one list of events, the DefaultDispatchQueue is designed to be aware of two different kinds of events: Control events, and View events. This corresponds nicely with both the Http Req/Response model and the Model 2 Controller/View distinction.
This means that when you add an event to the queue, internally gets filtered into either a control list or a view list. Consequently, when iterating through the queue, you will always get all control events first, then you will get all view events. The DefaultEventDispatcher makes use of this distinction to implement a 2 phase event dispatch: request events are dispatched first, followed by response events.
The queue can also be used for a single phased dispatch by setting requiresResponse = false.
The queue is smart enough so that as you add events to it, duplicate events are collapsed together and redundancies are eliminated (ie. if I add 3 RepaintView events, they would be combined into one, which appears at the end of the queue).
As a final note, observe that not all of the methods are public. This is to limit BaseEventListener access: listeners add events to the queue, see what events are in the queue, and even mark them handled. But they cannot actually remove events from the queue. That duty belongs to the Event Dispatcher, which of necessity must be in the same package as the DispatchQueue in order to be able to access all methods.
Field Summary | |
protected java.util.List |
controlList
|
protected static org.apache.log4j.Logger |
logger
|
protected java.util.List |
procList
|
protected boolean |
requiresResponse
|
protected boolean |
responseHandled
|
protected java.util.List |
viewList
|
Constructor Summary | |
DefaultDispatchQueue(boolean irequiresResponse)
Public noargs constructor. |
Method Summary | |
void |
addEvent(BaseEvent baseEvent)
Adds an event to the queue. |
void |
dumpEventQueueToConsole(int targetDepth)
Dunp event queue to console for debugging purposes. |
java.util.List |
listProcessedEvents()
List events which have already been processed through the queue |
java.util.List |
listRemainingEvents()
List all events remaining in the queue (Request events first, then Response events) |
int |
numberOfEventsProcessed()
get the number of events that have been processed |
int |
numberOfEventsRemaining()
get the number of events remaining in the queue |
boolean |
requiresResponse()
Does this queue require a response? |
boolean |
responseHandled()
Has the response for this queue been handled? |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static org.apache.log4j.Logger logger
protected boolean requiresResponse
protected boolean responseHandled
protected java.util.List controlList
protected java.util.List viewList
protected java.util.List procList
Constructor Detail |
public DefaultDispatchQueue(boolean irequiresResponse)
irequiresResponse
- true if this queue requires a responseMethod Detail |
public boolean requiresResponse()
requiresResponse
in interface DispatchQueue
public boolean responseHandled()
responseHandled
in interface DispatchQueue
public void addEvent(BaseEvent baseEvent)
addEvent
in interface DispatchQueue
baseEvent
- the event to be added to the queuepublic int numberOfEventsRemaining()
numberOfEventsRemaining
in interface DispatchQueue
public java.util.List listRemainingEvents()
listRemainingEvents
in interface DispatchQueue
public int numberOfEventsProcessed()
numberOfEventsProcessed
in interface DispatchQueue
public java.util.List listProcessedEvents()
listProcessedEvents
in interface DispatchQueue
public void dumpEventQueueToConsole(int targetDepth)
targetDepth
- the depth at which we should start
printing debug information
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |