org.mortbay.http
Class HttpContext

java.lang.Object
  extended byorg.mortbay.util.Container
      extended byorg.mortbay.http.HttpContext
All Implemented Interfaces:
EventProvider, HttpHandler, LifeCycle, java.io.Serializable
Direct Known Subclasses:
ServletHttpContext

public class HttpContext
extends Container
implements LifeCycle, HttpHandler, EventProvider, java.io.Serializable

Context for a collection of HttpHandlers. HTTP Context provides an ordered container for HttpHandlers that share the same path prefix, filebase, resourcebase and/or classpath.

A HttpContext is analagous to a ServletContext in the Servlet API, except that it may contain other types of handler other than servlets.

A ClassLoader is created for the context and it uses Thread.currentThread().getContextClassLoader(); as it's parent loader. The class loader is initialized during start(), when a derived context calls initClassLoader() or on the first call to loadClass()

Note. that order is important when configuring a HttpContext. For example, if resource serving is enabled before servlets, then resources take priority.

Version:
$Id: HttpContext.java,v 1.135 2005/11/19 09:04:53 gregwilkins Exp $
Author:
Greg Wilkins (gregw)
See Also:
HttpServer, HttpHandler, ServletHttpContext, Serialized Form

Field Summary
static java.lang.String __ErrorHandler
           
static java.lang.String __fileClassPathAttr
          File class path attribute.
 
Constructor Summary
HttpContext()
          Constructor.
HttpContext(HttpServer httpServer, java.lang.String contextPathSpec)
          Constructor.
 
Method Summary
 void addClassPath(java.lang.String classPath)
          Add the class path element to the context.
 void addClassPaths(Resource lib)
          Add elements to the class path for the context from the jar and zip files found in the specified resource.
 void addHandler(HttpHandler handler)
          Add a HttpHandler to the context.
 void addHandler(int i, HttpHandler handler)
          Add a handler.
 void addPermission(java.security.Permission permission)
          Add a permission to this context.
 void addSecurityConstraint(java.lang.String pathSpec, SecurityConstraint sc)
           
 void addVirtualHost(java.lang.String hostname)
          Add a virtual host alias to this context.
 void addWelcomeFile(java.lang.String welcomeFile)
           
