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
| Constructor and Description |
|---|
AbstractJacksonDataFormat()
Use the default Jackson
ObjectMapper and Object |
AbstractJacksonDataFormat(Class<?> unmarshalType)
Use the default Jackson
ObjectMapper and with a custom unmarshal type |
AbstractJacksonDataFormat(Class<?> unmarshalType,
Class<?> jsonView)
Use the default Jackson
ObjectMapper and with a custom unmarshal type and JSON view |
AbstractJacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper,
Class<?> unmarshalType)
Use a custom Jackson mapper and and unmarshal type
|
AbstractJacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper,
Class<?> unmarshalType,
Class<?> jsonView)
Use a custom Jackson mapper, unmarshal type and JSON view
|
| Modifier and Type | Method and Description |
|---|---|
void |
addModule(com.fasterxml.jackson.databind.Module module)
To use the custom Jackson module
|
protected abstract com.fasterxml.jackson.databind.ObjectMapper |
createNewObjectMapper() |
void |
disableFeature(com.fasterxml.jackson.databind.DeserializationFeature feature) |
void |
disableFeature(com.fasterxml.jackson.databind.MapperFeature feature) |
void |
disableFeature(com.fasterxml.jackson.databind.SerializationFeature feature) |
protected void |
doInit() |
protected void |
doStart() |
protected void |
doStop() |
void |
enableFeature(com.fasterxml.jackson.databind.DeserializationFeature feature) |
void |
enableFeature(com.fasterxml.jackson.databind.MapperFeature feature) |
void |
enableFeature(com.fasterxml.jackson.databind.SerializationFeature feature) |
org.apache.camel.CamelContext |
getCamelContext() |
Class<? extends Collection> |
getCollectionType() |
String |
getCollectionTypeName() |
abstract String |
getDataFormatName() |
protected abstract String |
getDefaultContentType() |
String |
getDisableFeatures() |
String |
getEnableFeatures() |
String |
getInclude() |
Class<?> |
getJsonView() |
String |
getJsonViewTypeName() |
String |
getModuleClassNames() |
String |
getModuleRefs() |
List<com.fasterxml.jackson.databind.Module> |
getModules() |
com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper() |
protected abstract Class<? extends com.fasterxml.jackson.databind.ObjectMapper> |
getObjectMapperClass() |
SchemaResolver |
getSchemaResolver() |
TimeZone |
getTimezone() |
Class<?> |
getUnmarshalType() |
String |
getUnmarshalTypeName() |
boolean |
isAllowJmsType() |
boolean |
isAllowUnmarshallType() |
boolean |
isAutoDiscoverObjectMapper() |
boolean |
isAutoDiscoverSchemaResolver() |
boolean |
isContentTypeHeader() |
boolean |
isEnableJacksonTypeConverter() |
boolean |
isPrettyPrint() |
boolean |
isUseDefaultObjectMapper() |
boolean |
isUseList() |
void |
marshal(org.apache.camel.Exchange exchange,
Object graph,
OutputStream stream) |
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.
|
void |
setAllowUnmarshallType(boolean allowJacksonUnmarshallType)
If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the
unmarshalling.
|
void |
setAutoDiscoverObjectMapper(boolean autoDiscoverObjectMapper)
If set to true then Jackson will lookup for an objectMapper into the registry
|
void |
setAutoDiscoverSchemaResolver(boolean autoDiscoverSchemaResolver)
When not disabled, the SchemaResolver will be looked up into the registry
|
void |
setCamelContext(org.apache.camel.CamelContext camelContext) |
void |
setCollectionType(Class<? extends Collection> collectionType) |
void |
setCollectionTypeName(String collectionTypeName) |
void |
setContentTypeHeader(boolean contentTypeHeader)
If enabled then Jackson will set the Content-Type header to the correct mime type when marshalling.
|
void |
setDisableFeatures(String disableFeatures)
Set of features to disable on the Jackson
ObjectMapper. |
void |
setEnableFeatures(String enableFeatures)
Set of features to enable on the Jackson
ObjectMapper. |
void |
setEnableJacksonTypeConverter(boolean enableJacksonTypeConverter)
If enabled then Jackson is allowed to attempt to be used during Camels
type converter as a
FallbackConverter that attempts to convert POJOs to/from Map/List types. |
void |
setInclude(String include) |
void |
setJsonView(Class<?> jsonView) |
void |
setJsonViewTypeName(String jsonViewTypeName) |
void |
setModuleClassNames(String moduleClassNames)
To use custom Jackson
Modules specified as a String with FQN class names. |
void |
setModuleRefs(String moduleRefs)
To use custom Jackson modules referred from the Camel registry.
|
void |
setModules(List<com.fasterxml.jackson.databind.Module> modules)
To use custom Jackson
Modules |
void |
setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) |
void |
setPrettyPrint(boolean prettyPrint) |
void |
setSchemaResolver(SchemaResolver schemaResolver)
Optional schema resolver used to lookup schemas for the data in transit.
|
void |
setTimezone(TimeZone timezone)
If set then Jackson will use the Timezone when marshalling/unmarshalling.
|
void |
setUnmarshalType(Class<?> unmarshalType) |
void |
setUnmarshalTypeName(String unmarshalTypeName) |
void |
setUseDefaultObjectMapper(boolean useDefaultObjectMapper) |
void |
setUseList(boolean useList) |
Object |
unmarshal(org.apache.camel.Exchange exchange,
InputStream stream) |
void |
useList()
Uses
ArrayList when unmarshalling. |
void |
useMap()
Uses
HashMap when unmarshalling. |
build, doBuild, doFail, 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, suspendclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic AbstractJacksonDataFormat()
ObjectMapper and Objectpublic AbstractJacksonDataFormat(Class<?> unmarshalType)
ObjectMapper and with a custom unmarshal typeunmarshalType - the custom unmarshal typepublic AbstractJacksonDataFormat(Class<?> unmarshalType, Class<?> jsonView)
ObjectMapper and with a custom unmarshal type and JSON viewunmarshalType - the custom unmarshal typejsonView - marker class to specify properties to be included during marshalling. See also
http://wiki.fasterxml.com/JacksonJsonViewspublic AbstractJacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper,
Class<?> unmarshalType)
mapper - the custom mapperunmarshalType - the custom unmarshal typepublic AbstractJacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper,
Class<?> unmarshalType,
Class<?> jsonView)
mapper - the custom mapperunmarshalType - the custom unmarshal typejsonView - marker class to specify properties to be included during marshalling. See also
http://wiki.fasterxml.com/JacksonJsonViewspublic org.apache.camel.CamelContext getCamelContext()
getCamelContext in interface org.apache.camel.CamelContextAwarepublic void setCamelContext(org.apache.camel.CamelContext camelContext)
setCamelContext in interface org.apache.camel.CamelContextAwarepublic void marshal(org.apache.camel.Exchange exchange,
Object graph,
OutputStream stream)
throws Exception
marshal in interface org.apache.camel.spi.DataFormatExceptionpublic Object unmarshal(org.apache.camel.Exchange exchange, InputStream stream) throws Exception
unmarshal in interface org.apache.camel.spi.DataFormatExceptionpublic com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
public boolean isUseDefaultObjectMapper()
public void setUseDefaultObjectMapper(boolean useDefaultObjectMapper)
public Class<?> getUnmarshalType()
public void setUnmarshalType(Class<?> unmarshalType)
public String getUnmarshalTypeName()
public void setUnmarshalTypeName(String unmarshalTypeName)
public Class<? extends Collection> getCollectionType()
public void setCollectionType(Class<? extends Collection> collectionType)
public String getCollectionTypeName()
public void setCollectionTypeName(String collectionTypeName)
public Class<?> getJsonView()
public void setJsonView(Class<?> jsonView)
public String getJsonViewTypeName()
public void setJsonViewTypeName(String jsonViewTypeName)
public String getInclude()
public void setInclude(String include)
public boolean isAllowJmsType()
public boolean isPrettyPrint()
public void setPrettyPrint(boolean prettyPrint)
public boolean isUseList()
public void setUseList(boolean useList)
public List<com.fasterxml.jackson.databind.Module> getModules()
public void setModules(List<com.fasterxml.jackson.databind.Module> modules)
Modulespublic String getModuleClassNames()
public void addModule(com.fasterxml.jackson.databind.Module module)
public void setModuleClassNames(String moduleClassNames)
Modules specified as a String with FQN class names. Multiple classes can be
separated by comma.public String getModuleRefs()
public void setModuleRefs(String moduleRefs)
public void useList()
ArrayList when unmarshalling.public void useMap()
HashMap when unmarshalling.public void setAllowJmsType(boolean allowJmsType)
public boolean isEnableJacksonTypeConverter()
public void setEnableJacksonTypeConverter(boolean enableJacksonTypeConverter)
FallbackConverter that attempts to convert POJOs to/from Map/List types.
This should only be enabled when desired to be used.public boolean isAllowUnmarshallType()
public void setAllowUnmarshallType(boolean allowJacksonUnmarshallType)
public boolean isContentTypeHeader()
public void setContentTypeHeader(boolean contentTypeHeader)
setContentTypeHeader in interface org.apache.camel.spi.DataFormatContentTypeHeaderpublic TimeZone getTimezone()
public void setTimezone(TimeZone timezone)
public boolean isAutoDiscoverObjectMapper()
public void setAutoDiscoverObjectMapper(boolean autoDiscoverObjectMapper)
public SchemaResolver getSchemaResolver()
public void setSchemaResolver(SchemaResolver schemaResolver)
public boolean isAutoDiscoverSchemaResolver()
public void setAutoDiscoverSchemaResolver(boolean autoDiscoverSchemaResolver)
public String getEnableFeatures()
public void setEnableFeatures(String enableFeatures)
ObjectMapper. The features should be a name that matches a enum
from SerializationFeature, DeserializationFeature, or MapperFeature.public String getDisableFeatures()
public void setDisableFeatures(String disableFeatures)
ObjectMapper. The features should be a name that matches a enum
from SerializationFeature, DeserializationFeature, or MapperFeature.public void enableFeature(com.fasterxml.jackson.databind.SerializationFeature feature)
public void enableFeature(com.fasterxml.jackson.databind.DeserializationFeature feature)
public void enableFeature(com.fasterxml.jackson.databind.MapperFeature feature)
public void disableFeature(com.fasterxml.jackson.databind.SerializationFeature feature)
public void disableFeature(com.fasterxml.jackson.databind.DeserializationFeature feature)
public void disableFeature(com.fasterxml.jackson.databind.MapperFeature feature)
protected void doInit()
throws Exception
doInit in class org.apache.camel.support.service.BaseServiceExceptionprotected void doStart()
throws Exception
doStart in class org.apache.camel.support.service.BaseServiceExceptionprotected void doStop()
throws Exception
doStop in class org.apache.camel.support.service.BaseServiceExceptionpublic abstract String getDataFormatName()
getDataFormatName in interface org.apache.camel.spi.DataFormatNameprotected abstract com.fasterxml.jackson.databind.ObjectMapper createNewObjectMapper()
protected abstract Class<? extends com.fasterxml.jackson.databind.ObjectMapper> getObjectMapperClass()
protected abstract String getDefaultContentType()
Apache Camel