Tabnine Logo
AnnotatedAggregate.initialize
Code IndexAdd Tabnine to your IDE (free)

How to use
initialize
method
in
org.axonframework.modelling.command.inspection.AnnotatedAggregate

Best Java code snippets using org.axonframework.modelling.command.inspection.AnnotatedAggregate.initialize (Showing top 14 results out of 315)

origin: AxonFramework/AxonFramework

/**
 * Initialize an aggregate with the given {@code aggregateRoot} which is described in the given
 * {@code aggregateModel}. The given {@code eventBus} is used to publish events generated by the aggregate.
 *
 * @param aggregateRoot  The aggregate root instance
 * @param aggregateModel The model describing the aggregate structure
 * @param eventBus       The EventBus to publish events on
 * @param <T>            The type of the Aggregate root
 * @return An Aggregate instance, fully initialized
 */
public static <T> AnnotatedAggregate<T> initialize(T aggregateRoot,
                          AggregateModel<T> aggregateModel,
                          EventBus eventBus) {
  return initialize(aggregateRoot, aggregateModel, eventBus, null);
}
origin: AxonFramework/AxonFramework

/**
 * Initialize an aggregate created by the given {@code aggregateFactory} which is described in the given
 * {@code aggregateModel}. The given {@code eventBus} is used to publish events generated by the aggregate.
 *
 * @param aggregateFactory   The factory to create the aggregate root instance with
 * @param aggregateModel     The model describing the aggregate structure
 * @param eventBus           The EventBus to publish events on
 * @param repositoryProvider Provides repositories for specific aggregate types
 * @param <T>                The type of the Aggregate root
 * @return An Aggregate instance, fully initialized
 *
 * @throws Exception when an error occurs creating the aggregate root instance
 */
public static <T> AnnotatedAggregate<T> initialize(Callable<T> aggregateFactory,
                          AggregateModel<T> aggregateModel,
                          EventBus eventBus,
                          RepositoryProvider repositoryProvider) throws Exception {
  return initialize(aggregateFactory, aggregateModel, eventBus, repositoryProvider, false);
}
origin: AxonFramework/AxonFramework

/**
 * Initialize an aggregate created by the given {@code aggregateFactory} which is described in the given
 * {@code aggregateModel}. The given {@code eventBus} is used to publish events generated by the aggregate.
 *
 * @param aggregateFactory The factory to create the aggregate root instance with
 * @param aggregateModel   The model describing the aggregate structure
 * @param eventBus         The EventBus to publish events on
 * @param <T>              The type of the Aggregate root
 * @return An Aggregate instance, fully initialized
 *
 * @throws Exception when an error occurs creating the aggregate root instance
 */
public static <T> AnnotatedAggregate<T> initialize(Callable<T> aggregateFactory, AggregateModel<T> aggregateModel,
                          EventBus eventBus)
    throws Exception {
  return initialize(aggregateFactory, aggregateModel, eventBus, false);
}
origin: AxonFramework/AxonFramework

/**
 * Initialize an aggregate created by the given {@code aggregateFactory} which is described in the given
 * {@code aggregateModel}. The given {@code eventBus} is used to publish events generated by the aggregate.
 *
 * @param aggregateFactory  The factory to create the aggregate root instance with
 * @param aggregateModel    The model describing the aggregate structure
 * @param eventBus          The EventBus to publish events on
 * @param generateSequences Whether to generate sequence numbers on events published from this aggregate
 * @param <T>               The type of the Aggregate root
 * @return An Aggregate instance, fully initialized
 *
 * @throws Exception when an error occurs creating the aggregate root instance
 */
public static <T> AnnotatedAggregate<T> initialize(Callable<T> aggregateFactory,
                          AggregateModel<T> aggregateModel,
                          EventBus eventBus,
                          boolean generateSequences) throws Exception {
  return initialize(aggregateFactory, aggregateModel, eventBus, null, generateSequences);
}
origin: AxonFramework/AxonFramework

@Override
protected AnnotatedAggregate<T> doCreateNewForLock(Callable<T> factoryMethod) throws Exception {
  // generate sequence numbers in events when using an Event Store
  return AnnotatedAggregate.initialize(factoryMethod,
                     aggregateModel(),
                     eventBus,
                     repositoryProvider,
                     eventBus instanceof DomainEventSequenceAware);
}
origin: AxonFramework/AxonFramework

