JSR 286 - Portlet Filters

● Modeled after Servlet Filters
● Modify request data by wrapping request
● Modify response data by wrapping response
● Intercept invocation of a portlet before and after it is called
● Filters may be chained

Portlet Filter Interface:
● Must implement javax.portlet.Filter interface
● Must provide a public no-arg constructor
● init() method will be called on all Filters before being called on any Portlets
● destroy() will be called if Filter is removed from service
● doFilter() method called if processAction(),processEvent(), render(), or serveResource() would be called on Filtered Portlet

Declaring Portlet Filters
● Declared in portlet.xml in <filter> element
<filter-mapping> element must specify the applicable portlets
● Restrict to specific lifecycle methods using the <lifecycle> element in <filter-mapping>
● Order in portlet.xml matters for multiple filters of the same portlet
● Portlet containers are expected/allowed to cache the "filter chain"

Wrapping Requests/Reponses
–  ActionRequestWrapper      ActionResponseWrapper
–  EventRequestWrapper        EventResponseWrapper
–  RenderRequestWrapper     RenderResponseWrapper
–  ResourceRequestWrapper  ResourceResponseWrapper