|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.grizzly.http.server.HttpHandler
org.glassfish.grizzly.http.server.StaticHttpHandler
public class StaticHttpHandler
HttpHandler, which processes requests to a static resources.
| Field Summary | |
|---|---|
protected ArraySet<File> |
docRoots
|
| Constructor Summary | |
|---|---|
StaticHttpHandler()
Create HttpHandler, which, by default, will handle requests to the static resources located in the current directory. |
|
StaticHttpHandler(Set<String> docRoots)
Create a new instance which will look for static pages located under the docRoot. |
|
StaticHttpHandler(String... docRoots)
Create a new instance which will look for static pages located under the docRoot. |
|
| Method Summary | |
|---|---|
void |
addDocRoot(File docRoot)
Add the directory to the list of directories where files will be serviced from. |
File |
addDocRoot(String docRoot)
Add the directory to the list of directories where files will be serviced from. |
boolean |
addToFileCache(Request req,
Response res,
File resource)
|
File |
getDefaultDocRoot()
Return the default directory from where files will be serviced. |
ArraySet<File> |
getDocRoots()
Return the list of directories where files will be serviced from. |
protected String |
getRelativeURI(Request request)
|
protected boolean |
handle(String uri,
Request request,
Response response)
Lookup a resource based on the request URI, and send it using send file. |
boolean |
isFileCacheEnabled()
Returns true if this StaticHttpHandler has been configured to use file cache to serve static resources, or false otherwise. |
protected void |
onMissingResource(Request request,
Response response)
The method will be called, if the static resource requested by the Request
wasn't found, so StaticHttpHandler implementation may try to
workaround this situation. |
void |
removeDocRoot(File docRoot)
Removes the directory from the list of directories where static files will be serviced from. |
static void |
sendFile(Response response,
File file)
|
void |
service(Request request,
Response response)
Based on the Request URI, try to map the file from the
getDocRoots(), and send it back to a client. |
void |
setFileCacheEnabled(boolean isFileCacheEnabled)
Set true to configure this StaticHttpHandler to use file cache to serve static resources, or false otherwise. |
| Methods inherited from class org.glassfish.grizzly.http.server.HttpHandler |
|---|
customizedErrorPage, destroy, doHandle, getName, getRequestURIEncoding, isAllowCustomStatusMessage, isAllowEncodedSlash, sendAcknowledgment, setAllowCustomStatusMessage, setAllowEncodedSlash, setDecodeUrl, setDispatcherHelper, setRequestURIEncoding, setRequestURIEncoding, start, updatePaths |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final ArraySet<File> docRoots
| Constructor Detail |
|---|
public StaticHttpHandler()
public StaticHttpHandler(String... docRoots)
docRoots - the folder(s) where the static resource are located.
If the docRoot is null - static pages won't be served
by this HttpHandlerpublic StaticHttpHandler(Set<String> docRoots)
docRoots - the folders where the static resource are located.
If the docRoot is empty - static pages won't be served
by this HttpHandler| Method Detail |
|---|
public File getDefaultDocRoot()
public ArraySet<File> getDocRoots()
public final File addDocRoot(String docRoot)
docRoot - the directory to be added to the list of directories
where files will be serviced from.
File representation of the passed docRoot.public final void addDocRoot(File docRoot)
docRoot - the directory to be added to the list of directories
where files will be serviced from.public void removeDocRoot(File docRoot)
docRoot - the directory to remove.public boolean isFileCacheEnabled()
FileCache.isEnabled(). In this case StaticHttpHandler will operate
as if file cache was disabled.
public void setFileCacheEnabled(boolean isFileCacheEnabled)
FileCache.isEnabled(). In this case StaticHttpHandler will operate
as if file cache was disabled.
isFileCacheEnabled - true to configure this
StaticHttpHandler to use file cache to serve static resources,
or false otherwise.
public static void sendFile(Response response,
File file)
throws IOException
IOException
public final boolean addToFileCache(Request req,
Response res,
File resource)
public void service(Request request,
Response response)
throws Exception
Request URI, try to map the file from the
getDocRoots(), and send it back to a client.
service in class HttpHandlerrequest - the Requestresponse - the Response
Exceptionprotected String getRelativeURI(Request request)
protected void onMissingResource(Request request,
Response response)
throws Exception
Request
wasn't found, so StaticHttpHandler implementation may try to
workaround this situation.
The default implementation - sends a 404 response page by calling HttpHandler.customizedErrorPage(Request, Response).
request - the Requestresponse - the Response
Exception
protected boolean handle(String uri,
Request request,
Response response)
throws Exception
uri - The request URIrequest - the Requestresponse - the Response
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||