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 java.lang.StringCHECK_NON_SLASH_TERMINATED_FOLDERS_PROP
-
Constructor Summary
Constructors Constructor Description CLStaticHttpHandler(java.lang.ClassLoader classLoader, java.lang.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(java.lang.String docRoot)Adds doc root (path prefix), which will be used to look up resources.java.lang.ClassLoadergetClassLoader()Returns theClassLoaderused to resolve the requested HTTP resources.protected booleanhandle(java.lang.String resourcePath, Request request, Response response)Lookup a resource based on the request URI, and process it.booleanremoveDocRoot(java.lang.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
-
-
-
-
Constructor Detail
-
CLStaticHttpHandler
public CLStaticHttpHandler(java.lang.ClassLoader classLoader, java.lang.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:
java.lang.IllegalArgumentException- if one of the docRoots doesn't end with slash ('/')
-
-
Method Detail
-
addDocRoot
public boolean addDocRoot(java.lang.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:
java.lang.IllegalArgumentException- if one of the docRoots doesn't end with slash ('/')
-
removeDocRoot
public boolean removeDocRoot(java.lang.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 java.lang.ClassLoader getClassLoader()
Returns theClassLoaderused to resolve the requested HTTP resources.
-
handle
protected boolean handle(java.lang.String resourcePath, Request request, Response response) throws java.lang.ExceptionLookup 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:
java.lang.Exception
-
-