public class ChainingConverter extends Object implements Converter
/META-INF/services/org.axonframework.serialization.ContentTypeConverter
files on the classpath. These
files must contain the fully qualified class names of the implementations to use.Constructor and Description |
---|
ChainingConverter()
Initialize a new ChainingConverter with the context ClassLoader for this thread.
|
ChainingConverter(ClassLoader classLoader)
Initialize a new ChainingConverter.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canConvert(Class<?> sourceType,
Class<?> targetType)
Indicates whether this converter is capable of converting the given
sourceType to the targetType . |
<T> T |
convert(Object original,
Class<?> sourceType,
Class<T> targetType)
Converts the given object into another using the source type to find the conversion path.
|
void |
registerConverter(Class<? extends ContentTypeConverter> converterType)
Registers a convert of the given
converterType with this factory, only if initialization of such a
converter is possible. |
void |
registerConverter(ContentTypeConverter converter)
Registers the given
converter with this factory. |
void |
setAdditionalConverters(List<ContentTypeConverter> additionalConverters)
Setter for dependency injection frameworks that require property methods.
|
public ChainingConverter()
/META-INF/services/org.axonframework.serialization.ContentTypeConverter
files on the class
path.
Instances of ChainingConverter are safe for use in a multi-threaded environment, with exception of the registerConverter(ContentTypeConverter)
method.public ChainingConverter(ClassLoader classLoader)
/META-INF/services/org.axonframework.serialization.ContentTypeConverter
files on the class path.
Instances of ChainingConverter are safe for use in a multi-threaded environment, with exception of the
registerConverter(ContentTypeConverter)
method.classLoader
- the class loader used to load the converterspublic boolean canConvert(Class<?> sourceType, Class<?> targetType)
Converter
sourceType
to the targetType
.canConvert
in interface Converter
sourceType
- The type of data to convert fromtargetType
- The type of data to convert totrue
if conversion is possible, false
otherwisepublic <T> T convert(Object original, Class<?> sourceType, Class<T> targetType)
Converter
public void registerConverter(ContentTypeConverter converter)
converter
with this factory. The converter which is registered last
will be inspected first when finding a suitable converter for a given input and output type.
An alternative to explicit converter registration (but without the ordering guarantees) is to create a file
called org.axonframework.serialization.ContentTypeConverter
in /META-INF/services/
on the
class path which contains the fully qualified class names of the converters, separated by newlines. These
implementations must have a public no-arg constructor.converter
- the converter to register.public void registerConverter(Class<? extends ContentTypeConverter> converterType)
converterType
with this factory, only if initialization of such a
converter is possible. Both the expected source type and target type classes are checked for availability on the
class path. In contrast to registerConverter(ContentTypeConverter)
, this method allows potentially
unsafe (in terms of class dependencies) converters to be registered.
The converter which is registered last will be inspected first when finding a suitable
converter for a given input and output type.
An alternative to explicit converter registration (but without the ordering guarantees) is to create a file
called org.axonframework.serialization.ContentTypeConverter
in /META-INF/services/
on the
class path which contains the fully qualified class names of the converters, separated by newlines. These
implementations must have a public no-arg constructor.converterType
- the type of converter to register.public void setAdditionalConverters(List<ContentTypeConverter> additionalConverters)
registerConverter(ContentTypeConverter)
for each converter in the given list of
additionalConverters
.additionalConverters
- The converters to register with this factoryCopyright © 2010–2022. All rights reserved.