gov.virginia.dcjs.server
Class ClearServer

java.lang.Object
  extended byjava.rmi.server.RemoteObject
      extended byjava.rmi.server.RemoteServer
          extended byjava.rmi.server.UnicastRemoteObject
              extended bygov.virginia.dcjs.jini.service.GenericService
                  extended bygov.virginia.dcjs.server.TCPServer
                      extended bygov.virginia.dcjs.server.ClearServer
All Implemented Interfaces:
net.jini.admin.Administrable, AdministrableRMI, java.lang.Cloneable, com.sun.jini.admin.DestroyAdmin, java.util.EventListener, java.rmi.Remote, java.lang.Runnable, java.io.Serializable, ServiceAdmin, net.jini.lookup.ServiceIDListener, TCPService, TCPServiceRMI
Direct Known Subclasses:
EncryptedServer

public abstract class ClearServer
extends TCPServer

This is the superclass of distributed TCP / IP servers. * This class listens for and presides over communications with * clients. Each client thread remains active until either the * prespecified timeout expires, or the client sends an * gov.virginia.dcjs.client.util.CommunicationRequestType.BYE object. *

* Please Note: Subclasses must register at least one * gov.virginia.dcjs.server.util.RequestHandler object to do anything * meaningful.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class gov.virginia.dcjs.jini.service.GenericService
r_name
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
ClearServer(java.lang.String config)
           
 
Method Summary
 void addHandler(RequestHandler handler)
          Register the provided handler for request processing.
protected  void closeStreams()
          Ends communication with client.
protected  Request receiveRequest()
          Wait until the next request is received from the client via a clear stream.
 void removeHandler(RequestHandler handler)
          Unregister the provided handler for request processing.
protected  void requestsFinished()
          Client requests are completed.
protected  boolean sendResponse(Response response)
          Send the specified response to the client via a clear stream.
protected  void serveClient()
          This method is called by the superclass for each client connection.
 
Methods inherited from class gov.virginia.dcjs.server.TCPServer
finalize, getConfiguration, getPort, getSocket, logWrite, run, start, stop
 
Methods inherited from class gov.virginia.dcjs.jini.service.GenericService
destroy, getAdmin, initializeServiceName, serviceIDNotify
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.jini.admin.Administrable
getAdmin
 

Constructor Detail

ClearServer

public ClearServer(java.lang.String config)
            throws java.rmi.RemoteException
Parameters:
config - URL of server configuration file conforming to the * ClearStream.dtd at that site.
Method Detail

sendResponse

protected final boolean sendResponse(Response response)
Send the specified response to the client via a clear stream. * @param response Server response to send to client. * @return True for a successful transmission, false otherwise.


receiveRequest

protected final Request receiveRequest()
                                throws java.nio.channels.ClosedChannelException
Wait until the next request is received from the client via a clear stream. * @return Request received from client, or null if communication failed.

Throws:
java.nio.channels.ClosedChannelException

serveClient

protected void serveClient()
This method is called by the superclass for each client connection. * @param socket Specific socket connection between client and this * server

Specified by:
serveClient in class TCPServer

addHandler

public final void addHandler(RequestHandler handler)
Register the provided handler for request processing. * @param handler Class to be considered for request processing.


removeHandler

public final void removeHandler(RequestHandler handler)
Unregister the provided handler for request processing. * @param handler Class to be removed from request processing.


requestsFinished

protected void requestsFinished()
Client requests are completed. Subclasses may perform any final * cleanup operations here by overriding this method.


closeStreams

protected void closeStreams()
Ends communication with client. * This method is protected so that subclasses, such as * IpApplicationServer, can clean up their own streams * prior to calling super.closeStreams().