|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecthmi.bml.bridge.TCPIPRealizerBridgeClient
public final class TCPIPRealizerBridgeClient
A RealizerBridge that uses a tcp/ip connection to provide transparent access to a
BML Realizer running on a remote machine. The connection is "self-healing".
Detailed documentation can be found in the project report.
| Nested Class Summary | |
|---|---|
private class |
TCPIPRealizerBridgeClient.FeedbackReader
The process that reads feedback from the network connection, and puts it in the feedback queue. |
private class |
TCPIPRealizerBridgeClient.FeedbackRedirector
The process that reads feedback from the feedback queue, and sends it to the BML feedback listeners. |
| Field Summary | |
|---|---|
private ConcurrentLinkedQueue<String> |
bmlRequestQ
Incoming BML Requests from the application are stored here. |
private Socket |
bmlSendSocket
|
private InetSocketAddress |
bmlSendSocketAddress
|
private PrintWriter |
bmlSendWriter
|
private static int |
CONNECT_RETRY_WAIT
|
private Object |
connectionLock
Locking object for the states of the main networking loop. |
private BMLFeedbackManager |
fbManager
|
private static long |
FEEDBACK_REDIRECT_WAIT_MILLI
Sleeping time of the FeedbackRedirector if the feedback queue is empty |
private Object |
feedbackLock
Locking object for the feedbacklisteners -- needed to avoid a situation where feedback is sent out simultaneously with setting the feedbacklisteners. |
private ConcurrentLinkedQueue<BMLFeedback> |
feedbackQ
Incoming feedback from the server are stored here. |
private TCPIPRealizerBridgeClient.FeedbackReader |
feedbackReader
|
private Thread |
feedbackReaderThread
|
private BufferedReader |
feedbackReadReader
|
private ServerSocket |
feedbackReadServerSocket
|
private Socket |
feedbackReadSocket
|
private TCPIPRealizerBridgeClient.FeedbackRedirector |
feedbackRedirector
redirects feedback that has come in over the socket to the listeners |
private Thread |
feedbackRedirectorThread
the thread under which the feedbackRedirector runs. |
private boolean |
isconnected
Internal state var: true if a conenction to a server is active |
private static org.slf4j.Logger |
logger
|
private boolean |
mustconnect
Internal state var: true if a connect request has been given |
private boolean |
mustdisconnect
Internal state var: true if a disconnect request has been given |
private boolean |
mustshutdown
Internal state var: true if a shutdown request has been given |
private long |
nextMainLoopWait
Waiting time for next run() loop. |
private ServerInfo |
serverInfo
Internal state var: The ServerInfo for the connection that must be set up (see #mustconnect). |
private static int |
SOCKET_TIMEOUT
|
| Constructor Summary | |
|---|---|
TCPIPRealizerBridgeClient()
Set the state variables to appropriate values, start the main processing loop, and start the processing loop that will deliver feedback messages to the BML Feedback listeners. |
|
| Method Summary | |
|---|---|
void |
addListeners(BMLListener... bmlListeners)
Listeners must be stored; they will get updates from the feedbackRedirectionThread |
void |
connect(ServerInfo serverInfo)
May return before connection is actually made. |
void |
disconnect()
Instigates disconnection procedure. |
private void |
doconnect()
Attempt to connect to server, given ServerInfo. |
private void |
dodisconnect()
Disconnect from server (if connected); close feedback reading thread; return when processes finished. |
private void |
dosendBML(String bmlRequest)
Send given BML request. |
private void |
doshutdown()
Disconnect. |
private void |
failConnect(String msg)
Fail and don't try again |
protected ServerInfo |
getServerInfo()
|
boolean |
isConnected()
Returns true iff there is a connection to a server active (and has not been lost). |
void |
performBML(String bmlString)
Add BML request to the queue and return. |
private void |
retryConnect(String msg)
Error connecting, prepare to retry |
void |
run()
The main loop! |
void |
shutdown()
Instigates total shutdown. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private BMLFeedbackManager fbManager
private static org.slf4j.Logger logger
private static final long FEEDBACK_REDIRECT_WAIT_MILLI
private static final int SOCKET_TIMEOUT
private static final int CONNECT_RETRY_WAIT
private ConcurrentLinkedQueue<String> bmlRequestQ
private Object connectionLock
private boolean isconnected
private boolean mustshutdown
private boolean mustconnect
private ServerInfo serverInfo
private boolean mustdisconnect
private long nextMainLoopWait
private InetSocketAddress bmlSendSocketAddress
private Socket bmlSendSocket
private PrintWriter bmlSendWriter
private ServerSocket feedbackReadServerSocket
private Socket feedbackReadSocket
private BufferedReader feedbackReadReader
private TCPIPRealizerBridgeClient.FeedbackReader feedbackReader
private Thread feedbackReaderThread
private Object feedbackLock
private TCPIPRealizerBridgeClient.FeedbackRedirector feedbackRedirector
private Thread feedbackRedirectorThread
private ConcurrentLinkedQueue<BMLFeedback> feedbackQ
| Constructor Detail |
|---|
public TCPIPRealizerBridgeClient()
| Method Detail |
|---|
public void disconnect()
public void connect(ServerInfo serverInfo)
protected ServerInfo getServerInfo()
public void shutdown()
public boolean isConnected()
public void addListeners(BMLListener... bmlListeners)
addListeners in interface RealizerBridgepublic void performBML(String bmlString)
performBML in interface RealizerBridgepublic void run()
run in interface Runnableprivate void dodisconnect()
private void doconnect()
private void failConnect(String msg)
private void retryConnect(String msg)
private void doshutdown()
private void dosendBML(String bmlRequest)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||