Class JsonbDataFormat

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.component.jsonb.JsonbDataFormat
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.spi.HasCamelContext, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

@Dataformat("jsonb") @Metadata(includeProperties="unmarshalTypeName,unmarshalType,objectMapper,prettyPrint,binaryStrategy,encoding,propertyOrder,propertyNamingStrategy,skipNull") public class JsonbDataFormat 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 JSON-B.
  • Constructor Details

    • JsonbDataFormat

      public JsonbDataFormat()
    • JsonbDataFormat

      public JsonbDataFormat(Type customType)
      Use the default JSON-B Jsonb and with a custom unmarshal type
      Parameters:
      customType - the custom unmarshal type
    • JsonbDataFormat

      public JsonbDataFormat(Class<?> unmarshalType)
    • JsonbDataFormat

      public JsonbDataFormat(String unmarshalTypeName)
    • JsonbDataFormat

      public JsonbDataFormat(jakarta.json.bind.Jsonb mapper, Class<?> unmarshalType)
      Use a custom JSON-B instance and unmarshal type
      Parameters:
      mapper - the custom mapper
      unmarshalType - the custom unmarshal type
  • Method Details

    • 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.spi.HasCamelContext
    • getDataFormatName

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

      public jakarta.json.bind.Jsonb getObjectMapper()
    • setObjectMapper

      public void setObjectMapper(jakarta.json.bind.Jsonb objectMapper)
      Set a custom Jsonb instance, potentially initialized with a custom JsonbConfig.
      Parameters:
      objectMapper - the Jsonb instance to set.
    • getUnmarshalType

      public Class<?> getUnmarshalType()
    • setUnmarshalType

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

      public String getUnmarshalTypeName()
    • setUnmarshalTypeName

      public void setUnmarshalTypeName(String unmarshalTypeName)
    • isPrettyPrint

      public boolean isPrettyPrint()
    • setPrettyPrint

      public void setPrettyPrint(boolean prettyPrint)
    • getEncoding

      public String getEncoding()
    • setEncoding

      public void setEncoding(String encoding)
    • isSkipNull

      public boolean isSkipNull()
    • setSkipNull

      public void setSkipNull(boolean skipNull)
    • getBinaryStrategy

      public String getBinaryStrategy()
    • setBinaryStrategy

      public void setBinaryStrategy(String binaryStrategy)
    • getPropertyOrder

      public String getPropertyOrder()
    • setPropertyOrder

      public void setPropertyOrder(String propertyOrder)
    • getPropertyNamingStrategy

      public String getPropertyNamingStrategy()
    • setPropertyNamingStrategy

      public void setPropertyNamingStrategy(String propertyNamingStrategy)
    • marshal

      public void marshal(org.apache.camel.Exchange exchange, Object graph, OutputStream stream)
      Specified by:
      marshal in interface org.apache.camel.spi.DataFormat
    • 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
    • doInit

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

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

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