public class ChainingConverterFactory extends Object implements ConverterFactory
/META-INF/services/org.axonframework.serializer.ContentTypeConverter
files on the classpath. These
files must contain the fully qualified class names of the implementations to use.Constructor and Description |
---|
ChainingConverterFactory()
Initialize a new ChainingConverterFactory.
|
Modifier and Type | Method and Description |
---|---|
<S,T> ContentTypeConverter<S,T> |
getConverter(Class<S> sourceContentType,
Class<T> targetContentType)
Returns a converter that is capable of converting IntermediateRepresentation object containing the given
sourceContentType to the given targetContentType . |
<S,T> boolean |
hasConverter(Class<S> sourceContentType,
Class<T> targetContentType)
Indicates whether this factory contains a converter capable of converting the given
sourceContentType into the targetContentType . |
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 ChainingConverterFactory()
/META-INF/services/org.axonframework.serializer.ContentTypeConverter
files on the class path.
Instances of ChainingConverterFactory are safe for use in a multi-threaded environment, with exception of the
registerConverter(ContentTypeConverter)
method.public <S,T> boolean hasConverter(Class<S> sourceContentType, Class<T> targetContentType)
ConverterFactory
sourceContentType
into the targetContentType
.hasConverter
in interface ConverterFactory
S
- The type of source data for which a converter must be availableT
- The type of target data for which a converter must be availablesourceContentType
- The type of source data for which a converter must be availabletargetContentType
- The type of target data for which a converter must be availabletrue
if a converter is available, otherwise false
.public <S,T> ContentTypeConverter<S,T> getConverter(Class<S> sourceContentType, Class<T> targetContentType)
ConverterFactory
sourceContentType
to the given targetContentType
.getConverter
in interface ConverterFactory
S
- The source content typeT
- The target content typesourceContentType
- The type of data the converter accepts as inputtargetContentType
- The type of data the converter producessourceContentType
to
targetContentType
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.serializer.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.serializer.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-2014. All Rights Reserved.