Events
The Observer Pattern is a very popular software design pattern in every object oriented programming language. The concept is that an object, the subject, will be monitored by one or more objects, the observer(s), which will be notified when specific state changes happen on the subject. The state change is called an event and this pattern is at the core of most event-handling systems.
Events are part of Java SE since its very beginning and have always been standard in common UI frameworks such as AWT, Swing, and JavaFX. By contrast, Java EE never had a specific JSR to attend to such requirements until the JSR 299 (Context and Dependency Injection for Java EE) release that defines an event-handling mechanism which is completely integrated with Java EE and easy to use.
In order to show an example of this mechanism, we're going to create an auditing module for the Store application, which is very similar to what has been accomplished by the logging interceptor in the previous section, illustrating...