|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.vodafone360.people.service.io.RequestQueue
public class RequestQueue
Holds a queue of outgoing requests. The Requester adds Requests to the queue. The transport layer gets one or more items from the queue when it is ready to send more requests to the server. When a Request is added a request id is generated for this request. Requests are removed from the queue on completion or if an error requires us to clear any outstanding requests.
Nested Class Summary | |
---|---|
private static class |
RequestQueue.RequestQueueHolder
Use Initialization on demand holder pattern |
Field Summary | |
---|---|
private int |
mCurrentRequestId
A unique ID identifying this request |
private static int |
MILLIS_PER_SECOND
|
private java.util.List<IQueueListener> |
mListeners
Contains a list of listeners that will receive events when items are added to the queue. |
private java.util.List<Request> |
mRequests
The queue data, a List-array of Request items. |
private TimeOutWatcher |
mTimeOutWatcher
|
Constructor Summary | |
---|---|
protected |
RequestQueue()
Constructs the request queue |
Method Summary | |
---|---|
protected void |
addQueueListener(IQueueListener listener)
Add listener listening for RequestQueue changes. |
protected int |
addRequest(Request req)
Adds a request to the queue without sending an event to the listeners |
protected int[] |
addRequest(Request[] requests)
Adds requests to the queue. |
protected int |
addRequestAndNotify(Request req)
Add request to queue |
protected void |
clearActiveRequests(boolean rpgOnly)
Clear active requests (i.e add dummy response to response queue). |
protected void |
clearAllRequests()
Clears all requests from the queue and puts null responses on the response queue to tell the engines that they have been cleared. |
protected void |
clearTheTimeOuts()
Removes all items that are being watched for timeouts |
protected void |
fireQueueStateChanged()
Fire RequestQueue state changed message |
protected java.util.List<Request> |
getAllRequests()
Returns all requests from the queue. |
protected java.util.List<Request> |
getApiRequests()
Returns all requests from the queue needing the API or both to work. |
protected static RequestQueue |
getInstance()
Get instance of RequestQueue - we only have a single instance. |
protected Request |
getRequest(int requestId)
Return Request from specified request ID. |
private java.util.List<Request> |
getRequests(boolean needsRpgForRequest)
Returns a list of either requests needing user authentication or requests not needing user authentication depending on the flag passed to this method. |
protected java.util.List<Request> |
getRpgRequests()
Returns all requests from the queue needing the RPG or both to work. |
protected TimeOutWatcher |
getTimeoutWatcher()
Return handle to TimeOutWatcher. |
protected void |
removeQueueListener(IQueueListener listener)
Remove RequestQueue listener |
protected boolean |
removeRequest(int requestId)
Removes the request for the given request ID from the queue and searches the queue for requests older than Settings.REMOVE_REQUEST_FROM_QUEUE_MILLIS and removes them as well. |
private int |
requestCount()
|
java.lang.String |
toString()
Overrides the toString() method of Object and gives detailed infos which objects are on the queue and whether they are active or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final int MILLIS_PER_SECOND
private final java.util.List<Request> mRequests
private volatile int mCurrentRequestId
private final java.util.List<IQueueListener> mListeners
private TimeOutWatcher mTimeOutWatcher
Constructor Detail |
---|
protected RequestQueue()
Method Detail |
---|
protected static RequestQueue getInstance()
protected void addQueueListener(IQueueListener listener)
listener
- listener to addprotected void removeQueueListener(IQueueListener listener)
listener
- listener to removeprotected void fireQueueStateChanged()
protected int addRequestAndNotify(Request req)
req
- Request to add to queue
protected int addRequest(Request req)
req
- The request to add
protected int[] addRequest(Request[] requests)
requests
- The requests to add.
private int requestCount()
protected java.util.List<Request> getAllRequests()
protected java.util.List<Request> getApiRequests()
protected java.util.List<Request> getRpgRequests()
private java.util.List<Request> getRequests(boolean needsRpgForRequest)
needsUserAuthentication
- If true only requests that need to have a
valid user authentication will be returned. Otherwise methods
requiring application authentication will be returned.
protected Request getRequest(int requestId)
requestId
- Request Id of required request
protected boolean removeRequest(int requestId)
requestId
- The ID of the request to remove.
protected void clearActiveRequests(boolean rpgOnly)
rpgOnly
- protected void clearAllRequests()
protected TimeOutWatcher getTimeoutWatcher()
protected void clearTheTimeOuts()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
JavaDoc