|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.net.httpserver.HttpServer
sun.net.httpserver.HttpServerImpl
public class HttpServerImpl
| Method Summary | |
|---|---|
void |
bind(java.net.InetSocketAddress addr,
int backlog)
Binds a currently unbound HttpServer to the given address and port number. |
sun.net.httpserver.HttpContextImpl |
createContext(java.lang.String path)
Creates a HttpContext without initially specifying a handler. |
sun.net.httpserver.HttpContextImpl |
createContext(java.lang.String path,
HttpHandler handler)
Creates a HttpContext. |
java.net.InetSocketAddress |
getAddress()
returns the address this server is listening on |
java.util.concurrent.Executor |
getExecutor()
returns this server's Executor object if one was specified with HttpServer.setExecutor(Executor), or null if none was
specified. |
void |
removeContext(HttpContext context)
Removes the given context from the server. |
void |
removeContext(java.lang.String path)
Removes the context identified by the given path from the server. |
void |
setExecutor(java.util.concurrent.Executor executor)
sets this server's Executor object. |
void |
start()
Starts this server in a new background thread. |
void |
stop(int delay)
stops this server by closing the listening socket and disallowing any new exchanges from being processed. |
| Methods inherited from class com.sun.net.httpserver.HttpServer |
|---|
create, create |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public void bind(java.net.InetSocketAddress addr,
int backlog)
throws java.io.IOException
HttpServer
bind in class HttpServeraddr - the address to listen onbacklog - the socket backlog. If this value is less than or equal to zero,
then a system default value is used.
java.net.BindException - if the server cannot bind to the requested address or if the server
is already bound.
java.io.IOExceptionpublic void start()
HttpServer
start in class HttpServerpublic void setExecutor(java.util.concurrent.Executor executor)
HttpServerExecutor object. An
Executor must be established before HttpServer.start() is called.
All HTTP requests are handled in tasks given to the executor.
If this method is not called (before start()) or if it is
called with a null Executor, then
a default implementation is used, which uses the thread
which was created by the HttpServer.start() method.
setExecutor in class HttpServerexecutor - the Executor to set, or null for default
implementationpublic java.util.concurrent.Executor getExecutor()
HttpServerHttpServer.setExecutor(Executor), or null if none was
specified.
getExecutor in class HttpServernull if not set.public void stop(int delay)
HttpServer
stop in class HttpServerdelay - the maximum time in seconds to wait until exchanges have finished.
public sun.net.httpserver.HttpContextImpl createContext(java.lang.String path,
HttpHandler handler)
HttpServerHttpServer.removeContext(String) method.
The path specifies the root URI path for this context. The first character of path must be '/'.
The class overview describes how incoming request URIs are mapped to HttpContext instances.
createContext in class HttpServerpath - the root URI path to associate the context withhandler - the handler to invoke for incoming requests.public sun.net.httpserver.HttpContextImpl createContext(java.lang.String path)
HttpServerHttpContext.setHandler(HttpHandler). A HttpContext represents a mapping from a
URI path to an exchange handler on this HttpServer. Once created, and when
the handler has been set, all requests
received by the server for the path will be handled by calling
the handler object. The context is identified by the path, and
can later be removed from the server using this with the HttpServer.removeContext(String) method.
The path specifies the root URI path for this context. The first character of path must be '/'.
The class overview describes how incoming request URIs are mapped to HttpContext instances.
createContext in class HttpServerpath - the root URI path to associate the context with
public void removeContext(java.lang.String path)
throws java.lang.IllegalArgumentException
HttpServer
removeContext in class HttpServerpath - the path of the handler to remove
java.lang.IllegalArgumentException - if no handler corresponding to this
path exists.
public void removeContext(HttpContext context)
throws java.lang.IllegalArgumentException
HttpServer
removeContext in class HttpServercontext - the context to remove
java.lang.IllegalArgumentExceptionpublic java.net.InetSocketAddress getAddress()
HttpServer
getAddress in class HttpServer
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||