|
copyright The Portico Project 2008. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.portico.binding.jsop.rti.JSOPDaemon
public class JSOPDaemon
The JSOPDaemon
is responsible for handling incoming requets from remote clients wishing
to connect to the RTI. The lifecycle of the daemon is controlled by the JSOPBootstrap
class. Instances of this class are started in separate threads. When an instance is started (via
the run()
method), a new server socket is opened and the thread will continually sit
and wait, listening for incoming connection requests.
JSOPActiveConnection
that manages the LRC-RTI conversation from thereon in. When the daemon is asked to shutdown, it
in turn informs all of the remaining active connections and asks them to also shutdown.
Field Summary | |
---|---|
private List<JSOPActiveConnection> |
active
|
private JSOPBootstrap |
bootstrap
|
private org.apache.log4j.Logger |
logger
|
private int |
port
|
private ServerSocket |
serverSocket
|
Constructor Summary | |
---|---|
JSOPDaemon(JSOPBootstrap bootstrap,
int port)
Create a new daemon that is to be associted with the given bootstrap and that should listen on the given port. |
Method Summary | |
---|---|
private void |
addConnection(JSOPActiveConnection connection)
Add the given connection to our local store. |
protected void |
removeConnection(JSOPActiveConnection connection)
So that references to long dead connection objects are not kept lying around (and thus can be garbage collected), this method is provided with the sole intent that JSOPActiveConnection instances will use it to remove themselves from the store of
active connections when they end processing through natural causes (this does not include
when they are being asked ot manually shut down). |
void |
run()
This method will start listening on the server socket, creating a new JSOPActiveConnection for each client that contacts it. |
void |
shutdown()
This method will close the daemon's server socket (provided that it is active). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private JSOPBootstrap bootstrap
private int port
private org.apache.log4j.Logger logger
private ServerSocket serverSocket
private List<JSOPActiveConnection> active
Constructor Detail |
---|
public JSOPDaemon(JSOPBootstrap bootstrap, int port) throws IOException
bootstrap
- The bootstrap is kept so that it can be passed to all newly created
JSOPActiveConnection
'sport
- The port on which the daemon should listen for incoming connections
IOException
- If there is a problem creating the server socketMethod Detail |
---|
public void run()
JSOPActiveConnection
for each client that contacts it. Once the new connection has
been created, it will store it in the local list of active connections and tell it to start
working (via the Thread.start()
call).
The thread will continue executing until the server socket is closed. Note that when this
happens, all the currently active connections will not be asked to shutdown. All that
will happen is that the thread will exit and there will no longer be a way for new clients
to connect to the RTI via JSOP. The same process occurs if an unexpected IOException occurs
while working with the server socket.
run
in interface Runnable
public void shutdown()
JSOPActiveConnection
s and invoke their
JSOPActiveConnection.shutdown()
method. At each step, it will wait until the thread
associated with the connection has stopped before it moves on.
private void addConnection(JSOPActiveConnection connection)
removeConnection(JSOPActiveConnection)
) is also synchronized.
protected void removeConnection(JSOPActiveConnection connection)
JSOPActiveConnection
instances will use it to remove themselves from the store of
active connections when they end processing through natural causes (this does not include
when they are being asked ot manually shut down).
|
copyright The Portico Project 2008. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |