@Component
public class Post {
private final DomainEventPublisher eventPublisher;
@Inject
public Post(DomainEventPublisher eventPublisher) {
this.eventPublisher = eventPublisher;
}
public void publish() {
//....
eventPublisher.publish(postPublished);
//....
}
}