ecologylab.services.distributed.legacy
Class ServicesServerBase

java.lang.Object
  extended by ecologylab.generic.Debug
      extended by ecologylab.services.distributed.legacy.ServicesServerBase
All Implemented Interfaces:
StartAndStoppable, Shutdownable, java.lang.Runnable
Direct Known Subclasses:
ServicesServer

public abstract class ServicesServerBase
extends Debug
implements java.lang.Runnable, StartAndStoppable, Shutdownable

A base set of fields and methods that are necessary for any server implementation.

Author:
Zachary O. Toups (toupsz@cs.tamu.edu)

Field Summary
protected  int connectionCount
           
protected  boolean finished
           
protected  Scope objectRegistry
          Provides a context for request processing.
protected  int portNumber
           
protected  TranslationSpace requestTranslationSpace
          Space that defines mappings between xml names, and Java class names, for request messages.
protected  java.util.LinkedList<ServerListener> serverListeners
           
protected  java.net.ServerSocket serverSocket
           
protected  boolean shuttingDown
           
 
Constructor Summary
protected ServicesServerBase(int portNumber, TranslationSpace requestTranslationSpace, Scope objectRegistry)
          Creates a Services Server Base.
 
Method Summary
 void addServerListener(ServerListener listener)
           
protected  void connectionTerminated()
          Remove the argument passed in from the set of connections we know about.
protected  void fireServerEvent(java.lang.String event)
           
protected  java.lang.String generateSessionToken(java.net.Socket incomingSocket)
          Generates a unique identifier String for the given socket, based upon actual ports used and ip addresses with a hash.
 java.net.SocketAddress getAddress()
           
 Scope getObjectRegistry()
          Get the message passing context associated with this server.
 int getPortNumber()
           
 TranslationSpace getRequestTranslationSpace()
           
 ResponseMessage performService(RequestMessage requestMessage)
          Perform the service associated with a RequestMessage, by calling the performService() method on that message.
protected  void terminationAction()
          This defines the actions that server needs to perform when the client ends unexpected way.
 RequestMessage translateXMLStringToRequestMessage(java.lang.String messageString, boolean doRecursiveDescent)
           
 
Methods inherited from class ecologylab.generic.Debug
classSimpleName, closeLoggingFile, debug, debug, debug, debug, debugA, debugA, debugA, debugI, debugI, debugI, error, error, getClassName, getClassName, getInteractive, getPackageName, getPackageName, getPackageName, initialize, level, level, level, logToFile, print, print, println, println, println, println, println, println, printlnA, printlnA, printlnA, printlnI, printlnI, printlnI, printlnI, setLoggingFile, show, show, superString, toggleInteractive, toString, toString, warning, warning, weird, weird
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ecologylab.generic.StartAndStoppable
start, stop
 
Methods inherited from interface ecologylab.services.distributed.impl.Shutdownable
shutdown
 

Field Detail

portNumber

protected int portNumber

serverSocket

protected java.net.ServerSocket serverSocket

finished

protected boolean finished

shuttingDown

protected boolean shuttingDown

serverListeners

protected java.util.LinkedList<ServerListener> serverListeners

requestTranslationSpace

protected TranslationSpace requestTranslationSpace
Space that defines mappings between xml names, and Java class names, for request messages.


objectRegistry

protected Scope objectRegistry
Provides a context for request processing.


connectionCount

protected int connectionCount
Constructor Detail

ServicesServerBase

protected ServicesServerBase(int portNumber,
                             TranslationSpace requestTranslationSpace,
                             Scope objectRegistry)
                      throws java.io.IOException,
                             java.net.BindException
Creates a Services Server Base. Sets internal variables, but does not bind the port. Port binding is to be handled by sublcasses.

Parameters:
portNumber -
translationSpace -
objectRegistry - Provides a context for request processing.
Throws:
java.io.IOException
java.net.BindException
Method Detail

generateSessionToken

protected java.lang.String generateSessionToken(java.net.Socket incomingSocket)
Generates a unique identifier String for the given socket, based upon actual ports used and ip addresses with a hash.

Parameters:
incomingSocket -
Returns:

performService

public ResponseMessage performService(RequestMessage requestMessage)
Perform the service associated with a RequestMessage, by calling the performService() method on that message.

Parameters:
requestMessage - Message to perform.
Returns:
Response to the message.

translateXMLStringToRequestMessage

public RequestMessage translateXMLStringToRequestMessage(java.lang.String messageString,
                                                         boolean doRecursiveDescent)
                                                  throws XMLTranslationException
Throws:
XMLTranslationException

connectionTerminated

protected void connectionTerminated()
Remove the argument passed in from the set of connections we know about.


terminationAction

protected void terminationAction()
This defines the actions that server needs to perform when the client ends unexpected way. Detail implementations will be in subclasses.


getObjectRegistry

public Scope getObjectRegistry()
Get the message passing context associated with this server.

Returns:

getRequestTranslationSpace

public TranslationSpace getRequestTranslationSpace()
Returns:
Returns the translationSpace.

getAddress

public java.net.SocketAddress getAddress()

addServerListener

public void addServerListener(ServerListener listener)

fireServerEvent

protected void fireServerEvent(java.lang.String event)

getPortNumber

public int getPortNumber()
Returns:
the portNumber