public abstract class HttpHost extends Object
HttpServer
subclass. A "virtual" host allows for more than one set of registered contexts
per physical server, differentiated by host name, IP address, or other criteria.
One or more HttpHandler
objects must be associated with a host
in order to process requests. Each such HttpHandler is registered
with a root URI path which represents the
location of the application or service on this server. The mapping of a handler
to a HttpHost
is essentially equivalent to the mapping of a handler to a
HttpServer
.
Constructor and Description |
---|
HttpHost() |
Modifier and Type | Method and Description |
---|---|
abstract HttpContext |
createContext(String path)
Creates a
HttpContext without initially specifying a handler. |
abstract HttpContext |
createContext(String path,
HttpHandler handler)
Creates a
HttpContext . |
abstract void |
removeContext(HttpContext context)
Removes the given context from the server.
|
abstract void |
removeContext(String path)
Removes the context identified by the given path from the server.
|
public abstract HttpContext createContext(String path, HttpHandler handler)
HttpContext
. A HttpContext
represents a mapping from a
URI path to a exchange handler on this HttpHost
. Once created, all requests
received by the server for the path will be handled by calling
the given handler object. The context is identified by the path, and
can later be removed from the server using this with the 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.
path
- the root URI path to associate the context withhandler
- the handler to invoke for incoming requests.IllegalArgumentException
- if path is invalid, or if a context
already exists for this pathNullPointerException
- if either path, or handler are null
public abstract HttpContext createContext(String path)
HttpContext
without initially specifying a handler. The handler must later be specified using
com.sun.net.httpserver.HttpContext#setHandler(com.sun.net.httpserver.HttpHandler)
. A HttpContext
represents a mapping from a
URI path to an exchange handler on this HttpHost
. 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 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.
path
- the root URI path to associate the context withIllegalArgumentException
- if path is invalid, or if a context
already exists for this pathNullPointerException
- if path is null
public abstract void removeContext(String path) throws IllegalArgumentException
path
- the path of the handler to removeIllegalArgumentException
- if no handler corresponding to this
path exists.NullPointerException
- if path is null
public abstract void removeContext(HttpContext context) throws IllegalArgumentException
context
- the context to removeIllegalArgumentException
- if the given context is not registered on this hostNullPointerException
- if context is null
Copyright © 2013 JBoss, a division of Red Hat, Inc.. All Rights Reserved.