|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.axonframework.serializer.ChainingConverterFactory
public class ChainingConverterFactory
ConverterFactory implementation that will combine converters to form chains of converters to be able to convert from one type to another, for which there is no suitable single converter.
This implementation will also autodetect ContentTypeConverter implementations by scanning/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 Summary | |
---|---|
ChainingConverterFactory()
Initialize a new ChainingConverterFactory. |
Method Summary | ||
---|---|---|
|
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 . |
|
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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.
Method Detail |
---|
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 available
true
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 produces
sourceContentType
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 factory
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |