|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jasig.springframework.web.portlet.filter.GenericPortletFilterBean
org.jasig.springframework.web.portlet.filter.DelegatingPortletFilterProxy
public class DelegatingPortletFilterProxy
Proxy for a standard Portlet 2.0 Filter, delegating to a Spring-managed
bean that implements the Filter interface. Supports a "targetBeanName"
filter init-param in portlet.xml, specifying the name of the
target bean in the Spring application context.
portlet.xml will usually contain a DelegatingPortletFilterProxy
definition, with the specified filter-name corresponding to a bean name in
Spring's root portlet application context. All calls to the filter proxy will then
be delegated to that bean in the Spring context, which is required to implement
the standard Portlet 2.0 Filter interface.
This approach is particularly useful for Filter implementation with complex setup needs, allowing to apply the full Spring bean definition machinery to Filter instances. Alternatively, consider standard Filter setup in combination with looking up service beans from the Spring root application context.
NOTE: The lifecycle methods defined by the Portlet Filter interface
will by default not be delegated to the target bean, relying on the
Spring application context to manage the lifecycle of that bean. Specifying
the "targetFilterLifecycle" filter init-param as "true" will enforce invocation
of the PortletFilter.init and PortletFilter.destroy lifecycle methods
on the target bean, letting the portlet container manage the filter lifecycle.
This class was originally inspired by Spring's DelegatingFilterProxy
setTargetBeanName(java.lang.String),
setTargetFilterLifecycle(boolean),
ActionFilter.doFilter(javax.portlet.ActionRequest, javax.portlet.ActionResponse, javax.portlet.filter.FilterChain),
EventFilter.doFilter(javax.portlet.EventRequest, javax.portlet.EventResponse, javax.portlet.filter.FilterChain),
RenderFilter.doFilter(javax.portlet.RenderRequest, javax.portlet.RenderResponse, javax.portlet.filter.FilterChain),
ResourceFilter.doFilter(javax.portlet.ResourceRequest, javax.portlet.ResourceResponse, javax.portlet.filter.FilterChain),
PortletFilter.init(javax.portlet.filter.FilterConfig),
PortletFilter.destroy(),
#DelegatingFilterProxy(Filter),
#DelegatingFilterProxy(String),
#DelegatingFilterProxy(String, WebApplicationContext),
WebApplicationInitializer| Field Summary |
|---|
| Fields inherited from class org.jasig.springframework.web.portlet.filter.GenericPortletFilterBean |
|---|
logger |
| Constructor Summary | |
|---|---|
DelegatingPortletFilterProxy()
|
|
| Method Summary | |
|---|---|
void |
destroy()
Subclasses may override this to perform custom filter shutdown. |
protected void |
destroyDelegate(javax.portlet.filter.PortletFilter delegate)
Destroy the PortletFilter delegate. |
void |
doFilter(javax.portlet.ActionRequest request,
javax.portlet.ActionResponse response,
javax.portlet.filter.FilterChain chain)
Calls GenericPortletFilterBean.doCommonFilter(PortletRequest, PortletResponse, FilterChain) |
void |
doFilter(javax.portlet.EventRequest request,
javax.portlet.EventResponse response,
javax.portlet.filter.FilterChain chain)
Calls GenericPortletFilterBean.doCommonFilter(PortletRequest, PortletResponse, FilterChain) |
void |
doFilter(javax.portlet.RenderRequest request,
javax.portlet.RenderResponse response,
javax.portlet.filter.FilterChain chain)
Calls GenericPortletFilterBean.doCommonFilter(PortletRequest, PortletResponse, FilterChain) |
void |
doFilter(javax.portlet.ResourceRequest request,
javax.portlet.ResourceResponse response,
javax.portlet.filter.FilterChain chain)
Calls GenericPortletFilterBean.doCommonFilter(PortletRequest, PortletResponse, FilterChain) |
protected org.springframework.context.ApplicationContext |
findWebApplicationContext()
Retrieve a WebApplicationContext from the PortletContext. |
String |
getContextAttribute()
Return the name of the ServletContext attribute which should be used to retrieve the PortletApplicationContext from which to load the delegate PortletFilter bean. |
protected String |
getTargetBeanName()
Return the name of the target bean in the Spring application context. |
protected void |
initDelegate(boolean require)
Initialize the PortletFilter delegate, defined as bean the given Spring application context. |
protected void |
initFilterBean()
Subclasses may override this to perform custom initialization. |
protected void |
invokeDelegate(javax.portlet.filter.ActionFilter delegate,
javax.portlet.ActionRequest request,
javax.portlet.ActionResponse response,
javax.portlet.filter.FilterChain filterChain)
Actually invoke the delegate ActionFilter with the given request and response. |
protected void |
invokeDelegate(javax.portlet.filter.EventFilter delegate,
javax.portlet.EventRequest request,
javax.portlet.EventResponse response,
javax.portlet.filter.FilterChain filterChain)
Actually invoke the delegate EventFilter with the given request and response. |
protected void |
invokeDelegate(javax.portlet.filter.RenderFilter delegate,
javax.portlet.RenderRequest request,
javax.portlet.RenderResponse response,
javax.portlet.filter.FilterChain filterChain)
Actually invoke the delegate RenderFilter with the given request and response. |
protected void |
invokeDelegate(javax.portlet.filter.ResourceFilter delegate,
javax.portlet.ResourceRequest request,
javax.portlet.ResourceResponse response,
javax.portlet.filter.FilterChain filterChain)
Actually invoke the delegate ResourceFilter with the given request and response. |
protected boolean |
isTargetFilterLifecycle()
Return whether to invoke the PortletFilter.init and
PortletFilter.destroy lifecycle methods on the target bean. |
void |
setContextAttribute(String contextAttribute)
Set the name of the ServletContext attribute which should be used to retrieve the PortletApplicationContext from which to load the delegate PortletFilter bean. |
void |
setTargetBeanName(String targetBeanName)
Set the name of the target bean in the Spring application context. |
void |
setTargetFilterLifecycle(boolean targetFilterLifecycle)
Set whether to invoke the PortletFilter.init and
PortletFilter.destroy lifecycle methods on the target bean. |
| Methods inherited from class org.jasig.springframework.web.portlet.filter.GenericPortletFilterBean |
|---|
addRequiredProperty, afterPropertiesSet, doCommonFilter, getFilterConfig, getFilterName, getPortletContext, init, initBeanWrapper, setBeanName, setEnvironment, setPortletContext |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DelegatingPortletFilterProxy()
| Method Detail |
|---|
public void setContextAttribute(String contextAttribute)
PortletApplicationContext from which to load the delegate PortletFilter bean.
public String getContextAttribute()
PortletApplicationContext from which to load the delegate PortletFilter bean.
public void setTargetBeanName(String targetBeanName)
By default, the filter-name as specified for the
DelegatingPortletFilterProxy in portlet.xml will be used.
protected String getTargetBeanName()
public void setTargetFilterLifecycle(boolean targetFilterLifecycle)
PortletFilter.init and
PortletFilter.destroy lifecycle methods on the target bean.
Default is "false"; target beans usually rely on the Spring application context for managing their lifecycle. Setting this flag to "true" means that the portlet container will control the lifecycle of the target PortletFilter, with this proxy delegating the corresponding calls.
protected boolean isTargetFilterLifecycle()
PortletFilter.init and
PortletFilter.destroy lifecycle methods on the target bean.
protected void initFilterBean()
throws javax.portlet.PortletException
GenericPortletFilterBeanNote: This method will be called from standard filter initialization as well as filter bean initialization in a Spring application context. Filter name and PortletContext will be available in both cases.
This default implementation is empty.
initFilterBean in class GenericPortletFilterBeanjavax.portlet.PortletException - if subclass initialization failsGenericPortletFilterBean.getFilterName(),
GenericPortletFilterBean.getPortletContext()
public void doFilter(javax.portlet.ResourceRequest request,
javax.portlet.ResourceResponse response,
javax.portlet.filter.FilterChain chain)
throws IOException,
javax.portlet.PortletException
GenericPortletFilterBeanGenericPortletFilterBean.doCommonFilter(PortletRequest, PortletResponse, FilterChain)
doFilter in interface javax.portlet.filter.ResourceFilterdoFilter in class GenericPortletFilterBeanIOException
javax.portlet.PortletException
public void doFilter(javax.portlet.EventRequest request,
javax.portlet.EventResponse response,
javax.portlet.filter.FilterChain chain)
throws IOException,
javax.portlet.PortletException
GenericPortletFilterBeanGenericPortletFilterBean.doCommonFilter(PortletRequest, PortletResponse, FilterChain)
doFilter in interface javax.portlet.filter.EventFilterdoFilter in class GenericPortletFilterBeanIOException
javax.portlet.PortletException
public void doFilter(javax.portlet.RenderRequest request,
javax.portlet.RenderResponse response,
javax.portlet.filter.FilterChain chain)
throws IOException,
javax.portlet.PortletException
GenericPortletFilterBeanGenericPortletFilterBean.doCommonFilter(PortletRequest, PortletResponse, FilterChain)
doFilter in interface javax.portlet.filter.RenderFilterdoFilter in class GenericPortletFilterBeanIOException
javax.portlet.PortletException
public void doFilter(javax.portlet.ActionRequest request,
javax.portlet.ActionResponse response,
javax.portlet.filter.FilterChain chain)
throws IOException,
javax.portlet.PortletException
GenericPortletFilterBeanGenericPortletFilterBean.doCommonFilter(PortletRequest, PortletResponse, FilterChain)
doFilter in interface javax.portlet.filter.ActionFilterdoFilter in class GenericPortletFilterBeanIOException
javax.portlet.PortletExceptionpublic void destroy()
GenericPortletFilterBeanNote: This method will be called from standard filter destruction as well as filter bean destruction in a Spring application context.
This default implementation is empty.
destroy in interface javax.portlet.filter.PortletFilterdestroy in interface org.springframework.beans.factory.DisposableBeandestroy in class GenericPortletFilterBeanprotected org.springframework.context.ApplicationContext findWebApplicationContext()
WebApplicationContext from the PortletContext. The
WebApplicationContext must have already been loaded and stored in the
PortletContext before this filter gets initialized (or invoked).
Subclasses may override this method to provide a different
WebApplicationContext retrieval strategy.
null if not found
protected void initDelegate(boolean require)
throws javax.portlet.PortletException
The default implementation fetches the bean from the application context
and calls the standard PortletFilter.init method on it, passing
in the FilterConfig of this PortletFilter proxy.
wac - the root application context
javax.portlet.PortletException - if thrown by the PortletFiltergetTargetBeanName(),
isTargetFilterLifecycle(),
GenericPortletFilterBean.getFilterConfig(),
PortletFilter.init(javax.portlet.filter.FilterConfig)
protected void invokeDelegate(javax.portlet.filter.ActionFilter delegate,
javax.portlet.ActionRequest request,
javax.portlet.ActionResponse response,
javax.portlet.filter.FilterChain filterChain)
throws javax.portlet.PortletException,
IOException
delegate - the delegate ActionFilterrequest - the current action requestresponse - the current action responsefilterChain - the current FilterChain
javax.portlet.PortletException - if thrown by the PortletFilter
IOException - if thrown by the PortletFilter
protected void invokeDelegate(javax.portlet.filter.EventFilter delegate,
javax.portlet.EventRequest request,
javax.portlet.EventResponse response,
javax.portlet.filter.FilterChain filterChain)
throws javax.portlet.PortletException,
IOException
delegate - the delegate EventFilterrequest - the current Event requestresponse - the current Event responsefilterChain - the current FilterChain
javax.portlet.PortletException - if thrown by the PortletFilter
IOException - if thrown by the PortletFilter
protected void invokeDelegate(javax.portlet.filter.RenderFilter delegate,
javax.portlet.RenderRequest request,
javax.portlet.RenderResponse response,
javax.portlet.filter.FilterChain filterChain)
throws javax.portlet.PortletException,
IOException
delegate - the delegate RenderFilterrequest - the current Render requestresponse - the current Render responsefilterChain - the current FilterChain
javax.portlet.PortletException - if thrown by the PortletFilter
IOException - if thrown by the PortletFilter
protected void invokeDelegate(javax.portlet.filter.ResourceFilter delegate,
javax.portlet.ResourceRequest request,
javax.portlet.ResourceResponse response,
javax.portlet.filter.FilterChain filterChain)
throws javax.portlet.PortletException,
IOException
delegate - the delegate ResourceFilterrequest - the current Resource requestresponse - the current Resource responsefilterChain - the current FilterChain
javax.portlet.PortletException - if thrown by the PortletFilter
IOException - if thrown by the PortletFilterprotected void destroyDelegate(javax.portlet.filter.PortletFilter delegate)
PortletFilter.destroy on it.
delegate - the PortletFilter delegate (never null)isTargetFilterLifecycle(),
PortletFilter.destroy()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||