|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
com.bbn.openmap.layer.util.http.HttpServer
A simple HTTP Server implementing HTTP/0.9 protocols.
Cobbled together from a server originally written by David Flanagan
for the book
Field Summary | |
static int |
DEFAULT_PORT
The default port. |
protected java.net.ServerSocket |
listen_socket
|
protected java.util.Vector |
listeners
|
protected int |
port
|
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
HttpServer()
Creates an Http Server on any free port, and then starts a thread that listens to that port. |
|
HttpServer(int port)
Creates an Http Server on the indicated port, and then starts a thread that listens to that port. |
|
HttpServer(int port,
boolean asDaemon)
Creates an Http Server on the indicated port, and then starts a thread that listens to that port. |
Method Summary | |
void |
addHttpRequestListener(HttpRequestListener l)
Adds a new http request listener. |
HttpRequestEvent |
fireHttpRequestEvent(java.lang.String request,
java.io.OutputStream output)
Creates a HttpRequestEvent and sends it to all registered listeners. |
int |
getPort()
Gets the port associate with this server. |
static void |
main(java.lang.String[] args)
A main routine for unit testing. |
void |
removeHttpRequestListener(HttpRequestListener l)
Removes an http request listener. |
void |
run()
The body of the server thread. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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 |
public static final int DEFAULT_PORT
protected int port
protected java.net.ServerSocket listen_socket
protected java.util.Vector listeners
Constructor Detail |
public HttpServer(int port) throws java.io.IOException
port
- the port to openServerSocket
public HttpServer(int port, boolean asDaemon) throws java.io.IOException
port
- the port to openasDaemon
- whether to make thread a daemonServerSocket
public HttpServer() throws java.io.IOException
ServerSocket
Method Detail |
public void run()
HttpConnection
,
Socket
public int getPort()
public HttpRequestEvent fireHttpRequestEvent(java.lang.String request, java.io.OutputStream output) throws java.io.IOException
request
- the parsed http requestoutput
- OutputStream associated with the request's client
connection.
java.io.IOException
DataOutputStream
,
HttpRequestListener
,
HttpRequestEvent
public void addHttpRequestListener(HttpRequestListener l)
l
- the listenerHttpRequestListener
public void removeHttpRequestListener(HttpRequestListener l)
l
- a listenerHttpRequestListener
public static void main(java.lang.String[] args)
Usage: java com.bbn.openmap.layer.util.http.HttpServer [port]
If no port is specified, the default port is used.
If port zero is specified, the system chooses the port.
If a port other than zero is specified, the http server will attempt to open that port, or fail if it is in use.
Examples:
java com.bbn.openmap.layer.util.http.HttpServer
java com.bbn.openmap.layer.util.http.HttpServer 8000
java com.bbn.openmap.layer.util.http.HttpServer 0
args
- command line args
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |