org.lsst.ccs.subsystems.fcs.drivers
Class CommandDispenser

java.lang.Object
  extended by org.lsst.ccs.subsystems.fcs.drivers.CommandDispenser

public class CommandDispenser
extends Object

This is a pale copy of Bernard's commandWord dispenser pattern. The CommandDispenser provides methods and internal classes to stored the commands we send to the tcpProxy and to wait for the response. It is used by the method call of the tcpProxy to stored the initial commands and then to retrieve the response. The response is updated by the tcpProxy readingThread when it arrives from the tcp Socket. The CommandToRegister object has to be removed from the map by the client classes.

Author:
virieux

Nested Class Summary
protected  class CommandDispenser.CommandToRegister
           
static class CommandDispenser.TokenLostException
           
 
Constructor Summary
CommandDispenser()
           
 
Method Summary
 String getCommandResponse(String token, long timeout)
           
 boolean isTokenUsed(String token)
          tells if the token is known.
 String register(String command)
          registers a commandWord and returns a token to be used to run the invocation code
 String registerResponse(String token, String response)
          registers the response at a commandWord and the token is given by the calling code.
 void remove(String token)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandDispenser

public CommandDispenser()
Method Detail

register

public String register(String command)
registers a commandWord and returns a token to be used to run the invocation code

Parameters:
invoker - should not be null.
Returns:

registerResponse

public String registerResponse(String token,
                               String response)
registers the response at a commandWord and the token is given by the calling code.

Parameters:
token -
invoker -
Returns:

getCommandResponse

public String getCommandResponse(String token,
                                 long timeout)
                          throws TimeoutException
Throws:
TimeoutException

remove

public void remove(String token)

isTokenUsed

public boolean isTokenUsed(String token)
tells if the token is known. beware : in a multihreaded environment there may be race condition where this method returns true but where an Exception is fired upon call of callback Method.

Parameters:
token -
Returns:


Copyright © 2013 LSST. All Rights Reserved.