API updates introduced in Java EE 8
This book focuses on enterprise applications with Java EE 8.
There have been certain standards that have been updated in the course of this version. The following are the most important new features and standards.
CDI 2.0
Since Java EE 8 and CDI 2.0, events cannot only be handled synchronously. As we have seen previously in this book, CDI natively supports handling events asynchronously. In fact, this was only possible before if the event observer method was a business method of an EJB, annotated with @Asynchronous
.
In order to emit and handle asynchronous CDI events, the publisher side uses the fireAsync
method. The observer method parameter is annotated with @ObservesAsync
.
Another new event functionality the advent of CDI 2.0 included is the possibility to order event observers. Therefore, the @Priority
annotation, which is well-known within the Java EE platform, is specified at the event observer method:
public void onCarCreated(@Observes @Priority(100)...