galaxy.server
Class FrameDispatcher

java.lang.Object
  |
  +--galaxy.server.FrameDispatcher

public class FrameDispatcher
extends java.lang.Object

This class encapsulates methods for dispatching and writing frames to a Hub.


Constructor Summary
FrameDispatcher(GalaxyInputStream in)
          Constructor.
 
Method Summary
 GFrame dispatchFrame(GFrame frame, java.lang.String providerID, Environment env)
          Dispatches a frame to the Hub.
protected  GalaxyMessage getNextMessage()
          Returns the next message on the queue of unprocessed messages encountered during calls to dispatchFrame.
protected  GalaxyMessage getNextNonReplyMessage()
          Removes the next non-reply message off the queue and returns it.
static int getServerTidx()
          Returns the next free server token index.
protected  void queueMessage(GalaxyMessage msg)
          Adds a message to the end of the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FrameDispatcher

public FrameDispatcher(GalaxyInputStream in)
Constructor.
Parameters:
in - the input stream to use
Method Detail

getServerTidx

public static int getServerTidx()
Returns the next free server token index.
Returns:
the server token index

getNextMessage

protected GalaxyMessage getNextMessage()
Returns the next message on the queue of unprocessed messages encountered during calls to dispatchFrame.
Returns:
the next message on the queue or null if the queue is empty

getNextNonReplyMessage

protected GalaxyMessage getNextNonReplyMessage()
Removes the next non-reply message off the queue and returns it.
Returns:
the message or null if no non-reply message was found

queueMessage

protected void queueMessage(GalaxyMessage msg)
Adds a message to the end of the queue.
Parameters:
msg - the message to add

dispatchFrame

public GFrame dispatchFrame(GFrame frame,
                            java.lang.String providerID,
                            Environment env)
                     throws DispatchError
Dispatches a frame to the Hub. This adds the keys GFrame.GAL_ROUND_TRIP_FRAME_KEY (value of 1) and GFrame.GAL_SERVER_TOKEN_INDEX_FRAME_KEY (set to next server index value) to the frame before it is sent.
Parameters:
frame - the frame to dispatch
providerID - the id of the the target service provider
env - environment in which to dispatch the frame
Returns:
the reply frame sent from the Hub
Throws:
DispatchError - exception if it reads an error back from the Hub