List of usage examples for com.fasterxml.jackson.module.jaxb JaxbAnnotationModule JaxbAnnotationModule
public JaxbAnnotationModule()
From source file:com.oracle.cloud.cache.rest.JacksonMapperProvider.java
/** * Creates a default {@link ObjectMapper}. * * @return a new {@link ObjectMapper}// ww w . ja v a 2 s . c o m */ private static ObjectMapper createDefaultMapper() { final ObjectMapper mapper = new ObjectMapper(); JaxbAnnotationModule module = new JaxbAnnotationModule(); mapper.registerModule(module); mapper.configure(MapperFeature.AUTO_DETECT_FIELDS, false); mapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true); mapper.configure(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME, true); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.FAIL_ON_NUMBERS_FOR_ENUMS, true); mapper.configure(MapperFeature.USE_GETTERS_AS_SETTERS, false); mapper.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false); return mapper; }
From source file:org.excalibur.jackson.databind.JsonYamlObjectMapper.java
public JsonYamlObjectMapper() { super(new YAMLFactory()); this.configure(SerializationFeature.INDENT_OUTPUT, true); this.registerModule(new JaxbAnnotationModule()); }
From source file:org.excalibur.fm.configuration.ui.JsonJaxbObjectMapper.java
public JsonJaxbObjectMapper(boolean failureOnUnknownProperties) { this.configure(SerializationFeature.INDENT_OUTPUT, true); this.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, failureOnUnknownProperties); this.registerModule(new JaxbAnnotationModule()); }
From source file:com.codeveo.lago.bot.stomp.client.LagoJsonMessageConverter.java
public LagoJsonMessageConverter() { mapper = new ObjectMapper(); /* make serializer use JAXB annotations (only) */ JaxbAnnotationModule module = new JaxbAnnotationModule(); mapper.registerModule(module);// w w w . j a va2 s . co m mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.setSerializationInclusion(Include.NON_NULL); }
From source file:org.truelicense.v2.json.V2JsonLicenseApplicationContext.java
/** * Returns a new object mapper for use with {@linkplain #license licenses} * and {@linkplain #repositoryContext repositories}. * This method is normally only called once. * In a multi-threaded environment, it may get called more than once, but * then each invocation must return an object which behaves equivalent to * any previously returned object./* w ww.j a va 2s. co m*/ */ protected ObjectMapper newObjectMapper() { final ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT); mapper.registerModule(new JaxbAnnotationModule()); return mapper; }
From source file:io.fabric8.cxf.endpoint.JsonSchemaLookup.java
public void init() { LOG.log(Level.INFO, "Creating JsonSchemaLookup instance"); try {//w w w .ja va 2s . c om if (mapper == null) { mapper = new ObjectMapper(); mapper.setVisibility(new IgnorePropertiesBackedByTransientFields(mapper.getVisibilityChecker())); JaxbAnnotationModule module1 = new JaxbAnnotationModule(); mapper.registerModule(module1); BeanValidationAnnotationModule module2 = new BeanValidationAnnotationModule(); mapper.registerModule(module2); } // now lets expose the mbean... singleton = this; } catch (Exception e) { LOG.log(Level.WARNING, "Exception during initialization: ", e); throw new RuntimeException(e); } }
From source file:org.springframework.boot.actuate.metrics.ambari.DummyAmbariMetricWriter.java
public DummyAmbariMetricWriter(String metricsCollectorHost, String metricsCollectorPort, String applicationId, String hostName, String instanceId, int metricsBufferSize) { super(applicationId, hostName, instanceId, metricsBufferSize); JaxbAnnotationModule module = new JaxbAnnotationModule(); objectMapper = new ObjectMapper(); objectMapper.enable(SerializationFeature.INDENT_OUTPUT); objectMapper.registerModule(module); objectMapper.setSerializationInclusion(Include.NON_NULL); }
From source file:org.apache.unomi.persistence.spi.CustomObjectMapper.java
public CustomObjectMapper() { super();/*from ww w.j a va2 s . c o m*/ super.registerModule(new JaxbAnnotationModule()); configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); ISO8601DateFormat dateFormat = new ISO8601DateFormat(); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); setDateFormat(dateFormat); SimpleModule deserializerModule = new SimpleModule("PropertyTypedObjectDeserializerModule", new Version(1, 0, 0, null, "org.apache.unomi.rest", "deserializer")); PropertyTypedObjectDeserializer propertyTypedObjectDeserializer = new PropertyTypedObjectDeserializer(); propertyTypedObjectDeserializer.registerMapping("type=.*Condition", Condition.class); deserializerModule.addDeserializer(Object.class, propertyTypedObjectDeserializer); ItemDeserializer itemDeserializer = new ItemDeserializer(); deserializerModule.addDeserializer(Item.class, itemDeserializer); Map<String, Class<? extends Item>> classes = new HashMap<>(); classes.put(Campaign.ITEM_TYPE, Campaign.class); classes.put(CampaignEvent.ITEM_TYPE, CampaignEvent.class); classes.put(Event.ITEM_TYPE, Event.class); classes.put(Goal.ITEM_TYPE, Goal.class); classes.put(Persona.ITEM_TYPE, Persona.class); classes.put(Rule.ITEM_TYPE, Rule.class); classes.put(Scoring.ITEM_TYPE, Scoring.class); classes.put(Segment.ITEM_TYPE, Segment.class); classes.put(Session.ITEM_TYPE, Session.class); classes.put(ConditionType.ITEM_TYPE, ConditionType.class); classes.put(ActionType.ITEM_TYPE, ActionType.class); for (Map.Entry<String, Class<? extends Item>> entry : classes.entrySet()) { propertyTypedObjectDeserializer.registerMapping("itemType=" + entry.getKey(), entry.getValue()); itemDeserializer.registerMapping(entry.getKey(), entry.getValue()); } propertyTypedObjectDeserializer.registerMapping("itemType=.*", CustomItem.class); super.registerModule(deserializerModule); }
From source file:com.danperron.gamesdbclient.impl.GamesDBClientImpl.java
public GamesDBClientImpl(ExecutorService executorService) { xmlMapper = new XmlMapper(); xmlMapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector()); xmlMapper.registerModule(new JaxbAnnotationModule()); xmlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); this.executorService = executorService; }
From source file:edu.psu.swe.scim.server.utility.AttributeUtil.java
@PostConstruct public void init() { // TODO move this to a CDI producer objectMapper = new ObjectMapper(); JaxbAnnotationModule jaxbAnnotationModule = new JaxbAnnotationModule(); objectMapper.registerModule(jaxbAnnotationModule); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); AnnotationIntrospector jaxbIntrospector = new JaxbAnnotationIntrospector(objectMapper.getTypeFactory()); AnnotationIntrospector jacksonIntrospector = new JacksonAnnotationIntrospector(); AnnotationIntrospector pair = new AnnotationIntrospectorPair(jacksonIntrospector, jaxbIntrospector); objectMapper.setAnnotationIntrospector(pair); objectMapper.setSerializationInclusion(Include.NON_NULL); SimpleModule module = new SimpleModule(); module.addDeserializer(ScimResource.class, new ScimResourceDeserializer(this.registry, this.objectMapper)); objectMapper.registerModule(module); }