|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
com.bbn.openmap.util.http.HttpServer
public class HttpServer
A simple HTTP Server implementing HTTP/0.9 protocols. Cobbled together from a server originally written by David Flanagan for the book Java in a Nutshell , Copyright(c) 1996 O'Reilly & Associates. Modified to use JDK 1.1 Readers, and Writers. Further modified to use the JDK 1.1 Event model.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| 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, clone, 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 |
|---|
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 open
java.io.IOExceptionServerSocket
public HttpServer(int port,
boolean asDaemon)
throws java.io.IOException
port - the port to openasDaemon - whether to make thread a daemon
java.io.IOExceptionServerSocket
public HttpServer()
throws java.io.IOException
java.io.IOExceptionServerSocket| Method Detail |
|---|
public void run()
run in interface java.lang.Runnablerun in class java.lang.ThreadHttpConnection,
Socketpublic 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.IOExceptionDataOutputStream,
HttpRequestListener,
HttpRequestEventpublic void addHttpRequestListener(HttpRequestListener l)
l - the listenerHttpRequestListenerpublic void removeHttpRequestListener(HttpRequestListener l)
l - a listenerHttpRequestListenerpublic 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 | |||||||||