|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.shale.remoting.impl.FilteringProcessor org.apache.shale.remoting.impl.AbstractResourceProcessor
public abstract class AbstractResourceProcessor
Convenience abstract base class for Processor
implementations
that serve up static resources.
Field Summary | |
---|---|
protected Map |
mimeTypes
Map of MIME types, keyed by file extension. |
Constructor Summary | |
---|---|
AbstractResourceProcessor()
|
Method Summary | |
---|---|
protected void |
copyStream(javax.faces.context.FacesContext context,
InputStream inputStream,
OutputStream outputStream)
Copy the contents of the specified input stream to the specified output stream. |
int |
getBufferSize()
Return the buffer size when copying. |
long |
getLastModified()
Return the date/time (expressed as the number of milliseconds since the epoch) that will be generated on the Last-Modified
header of all resources served by this processor. |
String |
getLastModifiedString()
Return a String version of the last modified date/time, formatted as required by Section 3.3.1 of the HTTP/1.1 Specification. |
protected abstract URL |
getResourceURL(javax.faces.context.FacesContext context,
String resourceId)
Convert the specified resource identifier into a URL, if the resource actually exists. |
protected String |
httpTimestamp(Date timestamp)
Return a textual representation of the specified date/time stamp (expressed as a java.util.Date object)
in the format required by the HTTP/1.1 Specification (RFC 2616),
Section 3.3.1. |
protected String |
httpTimestamp(long timestamp)
Return a textual representation of the specified date/time stamp (expressed in milliseconds since the epoch, and assumed to be GMT) in the format required by the HTTP/1.1 Specification (RFC 2616), Section 3.3.1. |
protected long |
ifModifiedSince(javax.faces.context.FacesContext context)
Return the value of the If-Modified-Since header
included on this request, as a number of milliseconds since the
epoch. |
protected InputStream |
inputStream(javax.faces.context.FacesContext context,
URL url)
Return an InputStream derived from the specified URL,
which will point to the static resource to be served. |
protected String |
mimeType(javax.faces.context.FacesContext context,
String resourceId)
Return the appropriate MIME type (if known) for the specified resource path. |
protected OutputStream |
outputStream(javax.faces.context.FacesContext context,
String contentType)
Return an OutputStream to which our static
resource is to be served. |
void |
process(javax.faces.context.FacesContext context,
String resourceId)
Check if the specified resource actually exists. |
protected void |
sendContentType(javax.faces.context.FacesContext context,
String contentType)
Set the content type on the servlet or portlet response object. |
protected void |
sendLastModified(javax.faces.context.FacesContext context,
String timestamp)
Set the Last-Modified header to the specified timestamp. |
protected void |
sendNotFound(javax.faces.context.FacesContext context,
String resourceId)
Send a "not found" HTTP response, if possible. |
protected void |
sendNotModified(javax.faces.context.FacesContext context,
String resourceId)
Send a "not modified" HTTP response, if possible. |
protected boolean |
servletRequest(javax.faces.context.FacesContext context)
Return true if we are processing a servlet request (as
opposed to a portlet request). |
void |
setBufferSize(int bufferSize)
Set the buffer size when copying. |
void |
setLastModified(long lastModified)
Set the date/time (expressed as the number of milliseconds since the epoch) that wll be generated on the Last-Modified
header of all resources served by this processor. |
Methods inherited from class org.apache.shale.remoting.impl.FilteringProcessor |
---|
accept, getExcludes, getIncludes, setExcludes, setIncludes |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Map mimeTypes
Map
of MIME types, keyed by file extension. This is
used as a fallback if the ServletContext
or
PortletContext
call to mimeType()
does not
return any result.
Constructor Detail |
---|
public AbstractResourceProcessor()
Method Detail |
---|
public void process(javax.faces.context.FacesContext context, String resourceId) throws IOException
Check if the specified resource actually exists. If it does not, return an HTTP 404 status (servlet) or throw an IllegalArgumentException (portlet).
context
- FacesContext
for the current requestresourceId
- Resource identifier of the resource to be served
IllegalArgumentException
- if the specified resource does
not exist in a portlet environment (because we cannot return an
HTTP status 404)
IOException
- if an input/output error occurspublic int getBufferSize()
Return the buffer size when copying.
public void setBufferSize(int bufferSize)
Set the buffer size when copying.
bufferSize
- The new buffer sizepublic long getLastModified()
Return the date/time (expressed as the number of milliseconds since
the epoch) that will be generated on the Last-Modified
header of all resources served by this processor. If this value has
not been set upon first call to this method, it will be set to the
current date and time.
public void setLastModified(long lastModified)
Set the date/time (expressed as the number of milliseconds since
the epoch) that wll be generated on the Last-Modified
header of all resources served by this processor.
lastModified
- The new last modified valuepublic String getLastModifiedString()
Return a String version of the last modified date/time, formatted
as required by Section 3.3.1 of the HTTP/1.1 Specification. If the
lastModified
property has not been set upon first call to
this method, it will be set to the current date and time.
protected abstract URL getResourceURL(javax.faces.context.FacesContext context, String resourceId)
Convert the specified resource identifier into a URL, if the resource
actually exists. Otherwise, return null
.
context
- FacesContext
for the current requestresourceId
- Resource identifier to translateprotected void copyStream(javax.faces.context.FacesContext context, InputStream inputStream, OutputStream outputStream) throws IOException
Copy the contents of the specified input stream to the specified output stream.
context
- FacesContext
for the current requestinputStream
- InputStream
to be copied fromoutputStream
- OutputStream
to be copied to
IOException
- if an input/output error occursprotected String httpTimestamp(Date timestamp)
Return a textual representation of the specified date/time stamp
(expressed as a java.util.Date
object)
in the format required by the HTTP/1.1 Specification (RFC 2616),
Section 3.3.1. An example of this format is:
Sun, 06 Nov 1994 08:49:37 GMT
timestamp
- The date/time to be formatted, expressed as
a java.util.Date
protected String httpTimestamp(long timestamp)
Return a textual representation of the specified date/time stamp (expressed in milliseconds since the epoch, and assumed to be GMT) in the format required by the HTTP/1.1 Specification (RFC 2616), Section 3.3.1. An example of this format is:
Sun, 06 Nov 1994 08:49:37 GMT
timestamp
- The date/time to be formatted, expressed as the number
of milliseconds since the epochprotected long ifModifiedSince(javax.faces.context.FacesContext context)
Return the value of the If-Modified-Since
header
included on this request, as a number of milliseconds since the
epoch. If this header was not included (or we cannot tell if it
was included), return -1 instead.
context
- FacesContext
for the current requestprotected InputStream inputStream(javax.faces.context.FacesContext context, URL url) throws IOException
Return an InputStream
derived from the specified URL,
which will point to the static resource to be served.
context
- FacesContext
for the current requesturl
- URL
from which to derive an input stream
IOException
- if an input/output error occursprotected String mimeType(javax.faces.context.FacesContext context, String resourceId)
Return the appropriate MIME type (if known) for the specified resource
path. This method is portable across servlet and portlet environments.
If no MIME type is known, fall back to a configured list, based on the
extension of the requested resource. If no result can be found in the
fallback list, return null
.
context
- FacesContext
for the current requestresourceId
- Resource identifier of the resource to categorizeprotected OutputStream outputStream(javax.faces.context.FacesContext context, String contentType) throws IOException
Return an OutputStream
to which our static
resource is to be served.
context
- FacesContext
for the current requestcontentType
- Content type for this response
IOException
- if an input/output error occursprotected boolean servletRequest(javax.faces.context.FacesContext context)
Return true
if we are processing a servlet request (as
opposed to a portlet request).
context
- FacesContext
for the current requestprotected void sendContentType(javax.faces.context.FacesContext context, String contentType)
Set the content type on the servlet or portlet response object.
context
- FacesContext
for the current requestcontentType
- The content type to be setprotected void sendLastModified(javax.faces.context.FacesContext context, String timestamp)
Set the Last-Modified
header to the specified timestamp.
context
- FacesContext
for this requesttimestamp
- String version of the last modified timestampprotected void sendNotFound(javax.faces.context.FacesContext context, String resourceId) throws IOException
Send a "not found" HTTP response, if possible. Otherwise, throw an
IllegalArgumentException
that will ripple out.
context
- FacesContext
for the current requestresourceId
- Resource identifier of the resource that was not found
IllegalArgumentException
- if we cannot send an HTTP response
IOException
- if an input/output error occursprotected void sendNotModified(javax.faces.context.FacesContext context, String resourceId) throws IOException
Send a "not modified" HTTP response, if possible. Otherwise, throw an
IllegalArgumentException
that will ripple out.
context
- FacesContext
for the current requestresourceId
- Resource identifier of the resource that was not modified
IllegalArgumentException
- if we cannot send an HTTP response
IOException
- if an input/output error occurs
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |