Class JacksonXMLDataFormat

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.component.jacksonxml.JacksonXMLDataFormat
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.spi.HasCamelContext, org.apache.camel.StatefulService, org.apache.camel.SuspendableService
Direct Known Subclasses:
ListJacksonXMLDataFormat

@Dataformat("jacksonXml") public class JacksonXMLDataFormat extends org.apache.camel.support.service.ServiceSupport implements org.apache.camel.spi.DataFormat, org.apache.camel.spi.DataFormatName, org.apache.camel.spi.DataFormatContentTypeHeader, org.apache.camel.CamelContextAware
A data format (DataFormat) using Jackson to marshal to and from XML.
  • Constructor Details

    • JacksonXMLDataFormat

      public JacksonXMLDataFormat()
      Use the default Jackson XmlMapper and Map
    • JacksonXMLDataFormat

      public JacksonXMLDataFormat(Class<?> unmarshalType)
      Use the default Jackson XmlMapper and with a custom unmarshal type
      Parameters:
      unmarshalType - the custom unmarshal type
    • JacksonXMLDataFormat

      public JacksonXMLDataFormat(Class<?> unmarshalType, Class<?> jsonView)
      Use the default Jackson XmlMapper and with a custom unmarshal type and JSON view
      Parameters:
      unmarshalType - the custom unmarshal type
      jsonView - marker class to specify properties to be included during marshalling. See also https://github.com/FasterXML/jackson-annotations/blob/master/src/main/java/com/fasterxml/jackson/annotation/JsonView.java
    • JacksonXMLDataFormat

      public JacksonXMLDataFormat(Class<?> unmarshalType, Class<?> jsonView, boolean enableJaxbAnnotationModule)
      Use the default Jackson XmlMapper and with a custom unmarshal type and JSON view
      Parameters:
      unmarshalType - the custom unmarshal type
      jsonView - marker class to specify properties to be included during marshalling. See also https://github.com/FasterXML/jackson-annotations/blob/master/src/main/java/com/fasterxml/jackson/annotation/JsonView.java
      enableJaxbAnnotationModule - if it is true, will enable the JaxbAnnotationModule.
    • JacksonXMLDataFormat

      public JacksonXMLDataFormat(com.fasterxml.jackson.dataformat.xml.XmlMapper mapper, Class<?> unmarshalType)
      Use a custom Jackson mapper and and unmarshal type
      Parameters:
      mapper - the custom mapper
      unmarshalType - the custom unmarshal type
    • JacksonXMLDataFormat

      public JacksonXMLDataFormat(com.fasterxml.jackson.dataformat.xml.XmlMapper mapper, Class<?> unmarshalType, Class<?> jsonView)
      Use a custom Jackson mapper, unmarshal type and JSON view
      Parameters:
      mapper - the custom mapper
      unmarshalType - the custom unmarshal type
      jsonView - marker class to specify properties to be included during marshalling. See also https://github.com/FasterXML/jackson-annotations/blob/master/src/main/java/com/fasterxml/jackson/annotation/JsonView.java
  • Method Details

    • getDataFormatName

      public String getDataFormatName()
      Specified by:
      getDataFormatName in interface org.apache.camel.spi.DataFormatName
    • getCamelContext

      public org.apache.camel.CamelContext getCamelContext()
      Specified by:
      getCamelContext in interface org.apache.camel.spi.HasCamelContext
    • setCamelContext

      public void setCamelContext(org.apache.camel.CamelContext camelContext)
      Specified by:
      setCamelContext in interface org.apache.camel.CamelContextAware
    • marshal

      public void marshal(org.apache.camel.Exchange exchange, Object graph, OutputStream stream) throws Exception
      Specified by:
      marshal in interface org.apache.camel.spi.DataFormat
      Throws:
      Exception
    • unmarshal

      public Object unmarshal(org.apache.camel.Exchange exchange, InputStream stream) throws Exception
      Specified by:
      unmarshal in interface org.apache.camel.spi.DataFormat
      Throws:
      Exception
    • unmarshal

      public Object unmarshal(org.apache.camel.Exchange exchange, Object body) throws Exception
      Specified by:
      unmarshal in interface org.apache.camel.spi.DataFormat
      Throws:
      Exception
    • getXmlMapper

      public com.fasterxml.jackson.dataformat.xml.XmlMapper getXmlMapper()
    • setXmlMapper

      public void setXmlMapper(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper)
    • getUnmarshalTypeName

      public String getUnmarshalTypeName()
    • setUnmarshalTypeName

      public void setUnmarshalTypeName(String unmarshalTypeName)
    • getUnmarshalType

      public Class<?> getUnmarshalType()
    • setUnmarshalType

      public void setUnmarshalType(Class<?> unmarshalType)
    • getCollectionTypeName

      public String getCollectionTypeName()
    • setCollectionTypeName

      public void setCollectionTypeName(String collectionTypeName)
    • getCollectionType

      public Class<? extends Collection> getCollectionType()
    • setCollectionType

      public void setCollectionType(Class<? extends Collection> collectionType)
    • getJsonViewTypeName

      public String getJsonViewTypeName()
    • setJsonViewTypeName

      public void setJsonViewTypeName(String jsonViewTypeName)
    • getJsonView

      public Class<?> getJsonView()
    • setJsonView

      public void setJsonView(Class<?> jsonView)
    • getInclude

      public String getInclude()
    • setInclude

      public void setInclude(String include)
    • isAllowJmsType

      public boolean isAllowJmsType()
    • isPrettyPrint

      public boolean isPrettyPrint()
    • setPrettyPrint

      public void setPrettyPrint(boolean prettyPrint)
    • isUseList

      public boolean isUseList()
    • setUseList

      public void setUseList(boolean useList)
    • isEnableJaxbAnnotationModule

      public boolean isEnableJaxbAnnotationModule()
    • setEnableJaxbAnnotationModule

      public void setEnableJaxbAnnotationModule(boolean enableJaxbAnnotationModule)
    • getModules

      public List<com.fasterxml.jackson.databind.Module> getModules()
    • setModules

      public void setModules(List<com.fasterxml.jackson.databind.Module> modules)
      To use custom Jackson Modules
    • getModuleClassNames

      public String getModuleClassNames()
    • addModule

      public void addModule(com.fasterxml.jackson.databind.Module module)
      To use the custom Jackson module
    • setModuleClassNames

      public void setModuleClassNames(String moduleClassNames)
      To use custom Jackson Modules specified as a String with FQN class names. Multiple classes can be separated by comma.
    • getModuleRefs

      public String getModuleRefs()
    • setModuleRefs

      public void setModuleRefs(String moduleRefs)
      To use custom Jackson modules referred from the Camel registry. Multiple modules can be separated by comma.
    • useList

      public void useList()
      Uses ArrayList when unmarshalling.
    • useMap

      public void useMap()
      Uses LinkedHashMap when unmarshalling.
    • setAllowJmsType

      public void setAllowJmsType(boolean allowJmsType)
      Allows jackson to use the JMSType header as an indicator what the classname is for unmarshaling XML content to POJO

      By default this option is false.

    • isEnableJacksonTypeConverter

      public boolean isEnableJacksonTypeConverter()
    • setEnableJacksonTypeConverter

      public void setEnableJacksonTypeConverter(boolean enableJacksonTypeConverter)
      If enabled then Jackson is allowed to attempt to be used during Camels type converter as a
      invalid reference
      org.apache.camel.FallbackConverter
      that attempts to convert POJOs to/from Map/List types.

      This should only be enabled when desired to be used.

    • isAllowUnmarshallType

      public boolean isAllowUnmarshallType()
    • setAllowUnmarshallType

      public void setAllowUnmarshallType(boolean allowJacksonUnmarshallType)
      If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling.

      This should only be enabled when desired to be used.

    • isContentTypeHeader

      public boolean isContentTypeHeader()
    • setContentTypeHeader

      public void setContentTypeHeader(boolean contentTypeHeader)
      If enabled then Jackson will set the Content-Type header to application/xml when marshalling.
      Specified by:
      setContentTypeHeader in interface org.apache.camel.spi.DataFormatContentTypeHeader
    • getTimezone

      public TimeZone getTimezone()
    • setTimezone

      public void setTimezone(TimeZone timezone)
      If set then Jackson will use the Timezone when marshalling/unmarshalling.
    • getMaxStringLength

      public int getMaxStringLength()
    • setMaxStringLength

      public void setMaxStringLength(int maxStringLength)
    • getEnableFeatures

      public String getEnableFeatures()
    • setEnableFeatures

      public void setEnableFeatures(String enableFeatures)
      Set of features to enable on the Jackson XmlMapper. The features should be a name that matches a enum from SerializationFeature, DeserializationFeature, or MapperFeature.
    • getDisableFeatures

      public String getDisableFeatures()
    • setDisableFeatures

      public void setDisableFeatures(String disableFeatures)
      Set of features to disable on the Jackson XmlMapper. The features should be a name that matches a enum from SerializationFeature, DeserializationFeature, or MapperFeature.
    • enableFeature

      public void enableFeature(com.fasterxml.jackson.databind.SerializationFeature feature)
    • enableFeature

      public void enableFeature(com.fasterxml.jackson.databind.DeserializationFeature feature)
    • enableFeature

      public void enableFeature(com.fasterxml.jackson.databind.MapperFeature feature)
    • enableFeature

      public void enableFeature(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser.Feature feature)
    • disableFeature

      public void disableFeature(com.fasterxml.jackson.databind.SerializationFeature feature)
    • disableFeature

      public void disableFeature(com.fasterxml.jackson.databind.DeserializationFeature feature)
    • disableFeature

      public void disableFeature(com.fasterxml.jackson.databind.MapperFeature feature)
    • disableFeature

      public void disableFeature(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser.Feature feature)
    • createNewXmlMapper

      protected com.fasterxml.jackson.dataformat.xml.XmlMapper createNewXmlMapper()
    • doInit

      protected void doInit() throws Exception
      Overrides:
      doInit in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.apache.camel.support.service.BaseService
      Throws:
      Exception