private void registerAggregateCommandHandlers() { ensureRepositoryConfiguration(); if (!explicitCommandHandlersSet) { AggregateAnnotationCommandHandler.Builder<T> builder = AggregateAnnotationCommandHandler.<T>builder() .aggregateType(aggregateType) .parameterResolverFactory(parameterResolverFactory) .repository(this.repository); if (commandTargetResolver != null) { builder.commandTargetResolver(commandTargetResolver); } AggregateAnnotationCommandHandler<T> handler = builder.build(); handler.subscribe(commandBus); } }
@SuppressWarnings("unchecked") @Before public void setUp() { eventStore = spy(EmbeddedEventStore.builder().storageEngine(new InMemoryEventStorageEngine()).build()); Repository<MyAggregate> myAggregateRepository = EventSourcingRepository.builder(MyAggregate.class) .eventStore(eventStore) .build(); CommandBus commandBus = SimpleCommandBus.builder().build(); commandGateway = DefaultCommandGateway.builder().commandBus(commandBus).build(); AggregateAnnotationCommandHandler<MyAggregate> myAggregateCommandHandler = AggregateAnnotationCommandHandler.<MyAggregate>builder() .aggregateType(MyAggregate.class) .repository(myAggregateRepository) .build(); myAggregateCommandHandler.subscribe(commandBus); }
}); commandHandler = new Component<>(() -> parent, "aggregateCommandHandler<" + aggregate.getSimpleName() + ">", c -> AggregateAnnotationCommandHandler.<A>builder() .repository(repository.get()) .commandTargetResolver(commandTargetResolver.get())
}); commandHandler = new Component<>(() -> parent, "aggregateCommandHandler<" + aggregate.getSimpleName() + ">", c -> AggregateAnnotationCommandHandler.<A>builder() .repository(repository.get()) .commandTargetResolver(commandTargetResolver.get())