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 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.