Class Transformer

All Implemented Interfaces:
AutoCloseable, CamelContextAware, Service, ShutdownableService, HasCamelContext, StatefulService, SuspendableService

public abstract class Transformer extends ServiceSupport implements CamelContextAware
Transformer performs message transformation according to the declared data type.
invalid reference
org.apache.camel.processor.ContractAdvice
looks for a required Transformer and apply if input/output type declared on a route is different from current message type.
  • Constructor Details

    • Transformer

      public Transformer()
    • Transformer

      public Transformer(String name)
  • Method Details

    • transform

      public abstract void transform(Message message, DataType from, DataType to) throws Exception
      Perform data transformation with specified from/to type.
      Parameters:
      message - message to apply transformation
      from - 'from' data type
      to - 'to' data type
      Throws:
      Exception
    • getName

      public String getName()
      Get the transformer name that represents the supported data type model.
    • getFrom

      public DataType getFrom()
      Get 'from' data type.
    • getTo

      public DataType getTo()
      Get 'to' data type.
    • setName

      public Transformer setName(String name)
      Set the name for this transformer. Usually a combination of scheme and name.
    • setName

      public Transformer setName(String scheme, String name)
      Set the scheme and/or name for this transformer. When using only a scheme, the transformer applies to all transformations with that scheme.
      Parameters:
      scheme - supported data type scheme
      name - transformer name
    • setFrom

      public Transformer setFrom(String from)
      Set 'from' data type.
    • setTo

      public Transformer setTo(String to)
      Set 'to' data type.
    • getCamelContext

      public CamelContext getCamelContext()
      Description copied from interface: HasCamelContext
      Returns the camel context.
      Specified by:
      getCamelContext in interface HasCamelContext
      Returns:
      the camel context.
    • setCamelContext

      public void setCamelContext(CamelContext context)
      Description copied from interface: CamelContextAware
      Injects the CamelContext
      Specified by:
      setCamelContext in interface CamelContextAware
      Parameters:
      context - the Camel context
    • toString

      public String toString()
      Overrides:
      toString in class Object