public class ResourceHandler extends AbstractHttpHandler
| Constructor and Description |
|---|
ResourceHandler()
Construct a ResourceHandler.
|
| Modifier and Type | Method and Description |
|---|---|
String[] |
getAllowedMethods() |
String |
getAllowedString() |
int |
getMinGzipLength()
Get minimum content length for GZIP encoding.
|
boolean |
getRedirectWelcome() |
protected Resource |
getResource(String pathInContext)
get Resource to serve.
|
void |
handle(String pathInContext,
String pathParams,
HttpRequest request,
HttpResponse response)
Handle a request.
|
void |
handleGet(HttpRequest request,
HttpResponse response,
String pathInContext,
String pathParams,
Resource resource) |
boolean |
isAcceptRanges() |
boolean |
isDirAllowed() |
boolean |
isMethodAllowed(String method) |
void |
sendData(HttpRequest request,
HttpResponse response,
String pathInContext,
Resource resource,
boolean writeHeaders) |
void |
setAcceptRanges(boolean ar)
Set if the handler accepts range requests.
|
void |
setAllowedMethods(String[] methods) |
void |
setDirAllowed(boolean dirAllowed) |
void |
setMinGzipLength(int minGzipLength)
Set minimum content length for GZIP encoding.
|
void |
setRedirectWelcome(boolean redirectWelcome) |
void |
start()
Start the LifeCycle.
|
void |
stop()
Stop the LifeCycle.
|
void |
writeHeaders(HttpResponse response,
Resource resource,
long count) |
getHttpContext, getName, handleTrace, initialize, isStarted, setName, toStringpublic void start()
throws Exception
LifeCyclestart in interface LifeCyclestart in class AbstractHttpHandlerException - An arbitrary exception may be thrown.public void stop()
throws InterruptedException
LifeCyclestop in interface LifeCyclestop in class AbstractHttpHandlerInterruptedException - Stopping a lifecycle is rarely atomic
and may be interrupted by another thread. If this happens
InterruptedException is throw and the component will be in an
indeterminant state and should probably be discarded.public String[] getAllowedMethods()
public void setAllowedMethods(String[] methods)
public boolean isMethodAllowed(String method)
public String getAllowedString()
public boolean isDirAllowed()
public void setDirAllowed(boolean dirAllowed)
public boolean isAcceptRanges()
public boolean getRedirectWelcome()
public void setRedirectWelcome(boolean redirectWelcome)
redirectWelcome - True if welcome files are redirected to. False
if forward is used.public void setAcceptRanges(boolean ar)
ar - True if the handler should accept rangespublic int getMinGzipLength()
public void setMinGzipLength(int minGzipLength)
minGzipLength - If set to a positive integer, then static content
larger than this will be served as gzip content encoded
if a matching resource is found ending with ".gz"protected Resource getResource(String pathInContext) throws IOException
pathInContext - The path to find a resource for.IOExceptionpublic void handle(String pathInContext, String pathParams, HttpRequest request, HttpResponse response) throws HttpException, IOException
HttpHandlerpathInContext - The context pathpathParams - Path parameters such as encoded Session IDrequest - The HttpRequest requestresponse - The HttpResponse responseHttpExceptionIOExceptionpublic void handleGet(HttpRequest request, HttpResponse response, String pathInContext, String pathParams, Resource resource) throws IOException
IOExceptionpublic void writeHeaders(HttpResponse response, Resource resource, long count) throws IOException
IOExceptionpublic void sendData(HttpRequest request, HttpResponse response, String pathInContext, Resource resource, boolean writeHeaders) throws IOException
IOExceptionCopyright © 2013. All rights reserved.