|
copyright The Portico Project 2008. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
org.portico.binding.jsop.rti.JSOPActiveConnection
public class JSOPActiveConnection
This class represents an active JSOP socket connection between an LRC and the RTI. It waits for messages to be received from the LRC and routes them as required.
When a JSOP client connects to the RTI, a new instance of this class is created and started in a new Thread. Therun()
method goes into an infinite loop waiting for incoming messages from
the client. When a message is received, it is routed either to the appropriate federation, or to
the BootstrapHandler
(if it is one of the bootstrap methods - create,
destroy, join). When the response is obtained from that process, a ResponseMessage is created
and sent back down the socket connection to the client. If an exception occurs, it is wrapped in
an ExceptionMessage (commons class).
Callbacks sent to the LRC *from* the RTI are done so unsolicited. These are handled by subclasses
of the RTIConnection
class which is implemented here as the private inner-class
JSOPServerConnection
. The RTIConnection.sendCallback(MessageContext)
method
handles that process, and the sending is done in the thread of the caller, *NOT* the running
thread of this class. Access to the underlying socket is synchronized so as to avoid any race
conditions or corruption problems.
Nested Class Summary | |
---|---|
class |
JSOPActiveConnection.JSOPServerConnection
This class provides a link to the connection for the RTI. |
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
private boolean |
active
|
private JSOPBootstrap |
bootstrap
|
private com.lbf.commons.messaging.IMessageHandler |
bootstrapHandler
|
private static int |
COUNTER
|
private ObjectInputStream |
inStream
|
private org.apache.log4j.Logger |
logger
|
private ObjectOutputStream |
outStream
|
private JSOPActiveConnection.JSOPServerConnection |
rtiConnection
|
private Socket |
socket
|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
JSOPActiveConnection(Socket socket,
JSOPBootstrap bootstrap)
Creates a new active connection for the client that is connecting over the given socket. |
Method Summary | |
---|---|
private void |
closeSocket()
Closes off the socket that this connection was attached to. |
private com.lbf.commons.messaging.ResponseMessage |
fireJoinRequest(RTI_JoinFederation request)
Process a join request. |
private com.lbf.commons.messaging.ResponseMessage |
fireResignRequest(RTI_ResignFederation request)
This class will process a resign request. |
private com.lbf.commons.messaging.ResponseMessage |
fireToBootstrap(RTI_RequestMessage request)
This method will take the given request message and pass it on to the the bootstrap handler, returning the response. |
private com.lbf.commons.messaging.ResponseMessage |
fireToFederation(RTI_RequestMessage request)
Pass a message to the rti-request sink of the federation for processing, returning the given response. |
Socket |
getSocket()
Get the socket that this connection implementation is using to send/receive messages on. |
private void |
killConnection()
This will manually kill off and clean up the socket connection. |
void |
run()
This method will gain access to the incoming and outgoing streams of the socket used to create this instance. |
void |
shutdown()
Interrupts the running thread and gets it to close the socket connection and shutdown. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static int COUNTER
private Socket socket
private JSOPBootstrap bootstrap
private com.lbf.commons.messaging.IMessageHandler bootstrapHandler
private org.apache.log4j.Logger logger
private volatile boolean active
private ObjectInputStream inStream
private ObjectOutputStream outStream
private JSOPActiveConnection.JSOPServerConnection rtiConnection
Constructor Detail |
---|
public JSOPActiveConnection(Socket socket, JSOPBootstrap bootstrap)
Method Detail |
---|
public Socket getSocket()
public void run()
JSOPServerConnection
inner class. This will continue until the connection is
shutdown or disconnected.
run
in interface Runnable
run
in class Thread
private void killConnection()
private void closeSocket()
public void shutdown()
private com.lbf.commons.messaging.ResponseMessage fireToBootstrap(RTI_RequestMessage request)
private com.lbf.commons.messaging.ResponseMessage fireJoinRequest(RTI_JoinFederation request)
private com.lbf.commons.messaging.ResponseMessage fireResignRequest(RTI_ResignFederation request)
private com.lbf.commons.messaging.ResponseMessage fireToFederation(RTI_RequestMessage request)
|
copyright The Portico Project 2008. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |