org.milyn.smooks.camel.dataformat
Class SmooksDataFormat
java.lang.Object
org.milyn.smooks.camel.dataformat.SmooksDataFormat
- All Implemented Interfaces:
- org.apache.camel.CamelContextAware, org.apache.camel.Service, org.apache.camel.spi.DataFormat
public class SmooksDataFormat
- extends java.lang.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 the SmooksComponent or SmooksProcessor as they hook
into Camels lifecycle manegment and will close resources correctly.
- Author:
- Christian Mueller, Daniel Bevenius
|
Method Summary |
org.apache.camel.CamelContext |
getCamelContext()
|
protected java.lang.Object |
getResult(Exports exports,
javax.xml.transform.Result[] results,
org.apache.camel.Exchange exchange)
|
void |
marshal(org.apache.camel.Exchange exchange,
java.lang.Object fromBody,
java.io.OutputStream toStream)
Marshals the Object 'fromBody' to an OutputStream 'toStream' |
void |
setCamelContext(org.apache.camel.CamelContext camelContext)
|
void |
start()
|
void |
stop()
|
java.lang.Object |
unmarshal(org.apache.camel.Exchange exchange,
java.io.InputStream fromStream)
Unmarshals the fromStream to an Object. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SmooksDataFormat
public SmooksDataFormat(java.lang.String smooksConfig)
throws java.lang.Exception
- Throws:
java.lang.Exception
marshal
public void marshal(org.apache.camel.Exchange exchange,
java.lang.Object fromBody,
java.io.OutputStream toStream)
throws java.lang.Exception
- Marshals the Object 'fromBody' to an OutputStream 'toStream'
The Camel framework will call this method from
MarshalProcessor.process(Exchange)
and it will take care of setting the Out Message's body to the bytes written to the toStream
OutputStream.
- Specified by:
marshal in interface org.apache.camel.spi.DataFormat
- Parameters:
exchange - The Camel Exchange.fromBody - The object to be marshalled into the output stream.toStream - The output stream that will be written to.
- Throws:
java.lang.Exception
unmarshal
public java.lang.Object unmarshal(org.apache.camel.Exchange exchange,
java.io.InputStream fromStream)
throws java.lang.Exception
- Unmarshals the fromStream to an Object.
The Camel framework will call this method from
UnMarshalProcessor#process(Exchange)
and it will take care of setting the returned Object on the Out Message's body.
- Specified by:
unmarshal in interface org.apache.camel.spi.DataFormat
- Parameters:
exchange - The Camel Exchange.fromStream - The InputStream that will be unmarshalled into an Object instance.
- Throws:
java.lang.Exception
getResult
protected java.lang.Object getResult(Exports exports,
javax.xml.transform.Result[] results,
org.apache.camel.Exchange exchange)
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext)
- Specified by:
setCamelContext in interface org.apache.camel.CamelContextAware
getCamelContext
public org.apache.camel.CamelContext getCamelContext()
- Specified by:
getCamelContext in interface org.apache.camel.CamelContextAware
start
public void start()
throws java.lang.Exception
- Specified by:
start in interface org.apache.camel.Service
- Throws:
java.lang.Exception
stop
public void stop()
throws java.lang.Exception
- Specified by:
stop in interface org.apache.camel.Service
- Throws:
java.lang.Exception
Copyright © 2011. All Rights Reserved.