static java.lang.String canonicalContextPathSpec(java.lang.String contextPathSpec)
           
 boolean checkSecurityConstraints(java.lang.String pathInContext, HttpRequest request, HttpResponse response)
           
 void clearSecurityConstraints()
           
 void destroy()
          Destroy a context.
 java.lang.Object enterContextScope(HttpRequest request, HttpResponse response)
          Enter the context scope.
 void flushCache()
           
 java.lang.Object getAttribute(java.lang.String name)
           
 java.util.Enumeration getAttributeNames()
           
 java.util.Map getAttributes()
           
 Authenticator getAuthenticator()
           
 Resource getBaseResource()
           
 java.lang.ClassLoader getClassLoader()
          Get the classloader.
 java.lang.String getClassPath()
          Get the context classpath.
 java.lang.String getContextPath()
           
 java.lang.String getEncodingByMimeType(java.lang.String type)
           
 java.util.Map getEncodingMap()
           
 java.lang.String getFileClassPath()
          Get the file classpath of the context.
 HttpHandler getHandler(java.lang.Class handlerClass)
          Get a handler by class.
 int getHandlerIndex(HttpHandler handler)
          Get handler index.
 HttpHandler[] getHandlers()
          Get all handlers.
 java.lang.String[] getHosts()
          Get the hosts for the context.
 HttpConnection getHttpConnection()
          Get the ThreadLocal HttpConnection.
 HttpContext getHttpContext()
           
 java.lang.String getHttpContextName()
           
 HttpServer getHttpServer()
           
 java.lang.String getInitParameter(java.lang.String param)
          Get context init parameter.
 java.util.Enumeration getInitParameterNames()
          Get context init parameter.
 int getMaxCachedFileSize()
           
 int getMaxCacheSize()
           
 java.lang.String getMimeByExtension(java.lang.String filename)
           
 java.util.Map getMimeMap()
           
 java.lang.String getName()
          Get the name of the handler.
 java.lang.ClassLoader getParentClassLoader()
           
 java.security.PermissionCollection getPermissions()
          Get the permissions to be used for this context.
 UserRealm getRealm()
           
 java.lang.String getRealmName()
           
 RequestLog getRequestLog()
           
 int getRequests()
           
 int getRequestsActive()
           
 int getRequestsActiveMax()
           
 Resource getResource(java.lang.String pathInContext)
           
 java.lang.String getResourceBase()
           
 ResourceCache.ResourceMetaData getResourceMetaData(Resource resource)
           
 int getResponses1xx()
           
 int getResponses2xx()
           
 int getResponses3xx()
           
 int getResponses4xx()
           
 int getResponses5xx()
           
 java.lang.String[] getServerClasses()
          Get system classes.
 boolean getStatsOn()
           
 long getStatsOnMs()
           
 boolean getStopGracefully()
           
 java.lang.String[] getSystemClasses()
          Get system classes.
 java.io.File getTempDirectory()
          Get Context temporary directory.
 java.lang.String[] getVirtualHosts()
          Get the virtual hosts for the context.
 java.lang.String getWelcomeFile(Resource resource)
           
 java.lang.String[] getWelcomeFiles()
           
 void handle(HttpRequest request, HttpResponse response)
          Handler request.
 void handle(java.lang.String pathInContext, java.lang.String pathParams, HttpRequest request, HttpResponse response)
          Handler request.
 void initialize(HttpContext context)
           
 boolean isClassLoaderJava2Compliant()
          Get Java2 compliant classloading.
 boolean isRedirectNullPath()
           
 void leaveContextScope(HttpRequest request, HttpResponse response, java.lang.Object oldScope)
          Leave the context scope.
 java.lang.Class loadClass(java.lang.String className)
           
 void log(HttpRequest request, HttpResponse response, int length)
          Log a request and response.
 void removeAttribute(java.lang.String name)
           
 void removeHandler(HttpHandler handler)
          Remove a handler.
 HttpHandler removeHandler(int i)
          Remove a handler.
 void removeVirtualHost(java.lang.String hostname)
          remove a virtual host alias to this context.
 void removeWelcomeFile(java.lang.String welcomeFile)
           
static void sendContextError(HttpResponse response, int code, java.lang.String msg)
          Send an error response.
 void sendError(HttpResponse response, int code, java.lang.String msg)
          Send an error response.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Set a context attribute.
 void setAttributes(java.util.Map attributes)
           
 void setAuthenticator(Authenticator authenticator)
           
 void setBaseResource(Resource base)
           
 void setClassLoader(java.lang.ClassLoader loader)
          Set ClassLoader.
 void setClassLoaderJava2Compliant(boolean compliant)
          Set Java2 compliant classloading.
 void setClassPath(java.lang.String classPath)
          Sets the class path for the context.
 void setContextPath(java.lang.String contextPathSpec)
           
 void setEncodingMap(java.util.Map encodingMap)
           
 void setHandlers(HttpHandler[] handlers)
           
 void setHosts(java.lang.String[] hosts)
          Set the hosts for the context.
 void setHttpContextName(java.lang.String s)
           
 void setInitParameter(java.lang.String param, java.lang.String value)
          Set context init parameter.
 void setMaxCachedFileSize(int maxCachedFileSize)
           
 void setMaxCacheSize(int maxCacheSize)
           
 void setMimeMap(java.util.Map mimeMap)
           
 void setMimeMapping(java.lang.String extension, java.lang.String type)
           
 void setParentClassLoader(java.lang.ClassLoader loader)
          Set Parent ClassLoader.
 void setPermissions(java.security.PermissionCollection permissions)
          Set the permissions to be used for this context.
 void setRealm(UserRealm realm)
          Set the realm.
 void setRealmName(java.lang.String realmName)
          Set the realm name.
 void setRedirectNullPath(boolean b)
          Set null path redirection.
 void setRequestLog(RequestLog log)
          Set the request log.
 void setResourceBase(java.lang.String resourceBase)
           
 void setServerClasses(java.lang.String[] classes)
          Set system classes.
 void setStatsOn(boolean on)
          True set statistics recording on for this context.
 void setStopGracefully(boolean graceful)
           
 void setSystemClasses(java.lang.String[] classes)
          Set system classes.
 void setTempDirectory(java.io.File dir)
          Set temporary directory for context.
 void setTypeEncoding(java.lang.String mimeType, java.lang.String encoding)
           
 void setVirtualHosts(java.lang.String[] hosts)
          Set the virtual hosts for the context.
 void setWelcomeFiles(java.lang.String[] welcomes)
           
 void statsReset()
           
 void stop(boolean graceful)
          Stop the context.
 java.lang.String toString()
           
 java.lang.String toString(boolean detail)
           
 
