org.lsst.ccs.subsystems.fcs.drivers
Class CommandDispenser
java.lang.Object
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
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CommandDispenser
public CommandDispenser()
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.