public class HttpServerImpl extends HttpServer
Modifier and Type | Method and Description |
---|---|
void |
bind(InetSocketAddress addr,
int backlog)
Binds a currently unbound HttpServer to the given address and port number.
|
org.jboss.sun.net.httpserver.HttpContextImpl |
createContext(String path)
Creates a HttpContext without initially specifying a handler.
|
org.jboss.sun.net.httpserver.HttpContextImpl |
createContext(String path,
HttpHandler handler)
Creates a HttpContext.
|
InetSocketAddress |
getAddress()
returns the address this server is listening on
|
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(String path)
Removes the context identified by the given path from the server.
|
void |
setExecutor(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.
|
create, create, create
public void bind(InetSocketAddress addr, int backlog) throws IOException
HttpServer
bind
in class HttpServer
addr
- 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.BindException
- if the server cannot bind to the requested address or if the server
is already bound.IOException
public void start()
HttpServer
start
in class HttpServer
public void setExecutor(Executor executor)
HttpServer
Executor
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 HttpServer
executor
- the Executor to set, or null
for default
implementationpublic Executor getExecutor()
HttpServer
HttpServer.setExecutor(Executor)
, or null
if none was
specified.getExecutor
in class HttpServer
null
if not set.public void stop(int delay)
HttpServer
stop
in class HttpServer
delay
- the maximum time in seconds to wait until exchanges have finished.public org.jboss.sun.net.httpserver.HttpContextImpl createContext(String path, HttpHandler handler)
HttpServer
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 HttpServer
path
- the root URI path to associate the context withhandler
- the handler to invoke for incoming requests.public org.jboss.sun.net.httpserver.HttpContextImpl createContext(String path)
HttpServer
HttpContext.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 HttpServer
path
- the root URI path to associate the context withpublic void removeContext(String path) throws IllegalArgumentException
HttpServer
removeContext
in class HttpServer
path
- the path of the handler to removeIllegalArgumentException
- if no handler corresponding to this
path exists.public void removeContext(HttpContext context) throws IllegalArgumentException
HttpServer
removeContext
in class HttpServer
context
- the context to removeIllegalArgumentException
public InetSocketAddress getAddress()
HttpServer
getAddress
in class HttpServer
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.