Class MigrateMessageInterceptorSignatures

java.lang.Object
org.openrewrite.Recipe
org.axonframework.migration.MigrateMessageInterceptorSignatures
All Implemented Interfaces:
Cloneable

public class MigrateMessageInterceptorSignatures extends org.openrewrite.Recipe
Migrates the method signatures of 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 Exception becomes MessageStream<?> interceptOnHandle(M message, ProcessingContext context, MessageHandlerInterceptorChain<M> chain). Same idea for MessageDispatchInterceptor: BiFunction<Integer, T, T> handle(List<? extends T> messages) becomes MessageStream<?> interceptOnDispatch(M message, ProcessingContext context, MessageDispatchInterceptorChain<M> chain).
  • Body — left as-is. References to the dropped unitOfWork / interceptorChain / messages parameters 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 to docs/reference-guide/modules/migration/pages/paths/interceptors.adoc so 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
    org.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

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MigrateMessageInterceptorSignatures

      public MigrateMessageInterceptorSignatures()
  • Method Details

    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in class org.openrewrite.Recipe
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in class org.openrewrite.Recipe
    • getVisitor

      public org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getVisitor()
      Overrides:
      getVisitor in class org.openrewrite.Recipe