Methods inherited from class org.mortbay.util.Container
addEventListener, getComponents, isStarted, removeEventListener, start, stop
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mortbay.util.LifeCycle
isStarted, start, stop
 
Methods inherited from interface org.mortbay.util.EventProvider
addEventListener, removeEventListener
 

Field Detail

__fileClassPathAttr

public static final java.lang.String __fileClassPathAttr
File class path attribute. If this name is set as a context init parameter, then the attribute name given will be used to set the file classpath for the context as a context attribute.

See Also:
Constant Field Values

__ErrorHandler

public static final java.lang.String __ErrorHandler
See Also:
Constant Field Values
Constructor Detail

HttpContext

public HttpContext()
Constructor.


HttpContext

public HttpContext(HttpServer httpServer,
                   java.lang.String contextPathSpec)
Constructor.

Parameters:
httpServer -
contextPathSpec -
Method Detail

getHttpConnection

public HttpConnection getHttpConnection()
Get the ThreadLocal HttpConnection. Get the HttpConnection for current thread, if any. This method is not static in order to control access.

Returns:
HttpConnection for this thread.

getHttpServer

public HttpServer getHttpServer()

setStopGracefully

public void setStopGracefully(boolean graceful)

getStopGracefully

public boolean getStopGracefully()

canonicalContextPathSpec

public static java.lang.String canonicalContextPathSpec(java.lang.String contextPathSpec)

setContextPath

public void setContextPath(java.lang.String contextPathSpec)

getContextPath

public java.lang.String getContextPath()
Returns:
The context prefix

addVirtualHost

public void addVirtualHost(java.lang.String hostname)
Add a virtual host alias to this context.

Parameters:
hostname - A hostname. A null host name means any hostname is acceptable. Host names may String representation of IP addresses.
See Also:
setVirtualHosts(java.lang.String[])

removeVirtualHost

public void removeVirtualHost(java.lang.String hostname)
remove a virtual host alias to this context.

Parameters:
hostname - A hostname. A null host name means any hostname is acceptable. Host names may String representation of IP addresses.
See Also:
setVirtualHosts(java.lang.String[])

setVirtualHosts

public void setVirtualHosts(java.lang.String[] hosts)
Set the virtual hosts for the context. Only requests that have a matching host header or fully qualified URL will be passed to that context with a virtual host name. A context with no virtual host names or a null virtual host name is available to all requests that are not served by a context with a matching virtual host name.

Parameters:
hosts - Array of virtual hosts that this context responds to. A null host name or null/empty array means any hostname is acceptable. Host names may String representation of IP addresses.

getVirtualHosts

public java.lang.String[] getVirtualHosts()
Get the virtual hosts for the context. Only requests that have a matching host header or fully qualified URL will be passed to that context with a virtual host name. A context with no virtual host names or a null virtual host name is available to all requests that are not served by a context with a matching virtual host name.

Returns:
Array of virtual hosts that this context responds to. A null host name or empty array means any hostname is acceptable. Host names may be String representation of IP addresses.

setHosts

public void setHosts(java.lang.String[] hosts)
              throws java.net.UnknownHostException
Set the hosts for the context. Set the real hosts that this context will accept requests for. If not null or empty, then only requests from HttpListeners for hosts in this array are accepted by this context. Unlike virutal hosts, this value is not used by HttpServer for matching a request to a context.