@Override
public Aggregate<T> newInstance(Callable<T> factoryMethod) throws Exception {
  Assert.state(storedAggregate == null,
         () -> "Creating an Aggregate while one is already stored. Test fixtures do not allow multiple instances to be stored.");
  storedAggregate = AnnotatedAggregate.initialize(factoryMethod,
                          aggregateModel,
                          eventBus,
                          repositoryProvider,
                          true);
  return storedAggregate;
}
origin: AxonFramework/AxonFramework

@Override
protected AnnotatedAggregate<T> doLoadWithLock(String aggregateIdentifier, Long expectedVersion) {
  T aggregateRoot = entityManagerProvider.getEntityManager().find(getAggregateType(),
                                  identifierConverter.apply(aggregateIdentifier),
                                  LockModeType.PESSIMISTIC_WRITE);
  if (aggregateRoot == null) {
    throw new AggregateNotFoundException(aggregateIdentifier,
                       format("Aggregate [%s] with identifier [%s] not found",
                          getAggregateType().getSimpleName(), aggregateIdentifier));
  }
  AnnotatedAggregate<T> aggregate = AnnotatedAggregate.initialize(aggregateRoot,
                                  aggregateModel(),
                                  eventBus,
                                  repositoryProvider);
  if (eventBus instanceof DomainEventSequenceAware) {
    Optional<Long> sequenceNumber =
        ((DomainEventSequenceAware) eventBus).lastSequenceNumberFor(aggregateIdentifier);
    sequenceNumber.ifPresent(aggregate::initSequence);
  }
  return aggregate;
}
origin: AxonFramework/AxonFramework

@Test
public void testCommandsAreRoutedToCorrectEntity() throws Exception {
  AggregateModel<Book> bookAggregateModel = AnnotatedAggregateMetaModelFactory.inspectAggregate(Book.class);
  EventBus mockEventBus = SimpleEventBus.builder().build();
  mockEventBus.subscribe(m -> m.forEach(i -> System.out.println(i.getPayloadType().getName())));
  AnnotatedAggregate<Book> bookAggregate = AnnotatedAggregate.initialize((Book) null,
                                      bookAggregateModel,
                                      mockEventBus);
  bookAggregate.handle(command(new CreateBookCommand("book1")));
  bookAggregate.handle(command(new CreatePageCommand("book1")));
  bookAggregate.handle(command(new CreateParagraphCommand("book1", 0)));
  bookAggregate.handle(command(new CreateParagraphCommand("book1", 0)));
  bookAggregate.handle(command(new UpdateParagraphCommand("book1", 0, 0, "Hello world")));
  bookAggregate.handle(command(new UpdateParagraphCommand("book1", 0, 1, "Hello world2")));
  assertEquals("Hello world",
         bookAggregate.getAggregateRoot().getPages().get(0).getParagraphs().get(0).getText());
  assertEquals("Hello world2",
         bookAggregate.getAggregateRoot().getPages().get(0).getParagraphs().get(1).getText());
}
origin: org.axonframework/axon-modelling

/**
 * Initialize an aggregate with the given {@code aggregateRoot} which is described in the given
 * {@code aggregateModel}. The given {@code eventBus} is used to publish events generated by the aggregate.
 *
 * @param aggregateRoot  The aggregate root instance
 * @param aggregateModel The model describing the aggregate structure
 * @param eventBus       The EventBus to publish events on
 * @param <T>            The type of the Aggregate root
 * @return An Aggregate instance, fully initialized
 */
public static <T> AnnotatedAggregate<T> initialize(T aggregateRoot,
                          AggregateModel<T> aggregateModel,
                          EventBus eventBus) {
  return initialize(aggregateRoot, aggregateModel, eventBus, null);
}
origin: org.axonframework/axon-modelling

/**
 * Initialize an aggregate created by the given {@code aggregateFactory} which is described in the given
 * {@code aggregateModel}. The given {@code eventBus} is used to publish events generated by the aggregate.
 *
 * @param aggregateFactory  The factory to create the aggregate root instance with
 * @param aggregateModel    The model describing the aggregate structure
 * @param eventBus          The EventBus to publish events on
 * @param generateSequences Whether to generate sequence numbers on events published from this aggregate
 * @param <T>               The type of the Aggregate root
 * @return An Aggregate instance, fully initialized
 *
 * @throws Exception when an error occurs creating the aggregate root instance
 */
public static <T> AnnotatedAggregate<T> initialize(Callable<T> aggregateFactory,
                          AggregateModel<T> aggregateModel,
                          EventBus eventBus,
                          boolean generateSequences) throws Exception {
  return initialize(aggregateFactory, aggregateModel, eventBus, null, generateSequences);
}
origin: org.axonframework/axon-modelling

