org.apache.camel.converter.jaxb
Class JaxbDataFormat

java.lang.Object
  extended by org.apache.camel.impl.ServiceSupport
      extended by org.apache.camel.converter.jaxb.JaxbDataFormat
All Implemented Interfaces:
CamelContextAware, Service, ShutdownableService, DataFormat
Direct Known Subclasses:
SoapJaxbDataFormat

public class JaxbDataFormat
extends ServiceSupport
implements DataFormat, CamelContextAware

A data format (DataFormat) using JAXB2 to marshal to and from XML

Version:

Constructor Summary
JaxbDataFormat()
           
JaxbDataFormat(JAXBContext context)
           
JaxbDataFormat(String contextPath)
           
 
Method Summary
protected  JAXBContext createContext()
          Strategy to create JAXB context
protected  void doStart()
           
protected  void doStop()
           
 CamelContext getCamelContext()
          Get the CamelContext
 JAXBContext getContext()
           
 String getContextPath()
           
 String getEncoding()
           
 String getPartClass()
           
 QName getPartNamespace()
           
 boolean isFilterNonXmlChars()
           
 boolean isIgnoreJAXBElement()
           
 boolean isPrettyPrint()
           
 void marshal(Exchange exchange, Object graph, OutputStream stream)
          Marshals the object to the given Stream.
protected  boolean needFiltering(Exchange exchange)
           
 void setCamelContext(CamelContext camelContext)
          Injects the CamelContext
 void setContext(JAXBContext context)
           
 void setContextPath(String contextPath)
           
 void setEncoding(String encoding)
           
 void setFilterNonXmlChars(boolean filterNonXmlChars)
           
 void setIgnoreJAXBElement(boolean flag)
           
 void setPartClass(String partClass)
           
 void setPartNamespace(QName partNamespace)
           
 void setPrettyPrint(boolean prettyPrint)
           
 Object unmarshal(Exchange exchange, InputStream stream)
          Unmarshals the given stream into an object.
 
Methods inherited from class org.apache.camel.impl.ServiceSupport
addChildService, doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, removeChildService, resume, shutdown, start, start, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JaxbDataFormat

public JaxbDataFormat()

JaxbDataFormat

public JaxbDataFormat(JAXBContext context)

JaxbDataFormat

public JaxbDataFormat(String contextPath)
Method Detail

marshal

public void marshal(Exchange exchange,
                    Object graph,
                    OutputStream stream)
             throws IOException
Description copied from interface: DataFormat
Marshals the object to the given Stream.

Specified by:
marshal in interface DataFormat
Parameters:
exchange - the current exchange
graph - the object to be marshalled
stream - the output stream to write the marshalled result to
Throws:
IOException

unmarshal

public Object unmarshal(Exchange exchange,
                        InputStream stream)
                 throws IOException
Description copied from interface: DataFormat
Unmarshals the given stream into an object.

Notice: The result is set as body on the exchange OUT message. It is possible to mutate the OUT message provided in the given exchange parameter. For instance adding headers to the OUT message will be preserved.

Specified by:
unmarshal in interface DataFormat
Parameters:
exchange - the current exchange
stream - the input stream with the object to be unmarshalled
Returns:
the unmarshalled object
Throws:
IOException

needFiltering

protected boolean needFiltering(Exchange exchange)

isIgnoreJAXBElement

public boolean isIgnoreJAXBElement()

setIgnoreJAXBElement

public void setIgnoreJAXBElement(boolean flag)

getContext

public JAXBContext getContext()

setContext

public void setContext(JAXBContext context)

getContextPath

public String getContextPath()

setContextPath

public void setContextPath(String contextPath)

isPrettyPrint

public boolean isPrettyPrint()

setPrettyPrint

public void setPrettyPrint(boolean prettyPrint)

isFilterNonXmlChars

public boolean isFilterNonXmlChars()

setFilterNonXmlChars

public void setFilterNonXmlChars(boolean filterNonXmlChars)

getEncoding

public String getEncoding()

setEncoding

public void setEncoding(String encoding)

getPartNamespace

public QName getPartNamespace()

setPartNamespace

public void setPartNamespace(QName partNamespace)

getPartClass

public String getPartClass()

setPartClass

public void setPartClass(String partClass)

getCamelContext

public CamelContext getCamelContext()
Description copied from interface: CamelContextAware
Get the CamelContext

Specified by:
getCamelContext in interface CamelContextAware
Returns:
camelContext the Camel context

setCamelContext

public void setCamelContext(CamelContext camelContext)
Description copied from interface: CamelContextAware
Injects the CamelContext

Specified by:
setCamelContext in interface CamelContextAware
Parameters:
camelContext - the Camel context

doStart

protected void doStart()
                throws Exception
Specified by:
doStart in class ServiceSupport
Throws:
Exception

doStop

protected void doStop()
               throws Exception
Specified by:
doStop in class ServiceSupport
Throws:
Exception

createContext

protected JAXBContext createContext()
                             throws JAXBException
Strategy to create JAXB context

Throws:
JAXBException


Apache CAMEL