Throws:
java.net.UnknownHostException

getHosts

public java.lang.String[] getHosts()
Get the hosts for the context.


setSystemClasses

public void setSystemClasses(java.lang.String[] classes)
Set system classes. System classes cannot be overriden by context classloaders.

Parameters:
classes - array of classname Strings. Names ending with '.' are treated as package names. Names starting with '-' are treated as negative matches and must be listed before any enclosing packages.

getSystemClasses

public java.lang.String[] getSystemClasses()
Get system classes. System classes cannot be overriden by context classloaders.

Returns:
array of classname Strings. Names ending with '.' are treated as package names. Names starting with '-' are treated as negative matches and must be listed before any enclosing packages. Null if not set.

setServerClasses

public void setServerClasses(java.lang.String[] classes)
Set system classes. Servers classes cannot be seen by context classloaders.

Parameters:
classes - array of classname Strings. Names ending with '.' are treated as package names. Names starting with '-' are treated as negative matches and must be listed before any enclosing packages.

getServerClasses

public java.lang.String[] getServerClasses()
Get system classes. System classes cannot be seen by context classloaders.

Returns:
array of classname Strings. Names ending with '.' are treated as package names. Names starting with '-' are treated as negative matches and must be listed before any enclosing packages. Null if not set.

setHandlers

public void setHandlers(HttpHandler[] handlers)

getHandlers

public HttpHandler[] getHandlers()
Get all handlers.

Returns:
List of all HttpHandlers

addHandler

public void addHandler(int i,
                       HttpHandler handler)
Add a handler.

Parameters:
i - The position in the handler list
handler - The handler.

addHandler

public void addHandler(HttpHandler handler)
Add a HttpHandler to the context.

Parameters:
handler -

getHandlerIndex

public int getHandlerIndex(HttpHandler handler)
Get handler index.

Parameters:
handler - instance
Returns:
Index of handler in context or -1 if not found.

getHandler

public HttpHandler getHandler(java.lang.Class handlerClass)
Get a handler by class.

Parameters:
handlerClass -
Returns:
The first handler that is an instance of the handlerClass

removeHandler

public HttpHandler removeHandler(int i)
Remove a handler. The handler must be stopped before being removed.

Parameters:
i - index of handler

removeHandler

public void removeHandler(HttpHandler handler)
Remove a handler. The handler must be stopped before being removed.


setInitParameter

public void setInitParameter(java.lang.String param,
                             java.lang.String value)
Set context init parameter. Init Parameters differ from attributes as they can only have string values, servlets cannot set them and they do not have a package scoped name space.

Parameters:
param - param name
value - param value or null

getInitParameter

public java.lang.String getInitParameter(java.lang.String param)
Get context init parameter.

Parameters:
param - param name
Returns:
param value or null

getInitParameterNames

public java.util.Enumeration getInitParameterNames()
Get context init parameter.

Returns:
Enumeration of names

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Set a context attribute.

Parameters:
name - attribute name
value - attribute value

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Parameters:
name - attribute name
Returns:
attribute value or null

getAttributes

public java.util.Map getAttributes()

setAttributes

public void setAttributes(java.util.Map attributes)

getAttributeNames

public java.util.Enumeration getAttributeNames()
Returns:
enumaration of names.

removeAttribute

public void removeAttribute(java.lang.String name)
Parameters:
name - attribute name

flushCache

public void flushCache()

getWelcomeFiles

public java.lang.String[] getWelcomeFiles()

setWelcomeFiles

public void setWelcomeFiles(java.lang.String[] welcomes)

addWelcomeFile

public void addWelcomeFile(java.lang.String welcomeFile)

removeWelcomeFile

public void removeWelcomeFile(java.lang.String welcomeFile)

getWelcomeFile

public java.lang.String getWelcomeFile(Resource resource)
                                throws java.io.IOException
Throws:
java.io.IOException

getClassPath

public java.lang.String getClassPath()
Get the context classpath. This method only returns the paths that have been set for this context and does not include any paths from a parent or the system classloader. Note that this may not be a legal javac classpath.

