use of org.apache.camel.model.transformer.TransformerDefinition in project camel by apache.
the class TransformerBuilder method configure.
/**
* Configure a Transformer according to the configurations built on this builder
* and register it into given {@code CamelContext}.
*
* @param camelContext {@code CamelContext}
*/
public void configure(CamelContext camelContext) {
TransformerDefinition transformer;
if (uri != null) {
EndpointTransformerDefinition etd = new EndpointTransformerDefinition();
etd.setUri(uri);
transformer = etd;
} else if (dataFormat != null) {
DataFormatTransformerDefinition dtd = new DataFormatTransformerDefinition();
dtd.setDataFormatType(dataFormat);
transformer = dtd;
} else if (clazz != null) {
CustomTransformerDefinition ctd = new CustomTransformerDefinition();
ctd.setClassName(clazz.getName());
transformer = ctd;
} else if (beanRef != null) {
CustomTransformerDefinition ctd = new CustomTransformerDefinition();
ctd.setRef(beanRef);
transformer = ctd;
} else {
throw new IllegalArgumentException("No Transformer type was specified");
}
if (scheme != null) {
transformer.setScheme(scheme);
} else {
transformer.setFromType(from);
transformer.setToType(to);
}
camelContext.getTransformers().add(transformer);
}
Aggregations