org.jlab.coda.cMsg.cMsgDomain.server
Class cMsgDomainServer

java.lang.Object
  extended by java.lang.Thread
      extended by org.jlab.coda.cMsg.cMsgDomain.server.cMsgDomainServer
All Implemented Interfaces:
java.lang.Runnable

public class cMsgDomainServer
extends java.lang.Thread

This class implements a cMsg domain server in the cMsg domain. One object handles all connections to a single client.

Version:
1.0
Author:
Carl Timmer

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 cMsgClientInfo info
          Object containing information about the client this object is connected to.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
cMsgDomainServer(cMsgNameServer nameServer, cMsgSubdomainInterface handler, cMsgClientInfo info, int startingPort, boolean timeOrdered)
          Constructor.
 
Method Summary
 void finalize()
          Method to be run when this server's client is dead or disconnected and the server threads will be killed.
 cMsgSubdomainInterface getSubdomainHandler()
          Getter for the subdomain handler object.
 void killSpawnedThreads()
          Kill spawned threads.
 void run()
          This method is a thread which listens for TCP connections from the client.
 void setTimeOrdered(boolean timeOrdered)
          Set the time ordering property of the server.
 
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, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

info

public cMsgClientInfo info
Object containing information about the client this object is connected to. Certain members of info can only be filled in by this thread, such as the listening port & host.

Constructor Detail

cMsgDomainServer

public cMsgDomainServer(cMsgNameServer nameServer,
                        cMsgSubdomainInterface handler,
                        cMsgClientInfo info,
                        int startingPort,
                        boolean timeOrdered)
                 throws cMsgException
Constructor.

Parameters:
nameServer - nameServer object which created (is creating) this object
handler - object which handles all requests from the client for a particular subdomain
info - object containing information about the client for which this domain server was started
startingPort - suggested port on which to starting listening for connections
timeOrdered - if true, all non-(un)subscribe requests sent to this object are guaranteed to be passed in the order in which they were received.
Throws:
cMsgException - if listening socket could not be opened or a port to listen on could not be found
Method Detail

killSpawnedThreads

public void killSpawnedThreads()
Kill spawned threads.


getSubdomainHandler

public cMsgSubdomainInterface getSubdomainHandler()
Getter for the subdomain handler object.

Returns:
subdomain handler object

setTimeOrdered

public final void setTimeOrdered(boolean timeOrdered)
Set the time ordering property of the server. If this is true, then all non-(un)subscribe commands sent to it are guaranteed to be passed to the subdomain handler object in the order in which they were received.

Parameters:
timeOrdered - set to true if timeordering of commands is desired

finalize

public void finalize()
              throws cMsgException
Method to be run when this server's client is dead or disconnected and the server threads will be killed. It runs the "shutdown" method of its subdomainHandler object.

Finalize methods are run after an object has become unreachable and before the garbage collector is run;

Overrides:
finalize in class java.lang.Object
Throws:
cMsgException

run

public void run()
This method is a thread which listens for TCP connections from the client. There are 3 connections from each client. The first is a socket for communication from this server back to the client and is used to send responses to various client requests. The second socket is for keep alives to be sent to the server. The third is for client request to be sent to this server.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread