Design Pattern Intercepting Filter Pattern - Design Patterns

What is Design Pattern Intercepting Filter Pattern?

The intercepting filter design pattern is use when we want to do some pre-processing / post-processing with demand or response of the application. Filters are defined and apply on the request before passing the request to actual objective application. Filters can do the authentication/ authorization/ logging or tracking of request and then pass the requests to related handlers. Following are the entities of this type of design pattern.

  • Filter - Filter which will perform certain task prior or after execution of request by request handler.
  • Filter Chain - Filter Chain carries multiple filters and help to execute them in defined order on target.
  • Target - Target object is the request handler
  • Filter Manager - Filter Manager manages the filters and Filter Chain.
  • Client - Client is the object who sends request to the Target object.


We are going to form a FilterChain, FilterManager, Target, and Client as different objects representing our entities.AuthenticationFilter and DebugFilterrepresent concrete filters.

InterceptingFilterDemo, our demo class, will employ customer to demonstrate Intercepting Filter Design Pattern.


Step 1

Create Filter interface.

Step 2

Create concrete filters.

Step 3

Create Target

Step 4

Construct Filter Chain

Step 5

Create Filter Manager

Step 6

Create Client

Step 7

Use the customer to demonstrate Intercepting Filter Design Pattern.

Step 8

Verify the output.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

Design Patterns Topics