Class CommentOutSerializerConfiguration

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

public class CommentOutSerializerConfiguration extends org.openrewrite.Recipe
Comments out Axon Framework 4 serializer configuration under a // TODO(axon4to5): marker, as Axon Framework 5 replaces the Serializer with a Converter.

Axon Framework 5 has no Serializer, nor a JacksonSerializer, XStreamSerializer or other implementation of it, so code configuring one does not compile once migrated. The recipe does not port it to a converter either: the serializer's settings, such as the visibility or default typing of a JacksonSerializer's ObjectMapper, decide how Axon Framework 5 reads what Axon Framework 4 stored. A Saga field without accessors, written by a serializer with field visibility, reads back as null when those settings are dropped. The marker asks to define a converter with the equivalent settings and check it against the stored data. The recipe comments out, keeping the original source text after //:

  • a method returning an Axon Framework 4 serializer type that is a Spring @Bean method or builds a serializer, annotations included;
  • any other statement building a JacksonSerializer, Jackson3Serializer, XStreamSerializer, JavaSerializer or AvroSerializer, through builder(), defaultSerializer() or a constructor, such as a field, a local variable or a Configurer call. A return statement is not commented out on its own, as that leaves a result missing: the method it returns from is commented out, or the statement holding the lambda it returns from.
It removes the imports that only the commented-out code used, so the rename of the org.axonframework.serialization package that follows does not import types Axon Framework 5 does not have. An enum constant building a serializer cannot be commented out on its own and only gets the marker. A statement that MigrateDeadlineManagerBuilders already marked to replace serializer(..) is left to that marker. The recipe matches the Axon Framework 4 types, so it runs before the org.axonframework.serialization package is renamed. It changes Java sources only and is idempotent: commented-out code builds no serializer.
Since:
5.4.1
Author:
Stefan Dragisic
  • 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, 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

    Methods inherited from class java.lang.Object

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

    • CommentOutSerializerConfiguration

      public CommentOutSerializerConfiguration()
  • 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