All Known Implementing Classes:
StatefulAggregateInstanceFactory.ObjenesisAggregateInstanceFactory, StatefulAggregateInstanceFactory.ReflectionBasedAggregateInstanceFactory

public interface StatefulAggregateInstanceFactory
Factory that helps the StatefulAggregateRepository/StatefulAggregateInMemoryProjector to create an instance of a given Aggregate.
See Also:
  • Field Details

  • Method Details

    • create

      <ID, AGGREGATE> AGGREGATE create(ID id, Class<AGGREGATE> aggregateType)
      Create an instance of the Aggregate
      Type Parameters:
      ID - the type of aggregate id
      AGGREGATE - the Aggregate implementation type
      Parameters:
      id - the id value
      aggregateType - the Aggregate implementation type
      Returns:
      new aggregate instance
    • reflectionBasedAggregateRootFactory

      static StatefulAggregateInstanceFactory reflectionBasedAggregateRootFactory()
      Returns an StatefulAggregateInstanceFactory that calls the default no-arguments constructor on the concrete Aggregate type to create a new instance of the Aggregate
      Returns:
      #DEFAULT_CONSTRUCTOR_AGGREGATE_ROOT_FACTORY
    • objenesisAggregateRootFactory

      static StatefulAggregateInstanceFactory objenesisAggregateRootFactory()
      Returns an StatefulAggregateInstanceFactory that uses Objenesis to create a new instance of the Aggregate
      Please note: Objenesis doesn't initialize fields nor call any constructors, so you Aggregate design needs to take this into consideration.
      All concrete aggregates that extends AggregateRoot have been prepared to be initialized by Objenesis
      Returns:
      #OBJENESIS_AGGREGATE_ROOT_FACTORY