com.vodafone360.people.service.io
Class ResponseQueue

java.lang.Object
  extended by com.vodafone360.people.service.io.ResponseQueue

public class ResponseQueue
extends java.lang.Object

Queue of responses received from server. These may be either responses to requests issued by the People client or unsolicited ('Push') messages. The content of these Responses will have already been decoded by the DecoderThread and converted to data-types understood by the People Client.


Nested Class Summary
static class ResponseQueue.Response
          Class encapsulating a decoded response from the server A Response contains; a request id which should match a request id from a request issued by the People Client (responses to non-RPG requests or non-solicited messages will not have a request id), the request data, a list of decoded BaseDataTypes generated from the response content and an engine id informing the framework which engine the response should be routed to.
private static class ResponseQueue.ResponseQueueHolder
          Use Initialization on demand holder pattern
 
Field Summary
private  EngineManager mEngMgr
          The engine manager holding the various engines to cross check where responses belong to.
private  java.util.List<ResponseQueue.Response> mResponses
          The list of responses held by this queue.
 
Constructor Summary
protected ResponseQueue()
          Protected constructor to highlight the singleton nature of this class.
 
Method Summary
 void addToResponseQueue(java.lang.Integer reqId, java.util.List<BaseDataType> data, EngineManager.EngineId source)
          Adds a response item to the queue.
static ResponseQueue getInstance()
          Gets an instance of the ResponseQueue as part of the singleton pattern.
 ResponseQueue.Response getNextResponse(EngineManager.EngineId source)
          Retrieves the next response in the list if there is one.
private  int responseCount()
          Get number of items currently in the response queue.
protected  boolean responseExists(int reqId)
          Test if we have response for the specified request id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mResponses

private final java.util.List<ResponseQueue.Response> mResponses
The list of responses held by this queue. An array-list of Responses.


mEngMgr

private EngineManager mEngMgr
The engine manager holding the various engines to cross check where responses belong to.

Constructor Detail

ResponseQueue

protected ResponseQueue()
Protected constructor to highlight the singleton nature of this class.

Method Detail

getInstance

public static ResponseQueue getInstance()
Gets an instance of the ResponseQueue as part of the singleton pattern.

Returns:
The instance of ResponseQueue.

addToResponseQueue

public void addToResponseQueue(java.lang.Integer reqId,
                               java.util.List<BaseDataType> data,
                               EngineManager.EngineId source)
Adds a response item to the queue.

Parameters:
reqId - The request ID to add the response for.
data - The response data to add to the queue.
source - The corresponding engine that fired off the request for the response.

getNextResponse

public ResponseQueue.Response getNextResponse(EngineManager.EngineId source)
Retrieves the next response in the list if there is one.

Parameters:
source - The originating engine id that requested this response.
Returns:
Response The first response that matches the given engine or null if no response was found.

responseCount

private int responseCount()
Get number of items currently in the response queue.

Returns:
number of items currently in the response queue.

responseExists

protected boolean responseExists(int reqId)
Test if we have response for the specified request id.

Parameters:
reqId - Request ID.
Returns:
true If we have a response for this ID.


JavaDoc