/**
 * Initialize an aggregate created by the given {@code aggregateFactory} which is described in the given
 * {@code aggregateModel}. The given {@code eventBus} is used to publish events generated by the aggregate.
 *
 * @param aggregateFactory The factory to create the aggregate root instance with
 * @param aggregateModel   The model describing the aggregate structure
 * @param eventBus         The EventBus to publish events on
 * @param <T>              The type of the Aggregate root
 * @return An Aggregate instance, fully initialized
 *
 * @throws Exception when an error occurs creating the aggregate root instance
 */
public static <T> AnnotatedAggregate<T> initialize(Callable<T> aggregateFactory, AggregateModel<T> aggregateModel,
                          EventBus eventBus)
    throws Exception {
  return initialize(aggregateFactory, aggregateModel, eventBus, false);
}
origin: org.axonframework/axon-modelling

/**
 * Initialize an aggregate created by the given {@code aggregateFactory} which is described in the given
 * {@code aggregateModel}. The given {@code eventBus} is used to publish events generated by the aggregate.
 *
 * @param aggregateFactory   The factory to create the aggregate root instance with
 * @param aggregateModel     The model describing the aggregate structure
 * @param eventBus           The EventBus to publish events on
 * @param repositoryProvider Provides repositories for specific aggregate types
 * @param <T>                The type of the Aggregate root
 * @return An Aggregate instance, fully initialized
 *
 * @throws Exception when an error occurs creating the aggregate root instance
 */
public static <T> AnnotatedAggregate<T> initialize(Callable<T> aggregateFactory,
                          AggregateModel<T> aggregateModel,
                          EventBus eventBus,
                          RepositoryProvider repositoryProvider) throws Exception {
  return initialize(aggregateFactory, aggregateModel, eventBus, repositoryProvider, false);
}
origin: org.axonframework/axon-modelling

@Override
protected AnnotatedAggregate<T> doCreateNewForLock(Callable<T> factoryMethod) throws Exception {
  // generate sequence numbers in events when using an Event Store
  return AnnotatedAggregate.initialize(factoryMethod,
                     aggregateModel(),
                     eventBus,
                     repositoryProvider,
                     eventBus instanceof DomainEventSequenceAware);
}
origin: org.axonframework/axon-modelling

@Override
protected AnnotatedAggregate<T> doLoadWithLock(String aggregateIdentifier, Long expectedVersion) {
  T aggregateRoot = entityManagerProvider.getEntityManager().find(getAggregateType(),
                                  identifierConverter.apply(aggregateIdentifier),
                                  LockModeType.PESSIMISTIC_WRITE);
  if (aggregateRoot == null) {
    throw new AggregateNotFoundException(aggregateIdentifier,
                       format("Aggregate [%s] with identifier [%s] not found",
                          getAggregateType().getSimpleName(), aggregateIdentifier));
  }
  AnnotatedAggregate<T> aggregate = AnnotatedAggregate.initialize(aggregateRoot,
                                  aggregateModel(),
                                  eventBus,
                                  repositoryProvider);
  if (eventBus instanceof DomainEventSequenceAware) {
    Optional<Long> sequenceNumber =
        ((DomainEventSequenceAware) eventBus).lastSequenceNumberFor(aggregateIdentifier);
    sequenceNumber.ifPresent(aggregate::initSequence);
  }
  return aggregate;
}
org.axonframework.modelling.command.inspectionAnnotatedAggregateinitialize

Javadoc

Initialize an aggregate with the given aggregateRoot which is described in the given aggregateModel. The given eventBus is used to publish events generated by the aggregate.

Popular methods of AnnotatedAggregate

  • getAggregateRoot
    Get the annotated aggregate instance. Note that this method should probably never be used in normal
  • handle
  • publish
    Publish an event to the aggregate root and its entities first and external event handlers (using the
  • publishOnEventBus
    Publish an event to external event handlers using the given event bus.
  • <init>
    Initialize an Aggregate instance for the given aggregateRoot, described by the given aggregateModel
  • andThen
  • apply
  • applyMessageOrPayload
    Apply a new event message to the aggregate and then publish this message to external systems. If the
  • createMessage
    Creates an EventMessage with given payload and metaData.
  • doApply
  • execute
  • executeWithResult
  • execute,
  • executeWithResult,
  • identifier,
  • identifierAsString,
  • initSequence,
  • isDeleted,
  • registerRoot,
  • type,
  • version

Popular in Java

  • Reading from database using SQL prepared statement
  • getApplicationContext (Context)
  • onRequestPermissionsResult (Fragment)
  • findViewById (Activity)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now