Class JacksonComponentDescriptor
- All Implemented Interfaces:
ComponentDescriptor
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
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newJacksonComponentDescriptorwith a defaultObjectMapper.JacksonComponentDescriptor(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Constructs a newJacksonComponentDescriptorwith the providedObjectMapper. -
Method Summary
Modifier and TypeMethodDescriptiondescribe()Provides the description ofthis ComponentDescriptor.voiddescribeProperty(String name, Boolean value) Describe the givenvaluewiththisdescriptor for the givenname.voiddescribeProperty(String name, Long value) Describe the givenvaluewiththisdescriptor for the givenname.voiddescribeProperty(String name, Object object) Describe the givenobjectwiththisdescriptor for the givenname.voiddescribeProperty(String name, String value) Describe the givenvaluewiththisdescriptor for the givenname.voiddescribeProperty(String name, Collection<?> collection) Describe the givencollectionwiththisdescriptor for the givenname.voiddescribeProperty(String name, Map<?, ?> map) Describe the givenmapwiththisdescriptor for the givenname.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.common.infra.ComponentDescriptor
describeWrapperOf
-
Constructor Details
-
JacksonComponentDescriptor
public JacksonComponentDescriptor()Constructs a newJacksonComponentDescriptorwith a defaultObjectMapper. -
JacksonComponentDescriptor
public JacksonComponentDescriptor(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Constructs a newJacksonComponentDescriptorwith the providedObjectMapper.- Parameters:
objectMapper- The ObjectMapper to use for JSON conversion.
-
-
Method Details
-
describeProperty
Description copied from interface:ComponentDescriptorDescribe the givenobjectwiththisdescriptor for the givenname.If the
objectis aDescribableComponent,DescribableComponent.describeTo(ComponentDescriptor)is invoked withthisdescriptor.- Specified by:
describePropertyin interfaceComponentDescriptor- Parameters:
name- The name for theobjectto describe.object- The object to describe withthisdescriptor.
-
describeProperty
Description copied from interface:ComponentDescriptorDescribe the givencollectionwiththisdescriptor for the givenname.If any item in the
collectionis aDescribableComponent, it will be processed as ifComponentDescriptor.describeProperty(String, Object)was invoked for that item, andDescribableComponent.describeTo(ComponentDescriptor)will be called on it.The formatting of the
collectiontypically takes a regular array structure.- Specified by:
describePropertyin interfaceComponentDescriptor- Parameters:
name- The name for thecollectionto describe.collection- The collection to describe withthisdescriptor.
-
describeProperty
Description copied from interface:ComponentDescriptorDescribe the givenmapwiththisdescriptor for the givenname.If any value in the
mapis aDescribableComponent, it will be processed as ifComponentDescriptor.describeProperty(String, Object)was invoked for that value, andDescribableComponent.describeTo(ComponentDescriptor)will be called on it.The formatting of the
maptypically takes a regular key-value structure based on theentriesof themap.- Specified by:
describePropertyin interfaceComponentDescriptor- Parameters:
name- The name for themapto describe.map- The map to describe withthisdescriptor.
-
describeProperty
Description copied from interface:ComponentDescriptorDescribe the givenvaluewiththisdescriptor for the givenname.- Specified by:
describePropertyin interfaceComponentDescriptor- Parameters:
name- The name for thevalueto describe.value- The value to describe withthisdescriptor.
-
describeProperty
Description copied from interface:ComponentDescriptorDescribe the givenvaluewiththisdescriptor for the givenname.- Specified by:
describePropertyin interfaceComponentDescriptor- Parameters:
name- The name for thevalueto describe.value- The value to describe withthisdescriptor.
-
describeProperty
Description copied from interface:ComponentDescriptorDescribe the givenvaluewiththisdescriptor for the givenname.- Specified by:
describePropertyin interfaceComponentDescriptor- Parameters:
name- The name for thevalueto describe.value- The value to describe withthisdescriptor.
-
describe
Description copied from interface:ComponentDescriptorProvides the description ofthis ComponentDescriptor.- Specified by:
describein interfaceComponentDescriptor- Returns:
- The description result of
this ComponentDescriptor.
-