Class AbstractXStreamWrapper
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.dataformat.xstream.AbstractXStreamWrapper
-
- All Implemented Interfaces:
AutoCloseable,org.apache.camel.CamelContextAware,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.spi.DataFormat,org.apache.camel.spi.DataFormatContentTypeHeader,org.apache.camel.spi.DataFormatName,org.apache.camel.StatefulService,org.apache.camel.SuspendableService
- Direct Known Subclasses:
JsonDataFormat,XStreamDataFormat
public abstract class AbstractXStreamWrapper extends org.apache.camel.support.service.ServiceSupport implements org.apache.camel.CamelContextAware, org.apache.camel.spi.DataFormat, org.apache.camel.spi.DataFormatName, org.apache.camel.spi.DataFormatContentTypeHeaderAn abstract class which implement data format (DataFormat) interface which leverage the XStream library for XML or JSON's marshaling and unmarshaling
-
-
Constructor Summary
Constructors Constructor Description AbstractXStreamWrapper()AbstractXStreamWrapper(com.thoughtworks.xstream.XStream xstream)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract com.thoughtworks.xstream.io.HierarchicalStreamReadercreateHierarchicalStreamReader(org.apache.camel.Exchange exchange, InputStream stream)protected abstract com.thoughtworks.xstream.io.HierarchicalStreamWritercreateHierarchicalStreamWriter(org.apache.camel.Exchange exchange, Object body, OutputStream stream)protected com.thoughtworks.xstream.XStreamcreateXStream(org.apache.camel.spi.ClassResolver resolver, ClassLoader classLoader)protected voiddoStart()protected voiddoStop()Map<String,String>getAliases()org.apache.camel.CamelContextgetCamelContext()Map<String,String>getConverters()Map<String,String>getImplicitCollections()StringgetMode()protected intgetModeFromString(String modeString)Map<String,String>getOmitFields()StringgetPermissions()com.thoughtworks.xstream.XStreamgetXstream()com.thoughtworks.xstream.XStreamgetXStream(org.apache.camel.CamelContext context)Resolves the XStream instance to be used by this data format.com.thoughtworks.xstream.XStreamgetXStream(org.apache.camel.spi.ClassResolver resolver)Resolves the XStream instance to be used by this data format.com.thoughtworks.xstream.io.HierarchicalStreamDrivergetXstreamDriver()booleanisContentTypeHeader()voidmarshal(org.apache.camel.Exchange exchange, Object body, OutputStream stream)voidsetAliases(Map<String,String> aliases)voidsetCamelContext(org.apache.camel.CamelContext camelContext)voidsetContentTypeHeader(boolean contentTypeHeader)If enabled then XStream will set the Content-Type header to application/json when marshalling to JSon and application/xml when marshalling to XML.voidsetConverters(Map<String,String> converters)voidsetImplicitCollections(Map<String,String> implicitCollections)voidsetMode(String mode)voidsetOmitFields(Map<String,String> omitFields)voidsetPermissions(String permissions)voidsetXstream(com.thoughtworks.xstream.XStream xstream)voidsetXStream(com.thoughtworks.xstream.XStream xstream)voidsetXstreamDriver(com.thoughtworks.xstream.io.HierarchicalStreamDriver xstreamDriver)Objectunmarshal(org.apache.camel.Exchange exchange, InputStream stream)-
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, toString, wait, wait, wait
-
-
-
-
Method Detail
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()
- Specified by:
getCamelContextin interfaceorg.apache.camel.CamelContextAware
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext)
- Specified by:
setCamelContextin interfaceorg.apache.camel.CamelContextAware
-
getXStream
public com.thoughtworks.xstream.XStream getXStream(org.apache.camel.spi.ClassResolver resolver)
Resolves the XStream instance to be used by this data format. If XStream is not explicitly set, new instance will be created and cached.- Parameters:
resolver- class resolver to be used during a configuration of the XStream instance.- Returns:
- XStream instance used by this data format.
-
getXStream
public com.thoughtworks.xstream.XStream getXStream(org.apache.camel.CamelContext context)
Resolves the XStream instance to be used by this data format. If XStream is not explicitly set, new instance will be created and cached.- Parameters:
context- to be used during a configuration of the XStream instance- Returns:
- XStream instance used by this data format.
-
setXStream
public void setXStream(com.thoughtworks.xstream.XStream xstream)
-
createXStream
protected com.thoughtworks.xstream.XStream createXStream(org.apache.camel.spi.ClassResolver resolver, ClassLoader classLoader)
-
getModeFromString
protected int getModeFromString(String modeString)
-
getXstreamDriver
public com.thoughtworks.xstream.io.HierarchicalStreamDriver getXstreamDriver()
-
setXstreamDriver
public void setXstreamDriver(com.thoughtworks.xstream.io.HierarchicalStreamDriver xstreamDriver)
-
getPermissions
public String getPermissions()
-
setPermissions
public void setPermissions(String permissions)
-
getMode
public String getMode()
-
setMode
public void setMode(String mode)
-
isContentTypeHeader
public boolean isContentTypeHeader()
-
setContentTypeHeader
public void setContentTypeHeader(boolean contentTypeHeader)
If enabled then XStream will set the Content-Type header to application/json when marshalling to JSon and application/xml when marshalling to XML.- Specified by:
setContentTypeHeaderin interfaceorg.apache.camel.spi.DataFormatContentTypeHeader
-
getXstream
public com.thoughtworks.xstream.XStream getXstream()
-
setXstream
public void setXstream(com.thoughtworks.xstream.XStream xstream)
-
marshal
public void marshal(org.apache.camel.Exchange exchange, Object body, OutputStream stream) throws Exception- Specified by:
marshalin interfaceorg.apache.camel.spi.DataFormat- Throws:
Exception
-
unmarshal
public Object unmarshal(org.apache.camel.Exchange exchange, InputStream stream) throws Exception
- Specified by:
unmarshalin interfaceorg.apache.camel.spi.DataFormat- Throws:
Exception
-
createHierarchicalStreamWriter
protected abstract com.thoughtworks.xstream.io.HierarchicalStreamWriter createHierarchicalStreamWriter(org.apache.camel.Exchange exchange, Object body, OutputStream stream) throws XMLStreamException- Throws:
XMLStreamException
-
createHierarchicalStreamReader
protected abstract com.thoughtworks.xstream.io.HierarchicalStreamReader createHierarchicalStreamReader(org.apache.camel.Exchange exchange, InputStream stream) throws XMLStreamException- Throws:
XMLStreamException
-
doStart
protected void doStart() throws Exception- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
-