Class ConfigureEventSourcedAnnotation
- All Implemented Interfaces:
Cloneable
tagKey and idType attributes to @EventSourced annotations
that do not yet configure them.
The tagKey is set to the entity's simple class name — matching the framework default
(an empty tagKey resolves to the simple class name at runtime, but making it explicit
here ensures it is visible for review and stays stable even if the class is later renamed).
The idType is deduced from the type of the field annotated with @AggregateIdentifier
(the AF4 marker for the aggregate's identifier). The recipe runs in two phases:
- Scan – walks every field annotated with
@AggregateIdentifier(matching either the AF4 FQN, the post-ChangePackageAF5 FQN, or the simple name as a fallback) and recordsenclosingClassFqn → fieldTypeFqn. - Edit – for every
@EventSourcedannotation without atagKeyattribute, generates@EventSourced(tagKey = "<EntitySimpleName>", idType = <ResolvedType>.class). If no@AggregateIdentifierfield was discovered for the enclosing class, falls back toObject.classwith aTODO(axon4to5):comment so the developer notices and supplies the correct type manually.
When to run: while the AF4 @AggregateIdentifier annotation is still present on the
source (i.e. before Axon4ToAxon5Modelling strips it via RemoveAnnotation). The umbrella recipe orders Axon4ToAxon5SpringExtension
(which runs this step) ahead of Axon4ToAxon5Modelling for that reason. The visitor itself
targets the AF5 @EventSourced FQN, so callers must also run after the AF4 Spring stereotype
@Aggregate → AF5 @EventSourced rename.
- Since:
- 5.1.1
- Author:
- Mateusz Nowak
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRecordsenclosingClassFqn → idTypeFqnfor every@AggregateIdentifierfield.Nested classes/interfaces inherited from class org.openrewrite.Recipe
org.openrewrite.Recipe.Builder, org.openrewrite.Recipe.DelegatingRecipe -
Field Summary
Fields inherited from class org.openrewrite.Recipe
contributors, examples, PANIC -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetInitialValue(org.openrewrite.ExecutionContext ctx) org.openrewrite.TreeVisitor<?, org.openrewrite.ExecutionContext> org.openrewrite.TreeVisitor<?, org.openrewrite.ExecutionContext> Methods inherited from class org.openrewrite.ScanningRecipe
clone, generate, generate, getAccumulator, getVisitorMethods inherited from class org.openrewrite.Recipe
addDataTable, builder, buildRecipeList, causesAnotherCycle, createRecipeDescriptor, equals, getContributors, getDataTableDescriptors, getDescriptor, getEstimatedEffortPerOccurrence, getExamples, getInstanceName, getInstanceNameSuffix, getJacksonPolymorphicTypeTag, getMaintainers, getName, getRecipeList, getTags, hashCode, maxCycles, noop, onComplete, run, run, run, setContributors, setExamples, validate, validate, validateAll, validateAll, withOptions
-
Constructor Details
-
ConfigureEventSourcedAnnotation
public ConfigureEventSourcedAnnotation()
-
-
Method Details
-
getDisplayName
- Specified by:
getDisplayNamein classorg.openrewrite.Recipe
-
getDescription
- Specified by:
getDescriptionin classorg.openrewrite.Recipe
-
getInitialValue
public ConfigureEventSourcedAnnotation.Accumulator getInitialValue(org.openrewrite.ExecutionContext ctx) - Specified by:
getInitialValuein classorg.openrewrite.ScanningRecipe<ConfigureEventSourcedAnnotation.Accumulator>
-
getScanner
public org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getScanner(ConfigureEventSourcedAnnotation.Accumulator acc) - Specified by:
getScannerin classorg.openrewrite.ScanningRecipe<ConfigureEventSourcedAnnotation.Accumulator>
-
getVisitor
public org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getVisitor(ConfigureEventSourcedAnnotation.Accumulator acc) - Overrides:
getVisitorin classorg.openrewrite.ScanningRecipe<ConfigureEventSourcedAnnotation.Accumulator>
-