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, toString
public void start() throws Exception
LifeCycle
start
in interface LifeCycle
start
in class AbstractHttpHandler
Exception
- An arbitrary exception may be thrown.public void stop() throws InterruptedException
LifeCycle
stop
in interface LifeCycle
stop
in class AbstractHttpHandler
InterruptedException
- 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.IOException
public void handle(String pathInContext, String pathParams, HttpRequest request, HttpResponse response) throws HttpException, IOException
HttpHandler
pathInContext
- The context pathpathParams
- Path parameters such as encoded Session IDrequest
- The HttpRequest requestresponse
- The HttpResponse responseHttpException
IOException
public void handleGet(HttpRequest request, HttpResponse response, String pathInContext, String pathParams, Resource resource) throws IOException
IOException
public void writeHeaders(HttpResponse response, Resource resource, long count) throws IOException
IOException
public void sendData(HttpRequest request, HttpResponse response, String pathInContext, Resource resource, boolean writeHeaders) throws IOException
IOException
Copyright © 2016. All Rights Reserved.