More information: http://www.cs.berkeley.edu/~mdw/proj/seda/

seda.sandStorm.lib.http
Class httpServer

java.lang.Object
  |
  +--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.

Author:
Matt Welsh (mdw at cs dot berkeley dot edu)
See Also:
httpConnection, httpRequest

Field Summary
protected  SinkIF clientSink
           
protected  int listenPort
           
protected  ManagerIF mgr
           
protected  SinkIF mySink
           
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

listenPort

protected int listenPort

servsock

protected ATcpServerSocket servsock

mgr

protected ManagerIF mgr

mySink

protected SinkIF mySink

clientSink

protected SinkIF clientSink
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.

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.
Method Detail

init

public void init(ConfigDataIF config)
          throws java.lang.Exception
The Sandstorm stage initialization method.
Specified by:
init in interface EventHandlerIF
Following copied from interface: seda.sandStorm.api.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
Following copied from interface: seda.sandStorm.api.EventHandlerIF
Throws:
java.lang.Exception - The EventHandler can indicate an error to the runtime during shutdown by throwing an Exception.

handleEvent

public void handleEvent(QueueElementIF qel)
The main event handler.
Specified by:
handleEvent in interface EventHandlerIF
Following copied from interface: seda.sandStorm.api.EventHandlerIF
Throws:
EventHandlerException - The application may throw an exception to indicate an error condition during event processing.

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
Following copied from interface: seda.sandStorm.api.EventHandlerIF
Throws:
EventHandlerException - The application may throw an exception to indicate an error condition during event processing.

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.

More information: http://www.cs.berkeley.edu/~mdw/proj/seda/