use of com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule in project CFLint by cflint.
the class ConfigUtils method unmarshalJson.
public static <E> E unmarshalJson(final Reader reader, final Class<E> expectedClass) throws IOException {
final ObjectMapper objectMapper = new ObjectMapper();
final JaxbAnnotationModule module = new JaxbAnnotationModule();
objectMapper.registerModule(module);
return objectMapper.readValue(reader, expectedClass);
}
use of com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule in project camel by apache.
the class JacksonXMLDataFormat method doStart.
@Override
protected void doStart() throws Exception {
if (xmlMapper == null) {
xmlMapper = new XmlMapper();
}
if (enableJaxbAnnotationModule) {
// Enables JAXB processing
JaxbAnnotationModule module = new JaxbAnnotationModule();
LOG.info("Registering module: {}", module);
xmlMapper.registerModule(module);
}
if (useList) {
setCollectionType(ArrayList.class);
}
if (include != null) {
JsonInclude.Include inc = getCamelContext().getTypeConverter().mandatoryConvertTo(JsonInclude.Include.class, include);
xmlMapper.setSerializationInclusion(inc);
}
if (prettyPrint) {
xmlMapper.enable(SerializationFeature.INDENT_OUTPUT);
}
if (enableFeatures != null) {
Iterator<Object> it = ObjectHelper.createIterator(enableFeatures);
while (it.hasNext()) {
String enable = it.next().toString();
// it can be different kind
SerializationFeature sf = getCamelContext().getTypeConverter().tryConvertTo(SerializationFeature.class, enable);
if (sf != null) {
xmlMapper.enable(sf);
continue;
}
DeserializationFeature df = getCamelContext().getTypeConverter().tryConvertTo(DeserializationFeature.class, enable);
if (df != null) {
xmlMapper.enable(df);
continue;
}
MapperFeature mf = getCamelContext().getTypeConverter().tryConvertTo(MapperFeature.class, enable);
if (mf != null) {
xmlMapper.enable(mf);
continue;
}
throw new IllegalArgumentException("Enable feature: " + enable + " cannot be converted to an accepted enum of types [SerializationFeature,DeserializationFeature,MapperFeature]");
}
}
if (disableFeatures != null) {
Iterator<Object> it = ObjectHelper.createIterator(disableFeatures);
while (it.hasNext()) {
String disable = it.next().toString();
// it can be different kind
SerializationFeature sf = getCamelContext().getTypeConverter().tryConvertTo(SerializationFeature.class, disable);
if (sf != null) {
xmlMapper.disable(sf);
continue;
}
DeserializationFeature df = getCamelContext().getTypeConverter().tryConvertTo(DeserializationFeature.class, disable);
if (df != null) {
xmlMapper.disable(df);
continue;
}
MapperFeature mf = getCamelContext().getTypeConverter().tryConvertTo(MapperFeature.class, disable);
if (mf != null) {
xmlMapper.disable(mf);
continue;
}
throw new IllegalArgumentException("Disable feature: " + disable + " cannot be converted to an accepted enum of types [SerializationFeature,DeserializationFeature,MapperFeature]");
}
}
if (modules != null) {
for (Module module : modules) {
LOG.info("Registering module: {}", module);
xmlMapper.registerModules(module);
}
}
if (moduleClassNames != null) {
Iterable<Object> it = ObjectHelper.createIterable(moduleClassNames);
for (Object o : it) {
String name = o.toString();
Class<Module> clazz = camelContext.getClassResolver().resolveMandatoryClass(name, Module.class);
Module module = camelContext.getInjector().newInstance(clazz);
LOG.info("Registering module: {} -> {}", name, module);
xmlMapper.registerModule(module);
}
}
if (moduleRefs != null) {
Iterable<Object> it = ObjectHelper.createIterable(moduleRefs);
for (Object o : it) {
String name = o.toString();
if (name.startsWith("#")) {
name = name.substring(1);
}
Module module = CamelContextHelper.mandatoryLookup(camelContext, name, Module.class);
LOG.info("Registering module: {} -> {}", name, module);
xmlMapper.registerModule(module);
}
}
}
use of com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule in project camel by apache.
the class JacksonDataFormat method doStart.
@Override
protected void doStart() throws Exception {
if (objectMapper == null) {
objectMapper = new ObjectMapper();
}
if (enableJaxbAnnotationModule) {
// Enables JAXB processing
JaxbAnnotationModule module = new JaxbAnnotationModule();
LOG.debug("Registering JaxbAnnotationModule: {}", module);
objectMapper.registerModule(module);
}
if (useList) {
setCollectionType(ArrayList.class);
}
if (include != null) {
JsonInclude.Include inc = getCamelContext().getTypeConverter().mandatoryConvertTo(JsonInclude.Include.class, include);
objectMapper.setSerializationInclusion(inc);
}
if (prettyPrint) {
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
}
if (enableFeatures != null) {
Iterator<Object> it = ObjectHelper.createIterator(enableFeatures);
while (it.hasNext()) {
String enable = it.next().toString();
// it can be different kind
SerializationFeature sf = getCamelContext().getTypeConverter().tryConvertTo(SerializationFeature.class, enable);
if (sf != null) {
objectMapper.enable(sf);
continue;
}
DeserializationFeature df = getCamelContext().getTypeConverter().tryConvertTo(DeserializationFeature.class, enable);
if (df != null) {
objectMapper.enable(df);
continue;
}
MapperFeature mf = getCamelContext().getTypeConverter().tryConvertTo(MapperFeature.class, enable);
if (mf != null) {
objectMapper.enable(mf);
continue;
}
throw new IllegalArgumentException("Enable feature: " + enable + " cannot be converted to an accepted enum of types [SerializationFeature,DeserializationFeature,MapperFeature]");
}
}
if (disableFeatures != null) {
Iterator<Object> it = ObjectHelper.createIterator(disableFeatures);
while (it.hasNext()) {
String disable = it.next().toString();
// it can be different kind
SerializationFeature sf = getCamelContext().getTypeConverter().tryConvertTo(SerializationFeature.class, disable);
if (sf != null) {
objectMapper.disable(sf);
continue;
}
DeserializationFeature df = getCamelContext().getTypeConverter().tryConvertTo(DeserializationFeature.class, disable);
if (df != null) {
objectMapper.disable(df);
continue;
}
MapperFeature mf = getCamelContext().getTypeConverter().tryConvertTo(MapperFeature.class, disable);
if (mf != null) {
objectMapper.disable(mf);
continue;
}
throw new IllegalArgumentException("Disable feature: " + disable + " cannot be converted to an accepted enum of types [SerializationFeature,DeserializationFeature,MapperFeature]");
}
}
if (modules != null) {
for (Module module : modules) {
LOG.debug("Registering module: {}", module);
objectMapper.registerModules(module);
}
}
if (moduleClassNames != null) {
Iterable<Object> it = ObjectHelper.createIterable(moduleClassNames);
for (Object o : it) {
String name = o.toString();
Class<Module> clazz = camelContext.getClassResolver().resolveMandatoryClass(name, Module.class);
Module module = camelContext.getInjector().newInstance(clazz);
LOG.debug("Registering module: {} -> {}", name, module);
objectMapper.registerModule(module);
}
}
if (moduleRefs != null) {
Iterable<Object> it = ObjectHelper.createIterable(moduleRefs);
for (Object o : it) {
String name = o.toString();
if (name.startsWith("#")) {
name = name.substring(1);
}
Module module = CamelContextHelper.mandatoryLookup(camelContext, name, Module.class);
LOG.debug("Registering module: {} -> {}", name, module);
objectMapper.registerModule(module);
}
}
}
use of com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule in project ORCID-Source by ORCID.
the class MemberSwaggerResource method scan.
/**
* Scan the classes and add in the OAuth information
*/
@Override
protected synchronized Swagger scan(Application app) {
// tell swagger to pick up our jaxb annotations
Json.mapper().registerModule(new JaxbAnnotationModule());
Swagger s = super.scan(app);
OAuth2Definition oauth = new OAuth2Definition();
oauth.accessCode(this.authEndPoint, this.tokenEndPoint);
oauth.scope(ScopePathType.READ_LIMITED.value(), "Read Limited record");
oauth.scope(ScopePathType.PERSON_UPDATE.value(), "Update person");
oauth.scope(ScopePathType.ACTIVITIES_UPDATE.value(), "Update activities");
s.securityDefinition("orcid_auth", oauth);
OAuth2Definition oauthTwoLegs = new OAuth2Definition();
oauthTwoLegs.application(this.tokenEndPoint);
oauthTwoLegs.scope(ScopePathType.PREMIUM_NOTIFICATION.value(), "Notifications");
oauthTwoLegs.scope(ScopePathType.READ_PUBLIC.value(), "Read Public record");
oauthTwoLegs.scope(ScopePathType.GROUP_ID_RECORD_READ.value(), "Read groups");
oauthTwoLegs.scope(ScopePathType.GROUP_ID_RECORD_UPDATE.value(), "Update groups");
s.securityDefinition("orcid_two_legs", oauthTwoLegs);
return s;
}
use of com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule in project minijax by minijax.
the class Json method getObjectMapper.
public static ObjectMapper getObjectMapper() {
if (instance == null) {
instance = new ObjectMapper();
instance.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
instance.setSerializationInclusion(Include.NON_NULL);
instance.registerModule(new JaxbAnnotationModule());
instance.registerModule(new JavaTimeModule());
instance.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
instance.registerModule(new AfterburnerModule());
}
return instance;
}
Aggregations