seda.sandStorm.lib.http
Class httpServer

java.lang.Object
  extended by seda.sandStorm.lib.http.httpServer
All Implemented Interfaces:
EventHandlerIF, httpConst

public class httpServer
extends java.lang.Object
implements EventHandlerIF, httpConst

An httpServer is a SandStorm stage which accepts incoming HTTP connections. The server has a client sink associated with it, onto which httpConnection and httpRequest events are pushed. When a connection is closed, a SinkClosedEvent is pushed, with the sink pointer set to the httpConnection that closed.

See Also:
httpConnection, httpRequest

Field Summary
protected  SinkIF clientSink
           
private  java.util.Hashtable connTable
           
private static boolean DEBUG
           
protected  int listenPort
           
protected  ManagerIF mgr
           
protected  SinkIF mySink
           
private static int num_svrs
           
protected  ATcpServerSocket servsock
           
 
Fields inherited from interface seda.sandStorm.lib.http.httpConst
CRLF, DEFAULT_HTTP_PORT, HTTP_VERSION, WRITE_CLOG_THRESHOLD
 
Constructor Summary
httpServer(ManagerIF mgr, SinkIF clientSink)
          Create an HTTP server listening for incoming connections on the default port of 8080.
httpServer(ManagerIF mgr, SinkIF clientSink, int listenPort)
          Create an HTTP server listening for incoming connections on the given listenPort.
 
Method Summary
(package private)  void cleanupConnection(httpConnection hc)
           
 void destroy()
          The Sandstorm stage destroy method.
 ATcpServerSocket getServerSocket()
          Return the server socket being used by this httpServer.
(package private)  SinkIF getSink()
           
 void handleEvent(QueueElementIF qel)
          The main event handler.
 void handleEvents(QueueElementIF[] qelarr)
          Handle the events corresponding to the given QueueElementIF array.
 void init(ConfigDataIF config)
          The Sandstorm stage initialization method.
 void registerSink(SinkIF sink)
          Register a sink to receive incoming packets on this connection.
 void resumeAccept()
          Resume acceptance of new connections on this server.
 void suspendAccept()
          Suspend acceptance of new connections on this server.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

listenPort

protected int listenPort

servsock

protected ATcpServerSocket servsock

mgr

protected ManagerIF mgr

mySink

protected SinkIF mySink

clientSink

protected SinkIF clientSink

connTable

private java.util.Hashtable connTable

num_svrs

private static int num_svrs
Constructor Detail

httpServer

public httpServer(ManagerIF mgr,
                  SinkIF clientSink)
           throws java.lang.Exception
Create an HTTP server listening for incoming connections on the default port of 8080.

Throws:
java.lang.Exception

httpServer

public httpServer(ManagerIF mgr,
                  SinkIF clientSink,
                  int listenPort)
           throws java.lang.Exception
Create an HTTP server listening for incoming connections on the given listenPort.

Throws:
java.lang.Exception
Method Detail

init

public void init(ConfigDataIF config)
          throws java.lang.Exception
The Sandstorm stage initialization method.

Specified by:
init in interface EventHandlerIF
Parameters:
config - The set of configuration parameters for the stage.
Throws:
java.lang.Exception - The EventHandler can indicate an error to the runtime during initialization by throwing an Exception.

destroy

public void destroy()
The Sandstorm stage destroy method.

Specified by:
destroy in interface EventHandlerIF

handleEvent

public void handleEvent(QueueElementIF qel)
The main event handler.

Specified by:
handleEvent in interface EventHandlerIF

handleEvents

public void handleEvents(QueueElementIF[] qelarr)
Description copied from interface: EventHandlerIF
Handle the events corresponding to the given QueueElementIF array. This method is invoked when multiple events are pending for the event handler. The application may reorder, filter, or drop these events if it wishes to do so.

Specified by:
handleEvents in interface EventHandlerIF

cleanupConnection

void cleanupConnection(httpConnection hc)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

registerSink

public void registerSink(SinkIF sink)
Register a sink to receive incoming packets on this connection.


suspendAccept

public void suspendAccept()
Suspend acceptance of new connections on this server. This request will not be effective immediately.


resumeAccept

public void resumeAccept()
Resume acceptance of new connections on this server. This request will not be effective immediately.


getSink

SinkIF getSink()

getServerSocket

public ATcpServerSocket getServerSocket()
Return the server socket being used by this httpServer.