org.zkoss.zk.ui.impl
Class RequestQueueImpl

java.lang.Object
  extended by org.zkoss.zk.ui.impl.RequestQueueImpl
All Implemented Interfaces:
RequestQueue

public class RequestQueueImpl
extends java.lang.Object
implements RequestQueue

An implementation of RequestQueue behaving as a queue of AuRequest. There is one queue for each desktop.

Implementation Note: Unlike only of desktop members, this class must be thread-safe.

Author:
tomyeh

Constructor Summary
RequestQueueImpl()
           
 
Method Summary
 void addRequestId(java.lang.String requestId)
          Adds a request ID that uniquely identifies a request.
 boolean addRequests(java.util.Collection requests)
          Adds a list of requests.
 java.util.Collection clearRequestIds()
          Clears all request IDs that were added by RequestQueue.addRequestId(java.lang.String).
 boolean endWithRequest()
          Called when ending the processing of the request queue.
 AuRequest nextRequest()
          Returns the next request, or null if no more request.
 void setInProcess()
          Marks the queue to denote it is being processing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestQueueImpl

public RequestQueueImpl()
Method Detail

addRequestId

public void addRequestId(java.lang.String requestId)
Description copied from interface: RequestQueue
Adds a request ID that uniquely identifies a request. It is used to notify PerformanceMeter.

Specified by:
addRequestId in interface RequestQueue
Parameters:
requestId - the request ID (never null)

clearRequestIds

public java.util.Collection clearRequestIds()
Description copied from interface: RequestQueue
Clears all request IDs that were added by RequestQueue.addRequestId(java.lang.String). It is usually called after calling RequestQueue.endWithRequest().

Specified by:
clearRequestIds in interface RequestQueue
Returns:
a list of request IDs that were added by RequestQueue.addRequestId(java.lang.String), or null if no request ID was added.

endWithRequest

public boolean endWithRequest()
Description copied from interface: RequestQueue
Called when ending the processing of the request queue.

Note: the in-process flag is cleared after the invocation. In other words, this method is designed to be called when an execution is about to de-activate.

Typical use:
Call this method after timeout (there might be pending requests). If it returns true, the caller sends a response to ask client to send anther request.

Specified by:
endWithRequest in interface RequestQueue
Returns:
whether any request is available in the queue.

nextRequest

public AuRequest nextRequest()
Description copied from interface: RequestQueue
Returns the next request, or null if no more request. Onced returned, the request is removed from the queue.

Note: if no more request, this queue is automatically marked a flag to denote no one is processing the queue.

The call shall invoke this method until null is returned, or timeout. If timeout, it shall invoke RequestQueue.endWithRequest() in a way described in RequestQueue.endWithRequest().

Specified by:
nextRequest in interface RequestQueue

setInProcess

public void setInProcess()
Description copied from interface: RequestQueue
Marks the queue to denote it is being processing. Then, RequestQueue.addRequests(java.util.Collection) will return true to tell the caller is free to leave without process the pendinig requests.

Specified by:
setInProcess in interface RequestQueue

addRequests

public boolean addRequests(java.util.Collection requests)
Description copied from interface: RequestQueue
Adds a list of requests. Usually called by execs, that are not activated yeh, to pass request to the activated one.

Note: caller might check the returned value. If false is returned, it means the no one is processing queue, and the caller is responsible to process all pending requests. Before processing, it shall call RequestQueue.setInProcess() to notify following executions free to leave. On the other hand, if true is returned, it means the queue is being processed by some one else, and the caller is free to leave.

Specified by:
addRequests in interface RequestQueue
Returns:
whether the queue is being processed by another execution.


Copyright © 2005-2007 Potix Corporation. All Rights Reserved.