Package org.axonframework.migration
Class MigrateLegacyFixtureInterceptorLambdas
java.lang.Object
org.openrewrite.Recipe
org.axonframework.migration.MigrateLegacyFixtureInterceptorLambdas
- All Implemented Interfaces:
Cloneable
public class MigrateLegacyFixtureInterceptorLambdas
extends org.openrewrite.Recipe
Rewrites the Axon Framework 4 interceptor lambdas registered on the legacy test fixtures to the Axon Framework 5
interceptor signatures, which the fixtures ported by
axoniq-legacy-test take.
Axon Framework 4 dispatch interceptors were a function over a message batch,
messages -> (index, message) -> changed, and handler interceptors received the unit of work,
(unitOfWork, chain) -> chain.proceed(), changing the message through unitOfWork.transformMessage(..).
Axon Framework 5 interceptors receive the single message, the processing context and the chain, and continue by
handing the (possibly changed) message to the chain. The recipe rewrites the lambdas passed to:
SagaTestFixtureand the SagaFixtureConfiguration:registerDeadlineDispatchInterceptor(..),registerDeadlineHandlerInterceptor(..)andregisterEventHandlerInterceptor(..);StubDeadlineManager:registerDispatchInterceptor(..)andregisterHandlerInterceptor(..).
(message, context, chain) -> chain.proceed(..., context):
messages -> (i, m) -> expression, passing the expression withmrenamed;messages -> (i, m) -> { statements; return expression; }, keeping the statements and passing the returned expression, withmrenamed, when the block has no otherreturn;(unitOfWork, chain) -> chain.proceed(), passing the message unchanged;(unitOfWork, chain) -> { statements; return chain.proceed(); }, keeping the statements and passing the message unchanged, when the statements use the unit of work only to readunitOfWork.getMessage(), which becomes the message, and neither use the chain norreturn;(unitOfWork, chain) -> { unitOfWork.transformMessage(m -> expression); return chain.proceed(); }, passing the expression withmrenamed.
// TODO(axon4to5): marker on its
statement describing the Axon Framework 5 signature. An interceptor passed as a variable or as an instance of a
named class is left alone: the class is migrated by MigrateMessageInterceptorSignatures. Lambda parameter
names that would clash with a name already in scope get a numeric suffix. Java sources only. Idempotent: a lambda
already taking three parameters is in the Axon Framework 5 shape and 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
-
MigrateLegacyFixtureInterceptorLambdas
public MigrateLegacyFixtureInterceptorLambdas()
-
-
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
-