Class TransformerDefinition
java.lang.Object
org.apache.camel.model.transformer.TransformerDefinition
- Direct Known Subclasses:
CustomTransformerDefinition
,DataFormatTransformerDefinition
,EndpointTransformerDefinition
,LoadTransformerDefinition
Represents a
Transformer
which declarative transforms message content according to the
input type declared by InputTypeDefinition
and/or output type declared by OutputTypeDefinition
.
If you specify from='java:com.example.ABC' and to='xml:XYZ', the transformer will be picked up when current message
type is 'java:com.example.ABC' and expected message type is 'xml:XYZ'. If you specify from='java' to='xml', then it
will be picked up for all of Java to xml transformation.
Also, it's possible to specify a transformer name that identifies the transformer. Usually the name is a combination
of a scheme and a name that represents the supported data type name. The declared InputTypeDefinition
and/or
OutputTypeDefinition
can then reference the transformer by its name.
In case the transformer name should represent a data type scheme such as name='xml' that specific transformer will
also be picked up for all of Java to xml and xml to Java transformation as a fallback when no matching transformer is
found.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetName()
void
setFromType
(Class<?> clazz) Set the 'from' data type using Java class.void
setFromType
(String from) Set the 'from' data type name.void
Set the transformer name under which the transformer gets referenced when specifying the input/output data type on routes.void
Set a scheme name supported by the transformer.void
Set the 'to' data type using Java class.void
Set the 'to' data type name.
-
Constructor Details
-
TransformerDefinition
public TransformerDefinition()
-
-
Method Details
-
getScheme
-
setScheme
Set a scheme name supported by the transformer. If you specify 'csv', the transformer will be picked up for all of 'csv' from/to Java transformation. Note that the scheme matching is performed only when no exactly matched transformer exists.- Parameters:
scheme
- the supported data type scheme
-
getName
-
setName
Set the transformer name under which the transformer gets referenced when specifying the input/output data type on routes. If you specify a transformer name that matches a data type scheme like 'csv' the transformer will be picked up for all of 'csv:*' from/to Java transformation. Note that the scheme matching is performed only when no exactly matched transformer exists.- Parameters:
name
- transformer name
-
getFromType
-
setFromType
Set the 'from' data type name. If you specify 'xml:XYZ', the transformer will be picked up if source type is 'xml:XYZ'. If you specify just 'xml', the transformer matches with all of 'xml' source type like 'xml:ABC' or 'xml:DEF'.- Parameters:
from
- 'from' data type name
-
setFromType
Set the 'from' data type using Java class.- Parameters:
clazz
- 'from' Java class
-
getToType
-
setToType
Set the 'to' data type name. If you specify 'json:XYZ', the transformer will be picked up if destination type is 'json:XYZ'. If you specify just 'json', the transformer matches with all of 'json' destination type like 'json:ABC' or 'json:DEF'.- Parameters:
to
- 'to' data type name
-
setToType
Set the 'to' data type using Java class.- Parameters:
clazz
- 'to' Java class
-