csli.util.socket
Class BasicHttpServer

java.lang.Object
  extended by java.lang.Thread
      extended by csli.util.socket.BasicHttpServer
All Implemented Interfaces:
Runnable

public class BasicHttpServer
extends Thread

A very basic HTTP server which is it's own thread that listens to a socket on a specified port and sends requests to specified request handler. It subclasses thread, so all the usual mechanisms for changing priority, restarting, etc. are available.


Nested Class Summary
static interface BasicHttpServer.HttpRequestHandler
          The interface which the request handlers must implement.
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected static org.apache.log4j.Logger logger
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
BasicHttpServer()
           
 
Method Summary
 BasicHttpServer.HttpRequestHandler getRequestHandler()
          Get the currently set request handler.
 int getServerPort()
          Get the currently set port on which the server is accepting connections.
 File getWebRootDir()
          Get the directory where web content is located.
 void run()
           
 void setRequestHandler(BasicHttpServer.HttpRequestHandler requestHandler)
          Set the class which should be used as the request handler -- takes effect on the next accepted connection.
 void setServerPort(int port)
          Set the port on which the server will run -- takes effect only after the server has been restarted.
 
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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected static org.apache.log4j.Logger logger
Constructor Detail

BasicHttpServer

public BasicHttpServer()
Method Detail

getRequestHandler

public BasicHttpServer.HttpRequestHandler getRequestHandler()
Get the currently set request handler.

Returns:

getServerPort

public int getServerPort()
Get the currently set port on which the server is accepting connections.

Returns:

getWebRootDir

public File getWebRootDir()
Get the directory where web content is located.

Returns:
a directory as a File object

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

setRequestHandler

public void setRequestHandler(BasicHttpServer.HttpRequestHandler requestHandler)
Set the class which should be used as the request handler -- takes effect on the next accepted connection.

Parameters:
requestHandler -

setServerPort

public void setServerPort(int port)
Set the port on which the server will run -- takes effect only after the server has been restarted.

Parameters:
port -