Returns:
a comma or ';' separated list of class resources. These may be jar files, directories or URLs to jars or directories.
See Also:
getFileClassPath()

getFileClassPath

public java.lang.String getFileClassPath()
                                  throws java.lang.IllegalStateException
Get the file classpath of the context. This method makes a best effort to return a complete file classpath for the context. It is obtained by walking the classloader hierarchy and looking for URLClassLoaders. The system property java.class.path is also checked for file elements not already found in the loader hierarchy.

Returns:
Path of files and directories for loading classes.
Throws:
java.lang.IllegalStateException - HttpContext.initClassLoader has not been called.

setClassPath

public void setClassPath(java.lang.String classPath)
Sets the class path for the context. A class path is only required for a context if it uses classes that are not in the system class path.

Parameters:
classPath - a comma or ';' separated list of class resources. These may be jar files, directories or URLs to jars or directories.

addClassPath

public void addClassPath(java.lang.String classPath)
Add the class path element to the context. A class path is only required for a context if it uses classes that are not in the system class path.

Parameters:
classPath - a comma or ';' separated list of class resources. These may be jar files, directories or URLs to jars or directories.

addClassPaths

public void addClassPaths(Resource lib)
Add elements to the class path for the context from the jar and zip files found in the specified resource.

Parameters:
lib - the resource that contains the jar and/or zip files.
See Also:
setClassPath(String)

isClassLoaderJava2Compliant

public boolean isClassLoaderJava2Compliant()
Get Java2 compliant classloading.

Returns:
If true, the class loader will conform to the java 2 specification and delegate all loads to the parent classloader. If false, the context classloader only delegate loads for system classes or classes that it can't find itself.

setClassLoaderJava2Compliant

public void setClassLoaderJava2Compliant(boolean compliant)
Set Java2 compliant classloading.

Parameters:
compliant - If true, the class loader will conform to the java 2 specification and delegate all loads to the parent classloader. If false, the context classloader only delegate loads for system classes or classes that it can't find itself.

setTempDirectory

public void setTempDirectory(java.io.File dir)
Set temporary directory for context. The javax.servlet.context.tempdir attribute is also set.

Parameters:
dir - Writable temporary directory.

getTempDirectory

public java.io.File getTempDirectory()
Get Context temporary directory. A tempory directory is generated if it has not been set. The "javax.servlet.context.tempdir" attribute is consulted and if not set, the host, port and context are used to generate a directory within the JVMs temporary directory.

Returns:
Temporary directory as a File.

setClassLoader

public void setClassLoader(java.lang.ClassLoader loader)
Set ClassLoader.

Parameters:
loader - The loader to be used by this context.

getClassLoader

public java.lang.ClassLoader getClassLoader()
Get the classloader. If no classloader has been set and the context has been loaded normally, then null is returned. If no classloader has been set and the context was loaded from a classloader, that loader is returned. If a classloader has been set and no classpath has been set then the set classloader is returned. If a classloader and a classpath has been set, then a new URLClassloader initialized on the classpath with the set loader as a partent is return.

Returns:
Classloader or null.

setParentClassLoader

public void setParentClassLoader(java.lang.ClassLoader loader)
Set Parent ClassLoader. By default the parent loader is the thread context classloader of the thread that calls initClassLoader. If setClassLoader is called, then the parent is ignored.

Parameters:
loader - The class loader to use for the parent loader of the context classloader.

getParentClassLoader

public java.lang.ClassLoader getParentClassLoader()

loadClass

public java.lang.Class loadClass(java.lang.String className)
                          throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

setRealmName

public void setRealmName(java.lang.String realmName)
Set the realm name.

Parameters:
realmName - The name to use to retrieve the actual realm from the HttpServer

getRealmName

public java.lang.String getRealmName()

setRealm

public void setRealm(UserRealm realm)
Set the realm.


getRealm

public UserRealm getRealm()

getAuthenticator

public Authenticator getAuthenticator()

setAuthenticator

public void setAuthenticator(Authenticator authenticator)

addSecurityConstraint

public void addSecurityConstraint(java.lang.String pathSpec,
                                  SecurityConstraint sc)

clearSecurityConstraints

