/** * Enable sequences on this Aggregate, causing it to emit DomainEventMessages, starting at sequence 0. Each Event * applied will increase the sequence, allowing to trace each event back to the Aggregate instance that published * it, in the order published. */ public void initSequence() { initSequence(-1); }
/** * Initialize an aggregate created by the given {@code aggregateFactory} which is described in the given * {@code aggregateModel}. The given {@code eventBus} is used to publish events generated by the aggregate. * * @param aggregateFactory The factory to create the aggregate root instance with * @param aggregateModel The model describing the aggregate structure * @param eventBus The EventBus to publish events on * @param repositoryProvider Provides repositories for specific aggregate types * @param generateSequences Whether to generate sequence numbers on events published from this aggregate * @param <T> The type of the Aggregate root * @return An Aggregate instance, fully initialized * * @throws Exception when an error occurs creating the aggregate root instance */ public static <T> AnnotatedAggregate<T> initialize(Callable<T> aggregateFactory, AggregateModel<T> aggregateModel, EventBus eventBus, RepositoryProvider repositoryProvider, boolean generateSequences) throws Exception { AnnotatedAggregate<T> aggregate = new AnnotatedAggregate<>(aggregateModel, eventBus, repositoryProvider); if (generateSequences) { aggregate.initSequence(); } aggregate.registerRoot(aggregateFactory); return aggregate; }
/** * Enable sequences on this Aggregate, causing it to emit DomainEventMessages, starting at sequence 0. Each Event * applied will increase the sequence, allowing to trace each event back to the Aggregate instance that published * it, in the order published. */ public void initSequence() { initSequence(-1); }
/** * Initialize an aggregate created by the given {@code aggregateFactory} which is described in the given * {@code aggregateModel}. The given {@code eventBus} is used to publish events generated by the aggregate. * * @param aggregateFactory The factory to create the aggregate root instance with * @param aggregateModel The model describing the aggregate structure * @param eventBus The EventBus to publish events on * @param repositoryProvider Provides repositories for specific aggregate types * @param generateSequences Whether to generate sequence numbers on events published from this aggregate * @param <T> The type of the Aggregate root * @return An Aggregate instance, fully initialized * * @throws Exception when an error occurs creating the aggregate root instance */ public static <T> AnnotatedAggregate<T> initialize(Callable<T> aggregateFactory, AggregateModel<T> aggregateModel, EventBus eventBus, RepositoryProvider repositoryProvider, boolean generateSequences) throws Exception { AnnotatedAggregate<T> aggregate = new AnnotatedAggregate<>(aggregateModel, eventBus, repositoryProvider); if (generateSequences) { aggregate.initSequence(); } aggregate.registerRoot(aggregateFactory); return aggregate; }