public class JacksonDataFormat
extends org.apache.camel.support.ServiceSupport
implements org.apache.camel.spi.DataFormat, org.apache.camel.spi.DataFormatName, org.apache.camel.CamelContextAware
Constructor and Description |
---|
JacksonDataFormat()
Use the default Jackson
ObjectMapper and Map |
JacksonDataFormat(Class<?> unmarshalType)
Use the default Jackson
ObjectMapper and with a custom
unmarshal type |
JacksonDataFormat(Class<?> unmarshalType,
Class<?> jsonView)
Use the default Jackson
ObjectMapper and with a custom
unmarshal type and JSON view |
JacksonDataFormat(Class<?> unmarshalType,
Class<?> jsonView,
boolean enableJaxbAnnotationModule)
Use the default Jackson
ObjectMapper and with a custom
unmarshal type and JSON view |
JacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper,
Class<?> unmarshalType)
Use a custom Jackson mapper and and unmarshal type
|
JacksonDataFormat(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
|
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 |
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 |
getDataFormatName() |
String |
getDisableFeatures() |
String |
getEnableFeatures() |
String |
getInclude() |
Class<?> |
getJsonView() |
String |
getModuleClassNames() |
String |
getModuleRefs() |
List<com.fasterxml.jackson.databind.Module> |
getModules() |
com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper() |
Class<?> |
getUnmarshalType() |
boolean |
isAllowJmsType() |
boolean |
isAllowUnmarshallType() |
boolean |
isEnableJacksonTypeConverter() |
boolean |
isEnableJaxbAnnotationModule() |
boolean |
isPrettyPrint() |
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 json 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 |
setCamelContext(org.apache.camel.CamelContext camelContext) |
void |
setCollectionType(Class<? extends Collection> collectionType) |
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 |
setEnableJaxbAnnotationModule(boolean enableJaxbAnnotationModule) |
void |
setInclude(String include) |
void |
setJsonView(Class<?> jsonView) |
void |
setModuleClassNames(String moduleClassNames)
To use custom Jackson
Module s 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
Module s |
void |
setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) |
void |
setPrettyPrint(boolean prettyPrint) |
void |
setUnmarshalType(Class<?> unmarshalType) |
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. |
public JacksonDataFormat()
ObjectMapper
and Map
public JacksonDataFormat(Class<?> unmarshalType)
ObjectMapper
and with a custom
unmarshal typeunmarshalType
- the custom unmarshal typepublic JacksonDataFormat(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 JacksonDataFormat(Class<?> unmarshalType, Class<?> jsonView, boolean enableJaxbAnnotationModule)
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/JacksonJsonViewsenableJaxbAnnotationModule
- if it is true, will enable the JaxbAnnotationModule.public JacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper, Class<?> unmarshalType)
mapper
- the custom mapperunmarshalType
- the custom unmarshal typepublic JacksonDataFormat(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 String getDataFormatName()
getDataFormatName
in interface org.apache.camel.spi.DataFormatName
public org.apache.camel.CamelContext getCamelContext()
getCamelContext
in interface org.apache.camel.CamelContextAware
public void setCamelContext(org.apache.camel.CamelContext camelContext)
setCamelContext
in interface org.apache.camel.CamelContextAware
public void marshal(org.apache.camel.Exchange exchange, Object graph, OutputStream stream) throws Exception
marshal
in interface org.apache.camel.spi.DataFormat
Exception
public Object unmarshal(org.apache.camel.Exchange exchange, InputStream stream) throws Exception
unmarshal
in interface org.apache.camel.spi.DataFormat
Exception
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
public Class<?> getUnmarshalType()
public void setUnmarshalType(Class<?> unmarshalType)
public Class<? extends Collection> getCollectionType()
public void setCollectionType(Class<? extends Collection> collectionType)
public Class<?> getJsonView()
public void setJsonView(Class<?> jsonView)
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 boolean isEnableJaxbAnnotationModule()
public void setEnableJaxbAnnotationModule(boolean enableJaxbAnnotationModule)
public List<com.fasterxml.jackson.databind.Module> getModules()
public void setModules(List<com.fasterxml.jackson.databind.Module> modules)
Module
spublic String getModuleClassNames()
public void addModule(com.fasterxml.jackson.databind.Module module)
public void setModuleClassNames(String moduleClassNames)
Module
s 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 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 doStart() throws Exception
doStart
in class org.apache.camel.support.ServiceSupport
Exception
Apache Camel