public void clearSecurityConstraints()

checkSecurityConstraints

public boolean checkSecurityConstraints(java.lang.String pathInContext,
                                        HttpRequest request,
                                        HttpResponse response)
                                 throws HttpException,
                                        java.io.IOException
Throws:
HttpException
java.io.IOException

setRedirectNullPath

public void setRedirectNullPath(boolean b)
Set null path redirection.

Parameters:
b - if true a /context request will be redirected to /context/ if there is not path in the context.

isRedirectNullPath

public boolean isRedirectNullPath()
Returns:
True if a /context request is redirected to /context/ if there is not path in the context.

setPermissions

public void setPermissions(java.security.PermissionCollection permissions)
Set the permissions to be used for this context. The collection of permissions set here are used for all classes loaded by this context. This is simpler that creating a security policy file, as not all code sources may be statically known.

Parameters:
permissions -

getPermissions

public java.security.PermissionCollection getPermissions()
Get the permissions to be used for this context.


addPermission

public void addPermission(java.security.Permission permission)
Add a permission to this context. The collection of permissions set here are used for all classes loaded by this context. This is simpler that creating a security policy file, as not all code sources may be statically known.

Parameters:
permission -

handle

public void handle(HttpRequest request,
                   HttpResponse response)
            throws HttpException,
                   java.io.IOException
Handler request. Determine the path within the context and then call handle(pathInContext,request,response).

Parameters:
request -
response -
Returns:
True if the request has been handled.
Throws:
HttpException
java.io.IOException

handle

public void handle(java.lang.String pathInContext,
                   java.lang.String pathParams,
                   HttpRequest request,
                   HttpResponse response)
            throws HttpException,
                   java.io.IOException
Handler request. Call each HttpHandler until request is handled.

Specified by:
handle in interface HttpHandler
Parameters:
pathInContext - Path in context
pathParams - Path parameters such as encoded Session ID
request -
response -
Returns:
True if the request has been handled.
Throws:
HttpException
java.io.IOException

enterContextScope

public java.lang.Object enterContextScope(HttpRequest request,
                                          HttpResponse response)
Enter the context scope. This method is called (by handle or servlet dispatchers) to indicate that request handling is entering the scope of this context. The opaque scope object returned, should be passed to the leaveContextScope method.


leaveContextScope

public void leaveContextScope(HttpRequest request,
                              HttpResponse response,
                              java.lang.Object oldScope)
Leave the context scope. This method is called (by handle or servlet dispatchers) to indicate that request handling is leaveing the scope of this context. The opaque scope object returned by enterContextScope should be passed in.


getHttpContextName

public java.lang.String getHttpContextName()

setHttpContextName

public void setHttpContextName(java.lang.String s)

toString

public java.lang.String toString()

toString

public java.lang.String toString(boolean detail)

stop

public void stop(boolean graceful)
          throws java.lang.InterruptedException
Stop the context.

Parameters:
graceful - If true and statistics are on, then this method will wait for requestsActive to go to zero before calling stop()
Throws:
java.lang.InterruptedException

destroy

public void destroy()
Destroy a context. Destroy a context and remove it from the HttpServer. The HttpContext must be stopped before it can be destroyed.

Overrides:
destroy in class Container

setRequestLog

public void setRequestLog(RequestLog log)
Set the request log.

Parameters:
log - RequestLog to use.

getRequestLog

public RequestLog getRequestLog()

sendError

public void sendError(HttpResponse response,
                      int code,
                      java.lang.String msg)
               throws java.io.IOException
Send an error response. This method may be specialized to provide alternative error handling for errors generated by the container. The default implemenation calls HttpResponse.sendError

Parameters:
response - the response to send
code - The error code
msg - The message for the error or null for the default
Throws:
java.io.IOException - Problem sending response.

sendContextError

public static void sendContextError(HttpResponse response,
                                    int code,
                                    java.lang.String msg)
                             throws java.io.IOException
Send an error response. This method obtains the responses context and call sendError for context specific error handling.

Parameters:
response - the response to send
code - The error code
msg - The message for the error or null for the default
Throws:
java.io.IOException - Problem sending response.

