Class ConfigureEventSourcedAnnotation

java.lang.Object
org.openrewrite.Recipe
org.openrewrite.ScanningRecipe<ConfigureEventSourcedAnnotation.Accumulator>
org.axonframework.migration.ConfigureEventSourcedAnnotation
All Implemented Interfaces:
Cloneable

public class ConfigureEventSourcedAnnotation extends org.openrewrite.ScanningRecipe<ConfigureEventSourcedAnnotation.Accumulator>
Adds explicit 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:

  1. Scan – walks every field annotated with @AggregateIdentifier (matching either the AF4 FQN, the post-ChangePackage AF5 FQN, or the simple name as a fallback) and records enclosingClassFqn → fieldTypeFqn.
  2. Edit – for every @EventSourced annotation without a tagKey attribute, generates @EventSourced(tagKey = "<EntitySimpleName>", idType = <ResolvedType>.class). If no @AggregateIdentifier field was discovered for the enclosing class, falls back to Object.class with a TODO(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 Classes
    Modifier and Type
    Class
    Description
    static class 
    Records enclosingClassFqn → idTypeFqn for every @AggregateIdentifier field.

    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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
    getInitialValue(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, getVisitor

    Methods 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

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, toString, wait, wait, wait