Class SmooksDataFormat
- java.lang.Object
-
- org.smooks.cartridges.camel.dataformat.SmooksDataFormat
-
- All Implemented Interfaces:
AutoCloseable,org.apache.camel.CamelContextAware,org.apache.camel.Service,org.apache.camel.spi.DataFormat
public class SmooksDataFormat extends Object implements org.apache.camel.spi.DataFormat, org.apache.camel.CamelContextAware, org.apache.camel.Service
SmooksDataFormat is a Camel data format which is a pluggable transformer capable of transforming from one dataformat to another and back again. This means that what is marshaled can be unmarshaled by an instance of this class. A smooks configuration for a SmooksDataFormat should not utilize Smooks features such as routing that might allocated system resources. The reason for this is that there is no functionality in the SmooksDataFormat which will close those resources. If you need to use these Smooks features please take a look at theSmooksComponentorSmooksProcessoras they hook into Camels lifecycle manegment and will close resources correctly.- Author:
- Christian Mueller, Daniel Bevenius
-
-
Constructor Summary
Constructors Constructor Description SmooksDataFormat(String smooksConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.camel.CamelContextgetCamelContext()protected ObjectgetResult(org.smooks.io.payload.Exports exports, Result[] results, org.apache.camel.Exchange exchange)voidmarshal(org.apache.camel.Exchange exchange, Object fromBody, OutputStream toStream)Marshals the Object 'fromBody' to an OutputStream 'toStream'voidsetCamelContext(org.apache.camel.CamelContext camelContext)voidstart()voidstop()Objectunmarshal(org.apache.camel.Exchange exchange, InputStream fromStream)Unmarshals the fromStream to an Object.
-
-
-
Method Detail
-
marshal
public void marshal(org.apache.camel.Exchange exchange, Object fromBody, OutputStream toStream) throws ExceptionMarshals the Object 'fromBody' to an OutputStream 'toStream' The Camel framework will call this method fromAsyncProcessorSupport.process(Exchange)and it will take care of setting the Out Message's body to the bytes written to the toStream OutputStream.- Specified by:
marshalin interfaceorg.apache.camel.spi.DataFormat- Parameters:
exchange- The CamelExchange.fromBody- The object to be marshalled into the output stream.toStream- The output stream that will be written to.- Throws:
Exception
-
unmarshal
public Object unmarshal(org.apache.camel.Exchange exchange, InputStream fromStream)
Unmarshals the fromStream to an Object. The Camel framework will call this method fromAsyncProcessorSupport.process(Exchange)and it will take care of setting the returned Object on the Out Message's body.- Specified by:
unmarshalin interfaceorg.apache.camel.spi.DataFormat- Parameters:
exchange- The CamelExchange.fromStream- The InputStream that will be unmarshalled into an Object instance.
-
getResult
protected Object getResult(org.smooks.io.payload.Exports exports, Result[] results, org.apache.camel.Exchange exchange)
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext)
- Specified by:
setCamelContextin interfaceorg.apache.camel.CamelContextAware
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()
- Specified by:
getCamelContextin interfaceorg.apache.camel.CamelContextAware
-
start
public void start()
- Specified by:
startin interfaceorg.apache.camel.Service
-
stop
public void stop()
- Specified by:
stopin interfaceorg.apache.camel.Service
-
-