Codota Logo
AggregateConfigurer
Code IndexAdd Codota to your IDE (free)

How to use
AggregateConfigurer
in
org.axonframework.config

Best Java code snippets using org.axonframework.config.AggregateConfigurer (Showing top 17 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Connection c =
  • Codota IconDataSource dataSource;dataSource.getConnection()
  • Codota IconString url;DriverManager.getConnection(url)
  • Codota IconIdentityDatabaseUtil.getDBConnection()
  • Smart code suggestions by Codota
}
origin: AxonFramework/AxonFramework

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";
      aggregate.substring(0, 1).toLowerCase() + aggregate.substring(1) + "AggregateFactory";
  if (beanFactory.containsBean(repositoryName)) {
    aggregateConf.configureRepository(c -> beanFactory.getBean(repositoryName, Repository.class));
  } else {
    registry.registerBeanDefinition(repositoryName,
        .configureAggregateFactory(c -> beanFactory.getBean(factoryName, AggregateFactory.class));
    String triggerDefinition = aggregateAnnotation.snapshotTriggerDefinition();
    if (!"".equals(triggerDefinition)) {
      aggregateConf.configureSnapshotTrigger(
          c -> beanFactory.getBean(triggerDefinition, SnapshotTriggerDefinition.class));
      aggregateConf.configureRepository(
          c -> GenericJpaRepository.builder(aggregateType)
              .parameterResolverFactory(c.parameterResolverFactory())
  aggregateConf.configureRepository(
      c -> beanFactory.getBean(aggregateAnnotation.repository(), Repository.class));
  aggregateConf.configureCommandTargetResolver(c -> getBean(aggregateAnnotation.commandTargetResolver(),
                               c));
} else {
  findComponent(CommandTargetResolver.class).ifPresent(commandTargetResolver -> aggregateConf
origin: AxonFramework/AxonFramework

/**
 * Creates a Configuration for an aggregate of given {@code aggregateType}, which is mapped to a relational
 * database using an EntityManager provided by given {@code entityManagerProvider}. The given {@code aggregateType}
 * is expected to be a proper JPA Entity.
 *
 * @param aggregateType         The type of Aggregate to configure
 * @param entityManagerProvider The provider for Axon to retrieve the EntityManager from
 * @param <A>                   The type of Aggregate to configure
 * @return An AggregateConfigurer instance for further configuration of the Aggregate
 */
public static <A> AggregateConfigurer<A> jpaMappedConfiguration(Class<A> aggregateType,
                                EntityManagerProvider entityManagerProvider) {
  AggregateConfigurer<A> configurer = new AggregateConfigurer<>(aggregateType);
  return configurer.configureRepository(
      c -> GenericJpaRepository.builder(aggregateType)
          .aggregateModel(configurer.metaModel.get())
          .entityManagerProvider(entityManagerProvider)
          .eventBus(c.eventBus())
          .repositoryProvider(c::repository)
          .build()
  );
}
origin: AxonFramework/AxonFramework

/**
 * 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));
}
origin: AxonFramework/AxonFramework

@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)));
}
origin: AxonFramework/AxonFramework

/**
 * Creates a default Configuration for an aggregate of the given {@code aggregateType}. This required either a
 * Repository to be configured using {@link #configureRepository(Function)}, or that the Global Configuration
 * contains an Event Store and the Aggregate support Event Sourcing.
 *
 * @param aggregateType The type of Aggregate to configure
 * @param <A>           The type of Aggregate to configure
 * @return An AggregateConfigurer instance for further configuration of the Aggregate
 */
public static <A> AggregateConfigurer<A> defaultConfiguration(Class<A> aggregateType) {
  return new AggregateConfigurer<>(aggregateType);
}
origin: AxonFramework/AxonFramework

                                         c.handlerDefinition(aggregate))
              ).createModel(aggregate));
commandTargetResolver = new Component<>(() -> parent, name("commandTargetResolver"),
                    c -> c.getComponent(CommandTargetResolver.class,
                              AnnotationCommandTargetResolver::new));
snapshotTriggerDefinition = new Component<>(() -> parent, name("snapshotTriggerDefinition"),
                      c -> NoSnapshotTriggerDefinition.INSTANCE);
aggregateFactory =
    new Component<>(() -> parent, name("aggregateFactory"), c -> new GenericAggregateFactory<>(aggregate));
repository = new Component<>(
    () -> parent,
origin: org.axonframework/axon-core

/**
 * 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));
}
origin: org.axonframework/axon-core

/**
 * Creates a default Configuration for an aggregate of the given {@code aggregateType}. This required either a
 * Repository to be configured using {@link #configureRepository(Function)}, or that the Global Configuration
 * contains an Event Store and the Aggregate support Event Sourcing.
 *
 * @param aggregateType The type of Aggregate to configure
 * @param <A>           The type of Aggregate to configure
 * @return An AggregateConfigurer instance for further configuration of the Aggregate
 */
public static <A> AggregateConfigurer<A> defaultConfiguration(Class<A> aggregateType) {
  return new AggregateConfigurer<>(aggregateType);
}
origin: org.axonframework/axon-core

                                               c.handlerDefinition(aggregate)))
                 .createModel(aggregate));
