Class AnnotationBasedEventSourcedEntityFactory<E,ID>

java.lang.Object
org.axonframework.eventsourcing.annotation.reflection.AnnotationBasedEventSourcedEntityFactory<E,ID>
Type Parameters:
E - The type of entity to create.
ID - The type of identifier used by the entity.
All Implemented Interfaces:
EventSourcedEntityFactory<ID,E>

public class AnnotationBasedEventSourcedEntityFactory<E,ID> extends Object implements EventSourcedEntityFactory<ID,E>
Reflection-based implementation of the EventSourcedEntityFactory interface. This factory will look for EntityCreator-annotated constructors and static methods on the entity type and its supertypes to find a suitable constructor or static method to create an entity instance.

This class implements the requirements as per the EntityCreator annotation. This class is thread-safe.

Since:
5.0.0
Author:
Mitchell Herrijgers
  • Constructor Details

    • AnnotationBasedEventSourcedEntityFactory

      public AnnotationBasedEventSourcedEntityFactory(@Nonnull Class<E> entityType, @Nonnull Class<ID> idType, @Nonnull ParameterResolverFactory parameterResolverFactory, @Nonnull MessageTypeResolver messageTypeResolver, @Nonnull EventConverter converter)
      Instantiate an annotation-based EventSourcedEntityFactory for the given concrete entityType. When using a polymorphic entity type, you can use the AnnotationBasedEventSourcedEntityFactory(Class, Class, Set, ParameterResolverFactory, MessageTypeResolver, EventConverter), so that all subtypes of the entity type will be scanned for static methods and constructors.
      Parameters:
      entityType - The type of the entity to create. Must be concrete.
      idType - The type of the identifier used by the entity.
      parameterResolverFactory - The factory to use to resolve parameters.
      messageTypeResolver - The factory to use to resolve the payload type.
      converter - The converter to use for converting event payloads to the handler's expected type.
    • AnnotationBasedEventSourcedEntityFactory

      public AnnotationBasedEventSourcedEntityFactory(@Nonnull Class<E> entityType, @Nonnull Class<ID> idType, @Nonnull Set<Class<? extends E>> subTypes, @Nonnull ParameterResolverFactory parameterResolverFactory, @Nonnull MessageTypeResolver messageTypeResolver, @Nonnull EventConverter converter)
      Instantiate a reflection-based EventSourcedEntityFactory for the given super entityType, with the given subTypes. The subTypes must be concrete types that extend the entityType. The factory will look for static methods and constructors on the subTypes and their supertypes to find a suitable constructor or static method to create an entity instance.
      Parameters:
      entityType - The type of the entity to create. Can be abstract.
      idType - The type of the identifier used by the entity.
      subTypes - The concrete types that extend the entityType.
      parameterResolverFactory - The factory to use to resolve parameters.
      messageTypeResolver - The factory to use to resolve the payload type.
      converter - The converter to use for converting event payloads to the handler's expected type.
  • Method Details