Class JacksonComponentDescriptor

java.lang.Object
org.axonframework.common.infra.JacksonComponentDescriptor
All Implemented Interfaces:
ComponentDescriptor

public class JacksonComponentDescriptor extends Object implements ComponentDescriptor
A ComponentDescriptor implementation that uses Jackson's ObjectMapper to create JSON representations of components. This implementation produces a clean, hierarchical JSON structure.

This implementation supports circular references between components by using a reference mechanism. When a DescribableComponent is encountered for the first time, it is fully serialized including its unique identifier (_ref). Any subsequent occurrences of the same component instance are replaced with a reference object containing a $ref field pointing to the original component's identifier and a _type field indicating the component's type. This prevents infinite recursion and StackOverflowError when describing components with circular dependencies.

Example JSON with a circular reference:

 {
   "component": {
     "_ref": "12345",
     "_type": "MyComponent",
     "name": "First Component",
     "reference": {
       "_ref": "67890",
       "_type": "MyComponent",
       "name": "Second Component",
       "backReference": {
         "$ref": "12345",
         "_type": "MyComponent"
       }
     }
   }
 }
 
Since:
5.0.0
Author:
Mateusz Nowak