Class Transformer
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.spi.Transformer
- All Implemented Interfaces:
AutoCloseable, CamelContextAware, Service, ShutdownableService, HasCamelContext, StatefulService, SuspendableService
Performs message body transformation between two
inspects the current message's
DataTypes as part of Camel's
Transformer contract mechanism.
When a route declares an inputType or outputType, Camel's
invalid reference
org.apache.camel.processor.ContractAdvice
DataType and looks up a
matching Transformer in the TransformerRegistry. If the current type differs from the declared type,
the transformer's transform(org.apache.camel.Message, DataType, DataType) method is called automatically,
without requiring the route developer to add an explicit conversion step.
Transformers can be registered by annotating a subclass with DataTypeTransformer (the annotation drives
automatic registration) or manually via CamelContext.getTransformerRegistry().- See Also:
-
Field Summary
Fields inherited from class BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable CamelContextReturns the camel context.@Nullable DataTypegetFrom()Get 'from' data type.@Nullable StringgetName()Get the transformer name that represents the supported data type model.@Nullable DataTypegetTo()Get 'to' data type.voidsetCamelContext(CamelContext context) Injects theCamelContextSet 'from' data type.Set the scheme and/or name for this transformer.Set the name for this transformer.Set 'to' data type.toString()abstract voidPerform data transformation with specified from/to type.Methods inherited from class BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doStart, doStop, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ShutdownableService
shutdownMethods inherited from interface StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
Transformer
protected Transformer() -
Transformer
-
-
Method Details
-
transform
-
getName
Get the transformer name that represents the supported data type model. -
getFrom
Get 'from' data type. -
getTo
Get 'to' data type. -
setName
Set the name for this transformer. Usually a combination of scheme and name. -
setName
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 schemename- transformer name
-
setFrom
Set 'from' data type. -
setTo
Set 'to' data type. -
getCamelContext
Description copied from interface:HasCamelContextReturns the camel context.- Specified by:
getCamelContextin interfaceHasCamelContext- Returns:
- the camel context.
-
setCamelContext
Description copied from interface:CamelContextAwareInjects theCamelContext- Specified by:
setCamelContextin interfaceCamelContextAware- Parameters:
context- the Camel context
-
toString
-