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.DataFormatContentTypeHeader
An 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.HierarchicalStreamReader
createHierarchicalStreamReader(org.apache.camel.Exchange exchange, InputStream stream)
protected abstract com.thoughtworks.xstream.io.HierarchicalStreamWriter
createHierarchicalStreamWriter(org.apache.camel.Exchange exchange, Object body, OutputStream stream)
protected com.thoughtworks.xstream.XStream
createXStream(org.apache.camel.spi.ClassResolver resolver, ClassLoader classLoader)
protected void
doStart()
protected void
doStop()
Map<String,String>
getAliases()
org.apache.camel.CamelContext
getCamelContext()
Map<String,String>
getConverters()
Map<String,String>
getImplicitCollections()
String
getMode()
protected int
getModeFromString(String modeString)
Map<String,String>
getOmitFields()
String
getPermissions()
com.thoughtworks.xstream.XStream
getXstream()
com.thoughtworks.xstream.XStream
getXStream(org.apache.camel.CamelContext context)
Resolves the XStream instance to be used by this data format.com.thoughtworks.xstream.XStream
getXStream(org.apache.camel.spi.ClassResolver resolver)
Resolves the XStream instance to be used by this data format.com.thoughtworks.xstream.io.HierarchicalStreamDriver
getXstreamDriver()
boolean
isContentTypeHeader()
void
marshal(org.apache.camel.Exchange exchange, Object body, OutputStream stream)
void
setAliases(Map<String,String> aliases)
void
setCamelContext(org.apache.camel.CamelContext camelContext)
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.void
setConverters(Map<String,String> converters)
void
setImplicitCollections(Map<String,String> implicitCollections)
void
setMode(String mode)
void
setOmitFields(Map<String,String> omitFields)
void
setPermissions(String permissions)
void
setXstream(com.thoughtworks.xstream.XStream xstream)
void
setXStream(com.thoughtworks.xstream.XStream xstream)
void
setXstreamDriver(com.thoughtworks.xstream.io.HierarchicalStreamDriver xstreamDriver)
Object
unmarshal(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:
getCamelContext
in interfaceorg.apache.camel.CamelContextAware
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext)
- Specified by:
setCamelContext
in 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:
setContentTypeHeader
in 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:
marshal
in interfaceorg.apache.camel.spi.DataFormat
- Throws:
Exception
-
unmarshal
public Object unmarshal(org.apache.camel.Exchange exchange, InputStream stream) throws Exception
- Specified by:
unmarshal
in 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:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
-