Package org.axonframework.migration
Class MarkSagaResourceInjection
java.lang.Object
org.openrewrite.Recipe
org.axonframework.migration.MarkSagaResourceInjection
- All Implemented Interfaces:
Cloneable
public class MarkSagaResourceInjection
extends org.openrewrite.Recipe
Leaves a
// TODO(axon4to5): marker wherever an Axon Framework 4 Saga relies on resource injection, which
the Axoniq Framework legacy module does not port.
Axon Framework 4 injected collaborators into @Autowired or @Inject fields of a Saga instance through
a ResourceInjector, called its @Autowired or @Inject methods, such as setters, and set its
Spring @Value fields. Axon Framework 5 resolves those collaborators as parameters of the
@SagaEventHandler or @DeadlineHandler method instead. Which handlers need which collaborator is a
decision this recipe does not take, so it marks the places that need manual work:
- an
@Autowiredor@Injectfield or method of a Saga, being a class with a@SagaEventHandlermethod or the Spring@Sagastereotype; - a Spring
@Valuefield of a Saga, whose property a handler now reads itself; - a class member, or a class declaration, that uses one of the Axon Framework 4
ResourceInjectortypes, or that callsconfigureResourceInjector(..)orregisterResourceInjector(..).
CommandGateway field and its injection setter are not marked when it runs after
MigrateCommandGatewayInSagaEventHandler, which already replaces that field with a handler parameter, and
neither is a field MoveSagaFieldToHandlerParameter moved before, together with its injection setter. Without
a configured type, that recipe moves every field an injection setter assigns and a handler uses, so the setters left
to mark here belong to a field no handler uses, or to one that recipe leaves in place. The recipe is idempotent: a
member that already carries the marker is left alone.- Since:
- 5.4.0
- Author:
- Mateusz Nowak
-
Nested Class Summary
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 TypeMethodDescriptionorg.openrewrite.TreeVisitor<?, org.openrewrite.ExecutionContext> Methods inherited from class org.openrewrite.Recipe
addDataTable, aggregateDataTableDescriptors, builder, buildRecipeList, causesAnotherCycle, clone, 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
-
MarkSagaResourceInjection
public MarkSagaResourceInjection()
-
-
Method Details
-
getDisplayName
- Specified by:
getDisplayNamein classorg.openrewrite.Recipe
-
getDescription
- Specified by:
getDescriptionin classorg.openrewrite.Recipe
-
getVisitor
public org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getVisitor()- Overrides:
getVisitorin classorg.openrewrite.Recipe
-