In this period of almost 9 years as a developer, one of the project patterns that helped me the most in many moments was Interceptor. This pattern combined with the aspect-oriented programming (AOP) paradigm makes it much easier to apply behaviors, filters, among other devices applicable to systems, especially web ones.
It is a standard adopted by several existing resources/tools and many of them used on a daily basis, such as Spring Security. Spring's security module intercepts all requests and relies on information from the request to validate authentication and/or authorization.
Security is an example, there are others like @ControllerAdvice @ExceptionHandler, in web layers RequestInterceptor or ResponseInterceptor (Spring Web, RestTemplate and Feign), Hibernate interceptor, etc...
I mentioned interceptor applications in Java library resources... but resources/tools/frameworks from other languages also have Interceptor applications!
The above is the detailed content of Interceptor: A very useful Design Pattern!. For more information, please follow other related articles on the PHP Chinese website!