Annotation Interface ForcedEntityCreator
It is meta-annotated with EntityCreator to support all behavior as described on the EntityCreator.
What this annotation adds, is the assurance that if sufficient information is available to invoke the
annotated method or constructor, that it will be invoked regardless of downstream usages of the entity itself. This
adjusts the regular behavior of the no-arguments, identifier-only, and event-based EntityCreator solutions
like so:
- A no-arguments,
@EntityCreatorannotated constructor or method, will always create the entity. - An identifier-based,
@EntityCreatorannotated constructor or method, will create if an identifier can be resolved. - An event-based,
@EntityCreatorannotated constructor or method, will only create if an initial event is present.
This additional behavior becomes important for create-if-missing styled handlers. For plain EntityCreator
solutions, the create-if-missing handler should either (1) be static (read: marked as a creational handler)
when present in the entity itself or (2) moved out of the entity entirely. In both scenarios the create-if-missing
behavior would require the entity as a parameter to the message handling function validate if it does exist. If
optional subsequent decisions require life state changes of the potentially missing entity, the user is enforced to
inject a ManagedEntity instead.
This annotation adjusts that behavior, by simply invoking the @ForcedEntityCreator annotated constructor or
method and passing it through. This will effectively make the entity non-null for all no-argument scenarios and most
identifier-based scenarios. Furthermore, it allows the create-if-missing solution to work on instance command
handlers placed in the entity, resolving the need to make them static.
Note that this forced-creation-approach is viewed as an aggregate-centric solution, whereas this library aims to steer away from that. Hence, any opportunity to use other mechanisms than this are encouraged.
- Since:
- 5.3.1
- Author:
- Steven van Beelen
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionString[]The qualified names of the payload types that this factory method can handle.
-
Element Details
-
payloadQualifiedNames
String[] payloadQualifiedNamesThe qualified names of the payload types that this factory method can handle. If a payload parameter is declared, and this value is left at default, the payload's qualified name will be determined based on theMessageTypeResolver.- Returns:
- The qualified names of the payload types that this factory method can handle.
- Default:
{}
-