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); }