Thread.State, Thread.UncaughtExceptionHandler| Modifier and Type | Field and Description |
|---|---|
static String |
CX_AUTH |
static String |
CX_SOCKET |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
HttpServer()
Creates a new server.
|
| Modifier and Type | Method and Description |
|---|---|
void |
bind(InetSocketAddress address)
Set the server's listening address.
|
void |
bind(ServerSocketChannel newSock)
Set the server's listening socket.
|
void |
register(String pattern,
org.apache.http.protocol.HttpRequestHandler handler)
Register a path with a handler.
|
void |
run() |
void |
stopServer()
Shut down the HTTP server and all its workers, and close the listener socket.
|
void |
unregister(String pattern)
Unregister a given path.
|
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, yieldpublic static final String CX_SOCKET
public static final String CX_AUTH
public HttpServer()
bind(java.net.InetSocketAddress) method to make it use a socket,
and then invoke the Thread.start() method to start it up in the background.
Use register(String, org.apache.http.protocol.HttpRequestHandler) to add
handlers which respond to various URL pathspublic void bind(InetSocketAddress address) throws IOException
bind(java.nio.channels.ServerSocketChannel)address - The address the server should listen onIOException - if a new socket could not be createdpublic void bind(ServerSocketChannel newSock)
bind(java.net.InetSocketAddress).newSock - An existing listening socket.public void register(String pattern, org.apache.http.protocol.HttpRequestHandler handler)
UriHttpRequestHandlerMapperpattern - The path to registerhandler - The handler to handle the pathpublic void unregister(String pattern)
pattern - The pattern to unregister. Must have previously been registered
via register(String, org.apache.http.protocol.HttpRequestHandler)public void stopServer()
Copyright © 2017. All rights reserved.