info.magnolia.cms.filters
Class ServletDispatchingFilter

java.lang.Object
  extended by info.magnolia.cms.filters.AbstractMgnlFilter
      extended by info.magnolia.cms.filters.ServletDispatchingFilter
All Implemented Interfaces:
MgnlFilter, javax.servlet.Filter

public class ServletDispatchingFilter
extends AbstractMgnlFilter

A filter that dispatches requests to a wrapped servlet. TODO : cache matching URIs ?

Version:
$Id: ServletDispatchingFilter.java 32667 2010-03-13 00:37:06Z gjoseph $
Author:
vsteller

Constructor Summary
ServletDispatchingFilter()
           
 
Method Summary
 void addMapping(java.lang.String mapping)
          See SRV.11.2 Specification of Mappings in the Servlet Specification for the syntax of mappings.
 boolean bypasses(javax.servlet.http.HttpServletRequest request)
          Bypasses if the current request does not match any of the mappings of the servlet.
 void destroy()
          Delegates the destroy() call to the wrapper servlet, then to this filter itself.
protected  int determineMatchingEnd(javax.servlet.http.HttpServletRequest request)
          Determines the index of the first pathInfo character.
 void doFilter(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain chain)
          Dispatches the request to the servlet if not already bypassed.
protected  java.util.regex.Matcher findMatcher(javax.servlet.http.HttpServletRequest request)
           
protected  java.util.regex.Matcher findMatcher(java.lang.String uri)
           
 java.lang.String getComment()
           
 java.util.Collection getMappings()
           
 java.lang.String getName()
           
 java.util.Map getParameters()
           
 java.lang.String getServletClass()
           
 java.lang.String getServletName()
           
 void init(javax.servlet.FilterConfig filterConfig)
          Initializes the servlet and its mappings.
 void setComment(java.lang.String comment)
           
 void setMappings(java.util.Collection mappings)
           
 void setParameters(java.util.Map parameters)
           
 void setServletClass(java.lang.String servletClass)
           
 void setServletName(java.lang.String servletName)
           
 
Methods inherited from class info.magnolia.cms.filters.AbstractMgnlFilter
acceptsEncoding, acceptsGzipEncoding, addAndVerifyHeader, addBypass, doFilter, getBypasses, headerContains, isEnabled, setEnabled, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletDispatchingFilter

public ServletDispatchingFilter()
Method Detail

getName

public java.lang.String getName()
Specified by:
getName in interface MgnlFilter
Overrides:
getName in class AbstractMgnlFilter

init

public void init(javax.servlet.FilterConfig filterConfig)
          throws javax.servlet.ServletException
Initializes the servlet and its mappings. ServletConfig is wrapped to take init parameters into account.

Specified by:
init in interface javax.servlet.Filter
Overrides:
init in class AbstractMgnlFilter
Throws:
javax.servlet.ServletException

destroy

public void destroy()
Delegates the destroy() call to the wrapper servlet, then to this filter itself.

Specified by:
destroy in interface javax.servlet.Filter
Overrides:
destroy in class AbstractMgnlFilter

bypasses

public boolean bypasses(javax.servlet.http.HttpServletRequest request)
Bypasses if the current request does not match any of the mappings of the servlet. Explicit bypasses defined in the bypasses content node of this filter are taken into account as well.

Specified by:
bypasses in interface MgnlFilter
Overrides:
bypasses in class AbstractMgnlFilter

determineMatchingEnd

protected int determineMatchingEnd(javax.servlet.http.HttpServletRequest request)
Determines the index of the first pathInfo character. If the uri does not match any mapping this method returns -1.


findMatcher

protected java.util.regex.Matcher findMatcher(javax.servlet.http.HttpServletRequest request)

findMatcher

protected java.util.regex.Matcher findMatcher(java.lang.String uri)

doFilter

public void doFilter(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
Dispatches the request to the servlet if not already bypassed. The request is wrapped for properly setting the pathInfo.

Specified by:
doFilter in class AbstractMgnlFilter
Throws:
java.io.IOException
javax.servlet.ServletException

getServletName

public java.lang.String getServletName()

setServletName

public void setServletName(java.lang.String servletName)

getServletClass

public java.lang.String getServletClass()

setServletClass

public void setServletClass(java.lang.String servletClass)

getMappings

public java.util.Collection getMappings()

setMappings

public void setMappings(java.util.Collection mappings)

addMapping

public void addMapping(java.lang.String mapping)
See SRV.11.2 Specification of Mappings in the Servlet Specification for the syntax of mappings. Additionally, you can also use plain regular expressions to map your servlets, by prefix the mapping by "regex:". (in which case anything in the request url following the expression's match will be the pathInfo - if your pattern ends with a $, extra pathInfo won't match)


getParameters

public java.util.Map getParameters()

setParameters

public void setParameters(java.util.Map parameters)

getComment

public java.lang.String getComment()

setComment

public void setComment(java.lang.String comment)


Copyright © 2003-2010 Magnolia International Ltd.. All Rights Reserved.