Observing events in different transaction phases

If an observer method wishes to receive events as part of the before or after completion phases of a transaction in which the event was fired, they are referred to as transactional observer methods.

We could incorporate the transaction phase into our preceding observer with the following:

public void refreshOnBookRemoval
  (@Observes( during = AFTER_SUCCESS ) @Removed Book bk) { ... }

The possible values for during are defined on javax.enterprise.event.TransactionPhase. In the context of a transactional observer method, the values for TransactionPhase have the following meanings:

  • IN_PROGRESS: An observer method is called immediately. As this is the default value for all observers, there is no need to ...

Get JBoss Weld CDI for Java Platform now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.