In this chapter, we will look at the concept of aspect-oriented programming (AOP), focusing on which situations AOP should be used in, as well as how to achieve AOP with the use of CDI interceptors and decorators. Finally, we will also look at some examples of its implementation. By the end of this chapter, you will be able to identify a situation that requires AOP with the use of interceptors and decorators. Furthermore, you will also be able to identify the best approach to implementing these concepts. The topics covered in this chapter are as follows:
- Aspect-oriented programming
- AOP in a JEE scenario – the interceptor
- EJB interceptor implementation
- CDI interceptor implementation
- The decorator pattern
- The decorator pattern in a JEE scenario
- Decorator implementation