/** * Configures an Aggregate using default settings. This means the aggregate is expected to be Event Sourced if an * Event Store present in the configuration. Otherwise, an explicit repository must be configured and the * {@link #configureAggregate(AggregateConfiguration)} must be used to register the aggregate. * * @param aggregate The aggregate type to register with the Configuration * @param <A> The type of aggregate * @return the current instance of the Configurer, for chaining purposes */ default <A> Configurer configureAggregate(Class<A> aggregate) { return configureAggregate(AggregateConfigurer.defaultConfiguration(aggregate)); }
Aggregate aggregateAnnotation = beanFactory.findAnnotationOnBean(aggregate, Aggregate.class); Class<A> aggregateType = (Class<A>) beanFactory.getType(aggregate); AggregateConfigurer<A> aggregateConf = AggregateConfigurer.defaultConfiguration(aggregateType); if ("".equals(aggregateAnnotation.repository())) { String repositoryName = lcFirst(aggregateType.getSimpleName()) + "Repository";
@Before public void setUp() { configuration = DefaultConfigurer.defaultConfiguration() .configureEmbeddedEventStore(c -> new InMemoryEventStorageEngine()) .configureAggregate(AggregateConfigurer.defaultConfiguration(MyAggregate.class) .configureAggregateFactory(c -> new AggregateFactory<MyAggregate>() { @Override public MyAggregate createAggregateRoot(String aggregateIdentifier, DomainEventMessage<?> firstEvent) { return new MyAggregate(aggregateIdentifier); } @Override public Class<MyAggregate> getAggregateType() { return MyAggregate.class; } })) .registerCommandHandler(c -> new MyCommandHandler(c.repository(MyAggregate.class), c.commandGateway())) .buildConfiguration(); configuration.start(); command = new MyCommand("outer", aggregateIdentifier, new MyCommand("middle", aggregateIdentifier, new MyCommand("inner", aggregateIdentifier))); }
/** * Configures an Aggregate using default settings. This means the aggregate is expected to be Event Sourced if an * Event Store present in the configuration. Otherwise, an explicit repository must be configured and the * {@link #configureAggregate(AggregateConfiguration)} must be used to register the aggregate. * * @param aggregate The aggregate type to register with the Configuration * @param <A> The type of aggregate * @return the current instance of the Configurer, for chaining purposes */ default <A> Configurer configureAggregate(Class<A> aggregate) { return configureAggregate(AggregateConfigurer.defaultConfiguration(aggregate)); }
/** * Configures an Aggregate using default settings. This means the aggregate is expected to be Event Sourced if an * Event Store present in the configuration. Otherwise, an explicit repository must be configured and the * {@link #configureAggregate(AggregateConfiguration)} must be used to register the aggregate. * * @param aggregate The aggregate type to register with the Configuration * @param <A> The type of aggregate * @return the current instance of the Configurer, for chaining purposes */ default <A> Configurer configureAggregate(Class<A> aggregate) { return configureAggregate(AggregateConfigurer.defaultConfiguration(aggregate)); }