1.1. Intercepting Filter

Intercepting Filter intercepts incoming requests and outgoing responses and applies a filter. These filters may be added and removed in a declarative manner, allowing them to be applied unobtrusively in a variety of combinations. After this preprocessing and/or post-processing is complete, the final filter in the group vectors control to the original target object. For an incoming request, this is often a Front Controller, but may be a View. To summarize, the Intercepting Filter pattern provides the ability to manipulate a request prior to processing or to manipulate the response before sending the results of the request. 

UML Representation


The following lists the benefits of using the Intercepting Filter pattern:
  • Centralizes pre-processing of requests
  • Centralizes post-processing of responses

When to Use

You should use the Intercepting Filter pattern when:
  • You need to pre-process a request or response.
  • You need to post-process a request or response.