org.mortbay.http
public class HttpServer extends Container implements LifeCycle, EventProvider, Serializable
Version: $Id: HttpServer.java,v 1.70 2005/12/04 11:43:21 gregwilkins Exp $
See Also: HttpContext HttpHandler HttpConnection HttpListener Server
Constructor Summary | |
---|---|
HttpServer() Constructor. | |
HttpServer(boolean anonymous) Constructor. |
Method Summary | |
---|---|
HttpContext | addContext(HttpContext context) Add a context. |
HttpContext | addContext(String virtualHost, HttpContext context) Add a context.
|
HttpContext | addContext(String contextPath) Create and add a new context.
|
HttpContext | addContext(String virtualHost, String contextPathSpec) Create and add a new context.
|
void | addHostAlias(String virtualHost, String alias) Define a virtual host alias.
|
HttpListener | addListener(String address) Create and add a SocketListener.
|
HttpListener | addListener(InetAddrPort address) Create and add a SocketListener.
|
HttpListener | addListener(HttpListener listener) Add a HTTP Listener to the server. |
UserRealm | addRealm(UserRealm realm) |
void | destroy() Destroy a stopped server.
|
protected void | doStart() Start all handlers then listeners.
|
protected void | doStop() Stop all listeners then all contexts.
|
HttpHandler | findHandler(Class handlerClass, String uri, String[] vhosts) Find handler.
|
int | getConnections() |
long | getConnectionsDurationAve() |
long | getConnectionsDurationMax() |
long | getConnectionsDurationMin() |
long | getConnectionsDurationTotal() |
int | getConnectionsOpen() |
int | getConnectionsOpenMax() |
int | getConnectionsOpenMin() |
int | getConnectionsRequestsAve() |
int | getConnectionsRequestsMax() |
int | getConnectionsRequestsMin() |
HttpContext | getContext(String virtualHost, String contextPathSpec, int i) Get specific context. |
HttpContext | getContext(String virtualHost, String contextPathSpec) Get or create context. |
HttpContext | getContext(String contextPathSpec) Get or create context. |
HttpContext[] | getContexts() |
int | getErrors() |
Map | getHostMap() |
static List | getHttpServerList() |
static Collection | getHttpServers() Get HttpServer Collection.
|
HttpListener[] | getListeners() |
UserRealm | getRealm(String realmName) Get a named UserRealm. |
RequestLog | getRequestLog() |
int | getRequests() |
int | getRequestsActive() |
int | getRequestsActiveMax() |
int | getRequestsActiveMin() |
long | getRequestsDurationAve() |
long | getRequestsDurationMax() |
long | getRequestsDurationMin() |
long | getRequestsDurationTotal() |
int | getRequestsPerGC() Get the requests per GC.
|
boolean | getResolveRemoteHost() |
String[] | getServerClasses() Get system classes. |
boolean | getStatsOn() |
long | getStatsOnMs() |
boolean | getStopGracefully() |
String[] | getSystemClasses() Get system classes. |
boolean | getTrace() |
void | join() Join the listeners.
|
static void | main(String[] args) Construct server from command line arguments. |
protected HttpContext | newHttpContext() Create a new HttpContext.
|
boolean | removeContext(HttpContext context) Remove a context or Web application. |
void | removeListener(HttpListener listener) Remove a HTTP Listener. |
UserRealm | removeRealm(String realmName) |
void | save(String saveat) Save the HttpServer
The server is saved by serialization to the given filename or URL.
|
HttpContext | service(HttpRequest request, HttpResponse response) Service a request.
|
void | setAnonymous(boolean anonymous) |
void | setContexts(HttpContext[] contexts) |
void | setListeners(HttpListener[] listeners) |
void | setRequestLog(RequestLog log) Set the request log. |
void | setRequestsPerGC(int requestsPerGC) Set the requests per GC.
|
void | setResolveRemoteHost(boolean resolveRemoteHost) |
void | setServerClasses(String[] classes) Set system classes. |
void | setStatsOn(boolean on) |
void | setStopGracefully(boolean graceful) |
void | setSystemClasses(String[] classes) Set system classes. |
void | setTrace(boolean trace) |
void | statsReset() Reset statistics. |
void | stop(boolean graceful) Stop all listeners then all contexts. |
Parameters: anonymous If true, the server is not included in the static server lists and stopAll methods.
Parameters: context
Parameters: virtualHost The virtual host or null for all hosts. context
Parameters: contextPath
Returns: A HttpContext instance created by a call to newHttpContext.
Parameters: virtualHost Virtual hostname or null for all hosts. contextPathSpec Path specification relative to the context path.
Returns: A HttpContext instance created by a call to newHttpContext.
Deprecated: Use HttpContext.addVirtualHost
Define a virtual host alias. All requests to the alias are handled the same as request for the virtualHost.Parameters: virtualHost Host name or IP alias Alias hostname or IP
Parameters: address
Returns: the HttpListener.
Throws: IOException
Parameters: address
Returns: the HttpListener.
Throws: IOException
Parameters: listener The Listener.
Throws: IllegalArgumentException If the listener is not for this server.
Throws: MultiException A collection of exceptions thrown by start() method of subcomponents of the HttpServer.
Throws: InterruptedException If interrupted, stop may not have been called on everything.
Parameters: uri URI that must be satisfied by the servlet handler vhosts null or a list of virtual hosts names to search
Returns: HttpHandler
Returns: Number of connections accepted by the server since statsReset() called. Undefined if setStatsOn(false).
Returns: Average duration in milliseconds of open connections since statsReset() called. Undefined if setStatsOn(false).
Returns: Maximum duration in milliseconds of an open connection since statsReset() called. Undefined if setStatsOn(false).
Returns: Returns the connectionsDurationMin.
Returns: Returns the connectionsDurationTotal.
Returns: Number of connections currently open that were opened since statsReset() called. Undefined if setStatsOn(false).
Returns: Maximum number of connections opened simultaneously since statsReset() called. Undefined if setStatsOn(false).
Returns: Returns the connectionsOpenMin.
Returns: Average number of requests per connection since statsReset() called. Undefined if setStatsOn(false).
Returns: Maximum number of requests per connection since statsReset() called. Undefined if setStatsOn(false).
Returns: Returns the connectionsRequestsMin.
Parameters: virtualHost The virtual host or null for all hosts. contextPathSpec Path specification relative to the context path. i Index among contexts of same virtualHost and pathSpec.
Returns: The HttpContext or null.
Parameters: virtualHost The virtual host or null for all hosts. contextPathSpec
Returns: HttpContext. If multiple contexts exist for the same virtualHost and pathSpec, the most recently added context is returned. If no context exists, a new context is created by a call to newHttpContext.
Parameters: contextPathSpec Path specification relative to the context path.
Returns: The HttpContext If multiple contexts exist for the same pathSpec, the most recently added context is returned. If no context exists, a new context is created by a call to newHttpContext.
Returns: Number of errors generated while handling requests. since statsReset() called. Undefined if setStatsOn(false).
Deprecated: User getHttpServers()
Returns: Collection of all servers.
Returns: Array of HttpListeners.
Parameters: realmName The name of the realm or null.
Returns: The named realm. If the name is null and only a single realm is known, that is returned.
Returns: Number of requests since statsReset() called. Undefined if setStatsOn(false).
Returns: Number of requests currently active. Undefined if setStatsOn(false).
Returns: Maximum number of active requests since statsReset() called. Undefined if setStatsOn(false).
Returns: Returns the requestsActiveMin.
Returns: Average duration of request handling in milliseconds since statsReset() called. Undefined if setStatsOn(false).
Returns: Get maximum duration in milliseconds of request handling since statsReset() called. Undefined if setStatsOn(false).
Returns: Returns the requestsDurationMin.
Returns: Returns the requestsDurationTotal.
Returns: Approx requests per garbage collection.
Returns: True if the remote host name of connections is resolved.
UNKNOWN: Use HttpContext
Returns: True if statistics collection is turned on.
Returns: Timestamp stats were started at.
UNKNOWN: Use HttpContext
Returns: True if the TRACE method is fully implemented.
Throws: InterruptedException
Parameters: args
Returns: A new instance of HttpContext or a subclass of HttpContext
Throws: IllegalStateException if context not stopped
Parameters: listener
Parameters: saveat A file or URL to save the configuration at.
Throws: MalformedURLException IOException
Parameters: request response
Returns: The HttpContext that completed handling of the request or null.
Throws: IOException HttpException
Parameters: anonymous If true, the server is not included in the static server lists and stopAll methods.
Parameters: listeners Array of HttpListeners.
Parameters: log RequestLog to use.
Parameters: requestsPerGC Approx requests per garbage collection.
Parameters: resolveRemoteHost True if the remote host name of connections is resolved.
UNKNOWN: Use HttpContext
UNKNOWN: Use HttpContext
Parameters: trace True if the TRACE method is fully implemented.
Parameters: graceful If true and statistics are on for a context, then this method will wait for requestsActive to go to zero before stopping that context.