Class DefaultAggregateRepository.AnnotatedAggregateRepository<T>

java.lang.Object
io.fluxzero.sdk.persisting.repository.DefaultAggregateRepository.AnnotatedAggregateRepository<T>
Type Parameters:
T - the aggregate root type
Enclosing class:
DefaultAggregateRepository

public class DefaultAggregateRepository.AnnotatedAggregateRepository<T> extends Object
Aggregate-type-specific delegate used internally by DefaultAggregateRepository.

This class is instantiated per aggregate class and parses metadata from the Aggregate annotation to determine:

  • Whether the aggregate is event-sourced or backed by the document store.
  • If and how frequently snapshots should be created.
  • Whether the aggregate is indexed for search.
  • How events should be published and committed.
  • Which cache(s) to use.

It provides loading and committing capabilities tailored to the configured storage and publication strategy. It also supports refetching aggregates from the Fluxzero Runtime and maintaining relationships with child entities.

Snapshot and document-based aggregates are supported out of the box. Event replay is triggered as needed.

This class is not intended to be used directly outside the DefaultAggregateRepository.

  • Constructor Details

    • AnnotatedAggregateRepository

      public AnnotatedAggregateRepository(Class<T> type)
  • Method Details

    • fromValue

      public Entity<T> fromValue(T value)
      Wraps a value as a side-effect-free entity using its configured identifier property, without loading or storing aggregate state.
    • delete

      public CompletableFuture<Void> delete(Object id)
      Evicts cached aggregate state and removes its relationships, events, snapshots, and configured document. The future completes when the requested storage operations finish; failures are propagated.
    • load

      public Entity<T> load(Object id)
      Loads or reuses the aggregate in this repository's active context, reconstructing it from its snapshot and events when required by the configured loading policy.
    • loadSnapshot

      protected Entity<T> loadSnapshot(Object id)
    • restoreSnapshotId

      protected ImmutableAggregateRoot<T> restoreSnapshotId(Object id, Entity<T> snapshot)
    • withHistoricalSnapshots

      protected Entity<T> withHistoricalSnapshots(ImmutableAggregateRoot<T> snapshot, Object aggregateId)
    • eventSourceModel

      protected Entity<T> eventSourceModel(Entity<T> model)
    • commit

      public CompletableFuture<Void> commit(Entity<?> after, List<AppliedEvent> unpublishedEvents, Entity<?> before)
      Commits state and unpublished events using this aggregate's policies, updating relationships, caches, eligible snapshots, and its configured document. The returned future represents completion or failure of the required storage operations.
    • updatesAggregateState

      protected boolean updatesAggregateState(AppliedEvent event)