com.vodafone360.people.service.transport
Class DecoderThread

java.lang.Object
  extended by com.vodafone360.people.service.transport.DecoderThread
All Implemented Interfaces:
java.lang.Runnable

public class DecoderThread
extends java.lang.Object
implements java.lang.Runnable

Responsible for decoding 'raw' Hessian response data. Data is decoded into specific data types and added to the response queue. The Response queue stores request id (except for unsolicited Push msgs) and a source/destination engine to allow appropriate routing.


Nested Class Summary
static class DecoderThread.RawResponse
          Container class for raw undecoded response data.
 
Field Summary
private  java.util.List<DecoderThread.RawResponse> mResponses
           
private  ResponseQueue mRespQueue
           
private  boolean mRunning
           
private static java.lang.String THREAD_NAME
           
private static long THREAD_SLEEP_TIME
           
 
Constructor Summary
DecoderThread()
           
 
Method Summary
 void addToDecode(DecoderThread.RawResponse resp)
          Add raw response to decoding queue
 boolean getIsRunning()
           
 void handleResponse(byte[] response)
           Looks at the response and adds it to the necessary decoder.
 void run()
          Thread's run function If the decoding queue contains any entries we decode the first response and add the decoded data to the response queue.
protected  void startThread()
          Start decoder thread
protected  void stopThread()
          Stop decoder thread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THREAD_NAME

private static final java.lang.String THREAD_NAME
See Also:
Constant Field Values

THREAD_SLEEP_TIME

private static final long THREAD_SLEEP_TIME
See Also:
Constant Field Values

mRunning

private volatile boolean mRunning

mResponses

private final java.util.List<DecoderThread.RawResponse> mResponses

mRespQueue

private ResponseQueue mRespQueue
Constructor Detail

DecoderThread

public DecoderThread()
Method Detail

startThread

protected void startThread()
Start decoder thread


stopThread

protected void stopThread()
Stop decoder thread


addToDecode

public void addToDecode(DecoderThread.RawResponse resp)
Add raw response to decoding queue

Parameters:
resp - raw data

getIsRunning

public boolean getIsRunning()

run

public void run()
Thread's run function If the decoding queue contains any entries we decode the first response and add the decoded data to the response queue. If the decode queue is empty, the thread will become inactive. It is resumed when a raw data entry is added to the decode queue.

Specified by:
run in interface java.lang.Runnable

handleResponse

public void handleResponse(byte[] response)
                    throws java.lang.Exception

Looks at the response and adds it to the necessary decoder.

TODO: this method should be worked on. The decoder should take care of deciding which methods are decoded in which way.

Parameters:
response - The server response to decode.
Throws:
java.lang.Exception - Thrown if the returned status line was null or if the response was null.


JavaDoc