Publisher

Perhaps the most common use of Domain Events is when an Aggregate creates an Event and publishes it. The publisher resides in a Module (9) of the model, but it doesn’t model some aspect of the domain. Rather, it provides a simple service to Aggregates that need to notify subscribers of Events. The following is a DomainEventPublisher, which adheres to this definition. An abstract view of how the DomainEventPublisher is used can be found in Figure 8.2.

package com.saasovation.agilepm.domain.model; import java.util.ArrayList; import java.util.List; public class DomainEventPublisher {     @SuppressWarnings("unchecked")     private static final ThreadLocal<List> subscribers =             new ThreadLocal<List>(); ...

Get Implementing Domain-Driven Design now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.