Package org.apache.camel.spi
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,StatefulService,SuspendableService
public abstract class Transformer extends ServiceSupport implements CamelContextAware
Transformer performs message transformation according to the declared data type.org.apache.camel.processor.ContractAdvicelooks for a required Transformer and apply if input/output type declared on a route is different from current message type.
-
-
Field Summary
-
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
-
-
Constructor Summary
Constructors Constructor Description Transformer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voiddoStart()Implementations override this method to support customized start/stop.protected voiddoStop()Implementations override this method to support customized start/stop.CamelContextgetCamelContext()Get theCamelContextDataTypegetFrom()Get 'from' data type.StringgetModel()Get a data model which is supported by this transformer.DataTypegetTo()Get 'to' data type.voidsetCamelContext(CamelContext context)Injects theCamelContextTransformersetFrom(String from)Set 'from' data type.TransformersetModel(String model)Set data model.TransformersetTo(String to)Set 'to' data type.StringtoString()abstract voidtransform(Message message, DataType from, DataType to)Perform data transformation with specified from/to type.-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.camel.ShutdownableService
shutdown
-
Methods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
-
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
-
-
-
Method Detail
-
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 transformationfrom- 'from' data typeto- 'to' data type- Throws:
Exception
-
getModel
public String getModel()
Get a data model which is supported by this transformer.
-
getFrom
public DataType getFrom()
Get 'from' data type.
-
getTo
public DataType getTo()
Get 'to' data type.
-
setModel
public Transformer setModel(String model)
Set data model.- Parameters:
model- data model
-
setFrom
public Transformer setFrom(String from)
Set 'from' data type.- Parameters:
from- 'from' data type
-
setTo
public Transformer setTo(String to)
Set 'to' data type.- Parameters:
to- 'to' data type
-
getCamelContext
public CamelContext getCamelContext()
Description copied from interface:CamelContextAwareGet theCamelContext- Specified by:
getCamelContextin interfaceCamelContextAware- Returns:
- the Camel context
-
setCamelContext
public void setCamelContext(CamelContext context)
Description copied from interface:CamelContextAwareInjects theCamelContext- Specified by:
setCamelContextin interfaceCamelContextAware- Parameters:
context- the Camel context
-
doStart
protected void doStart() throws ExceptionDescription copied from class:BaseServiceImplementations override this method to support customized start/stop. Important: SeeBaseService.doStop()for more details.- Overrides:
doStartin classBaseService- Throws:
Exception- See Also:
BaseService.doStop()
-
doStop
protected void doStop() throws ExceptionDescription copied from class:BaseServiceImplementations override this method to support customized start/stop. Important: Camel will invoke thisBaseService.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 whenCamelContextis shutting down.- Overrides:
doStopin classBaseService- Throws:
Exception- See Also:
BaseService.doStart()
-
-