|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.myfaces.renderkit.html.util.MyFacesResourceLoader
public class MyFacesResourceLoader
A ResourceLoader capable of fetching resources from the classpath, but only for classes under package org.apache.myfaces.custom.
The URI is expected to contain two pieces of information: the tomahawk class the resource is associated with, and a relative path from that class to the resource.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.apache.myfaces.renderkit.html.util.ResourceLoader |
---|
ResourceLoader.ClosedSocketException |
Field Summary | |
---|---|
protected static org.apache.commons.logging.Log |
log
|
Constructor Summary | |
---|---|
MyFacesResourceLoader()
|
Method Summary | |
---|---|
protected void |
defineCaching(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String resource,
long lastModified)
Output http headers telling the browser (and possibly intermediate caches) how to cache this data. |
protected void |
defineContentHeaders(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String resource,
int contentLength,
String contentEncoding)
Output http headers indicating the mime-type of the content being served. |
protected Class |
loadComponentClass(String componentClass)
|
void |
serveResource(javax.servlet.ServletContext context,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String resourceUri)
Given a URI of form "{partial.class.name}/{resourceName}", locate the specified file within the current classpath and write it to the response object. |
protected void |
validateCustomComponent(Class myfacesCustomComponent)
|
protected void |
writeResource(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
InputStream in)
Copy the content of the specified input stream to the servlet response. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.commons.logging.Log log
Constructor Detail |
---|
public MyFacesResourceLoader()
Method Detail |
---|
public void serveResource(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String resourceUri) throws IOException
The partial class name has "org.apache.myfaces.custom." prepended to it to form the fully qualified classname. This class object is loaded, and Class.getResourceAsStream is called on it, passing a uri of "resource/" + {resourceName}.
The data written to the response stream includes http headers which define the mime content-type; this is deduced from the filename suffix of the resource.
serveResource
in interface ResourceLoader
context
- TODOrequest
- the requestresponse
- the response to write the resource content toresourceUri
- contains the uri part after the uri which
is used to identify the resource loader
IOException
ResourceLoader.serveResource(javax.servlet.ServletContext,
javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)
protected void writeResource(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, InputStream in) throws IOException
IOException
protected void defineCaching(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String resource, long lastModified)
The expiry time in this header info is set to 7 days. This is not a problem as the overall URI contains a "cache key" that changes whenever the webapp is redeployed (see AddResource.getCacheKey), meaning that all browsers will effectively reload files on webapp redeploy.
protected void defineContentHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String resource, int contentLength, String contentEncoding)
protected Class loadComponentClass(String componentClass) throws ClassNotFoundException
ClassNotFoundException
protected void validateCustomComponent(Class myfacesCustomComponent)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |