|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.mortbay.http.HttpServer
HTTP Server. Services HTTP requests by maintaining a mapping between a collection of HttpListeners which generate requests and HttpContexts which contain collections of HttpHandlers. This class is configured by API calls. The org.mortbay.jetty.Server class uses XML configuration files to configure instances of this class. The HttpServer implements the BeanContext API so that membership events may be generated for HttpListeners, HttpContexts and WebApplications.
HttpContext
,
HttpHandler
,
HttpConnection
,
HttpListener
,
Server
,
Serialized FormNested Class Summary | |
class |
HttpServer.ComponentEvent
|
static interface |
HttpServer.ComponentEventListener
|
Constructor Summary | |
HttpServer()
Constructor. |
|
HttpServer(boolean anonymous)
Constructor. |
Method Summary | |
HttpContext |
addContext(HttpContext context)
Add a context. |
HttpContext |
addContext(java.lang.String contextPath)
Create and add a new context. |
HttpContext |
addContext(java.lang.String virtualHost,
HttpContext context)
Add a context. |
HttpContext |
addContext(java.lang.String virtualHost,
java.lang.String contextPathSpec)
Create and add a new context. |
void |
addEventListener(java.util.EventListener listener)
Add a server event listener. |
void |
addHostAlias(java.lang.String virtualHost,
java.lang.String alias)
Deprecated. Use HttpContext.addVirtualHost |
HttpListener |
addListener(HttpListener listener)
Add a HTTP Listener to the server. |
HttpListener |
addListener(InetAddrPort address)
Create and add a SocketListener. |
HttpListener |
addListener(java.lang.String address)
Create and add a SocketListener. |
UserRealm |
addRealm(UserRealm realm)
|
void |
destroy()
Destroy a stopped server. |
HttpHandler |
findHandler(java.lang.Class handlerClass,
java.lang.String uri,
java.lang.String[] vhosts)
Find handler. |
int |
getConnections()
|
long |
getConnectionsDurationAve()
|
long |
getConnectionsDurationMax()
|
int |
getConnectionsOpen()
|
int |
getConnectionsOpenMax()
|
int |
getConnectionsRequestsAve()
|
int |
getConnectionsRequestsMax()
|
HttpContext |
getContext(java.lang.String contextPathSpec)
Get or create context. |
HttpContext |
getContext(java.lang.String virtualHost,
java.lang.String contextPathSpec)
Get or create context. |
HttpContext |
getContext(java.lang.String virtualHost,
java.lang.String contextPathSpec,
int i)
Get specific context. |
HttpContext[] |
getContexts()
|
int |
getErrors()
|
java.util.Map |
getHostMap()
|
static java.util.List |
getHttpServerList()
Deprecated. User getHttpServers() |
static java.util.Collection |
getHttpServers()
Get HttpServer Collection. |
HttpListener[] |
getListeners()
|
UserRealm |
getRealm(java.lang.String realmName)
Get a named UserRealm. |
RequestLog |
getRequestLog()
|
int |
getRequests()
|
int |
getRequestsActive()
|
int |
getRequestsActiveMax()
|
long |
getRequestsDurationAve()
|
long |
getRequestsDurationMax()
|
int |
getRequestsPerGC()
Get the requests per GC. |
boolean |
getResolveRemoteHost()
|
boolean |
getStatsOn()
|
long |
getStatsOnMs()
|
boolean |
getTrace()
|
boolean |
isStarted()
|
void |
join()
Join the listeners. |
static void |
main(java.lang.String[] args)
Construct server from command line arguments. |
boolean |
removeContext(HttpContext context)
Remove a context or Web application. |
void |
removeEventListener(java.util.EventListener listener)
|
void |
removeListener(HttpListener listener)
Remove a HTTP Listener. |
UserRealm |
removeRealm(java.lang.String realmName)
|
void |
save(java.lang.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 |
setChunkingForced(boolean forced)
Deprecated. |
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 |
setStatsOn(boolean on)
|
void |
setTrace(boolean trace)
|
void |
start()
Start all handlers then listeners. |
void |
statsReset()
Reset statistics. |
void |
stop()
Stop all listeners then all contexts. |
void |
stop(boolean graceful)
Stop all listeners then all contexts. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public HttpServer()
public HttpServer(boolean anonymous)
anonymous
- If true, the server is not included in the
static server lists and stopAll methods.Method Detail |
public static java.util.Collection getHttpServers()
public static java.util.List getHttpServerList()
public void setAnonymous(boolean anonymous)
anonymous
- If true, the server is not included in the
static server lists and stopAll methods.public void setListeners(HttpListener[] listeners)
listeners
- Array of HttpListeners.public HttpListener[] getListeners()
public HttpListener addListener(java.lang.String address) throws java.io.IOException
address
-
java.io.IOException
public HttpListener addListener(InetAddrPort address) throws java.io.IOException
address
-
java.io.IOException
public HttpListener addListener(HttpListener listener) throws java.lang.IllegalArgumentException
listener
- The Listener.
java.lang.IllegalArgumentException
- If the listener is not for this
server.public void removeListener(HttpListener listener)
listener
- public void setContexts(HttpContext[] contexts)
public HttpContext[] getContexts()
public HttpContext addContext(HttpContext context)
context
- public boolean removeContext(HttpContext context) throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if context not stoppedpublic HttpContext addContext(java.lang.String virtualHost, HttpContext context)
virtualHost
- The virtual host or null for all hosts.context
- public HttpContext addContext(java.lang.String contextPath)
contextPath
-
public HttpContext addContext(java.lang.String virtualHost, java.lang.String contextPathSpec)
virtualHost
- Virtual hostname or null for all hosts.contextPathSpec
- Path specification relative to the context path.
public HttpContext getContext(java.lang.String virtualHost, java.lang.String contextPathSpec, int i)
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.
public HttpContext getContext(java.lang.String virtualHost, java.lang.String contextPathSpec)
virtualHost
- The virtual host or null for all hosts.contextPathSpec
-
public HttpContext getContext(java.lang.String contextPathSpec)
contextPathSpec
- Path specification relative to the context path.
public boolean getTrace()
public void setTrace(boolean trace)
trace
- True if the TRACE method is fully implemented.public int getRequestsPerGC()
public void setRequestsPerGC(int requestsPerGC)
requestsPerGC
- Approx requests per garbage collection.public void start() throws MultiException
start
in interface LifeCycle
MultiException
- A collection of exceptions thrown by
start() method of subcomponents of the HttpServer.public boolean isStarted()
isStarted
in interface LifeCycle
public void stop() throws java.lang.InterruptedException
stop
in interface LifeCycle
java.lang.InterruptedException
- If interrupted, stop may not have
been called on everything.public void stop(boolean graceful) throws java.lang.InterruptedException
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.
java.lang.InterruptedException
public void join() throws java.lang.InterruptedException
java.lang.InterruptedException
public void addHostAlias(java.lang.String virtualHost, java.lang.String alias)
virtualHost
- Host name or IPalias
- Alias hostname or IPpublic void setRequestLog(RequestLog log)
log
- RequestLog to use.public RequestLog getRequestLog()
public HttpContext service(HttpRequest request, HttpResponse response) throws java.io.IOException, HttpException
request
- response
-
java.io.IOException
HttpException
public HttpHandler findHandler(java.lang.Class handlerClass, java.lang.String uri, java.lang.String[] vhosts)
uri
- URI that must be satisfied by the servlet handlervhosts
- null or a list of virtual hosts names to search
public UserRealm addRealm(UserRealm realm)
public UserRealm getRealm(java.lang.String realmName)
realmName
- The name of the realm or null.
public UserRealm removeRealm(java.lang.String realmName)
public void setChunkingForced(boolean forced)
public java.util.Map getHostMap()
public boolean getResolveRemoteHost()
public void setResolveRemoteHost(boolean resolveRemoteHost)
resolveRemoteHost
- True if the remote host name of connections is resolved.public void statsReset()
public void setStatsOn(boolean on)
public boolean getStatsOn()
public long getStatsOnMs()
public int getConnections()
public int getConnectionsOpen()
public int getConnectionsOpenMax()
public long getConnectionsDurationAve()
public long getConnectionsDurationMax()
public int getConnectionsRequestsAve()
public int getConnectionsRequestsMax()
public int getErrors()
public int getRequests()
public int getRequestsActive()
public int getRequestsActiveMax()
public long getRequestsDurationAve()
public long getRequestsDurationMax()
public void addEventListener(java.util.EventListener listener)
listener
- HttpServer.ComponentEventListenerpublic void removeEventListener(java.util.EventListener listener)
public void save(java.lang.String saveat) throws java.net.MalformedURLException, java.io.IOException
saveat
- A file or URL to save the configuration at.
java.net.MalformedURLException
java.io.IOException
public void destroy()
public static void main(java.lang.String[] args)
args
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |