Class MigrateMessageInterceptorSignatures
- All Implemented Interfaces:
Cloneable
MessageHandlerInterceptor
and MessageDispatchInterceptor implementations to their
Axon Framework 5 shape, while leaving the method body untouched.
The interceptor migration cannot be fully mechanized — the body's call sites
(interceptorChain.proceed(), unitOfWork.onCommit(...), unitOfWork.onRollback(...),
etc.) change shape and lifecycle-phase semantics together, and several AF4 hooks (notably
onRollback) have no one-to-one AF5 equivalent. Rewriting them blindly would silently land
semantically-wrong code in non-trivial interceptors.
The pragmatic split this recipe takes:
- Signature — fully rewritten. The AF4 method
Object handle(UnitOfWork<? extends T> uow, InterceptorChain chain) throws ExceptionbecomesMessageStream<?> interceptOnHandle(M message, ProcessingContext context, MessageHandlerInterceptorChain<M> chain). Same idea forMessageDispatchInterceptor:BiFunction<Integer, T, T> handle(List<? extends T> messages)becomesMessageStream<?> interceptOnDispatch(M message, ProcessingContext context, MessageDispatchInterceptorChain<M> chain). - Body — left as-is. References to the dropped
unitOfWork/interceptorChain/messagesparameters become compile errors, which is exactly the desired feedback: every line that needs review surfaces at compile time rather than via a silent rewrite. - Class-level TODO — a
// TODO(axon4to5):comment is prepended to the class with a pointer todocs/reference-guide/modules/migration/pages/paths/interceptors.adocso a follow-up pass (LLM or human) knows where to look.
The M type is read from the implements MessageHandlerInterceptor<M> (or
MessageDispatchInterceptor<M>) clause on the enclosing class. If the implements clause
is raw (no type argument), the new parameter falls back to Message.
Idempotent — methods already on the AF5 names (interceptOnHandle /
interceptOnDispatch) are skipped, and the class-level TODO is only added once.
Must run after Axon4ToAxon5Messaging's ChangeType steps so that the
implements clause already references the AF5 FQNs.
- Since:
- 5.1.1
- 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, 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
-
MigrateMessageInterceptorSignatures
public MigrateMessageInterceptorSignatures()
-
-
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
-