Class TransformerBuilder


  • public class TransformerBuilder
    extends Object
    A Java DSL which is used to build a Transformer and register into CamelContext. It requires 'scheme' or a pair of 'from' and 'to' to be specified by scheme(), from() and to() method. And then you can choose a type of transformer by withUri(), withDataFormat(), withJava() or withBean() method.
    • Constructor Detail

      • TransformerBuilder

        public TransformerBuilder()
    • Method Detail

      • scheme

        public TransformerBuilder scheme​(String scheme)
        Set the 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 - scheme name
      • fromType

        public TransformerBuilder fromType​(String from)
        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
      • fromType

        public TransformerBuilder fromType​(Class<?> from)
        Set the 'from' data type using Java class.
        Parameters:
        from - 'from' Java class
      • toType

        public TransformerBuilder toType​(String to)
        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
      • toType

        public TransformerBuilder toType​(Class<?> to)
        Set the 'to' data type using Java class.
        Parameters:
        to - 'to' Java class
      • withUri

        public TransformerBuilder withUri​(String uri)
        Set the URI to be used for the endpoint Transformer.
        Parameters:
        uri - endpoint URI
      • withJava

        public TransformerBuilder withJava​(Class<? extends org.apache.camel.spi.Transformer> clazz)
        Set the Java Class represents a custom Transformer implementation class.
      • withBean

        public TransformerBuilder withBean​(String ref)
        Set the Java Bean name to be used for custom Transformer.
      • configure

        public void configure​(org.apache.camel.CamelContext camelContext)
        Configure a Transformer according to the configurations built on this builder and register it into given CamelContext.
        Parameters:
        camelContext - CamelContext