velosurf.util
Class TemplateNameFilter

java.lang.Object
  extended by velosurf.util.TemplateNameFilter
All Implemented Interfaces:
javax.servlet.Filter

public class TemplateNameFilter
extends java.lang.Object
implements javax.servlet.Filter

This class is a forwarding filter which allows to hide ".vtl" from resource URLs. It works by building a cache of all template names in the webapp, and adding

The purpose of this feature is to allow URLs to be independant of the status of the resource: regular file or template file, allowing this status to transparently change over time. You can store all resources in the same directory tree, templates having an additional ".vtl" like in "foo.html.vtl" or "bar.js.vtl".

In development mode, you can choose either to reset the cache periodically, or manually with the "reset-cache" URI, or both.

Initialization parameters:

Author:
Claude Brisson

Field Summary
private  long lastReset
           
private static int RESET_MANUAL
           
private static int RESET_NONE
           
private static int RESET_PERIODIC
           
private  int resetMethod
           
private  long resetPeriod
           
private  java.lang.String resetUri
           
private  javax.servlet.ServletContext servletContext
           
private  java.lang.String templateExtension
           
private  java.util.Set templates
           
 
Constructor Summary
TemplateNameFilter()
           
 
Method Summary
private  void buildsTemplateNamesList()
          Builds the cache, which consists of a hash set containing all template names.
 void destroy()
           
 void doFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain)
           
 void init(javax.servlet.FilterConfig filterConfig)
          init the filter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

servletContext

private javax.servlet.ServletContext servletContext

templateExtension

private java.lang.String templateExtension

RESET_NONE

private static final int RESET_NONE
See Also:
Constant Field Values

RESET_MANUAL

private static final int RESET_MANUAL
See Also:
Constant Field Values

RESET_PERIODIC

private static final int RESET_PERIODIC
See Also:
Constant Field Values

resetMethod

private int resetMethod

resetUri

private java.lang.String resetUri

resetPeriod

private long resetPeriod

templates

private java.util.Set templates

lastReset

private long lastReset
Constructor Detail

TemplateNameFilter

public TemplateNameFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig filterConfig)
          throws javax.servlet.ServletException
init the filter

Specified by:
init in interface javax.servlet.Filter
Parameters:
filterConfig - filter configuration
Throws:
javax.servlet.ServletException

buildsTemplateNamesList

private void buildsTemplateNamesList()
Builds the cache, which consists of a hash set containing all template names.


doFilter

public void doFilter(javax.servlet.ServletRequest servletRequest,
                     javax.servlet.ServletResponse servletResponse,
                     javax.servlet.FilterChain filterChain)
              throws javax.servlet.ServletException,
                     java.io.IOException
Specified by:
doFilter in interface javax.servlet.Filter
Throws:
javax.servlet.ServletException
java.io.IOException

destroy

public void destroy()
Specified by:
destroy in interface javax.servlet.Filter


~ooOoo~