pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.service
Class VersionRewriteFilter

java.lang.Object
  extended by org.torweg.pulse.service.AbstractPulseFilter
      extended by org.torweg.pulse.service.VersionRewriteFilter
All Implemented Interfaces:
javax.servlet.Filter

public class VersionRewriteFilter
extends AbstractPulseFilter

filters the version prefix from the request URI to allow far future expires headers for static resources.

see also: xsl/globals.xsl ($version.number).

If an URI is not rewritten, the rest of the FilterChain is processed. Since FilterChains are only constructed upon first request, filtering for rewritten URIs is aborted.

If you need to post process rewritten URIs, consider overwriting dispatch(ServletRequest, ServletResponse, RequestRewriter).

Version:
$Revision: 1825 $
Author:
Thomas Weber

Nested Class Summary
static class VersionRewriteFilter.RequestRewriter
          Utility to rewrite a request.
 
Nested classes/interfaces inherited from class org.torweg.pulse.service.AbstractPulseFilter
AbstractPulseFilter.WrappedResponse
 
Constructor Summary
VersionRewriteFilter()
           
 
Method Summary
 void destroy()
           
protected  void dispatch(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, VersionRewriteFilter.RequestRewriter requestRewriter)
          actually takes care of the dispatching to the rewritten URI.
 void doFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain chain)
          does the URL rewriting.
 void init(javax.servlet.FilterConfig conf)
          initialises the filter.
 
Methods inherited from class org.torweg.pulse.service.AbstractPulseFilter
getWebAppBasePath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VersionRewriteFilter

public VersionRewriteFilter()
Method Detail

destroy

public void destroy()
See Also:
Filter.destroy()

doFilter

public final void doFilter(javax.servlet.ServletRequest servletRequest,
                           javax.servlet.ServletResponse servletResponse,
                           javax.servlet.FilterChain chain)
                    throws java.io.IOException,
                           javax.servlet.ServletException
does the URL rewriting.

Parameters:
servletRequest - the current servlet request
servletResponse - the current servlet response
chain - the filter chain
Throws:
javax.servlet.ServletException - on errors while filtering
java.io.IOException - on errors while filtering
See Also:
Filter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)

dispatch

protected void dispatch(javax.servlet.ServletRequest servletRequest,
                        javax.servlet.ServletResponse servletResponse, VersionRewriteFilter.RequestRewriter requestRewriter)
                 throws javax.servlet.ServletException,
                        java.io.IOException
actually takes care of the dispatching to the rewritten URI.

This method can be overwritten by subclassing Filters.

The original code of this method is no more than:
requestRewriter.getRequestDispatcher().forward(servletRequest, servletResponse);

Parameters:
servletRequest - the current servlet request
servletResponse - the current servlet response
requestRewriter - the current rewrite request
Throws:
javax.servlet.ServletException - on errors while dispatching
java.io.IOException - on errors while dispatching

init

public void init(javax.servlet.FilterConfig conf)
initialises the filter.

Parameters:
conf - the filter config (which is ignored)