Class JohnzonDataFormat

  • 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.DataFormatName, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

    @Dataformat("johnzon")
    @Metadata(includeProperties="unmarshalType,unmarshalTypeName,objectMapper,prettyPrint")
    public class JohnzonDataFormat
    extends org.apache.camel.support.service.ServiceSupport
    implements org.apache.camel.spi.DataFormat, org.apache.camel.spi.DataFormatName, org.apache.camel.CamelContextAware
    Marshal POJOs to JSON and back using Johnzon
    • Constructor Detail

      • JohnzonDataFormat

        public JohnzonDataFormat()
      • JohnzonDataFormat

        public JohnzonDataFormat​(Class<?> unmarshalType)
        Use the default Johnzon Mapper and with a custom unmarshal type
        Parameters:
        unmarshalType - the custom unmarshal type
      • JohnzonDataFormat

        public JohnzonDataFormat​(org.apache.johnzon.mapper.reflection.JohnzonParameterizedType parameterizedType)
        Use the default Johnzon Mapper and with a custom parameterized type
        Parameters:
        parameterizedType - the custom parameterized type
      • JohnzonDataFormat

        public JohnzonDataFormat​(org.apache.johnzon.mapper.Mapper mapper,
                                 Class<?> unmarshalType)
        Use a custom Johnzon mapper and unmarshal type
        Parameters:
        mapper - the custom mapper
        unmarshalType - the custom unmarshal type
      • JohnzonDataFormat

        public JohnzonDataFormat​(org.apache.johnzon.mapper.Mapper mapper,
                                 org.apache.johnzon.mapper.reflection.JohnzonParameterizedType parameterizedType)
        Use a custom Johnzon mapper and unmarshal type
        Parameters:
        mapper - the custom mapper
        parameterizedType - the JohnzonParameterizedType type
    • Method Detail

      • setCamelContext

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

        public org.apache.camel.CamelContext getCamelContext()
        Specified by:
        getCamelContext in interface org.apache.camel.CamelContextAware
      • getDataFormatName

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

        public org.apache.johnzon.mapper.Mapper getObjectMapper()
      • setObjectMapper

        public void setObjectMapper​(org.apache.johnzon.mapper.Mapper objectMapper)
      • getUnmarshalType

        public Class<?> getUnmarshalType()
      • setUnmarshalType

        public void setUnmarshalType​(Class<?> unmarshalType)
      • getUnmarshalTypeName

        public String getUnmarshalTypeName()
      • setUnmarshalTypeName

        public void setUnmarshalTypeName​(String unmarshalTypeName)
      • getParameterizedType

        public org.apache.johnzon.mapper.reflection.JohnzonParameterizedType getParameterizedType()
      • setParameterizedType

        public void setParameterizedType​(org.apache.johnzon.mapper.reflection.JohnzonParameterizedType parameterizedType)
      • isPrettyPrint

        public boolean isPrettyPrint()
      • setPrettyPrint

        public void setPrettyPrint​(boolean prettyPrint)
      • getEncoding

        public String getEncoding()
      • setEncoding

        public void setEncoding​(String encoding)
      • isSkipEmptyArray

        public boolean isSkipEmptyArray()
      • setSkipEmptyArray

        public void setSkipEmptyArray​(boolean skipEmptyArray)
      • isSkipNull

        public boolean isSkipNull()
      • setSkipNull

        public void setSkipNull​(boolean skipNull)
      • setAttributeOrder

        public void setAttributeOrder​(Comparator<String> attributeOrder)
      • 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
      • 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