public class GetterSetter extends CommunicationHandler implements MessageListener
sendSet and sendGet
they are blocking until the entire command cycle has been completed.CommunicationHandler.Test| Modifier and Type | Field and Description |
|---|---|
private Map<Integer,CommunicationCycle> |
active
This is the lookup table of active commands.
|
private static long |
DEFACKTIMEOUT
Default value.
|
private static long |
DEFGETTIMEOUT
Default value.
|
private static boolean |
DEFSTRICTGET
Default value.
|
private static boolean |
DEFSTRICTSET
Default value.
|
static String |
KEY_ACKTIMEOUT
This key specifies the default acknowledge time out.
|
static String |
KEY_GETTIMEOUT
This key is the second reply timeout on getter commands.
|
static String |
KEY_STRICTGET
If this is true, only non-warning results are accepted for get.
|
static String |
KEY_STRICTSET
If this is true, only non-warning results are accepted for set.
|
KEY_RECEIVERWAIT, KEY_SENDERWAITKEY_CLOSETIMEOUT, KEY_SOCKETPORT, KEY_SOCKETSERVER, KEY_SOCKETTIMEOUTKEY_DRIVERNAMEKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORCONFIG, KEY_CLASS| Constructor and Description |
|---|
GetterSetter(Map<String,String> prop)
Constructs a new getter-setter communicator.
|
| Modifier and Type | Method and Description |
|---|---|
private CommunicationCycle |
complete(CommandMessage cm)
We initiate and wait.
|
CommandMessage |
createGet(Object dest,
String toget)
We create a get command using the property acknowledge and completion
time.
|
CommandMessage |
createSet(Object dest,
String toset,
long donetime)
We create a set command using the property acknowledge time.
|
protected List<String> |
executeGet(CommandMessage cm)
We issue a prepared getter function and wait for the result,
which is returned
as the cycle outcome.
|
List<String> |
executeGet(Object dest,
String toget)
We issue a getter function and wait for the result, which is returned
as the cycle outcome.
|
protected boolean |
executeSet(CommandMessage cm)
We issue a preparedsetter function and wait for the result, which is
then interpret as a boolean.
|
boolean |
executeSet(Object dest,
String toset,
long donetime)
We issue a setter function and wait for the result, which is
then interpret as a boolean.
|
void |
init()
On init, we create a new map of communication cycles.
|
protected CommunicationCycle |
initiate(CommandMessage cm)
We initiate sending a command.
|
void |
messageReceived(Message m)
If we receive a reply, we check if it belongs to one of the active
command cycles.
|
protected boolean |
removeCycle(CommandMessage cm)
Removes the command cycle to this command if still in active list.
|
String |
toString()
We are lazy and just override the toString method.
|
protected void |
waitForComplete(CommandMessage cm,
CommunicationCycle cc)
We wait for a command cycle to complete by synchronizing on the cycle
object and issuing maximum two wait states on it.
|
close, putMessage, setMessageListener, startTransmission, stopTransmissionauthenticate, exit, getInputStream, getOutputStream, getSocket, isOpen, open, setTimeoutcreateDriver, equals, getDriverName, hashCodeaugment, augment, augment, augment, augment, clone, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, initProperties, isNew, parseObject, parseObject, reload, reload, removeProperty, requires, rescanned, setObject, setProperties, setProperty, stringPropertiesfinalize, getClass, notify, notifyAll, wait, wait, waitgetDriverNamepublic static final String KEY_ACKTIMEOUT
public static final String KEY_GETTIMEOUT
public static final String KEY_STRICTSET
public static final String KEY_STRICTGET
private static final long DEFACKTIMEOUT
private static final long DEFGETTIMEOUT
private static final boolean DEFSTRICTGET
private static final boolean DEFSTRICTSET
private Map<Integer,CommunicationCycle> active
public void init()
init in interface Initializableinit in class CommunicationHandlerpublic CommandMessage createSet(Object dest, String toset, long donetime)
public CommandMessage createGet(Object dest, String toget)
public void messageReceived(Message m)
messageReceived in interface MessageListenerpublic boolean executeSet(Object dest, String toset, long donetime) throws AcknowledgeException, TimeoutException, IOException
protected boolean executeSet(CommandMessage cm) throws AcknowledgeException, TimeoutException, IOException
public List<String> executeGet(Object dest, String toget) throws AcknowledgeException, TimeoutException, IOException
protected List<String> executeGet(CommandMessage cm) throws AcknowledgeException, TimeoutException, IOException
protected CommunicationCycle initiate(CommandMessage cm) throws IOException
waitForComplete(stella.net.gregor.CommandMessage, stella.net.gregor.CommunicationCycle).IOExceptionprotected void waitForComplete(CommandMessage cm, CommunicationCycle cc) throws AcknowledgeException, TimeoutException
AcknowledgeExceptionTimeoutExceptionprotected boolean removeCycle(CommandMessage cm)
private CommunicationCycle complete(CommandMessage cm) throws AcknowledgeException, TimeoutException, IOException
public String toString()
toString in class PropertyContainer