f.Intercepting Filter

  1. Motivation
    1. To implement common pre- and post-processing steps around Web page requests?
  2. Summary
    1. It is an application of Chain of Responsibility Pattern.
    2. Create a chain of composable filters to implement common pre-processing and post-processing tasks during a Web page request.
    3. In some contexts, the term Intercepting Filter is associated with a specific implementation using the Decorator pattern
    4. A straightforward implementation of Intercepting Filter is a filter chain that iterates through a list of all filters. The Web request handler executes the filter chain before passing control to the application logic
    5.  Intercepting Filter class diagram Intercepting Filter sequence diagram

  3. When to Use
    1. TODO
  4. Types/Variants 
    1. Event-Driven Filters: It uses multiple Filter Chains one for each processing events and filter implementation are stateless.

  5. Implementation
    1. TODO
  6. Example 
    1. TODO
  7. Related Patterns
    1. Front Controller.Intercepting Filter is commonly used in combination with Front Controller.
    2. Decorator: An interesting alternative implementation to the Intercepting Filter pattern uses the Decorator pattern around a Front Controller.
  8. Related Technologies 
    1. TODO
  9. Specific Considerations 
    1. Decorator Vs Intercepting Filter 
      1.  The key difference between Intercepting Filter and Observerlies in the fact that the observer generally does not modify the source object; it "observes" passively what is going on in the source object. 
      2. The purpose of Intercepting Filter, on the other hand, is to intercept and modify the context in which it is called.
  10. References
    1. MSDN: Intercepting Filter Pattern
    2. MSDN:Implementing Intercepting Filter in ASP.NET Using HTTP Module.