Search in sources :

Example 1 with TransformerDefinition

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);
}
Also used : CustomTransformerDefinition(org.apache.camel.model.transformer.CustomTransformerDefinition) DataFormatTransformerDefinition(org.apache.camel.model.transformer.DataFormatTransformerDefinition) TransformerDefinition(org.apache.camel.model.transformer.TransformerDefinition) EndpointTransformerDefinition(org.apache.camel.model.transformer.EndpointTransformerDefinition) CustomTransformerDefinition(org.apache.camel.model.transformer.CustomTransformerDefinition) EndpointTransformerDefinition(org.apache.camel.model.transformer.EndpointTransformerDefinition) DataFormatTransformerDefinition(org.apache.camel.model.transformer.DataFormatTransformerDefinition)

Aggregations

CustomTransformerDefinition (org.apache.camel.model.transformer.CustomTransformerDefinition)1 DataFormatTransformerDefinition (org.apache.camel.model.transformer.DataFormatTransformerDefinition)1 EndpointTransformerDefinition (org.apache.camel.model.transformer.EndpointTransformerDefinition)1 TransformerDefinition (org.apache.camel.model.transformer.TransformerDefinition)1