|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.click.service.ClickResourceService
public class ClickResourceService
Provides a default Click static resource service class. This class will serve static resources contained in the web applications JARs, under the resource path META-INF/resources and which are contained under the WAR file web root.
This service is useful for application servers which do not allow Click to automatically deploy resources to the web root directory.
Field Summary | |
---|---|
protected ConfigService |
configService
The application configuration service. |
protected LogService |
logService
The application log service. |
protected Map<String,byte[]> |
resourceCache
The click resources cache. |
Constructor Summary | |
---|---|
ClickResourceService()
|
Method Summary | |
---|---|
protected List<String> |
getCacheableDirs()
Return the list of directories that contains cacheable resources. |
boolean |
isResourceRequest(HttpServletRequest request)
Return true if the request is for a static resource. |
void |
onDestroy()
Destroy the ResourceService. |
void |
onInit(ServletContext servletContext)
Initialize the ResourceService with the given application configuration service instance. |
void |
renderResource(HttpServletRequest request,
HttpServletResponse response)
Render the resource request to the given servlet resource response. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Map<String,byte[]> resourceCache
protected LogService logService
protected ConfigService configService
Constructor Detail |
---|
public ClickResourceService()
Method Detail |
---|
public void onInit(ServletContext servletContext) throws IOException
ResourceService
onInit
in interface ResourceService
servletContext
- the application servlet context
IOException
- if an IO error occurs initializing the serviceResourceService.onInit(ServletContext)
public void onDestroy()
ResourceService
onDestroy
in interface ResourceService
ResourceService.onDestroy()
public boolean isResourceRequest(HttpServletRequest request)
ResourceService
isResourceRequest
in interface ResourceService
request
- the servlet request
ResourceService.isResourceRequest(HttpServletRequest)
public void renderResource(HttpServletRequest request, HttpServletResponse response) throws IOException
ResourceService
renderResource
in interface ResourceService
request
- the servlet resource requestresponse
- the servlet response
IOException
- if an IO error occurs rendering the resourceResourceService.renderResource(HttpServletRequest, HttpServletResponse)
protected List<String> getCacheableDirs()
public class MyResourceService extends ClickResourceService { protected ListYou also need to add a mapping in your web.xml to forward requests for these resources on to Click:getCacheableDirs() { // Get default dirs which includes /click List list = super.getCacheableDirs(); // Add resources packaged under the folder /clickclick list.add("/clickclick"); // Add resources packaged under the folder /mycorp list.add("/mycorp"); } }
<-- The default Click *.htm mapping --> <servlet-mapping> <servlet-name>ClickServlet</servlet-name> <url-pattern>*.htm</url-pattern> </servlet-mapping> <-- Add a mapping to serve all resources under /click directly from the JARs. --> <servlet-mapping> <servlet-name>ClickServlet</servlet-name> <url-pattern>/click/*</url-pattern> </servlet-mapping> <-- Add another mapping to serve all resources under /clickclick from the JARs. --> <servlet-mapping> <servlet-name>ClickServlet</servlet-name> <url-pattern>/clickclick/*</url-pattern> </servlet-mapping> <-- Add a mapping to serve all resources under /mycorp from the JARs. --> <servlet-mapping> <servlet-name>ClickServlet</servlet-name> <url-pattern>/mycorp/*</url-pattern> </servlet-mapping>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |