Package org.axonframework.migration
Class MigrateSnapshotTriggerDefinitionToAnnotation
java.lang.Object
org.openrewrite.Recipe
org.openrewrite.ScanningRecipe<MigrateSnapshotTriggerDefinitionToAnnotation.Accumulator>
org.axonframework.migration.MigrateSnapshotTriggerDefinitionToAnnotation
- All Implemented Interfaces:
Cloneable
public class MigrateSnapshotTriggerDefinitionToAnnotation
extends org.openrewrite.ScanningRecipe<MigrateSnapshotTriggerDefinitionToAnnotation.Accumulator>
Migrates the AF4 Spring Boot snapshotting configuration to the AF5
@Snapshotting annotation.
In AF4, snapshotting required two parts:
- A
@Beanmethod in a@Configurationclass returning aSnapshotTriggerDefinition(e.g.new EventCountSnapshotTriggerDefinition(snapshotter, 100)). - A
snapshotTriggerDefinition = "beanName"attribute on the aggregate's@Aggregateannotation.
@Snapshotting(afterEvents = 100) directly on the entity class.
This recipe operates in two phases:
- Scan – collects all
@Beanmethods that return aSnapshotTriggerDefinition, recording the bean name and trigger type (event-count, load-time, or custom). - Edit – for each
@Aggregate/@EventSourcedclass referencing a collected bean:EventCountSnapshotTriggerDefinition→ adds@Snapshotting(afterEvents = N)AggregateLoadTimeSnapshotTriggerDefinition→ adds@Snapshotting(afterSourcingTime = "PTxS")- Custom implementation → prepends a
TODO(axon4to5):comment for manual review
snapshotTriggerDefinitionattribute is removed from the annotation. Known-type@Beanmethods are deleted from the configuration class; custom ones receive aTODO(axon4to5):comment and are left in place.
- Since:
- 5.1.1
- Author:
- Mateusz Nowak
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCross-file accumulator populated during the scan phase.static final recordMetadata collected for a single@Bean SnapshotTriggerDefinitionmethod.static enumClassification of a scannedSnapshotTriggerDefinitionbean.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
-
MigrateSnapshotTriggerDefinitionToAnnotation
public MigrateSnapshotTriggerDefinitionToAnnotation()
-
-
Method Details
-
getDisplayName
- Specified by:
getDisplayNamein classorg.openrewrite.Recipe
-
getDescription
- Specified by:
getDescriptionin classorg.openrewrite.Recipe
-
getInitialValue
public MigrateSnapshotTriggerDefinitionToAnnotation.Accumulator getInitialValue(org.openrewrite.ExecutionContext ctx) - Specified by:
getInitialValuein classorg.openrewrite.ScanningRecipe<MigrateSnapshotTriggerDefinitionToAnnotation.Accumulator>
-
getScanner
public org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getScanner(MigrateSnapshotTriggerDefinitionToAnnotation.Accumulator acc) - Specified by:
getScannerin classorg.openrewrite.ScanningRecipe<MigrateSnapshotTriggerDefinitionToAnnotation.Accumulator>
-
getVisitor
public org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getVisitor(MigrateSnapshotTriggerDefinitionToAnnotation.Accumulator acc) - Overrides:
getVisitorin classorg.openrewrite.ScanningRecipe<MigrateSnapshotTriggerDefinitionToAnnotation.Accumulator>
-