Class CLStaticHttpHandler
- java.lang.Object
-
- org.glassfish.grizzly.http.server.HttpHandler
-
- org.glassfish.grizzly.http.server.StaticHttpHandlerBase
-
- org.glassfish.grizzly.http.server.CLStaticHttpHandler
-
public class CLStaticHttpHandler extends StaticHttpHandlerBase
HttpHandler, which processes requests to a static resources resolved by a givenClassLoader.- Author:
- Grizzly Team
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringCHECK_NON_SLASH_TERMINATED_FOLDERS_PROP
-
Constructor Summary
Constructors Constructor Description CLStaticHttpHandler(ClassLoader classLoader, String... docRoots)Create HttpHandler, which will handle requests to the static resources resolved by the given class loader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddDocRoot(String docRoot)Adds doc root (path prefix), which will be used to look up resources.ClassLoadergetClassLoader()Returns theClassLoaderused to resolve the requested HTTP resources.protected booleanhandle(String resourcePath, Request request, Response response)Lookup a resource based on the request URI, and process it.booleanremoveDocRoot(String docRoot)Removes docRoot from the doc root list.-
Methods inherited from class org.glassfish.grizzly.http.server.StaticHttpHandlerBase
addCachingHeaders, addToFileCache, getRelativeURI, isFileCacheEnabled, lookupFileCache, onMissingResource, pickupContentType, sendFile, service, setFileCacheEnabled
-
Methods inherited from class org.glassfish.grizzly.http.server.HttpHandler
destroy, getErrorPageGenerator, getName, getRequestExecutorProvider, getRequestURIEncoding, getSessionCookieName, getSessionManager, isAllowCustomStatusMessage, isAllowEncodedSlash, sendAcknowledgment, setAllowCustomStatusMessage, setAllowEncodedSlash, setDecodeUrl, setDispatcherHelper, setRequestURIEncoding, setRequestURIEncoding, start, updatePaths
-
-
-
-
Field Detail
-
CHECK_NON_SLASH_TERMINATED_FOLDERS_PROP
protected static final String CHECK_NON_SLASH_TERMINATED_FOLDERS_PROP
-
-
Constructor Detail
-
CLStaticHttpHandler
public CLStaticHttpHandler(ClassLoader classLoader, String... docRoots)
Create HttpHandler, which will handle requests to the static resources resolved by the given class loader.- Parameters:
classLoader-ClassLoaderto be used to resolve the resourcesdocRoots- the doc roots (path prefixes), which will be used to find resources. Effectively each docRoot will be prepended to a resource path before passing it toClassLoader.getResource(java.lang.String). If no docRoots are set - the resources will be searched starting fromClassLoader's root.- Throws:
IllegalArgumentException- if one of the docRoots doesn't end with slash ('/')
-
-
Method Detail
-
addDocRoot
public boolean addDocRoot(String docRoot)
Adds doc root (path prefix), which will be used to look up resources. Effectively each registered docRoot will be prepended to a resource path before passing it toClassLoader.getResource(java.lang.String).- Parameters:
docRoot-- Returns:
- true if this docroot hasn't been registered before, or false otherwise.
- Throws:
IllegalArgumentException- if one of the docRoots doesn't end with slash ('/')
-
removeDocRoot
public boolean removeDocRoot(String docRoot)
Removes docRoot from the doc root list.- Parameters:
docRoot-- Returns:
- true if this docroot was found and removed from the list, or or false if this docroot was not found in the list.
-
getClassLoader
public ClassLoader getClassLoader()
Returns theClassLoaderused to resolve the requested HTTP resources.
-
handle
protected boolean handle(String resourcePath, Request request, Response response) throws Exception
Lookup a resource based on the request URI, and process it.- Specified by:
handlein classStaticHttpHandlerBase- Parameters:
resourcePath- The request URIrequest- theRequestresponse- theResponse- Returns:
- true, if the static resource has been found and processed, or false, if the static resource hasn't been found
- Throws:
Exception
-
-