setStatsOn

public void setStatsOn(boolean on)
True set statistics recording on for this context.

Parameters:
on - If true, statistics will be recorded for this context.

getStatsOn

public boolean getStatsOn()

getStatsOnMs

public long getStatsOnMs()

statsReset

public void statsReset()

getRequests

public int getRequests()
Returns:
Get the number of requests handled by this context since last call of statsReset(). If setStatsOn(false) then this is undefined.

getRequestsActive

public int getRequestsActive()
Returns:
Number of requests currently active. Undefined if setStatsOn(false).

getRequestsActiveMax

public int getRequestsActiveMax()
Returns:
Maximum number of active requests since statsReset() called. Undefined if setStatsOn(false).

getResponses1xx

public int getResponses1xx()
Returns:
Get the number of responses with a 2xx status returned by this context since last call of statsReset(). Undefined if if setStatsOn(false).

getResponses2xx

public int getResponses2xx()
Returns:
Get the number of responses with a 100 status returned by this context since last call of statsReset(). Undefined if if setStatsOn(false).

getResponses3xx

public int getResponses3xx()
Returns:
Get the number of responses with a 3xx status returned by this context since last call of statsReset(). Undefined if if setStatsOn(false).

getResponses4xx

public int getResponses4xx()
Returns:
Get the number of responses with a 4xx status returned by this context since last call of statsReset(). Undefined if if setStatsOn(false).

getResponses5xx

public int getResponses5xx()
Returns:
Get the number of responses with a 5xx status returned by this context since last call of statsReset(). Undefined if if setStatsOn(false).

log

public void log(HttpRequest request,
                HttpResponse response,
                int length)
Log a request and response. Statistics are also collected by this method.

Parameters:
request -
response -

getName

public java.lang.String getName()
Description copied from interface: HttpHandler
Get the name of the handler.

Specified by:
getName in interface HttpHandler
Returns:
The name of the handler used for logging and reporting.

getHttpContext

public HttpContext getHttpContext()
Specified by:
getHttpContext in interface HttpHandler

initialize

public void initialize(HttpContext context)
Specified by:
initialize in interface HttpHandler

getBaseResource

public Resource getBaseResource()
Returns:

getEncodingByMimeType

public java.lang.String getEncodingByMimeType(java.lang.String type)
Parameters:
type -
Returns:

getEncodingMap

public java.util.Map getEncodingMap()
Returns:

getMaxCachedFileSize

public int getMaxCachedFileSize()
Returns:

getMaxCacheSize

public int getMaxCacheSize()
Returns:

getMimeByExtension

public java.lang.String getMimeByExtension(java.lang.String filename)
Parameters:
filename -
Returns:

getMimeMap

public java.util.Map getMimeMap()
Returns:

getResource

public Resource getResource(java.lang.String pathInContext)
                     throws java.io.IOException
Parameters:
pathInContext -
Returns:
Throws:
java.io.IOException

getResourceBase

public java.lang.String getResourceBase()
Returns:

getResourceMetaData

public ResourceCache.ResourceMetaData getResourceMetaData(Resource resource)
Parameters:
resource -
Returns:

setBaseResource

public void setBaseResource(Resource base)
Parameters:
base -

setEncodingMap

public void setEncodingMap(java.util.Map encodingMap)
Parameters:
encodingMap -

setMaxCachedFileSize

public void setMaxCachedFileSize(int maxCachedFileSize)
Parameters:
maxCachedFileSize -

setMaxCacheSize

public void setMaxCacheSize(int maxCacheSize)
Parameters:
maxCacheSize -

setMimeMap

public void setMimeMap(java.util.Map mimeMap)
Parameters:
mimeMap -

setMimeMapping

public void setMimeMapping(java.lang.String extension,
                           java.lang.String type)
Parameters:
extension -
type -

setResourceBase

public void setResourceBase(java.lang.String resourceBase)
Parameters:
resourceBase -

setTypeEncoding

public void setTypeEncoding(java.lang.String mimeType,
                            java.lang.String encoding)
Parameters:
mimeType -
encoding -


Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.