commandTargetResolver = new Component<>(() -> parent, name("commandTargetResolver"),
                    c -> c.getComponent(CommandTargetResolver.class,
                              AnnotationCommandTargetResolver::new));
snapshotTriggerDefinition = new Component<>(() -> parent, name("snapshotTriggerDefinition"),
                      c -> NoSnapshotTriggerDefinition.INSTANCE);
aggregateFactory =
    new Component<>(() -> parent, name("aggregateFactory"), c -> new GenericAggregateFactory<>(aggregate));
repository = new Component<>(() -> parent, "Repository<" + aggregate.getSimpleName() + ">", c -> {
  Assert.state(c.eventBus() instanceof EventStore,
origin: AxonFramework/AxonFramework

AggregateConfigurer<A> configurer = new AggregateConfigurer<>(aggregateType);
return configurer.configureRepository(
    c -> {
      EntityManagerProvider entityManagerProvider = c.getComponent(
origin: org.axonframework/axon-configuration

/**
 * 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));
}
origin: org.axonframework/axon-configuration

/**
 * Creates a default Configuration for an aggregate of the given {@code aggregateType}. This required either a
 * Repository to be configured using {@link #configureRepository(Function)}, or that the Global Configuration
 * contains an Event Store and the Aggregate support Event Sourcing.
 *
 * @param aggregateType The type of Aggregate to configure
 * @param <A>           The type of Aggregate to configure
 * @return An AggregateConfigurer instance for further configuration of the Aggregate
 */
public static <A> AggregateConfigurer<A> defaultConfiguration(Class<A> aggregateType) {
  return new AggregateConfigurer<>(aggregateType);
}
origin: org.axonframework/axon-configuration

                                         c.handlerDefinition(aggregate))
              ).createModel(aggregate));
commandTargetResolver = new Component<>(() -> parent, name("commandTargetResolver"),
                    c -> c.getComponent(CommandTargetResolver.class,
                              AnnotationCommandTargetResolver::new));
snapshotTriggerDefinition = new Component<>(() -> parent, name("snapshotTriggerDefinition"),
                      c -> NoSnapshotTriggerDefinition.INSTANCE);
aggregateFactory =
    new Component<>(() -> parent, name("aggregateFactory"), c -> new GenericAggregateFactory<>(aggregate));
repository = new Component<>(
    () -> parent,
origin: org.axonframework/axon-core

/**
 * Creates a Configuration for an aggregate of given {@code aggregateType}, which is mapped to a relational
 * database using an EntityManager provided by given {@code entityManagerProvider}. The given {@code aggregateType}
 * is expected to be a proper JPA Entity.
 *
 * @param aggregateType         The type of Aggregate to configure
 * @param entityManagerProvider The provider for Axon to retrieve the EntityManager from
 * @param <A>                   The type of Aggregate to configure
 * @return An AggregateConfigurer instance for further configuration of the Aggregate
 */
public static <A> AggregateConfigurer<A> jpaMappedConfiguration(Class<A> aggregateType,
                                EntityManagerProvider entityManagerProvider) {
  AggregateConfigurer<A> configurer = new AggregateConfigurer<>(aggregateType);
  return configurer.configureRepository(
      c -> new GenericJpaRepository<>(entityManagerProvider,
                      configurer.metaModel.get(),
                      c.eventBus(),
                      (RepositoryProvider) c::repository));
}
origin: org.axonframework/axon-core

/**
 * Creates a Configuration for an aggregate of given {@code aggregateType}, which is mapped to a relational
 * database using an EntityManager obtained from the main configuration. The given {@code aggregateType}
 * is expected to be a proper JPA Entity.
 * <p>
 * The EntityManagerProvider is expected to have been registered with the Configurer (which would be the case when
 * using {@link DefaultConfigurer#jpaConfiguration(EntityManagerProvider)}. If that is not the case, consider using
 * {@link #jpaMappedConfiguration(Class, EntityManagerProvider)} instead.
 *
 * @param aggregateType The type of Aggregate to configure
 * @param <A>           The type of Aggregate to configure
 * @return An AggregateConfigurer instance for further configuration of the Aggregate
 */
public static <A> AggregateConfigurer<A> jpaMappedConfiguration(Class<A> aggregateType) {
  AggregateConfigurer<A> configurer = new AggregateConfigurer<>(aggregateType);
  return configurer.configureRepository(
      c -> new GenericJpaRepository<>(c.getComponent(EntityManagerProvider.class,
                              () -> {
                                throw new AxonConfigurationException(format(
                                    "JPA has not been correctly configured for aggregate [%s]. Either provide an EntityManagerProvider, or use DefaultConfigurer.jpaConfiguration(...) to define one for the entire configuration.",
                                    aggregateType.getSimpleName()));
                              }),
                      configurer.metaModel.get(),
                      c.eventBus(),
                      (RepositoryProvider) c::repository));
}
origin: org.axonframework/axon-configuration

/**
 * Creates a Configuration for an aggregate of given {@code aggregateType}, which is mapped to a relational
 * database using an EntityManager provided by given {@code entityManagerProvider}. The given {@code aggregateType}
 * is expected to be a proper JPA Entity.
 *
 * @param aggregateType         The type of Aggregate to configure
 * @param entityManagerProvider The provider for Axon to retrieve the EntityManager from
 * @param <A>                   The type of Aggregate to configure
 * @return An AggregateConfigurer instance for further configuration of the Aggregate
 */
public static <A> AggregateConfigurer<A> jpaMappedConfiguration(Class<A> aggregateType,
                                EntityManagerProvider entityManagerProvider) {
  AggregateConfigurer<A> configurer = new AggregateConfigurer<>(aggregateType);
  return configurer.configureRepository(
      c -> GenericJpaRepository.builder(aggregateType)
          .aggregateModel(configurer.metaModel.get())
          .entityManagerProvider(entityManagerProvider)
          .eventBus(c.eventBus())
          .repositoryProvider(c::repository)
          .build()
  );
}
origin: org.axonframework/axon-configuration

AggregateConfigurer<A> configurer = new AggregateConfigurer<>(aggregateType);
return configurer.configureRepository(
    c -> {
      EntityManagerProvider entityManagerProvider = c.getComponent(
org.axonframework.configAggregateConfigurer

Javadoc

Axon Configuration API extension that allows the definition of an Aggregate. This component will automatically setup all components required for the Aggregate to operate.

Most used methods

  • defaultConfiguration
    Creates a default Configuration for an aggregate of the given aggregateType. This required either a
  • configureRepository
    Defines the repository to use to load and store Aggregates of this type. The builder function receiv
  • <init>
    Creates a default configuration as described in #defaultConfiguration(Class). This constructor is av
  • configureAggregateFactory
    Defines the factory to use to to create new Aggregates instances of the type under configuration.
  • name
  • configureCommandTargetResolver
    Defines the CommandTargetResolver to use for the Aggregate type under configuration. The CommandTarg
  • configureSnapshotTrigger
    Configures snapshotting for the Aggregate type under configuration. Note that this configuration is

Popular in Java

  • Making http requests using okhttp
  • onCreateOptionsMenu (Activity)
  • putExtra (Intent)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • HashSet (java.util)
    This class implements the Set interface, backed by a hash table (actually a HashMap instance). It m
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Table (org.hibernate.mapping)
    A relational table
  • Runner (org.openjdk.jmh.runner)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now