public interface ResourceFilter extends PortletFilter
ResourceFilteris an object that performs filtering tasks on either the resource request to a portlet, or on the resource response from a portlet, or both.
Filters perform filtering in the
doFilter method. Every Filter has
access to a
FilterConfig object from which it can obtain
its initialization parameters, a reference to the PortletContext
which it can use, for example, to load resources needed for filtering tasks.
Filters are configured in the portlet deployment descriptor of a portlet application.
ResourceFilter is to support asynchronous mode, care must be taken
regarding resource allocation and release.
Any resources attached to the
ResourceRequest during the inbound portion
and needed during asynchronous processing should not be released during outbound processing
if asynchronous mode has been started.
If resources must be allocated in this way during inbound processing, the portlet should
PortletAsyncListener to release the resources upon request
completion even when error conditions or timeouts occur.
Alternatively, the portlet may
AsyncContext#dispatch() method at the end of asynchronous processing
in order to cause the portlet resource method to be invoked again with the same
The resources can be released during asynchronous dispatch outbound processing if
asynchronous mode is not active.
ResourceRequest#isAsyncStarted() method will return
if the portlet is currently in asynchronous mode.
ResourceRequest#igetDispatcherType() method will return
DispatcherType#REQUEST during initial request processing and
DipatcherType#ASYNC during processing resulting from an asynchronous dispatch.
|Modifier and Type||Method and Description|
void doFilter(ResourceRequest request, ResourceResponse response, FilterChain chain) throws IOException, PortletException
doFiltermethod of the Filter is called by the portlet container each time a resource request/response pair is passed through the chain due to a client request for a portlet method at the end of the chain.
FilterChain passed in to this method allows
the Filter to pass on the resource request and response to the next
component in the chain.
doFilter method of a filter will typically be implemented
following this or some subset of the following pattern:
ResourceRequestWrapperin order to modify request data.
doFiltermethod with a customized implementation of the response wrapper
ResourceResponseWrapperto modify response data.
doFiltermethod on the
FilterChainobject, and passing in the request and response with which it was called or passing in wrapped versions it may have created. The filter chain's implementation of the
doFiltermethod, provided by the portlet container, must locate the next component in the filter chain and invoke its
doFiltermethod, passing in the appropriate request and response objects. Alternatively, the filter chain can block the request by not making the call to invoke the next component, leaving the filter responsible for filling out the response object.
doFilterprocessing, the portlet container must not attempt continued processing down the filter chain. It may choose to retry the whole chain at a later time if the exception is not marked permanent.
Java Portlet 3.0 API Specification. See the Copyright and License provided with this distribution. Use is subject to license terms.