public abstract class Transformer extends ServiceSupport implements CamelContextAware
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.org.apache.camel.processor.ContractAdvice}
{@link DataType} {@link org.apache.camel.model.InputTypeDefinition} {@link org.apache.camel.model.OutputTypeDefinition}
BUILDED, FAILED, INITIALIZED, lock, log, NEW, SHUTDOWN, SHUTTINGDOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
Constructor and Description |
---|
Transformer() |
Modifier and Type | Method and Description |
---|---|
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
CamelContext |
getCamelContext()
Get the
CamelContext |
DataType |
getFrom()
Get 'from' data type.
|
String |
getModel()
Get a data model which is supported by this transformer.
|
DataType |
getTo()
Get 'to' data type.
|
void |
setCamelContext(CamelContext context)
Injects the
CamelContext |
Transformer |
setFrom(String from)
Set 'from' data type.
|
Transformer |
setModel(String model)
Set data model.
|
Transformer |
setTo(String to)
Set 'to' data type.
|
String |
toString() |
abstract void |
transform(Message message,
DataType from,
DataType to)
Perform data transformation with specified from/to type.
|
build, doBuild, doInit, doResume, doShutdown, doSuspend, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
trySetCamelContext
public Transformer()
public abstract void transform(Message message, DataType from, DataType to) throws Exception
message
- message to apply transformationfrom
- 'from' data typeto
- 'to' data typeException
public Transformer setModel(String model)
model
- data modelpublic Transformer setFrom(String from)
from
- 'from' data typepublic Transformer setTo(String to)
to
- 'to' data typepublic CamelContext getCamelContext()
CamelContextAware
CamelContext
getCamelContext
in interface CamelContextAware
public void setCamelContext(CamelContext context)
CamelContextAware
CamelContext
setCamelContext
in interface CamelContextAware
context
- the Camel contextprotected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.doStart
in class ServiceSupport
Exception
ServiceSupport.doStop()
protected void doStop() throws Exception
ServiceSupport
ServiceSupport.doStop()
method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext
is shutting down.doStop
in class ServiceSupport
Exception
ServiceSupport.doStart()
Apache Camel