public class CommunicationHandler extends AbstractSocketDriver
GRE_KIS-NOT-0013MessageListener| Modifier and Type | Class and Description |
|---|---|
private class |
CommunicationHandler.ReceiverThread
The reciever thread waits on the input line until data comes available.
|
private class |
CommunicationHandler.SenderThread
This thread performs the sending of a message.
|
static class |
CommunicationHandler.Test
This class connects to the DCP server as stated in the command line
properties, tries to connects and sends a NOP command.
|
| Modifier and Type | Field and Description |
|---|---|
private static long |
DEFRECEIVERWAIT
Default check time for incoming transmissions.
|
private static long |
DEFSENDERWAIT
Default wake-up period for sender, defines max time to cancel.
|
private static int |
DEFSOCKETPORT
Default port for the DCP.
|
private MessageListener |
ear
The message listener registered to this handler.
|
private Thread |
incoming
This thread handles the receiving of messages.
|
static String |
KEY_RECEIVERWAIT
The wait period for a receiver to check its stream.
|
static String |
KEY_SENDERWAIT
The wait period for a sender to check its queue.
|
private Deque<Message> |
outqueue
This is the dequeue used on output, no input queue necessary.
|
private Thread |
sender
This is the thread that handles the output.
|
KEY_CLOSETIMEOUT, KEY_SOCKETPORT, KEY_SOCKETSERVER, KEY_SOCKETTIMEOUTKEY_DRIVERNAMEKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORCONFIG, KEY_CLASS| Constructor and Description |
|---|
CommunicationHandler(Map<String,String> prop)
Low-level Communication is deferred to the parental class that provides
access to an input and an output stream.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
close()
On close, we additionally.
|
void |
init()
On init, we initialize the output queue.
|
boolean |
putMessage(Message m)
We send a message by placing it into the outqueue and notifying the
sender thread.
|
boolean |
setMessageListener(MessageListener receive)
Sets the single message listener, returns true if no one was registerd
yet.
|
boolean |
startTransmission()
We start the sender and receiver threads after ensuring proper opening
of the TCP connection.
|
void |
stopTransmission()
We stop transmission by canceling the sender and receiver thread.
|
authenticate, 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, stringProperties, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitgetDriverNamepublic static final String KEY_SENDERWAIT
public static final String KEY_RECEIVERWAIT
private static final long DEFSENDERWAIT
private static final long DEFRECEIVERWAIT
private static final int DEFSOCKETPORT
private MessageListener ear
private Deque<Message> outqueue
private Thread sender
private Thread incoming
public void init()
init in interface Initializableinit in class AbstractSocketDriverpublic boolean setMessageListener(MessageListener receive)
public boolean startTransmission()
throws IOException
IOExceptionpublic boolean putMessage(Message m) throws IOException
IOExceptionpublic boolean close()
throws IOException
close in interface Driverclose in class AbstractSocketDriverIOException - Exception to throw on disconnection errorpublic void stopTransmission()