Java Observer Pattern With Spring AOP and a Custom Annotation

The Java Observer Pattern is among the most interesting patterns. It allows the injection of some functionality into a system, or part of a system, with minimum impact on the existing code. In this article, we present a specific solution that implements this pattern, using features like Spring Aspect Oriented Programming (AOP), Spring BeanPostProcessor,  and custom annotations

This solution explains how to extend a system by catching its main events and attaching the wanted functionality. We already explained a strategy to extend an existing system in this article: Decorator Pattern to Solve Integration Scenarios in Existing Systems. There we talked about the Java Decorator Pattern.  The main difference compared to that design is that here we do not replace an object with a decorated version, but we catch events with specific payloads and trigger new features on those events' occurrences. 

CategoriesUncategorized