org.baswell.routes
Class RoutesFilter

java.lang.Object
  extended by org.baswell.routes.RoutesFilter
All Implemented Interfaces:
javax.servlet.Filter

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

An entry point for mapping HTTP servlet requests to route methods. This filter should be placed last in your filter chain. No filters in the chain below this filter will be processed when route method matches are found (i.e. chain.doFilter is not called). If no match is found, then chain.doFilter will be called so further processing can occur. This will allow, for example, to still serve up file resources (ex. html, jsp) directly as long as none of your routes match the file resource URL.

If your method routes are not the only mechanism for serving content, there are two parameters you can specify to improve the performance of this filter.

 <init-param>
   <param-name>ONLY</param-name>
   <param-value>/api/.*,/routes/.*</param-value>
 </init-param>
 
 

The ONLY parameter must be a list (comma delimited) of valid Java regular expression. If specified, only request URIs that match this pattern will be checked to see if they match any route methods. The URI matched against will not include the context your application is deployed at so do not include that in the pattern.

The other supported parameter is EXCEPT:

 <init-param>
   <param-name>EXCEPT</param-name>
   <param-value>.*\.html$,.*\.jsp$</param-value>
 </init-param>
 
 

The EXCEPT parameter must be a list (comma delimited) of valid Java regular expression. If specified, all request URIs will be checked to see if they match any route method except those that match one of these patterns. The URI matched against will not include the context your application is deployed at so do not include that in the pattern.

If both ONLY and EXCEPT are specified then the route methods will not be checked if the ONLY pattern does not match or the EXCEPT pattern does match.

See Also:
RoutesServlet, RoutesEngine

Constructor Summary
RoutesFilter()
           
 
Method Summary
 void destroy()
           
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
           
 void init(javax.servlet.FilterConfig filterConfig)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RoutesFilter

public RoutesFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig filterConfig)
          throws javax.servlet.ServletException
Specified by:
init in interface javax.servlet.Filter
Throws:
javax.servlet.ServletException

doFilter

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

destroy

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