@Override protected EventSourcedAggregate<T> doCreateNewForLock(Callable<T> factoryMethod) throws Exception { return EventSourcedAggregate.initialize(factoryMethod, aggregateModel(), eventStore, repositoryProvider, snapshotTriggerDefinition.prepareTrigger(getAggregateType())); }
@Override public Builder eventStore(EventStore eventStore) { super.eventStore(eventStore); return this; }
/** * Validates whether the fields contained in this Builder are set accordingly. * * @throws AxonConfigurationException if one field is asserted to be incorrect according to the Builder's * specifications */ @Override protected void validate() throws AxonConfigurationException { super.validate(); } }
private void ensureRepositoryConfiguration() { if (repository == null) { registerRepository(EventSourcingRepository.builder(aggregateType) .aggregateFactory(new GenericAggregateFactory<>(aggregateType)) .eventStore(eventStore) .parameterResolverFactory(parameterResolverFactory) .handlerDefinition(handlerDefinition) .repositoryProvider(getRepositoryProvider()) .build()); } }
protected void initializeRepository(LockFactory lockingStrategy) { EventSourcingRepository<CountingAggregate> repository = EventSourcingRepository.builder(CountingAggregate.class) .lockFactory(lockingStrategy) .aggregateFactory(new GenericAggregateFactory<>(CountingAggregate.class)) .eventStore(eventStore) .build(); new AnnotationCommandHandlerAdapter<>(new CounterCommandHandler(repository)).subscribe(commandBus); }
@Override public Aggregate<T> newInstance(Callable<T> factoryMethod) throws Exception { SnapshotTrigger trigger = snapshotTriggerDefinition.prepareTrigger(aggregateFactory.getAggregateType()); EventSourcedAggregate<T> aggregate = EventSourcedAggregate.initialize(factoryMethod, model, eventStore, repositoryProvider, trigger); firstLevelCache.put(aggregate.identifierAsString(), aggregate); cache.put(aggregate.identifierAsString(), new AggregateCacheEntry<>(aggregate)); return aggregate; }
@EventSourcingHandler public void on(InterceptorThrewEvent event) { // do nothing } }
@Test public void testInterceptorWithDeclaredChainAllowedToDeclareNonVoidReturnType() { EventSourcingRepository.builder(MyAggregateWithDeclaredInterceptorChainInterceptorReturningNonVoid.class) .eventStore(eventStore) .build(); }
@Override protected void publish(EventMessage<?> msg) { super.publish(msg); snapshotTrigger.eventHandled(msg); if (identifierAsString() == null) { throw new IncompatibleAggregateException("Aggregate identifier must be non-null after applying an event. " + "Make sure the aggregate identifier is initialized at " + "the latest when handling the creation event."); } }
@Override protected void doSaveWithLock(EventSourcedAggregate<T> aggregate) { super.doSaveWithLock(aggregate); cache.put(aggregate.identifierAsString(), new AggregateCacheEntry<>(aggregate)); }
@Override protected void doDeleteWithLock(EventSourcedAggregate<T> aggregate) { super.doDeleteWithLock(aggregate); cache.put(aggregate.identifierAsString(), new AggregateCacheEntry<>(aggregate)); }
/** * Initializes a {@link AggregateSnapshotter} as specified through this Builder. * * @return a {@link AggregateSnapshotter} as specified through this Builder */ public AggregateSnapshotter build() { return new AggregateSnapshotter(this); }
/** * Returns this DomainEventStream as a {@link Stream} of DomainEventMessages. Note that the returned Stream will * start at the current position of the DomainEventStream. * <p> * Note that iterating over the returned Stream may affect this DomainEventStream and vice versa. It is therefore * not recommended to use this DomainEventStream after invoking this method. * * @return This DomainEventStream as a Stream of event messages */ default Stream<? extends DomainEventMessage<?>> asStream() { return EventStreamUtils.asStream(this); }
@Override public Builder executor(Executor executor) { super.executor(executor); return this; }
@Override public Builder eventStore(EventStore eventStore) { super.eventStore(eventStore); return this; }
@Override public Builder transactionManager(TransactionManager transactionManager) { super.transactionManager(transactionManager); return this; }
/** * Validates whether the fields contained in this Builder are set accordingly. * * @throws AxonConfigurationException if one field is asserted to be incorrect according to the Builder's * specifications */ @Override protected void validate() throws AxonConfigurationException { super.validate(); } }
@Override public Builder repositoryProvider(RepositoryProvider repositoryProvider) { super.repositoryProvider(repositoryProvider); return this; }
@Override public Builder parameterResolverFactory(ParameterResolverFactory parameterResolverFactory) { super.parameterResolverFactory(parameterResolverFactory); return this; }
@Override public Builder handlerDefinition(HandlerDefinition handlerDefinition) { super.handlerDefinition(handlerDefinition); return this; }