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-
Field Summary
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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()org.apache.camel.CamelContextgetMode()protected intgetModeFromString(String modeString) com.thoughtworks.xstream.XStreamcom.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.HierarchicalStreamDriverbooleanvoidmarshal(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) voidvoidsetOmitFields(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) 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, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.spi.DataFormatName
getDataFormatNameMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
AbstractXStreamWrapper
public AbstractXStreamWrapper() -
AbstractXStreamWrapper
public AbstractXStreamWrapper(com.thoughtworks.xstream.XStream xstream)
-
-
Method Details
-
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
-
getConverters
-
setConverters
-
getAliases
-
setAliases
-
getOmitFields
-
setOmitFields
-
getImplicitCollections
-
setImplicitCollections
-
getXstreamDriver
public com.thoughtworks.xstream.io.HierarchicalStreamDriver getXstreamDriver() -
setXstreamDriver
public void setXstreamDriver(com.thoughtworks.xstream.io.HierarchicalStreamDriver xstreamDriver) -
getPermissions
-
setPermissions
-
getMode
-
setMode
-
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
- 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
- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-