|
1 | 1 | package com.iluwatar.intercepting.filter; |
2 | 2 |
|
3 | 3 | /** |
4 | | - * |
5 | | - * This is an app that checks whether the order request is valid through pre-processing done via {@link Filter}. |
6 | | - * Each field has its own corresponding {@link Filter} |
| 4 | + * |
| 5 | + * When a request enters a Web application, it often must pass several entrance |
| 6 | + * tests prior to the main processing stage. For example, |
| 7 | + * - Has the client been authenticated? |
| 8 | + * - Does the client have a valid session? |
| 9 | + * - Is the client's IP address from a trusted network? |
| 10 | + * - Does the request path violate any constraints? |
| 11 | + * - What encoding does the client use to send the data? |
| 12 | + * - Do we support the browser type of the client? |
| 13 | + * Some of these checks are tests, resulting in a yes or no answer that determines |
| 14 | + * whether processing will continue. Other checks manipulate the incoming data |
| 15 | + * stream into a form suitable for processing. |
| 16 | + * <p> |
| 17 | + * The classic solution consists of a series of conditional checks, with any failed |
| 18 | + * check aborting the request. Nested if/else statements are a standard strategy, |
| 19 | + * but this solution leads to code fragility and a copy-and-paste style of programming, |
| 20 | + * because the flow of the filtering and the action of the filters is compiled into |
| 21 | + * the application. |
| 22 | + * <p> |
| 23 | + * The key to solving this problem in a flexible and unobtrusive manner is to have a |
| 24 | + * simple mechanism for adding and removing processing components, in which each |
| 25 | + * component completes a specific filtering action. This is the Intercepting Filter |
| 26 | + * pattern in action. |
| 27 | + * <p> |
| 28 | + * In this example we check whether the order request is valid through pre-processing |
| 29 | + * done via {@link Filter}. Each field has its own corresponding {@link Filter} |
| 30 | + * <p> |
7 | 31 | * @author joshzambales |
8 | 32 | * |
9 | 33 | */ |
|
0 commit comments