@Override public void execute(Consumer<T> invocation) { execute(() -> invocation.accept(aggregateRoot)); }
/** * Registers the aggregate root created by the given {@code aggregateFactory} with this aggregate. Applies any * delayed events that have not been applied to the aggregate yet. * <p> * This is method is commonly called while an aggregate is being initialized. * * @param aggregateFactory the factory to create the aggregate root * @throws Exception if the aggregate factory fails to create the aggregate root */ protected void registerRoot(Callable<T> aggregateFactory) throws Exception { this.aggregateRoot = executeWithResult(aggregateFactory); execute(() -> { applying = true; while (!delayedTasks.isEmpty()) { delayedTasks.remove().run(); } applying = false; }); }
/** * Registers the aggregate root created by the given {@code aggregateFactory} with this aggregate. Applies any * delayed events that have not been applied to the aggregate yet. * <p> * This is method is commonly called while an aggregate is being initialized. * * @param aggregateFactory the factory to create the aggregate root * @throws Exception if the aggregate factory fails to create the aggregate root */ protected void registerRoot(Callable<T> aggregateFactory) throws Exception { this.aggregateRoot = executeWithResult(aggregateFactory); execute(() -> { applying = true; while (!delayedTasks.isEmpty()) { delayedTasks.remove().run(); } applying = false; }); }
@Override public void execute(Consumer<T> invocation) { execute(() -> invocation.accept(aggregateRoot)); }