Class AbstractJacksonDataFormat
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.component.jackson.AbstractJacksonDataFormat
- 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:
JacksonDataFormat
public abstract class AbstractJacksonDataFormat
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
Abstract superclass of Jackson based data formats.
-
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
ConstructorsModifierConstructorDescriptionprotectedUse the default JacksonObjectMapperandObjectprotectedAbstractJacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper, Class<?> unmarshalType) Use a custom Jackson mapper and and unmarshal typeprotectedAbstractJacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper, Class<?> unmarshalType, Class<?> jsonView) Use a custom Jackson mapper, unmarshal type and JSON viewprotectedAbstractJacksonDataFormat(Class<?> unmarshalType) Use the default JacksonObjectMapperand with a custom unmarshal typeprotectedAbstractJacksonDataFormat(Class<?> unmarshalType, Class<?> jsonView) Use the default JacksonObjectMapperand with a custom unmarshal type and JSON view -
Method Summary
Modifier and TypeMethodDescriptionvoidaddModule(com.fasterxml.jackson.databind.Module module) To use the custom Jackson moduleprotected abstract com.fasterxml.jackson.databind.ObjectMappervoiddisableFeature(com.fasterxml.jackson.databind.DeserializationFeature feature) voiddisableFeature(com.fasterxml.jackson.databind.MapperFeature feature) voiddisableFeature(com.fasterxml.jackson.databind.SerializationFeature feature) protected voiddoInit()protected voiddoStart()protected voiddoStop()voidenableFeature(com.fasterxml.jackson.databind.DeserializationFeature feature) voidenableFeature(com.fasterxml.jackson.databind.MapperFeature feature) voidenableFeature(com.fasterxml.jackson.databind.SerializationFeature feature) org.apache.camel.CamelContextClass<? extends Collection> abstract Stringprotected abstract StringClass<?> intList<com.fasterxml.jackson.databind.Module> com.fasterxml.jackson.databind.ObjectMapperprotected abstract Class<? extends com.fasterxml.jackson.databind.ObjectMapper> Class<?> booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanvoidmarshal(org.apache.camel.Exchange exchange, Object graph, OutputStream stream) voidsetAllowJmsType(boolean allowJmsType) Allows jackson to use the JMSType header as an indicator what the classname is for unmarshaling content to POJOvoidsetAllowUnmarshallType(boolean allowJacksonUnmarshallType) If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling.voidsetAutoDiscoverObjectMapper(boolean autoDiscoverObjectMapper) If set to true and useDefaultObjectMapper is true, then Jackson will look for an objectMapper in the registry.voidsetAutoDiscoverSchemaResolver(boolean autoDiscoverSchemaResolver) When not disabled, the SchemaResolver will be looked up into the registryvoidsetCamelContext(org.apache.camel.CamelContext camelContext) voidsetCollectionType(Class<? extends Collection> collectionType) voidsetCollectionTypeName(String collectionTypeName) voidsetCombineUnicodeSurrogates(boolean combineUnicodeSurrogates) voidsetContentTypeHeader(boolean contentTypeHeader) If enabled then Jackson will set the Content-Type header to the correct mime type when marshalling.voidsetDisableFeatures(String disableFeatures) Set of features to disable on the JacksonObjectMapper.voidsetEnableFeatures(String enableFeatures) Set of features to enable on the JacksonObjectMapper.voidsetEnableJacksonTypeConverter(boolean enableJacksonTypeConverter) If enabled then Jackson is allowed to attempt to be used during Camels type converter as athat attempts to convert POJOs to/frominvalid reference
org.apache.camel.FallbackConverterMap/Listtypes.voidsetInclude(String include) voidsetJsonView(Class<?> jsonView) voidsetJsonViewTypeName(String jsonViewTypeName) voidsetMaxStringLength(int maxStringLength) voidsetModuleClassNames(String moduleClassNames) To use custom JacksonModules specified as a String with FQN class names.voidsetModuleRefs(String moduleRefs) To use custom Jackson modules referred from the Camel registry.voidsetModules(List<com.fasterxml.jackson.databind.Module> modules) To use custom JacksonModulesvoidsetNamingStrategy(String namingStrategy) voidsetObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) voidsetPrettyPrint(boolean prettyPrint) voidsetSchemaResolver(SchemaResolver schemaResolver) Optional schema resolver used to lookup schemas for the data in transit.voidsetTimezone(TimeZone timezone) If set then Jackson will use the Timezone when marshalling/unmarshalling.voidsetUnmarshalType(Class<?> unmarshalType) voidsetUnmarshalTypeName(String unmarshalTypeName) voidsetUseDefaultObjectMapper(boolean useDefaultObjectMapper) voidsetUseList(boolean useList) unmarshal(org.apache.camel.Exchange exchange, InputStream stream) voiduseList()UsesArrayListwhen unmarshalling.voiduseMap()UsesLinkedHashMapwhen unmarshalling.Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getInternalLock, 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.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
-
AbstractJacksonDataFormat
protected AbstractJacksonDataFormat()Use the default JacksonObjectMapperandObject -
AbstractJacksonDataFormat
Use the default JacksonObjectMapperand with a custom unmarshal type- Parameters:
unmarshalType- the custom unmarshal type
-
AbstractJacksonDataFormat
Use the default JacksonObjectMapperand with a custom unmarshal type and JSON view- Parameters:
unmarshalType- the custom unmarshal typejsonView- 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
-
AbstractJacksonDataFormat
protected AbstractJacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper, Class<?> unmarshalType) Use a custom Jackson mapper and and unmarshal type- Parameters:
mapper- the custom mapperunmarshalType- the custom unmarshal type
-
AbstractJacksonDataFormat
protected AbstractJacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper, Class<?> unmarshalType, Class<?> jsonView) Use a custom Jackson mapper, unmarshal type and JSON view- Parameters:
mapper- the custom mapperunmarshalType- the custom unmarshal typejsonView- 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
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()- Specified by:
getCamelContextin interfaceorg.apache.camel.spi.HasCamelContext
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext) - Specified by:
setCamelContextin interfaceorg.apache.camel.CamelContextAware
-
marshal
public void marshal(org.apache.camel.Exchange exchange, Object graph, 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
-
unmarshal
- Specified by:
unmarshalin interfaceorg.apache.camel.spi.DataFormat- Throws:
Exception
-
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
setObjectMapper
public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
isUseDefaultObjectMapper
public boolean isUseDefaultObjectMapper() -
setUseDefaultObjectMapper
public void setUseDefaultObjectMapper(boolean useDefaultObjectMapper) -
getUnmarshalType
-
setUnmarshalType
-
getUnmarshalTypeName
-
setUnmarshalTypeName
-
isCombineUnicodeSurrogates
public boolean isCombineUnicodeSurrogates() -
setCombineUnicodeSurrogates
public void setCombineUnicodeSurrogates(boolean combineUnicodeSurrogates) -
getCollectionType
-
setCollectionType
-
getCollectionTypeName
-
setCollectionTypeName
-
getJsonView
-
setJsonView
-
getJsonViewTypeName
-
setJsonViewTypeName
-
getInclude
-
setInclude
-
isAllowJmsType
public boolean isAllowJmsType() -
isPrettyPrint
public boolean isPrettyPrint() -
setPrettyPrint
public void setPrettyPrint(boolean prettyPrint) -
isUseList
public boolean isUseList() -
setUseList
public void setUseList(boolean useList) -
getModules
-
getNamingStrategy
-
setNamingStrategy
-
getMaxStringLength
public int getMaxStringLength() -
setMaxStringLength
public void setMaxStringLength(int maxStringLength) -
setModules
To use custom JacksonModules -
getModuleClassNames
-
addModule
public void addModule(com.fasterxml.jackson.databind.Module module) To use the custom Jackson module -
setModuleClassNames
To use custom JacksonModules specified as a String with FQN class names. Multiple classes can be separated by comma. -
getModuleRefs
-
setModuleRefs
To use custom Jackson modules referred from the Camel registry. Multiple modules can be separated by comma. -
useList
public void useList()UsesArrayListwhen unmarshalling. -
useMap
public void useMap()UsesLinkedHashMapwhen unmarshalling. -
setAllowJmsType
public void setAllowJmsType(boolean allowJmsType) Allows jackson to use the JMSType header as an indicator what the classname is for unmarshaling 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 athat attempts to convert POJOs to/frominvalid reference
org.apache.camel.FallbackConverterMap/Listtypes. 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 the correct mime type when marshalling.- Specified by:
setContentTypeHeaderin interfaceorg.apache.camel.spi.DataFormatContentTypeHeader
-
getTimezone
-
setTimezone
If set then Jackson will use the Timezone when marshalling/unmarshalling. -
isAutoDiscoverObjectMapper
public boolean isAutoDiscoverObjectMapper() -
setAutoDiscoverObjectMapper
public void setAutoDiscoverObjectMapper(boolean autoDiscoverObjectMapper) If set to true and useDefaultObjectMapper is true, then Jackson will look for an objectMapper in the registry. -
getSchemaResolver
-
setSchemaResolver
Optional schema resolver used to lookup schemas for the data in transit. -
isAutoDiscoverSchemaResolver
public boolean isAutoDiscoverSchemaResolver() -
setAutoDiscoverSchemaResolver
public void setAutoDiscoverSchemaResolver(boolean autoDiscoverSchemaResolver) When not disabled, the SchemaResolver will be looked up into the registry -
getEnableFeatures
-
setEnableFeatures
Set of features to enable on the JacksonObjectMapper. The features should be a name that matches a enum fromSerializationFeature,DeserializationFeature, orMapperFeature. -
getDisableFeatures
-
setDisableFeatures
Set of features to disable on the JacksonObjectMapper. The features should be a name that matches a enum fromSerializationFeature,DeserializationFeature, orMapperFeature. -
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) -
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) -
doInit
- Overrides:
doInitin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStart
- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
getDataFormatName
- Specified by:
getDataFormatNamein interfaceorg.apache.camel.spi.DataFormatName
-
createNewObjectMapper
protected abstract com.fasterxml.jackson.databind.ObjectMapper createNewObjectMapper() -
getObjectMapperClass
protected abstract Class<? extends com.fasterxml.jackson.databind.ObjectMapper> getObjectMapperClass() -
getDefaultContentType
-