Example usage for com.fasterxml.jackson.dataformat.xml XmlMapper disable

List of usage examples for com.fasterxml.jackson.dataformat.xml XmlMapper disable

Introduction

In this page you can find the example usage for com.fasterxml.jackson.dataformat.xml XmlMapper disable.

Prototype

public ObjectMapper disable(FromXmlParser.Feature f) 

Source Link

Usage

From source file:com.ning.billing.recurly.model.RecurlyObject.java

public static XmlMapper newXmlMapper() {
    final XmlMapper xmlMapper = new XmlMapper();
    xmlMapper.setSerializerProvider(new RecurlyXmlSerializerProvider());
    final AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
    final AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
    final AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary);
    xmlMapper.setAnnotationIntrospector(pair);
    xmlMapper.registerModule(new JodaModule());
    xmlMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

    final SimpleModule m = new SimpleModule("module", new Version(1, 0, 0, null, null, null));
    m.addSerializer(Accounts.class, new RecurlyObjectsSerializer<Accounts, Account>(Accounts.class, "account"));
    m.addSerializer(AddOns.class, new RecurlyObjectsSerializer<AddOns, AddOn>(AddOns.class, "add_on"));
    m.addSerializer(Adjustments.class,
            new RecurlyObjectsSerializer<Adjustments, Adjustment>(Adjustments.class, "adjustment"));
    m.addSerializer(Coupons.class, new RecurlyObjectsSerializer<Coupons, Coupon>(Coupons.class, "coupon"));
    m.addSerializer(Invoices.class, new RecurlyObjectsSerializer<Invoices, Invoice>(Invoices.class, "invoice"));
    m.addSerializer(Plans.class, new RecurlyObjectsSerializer<Plans, Plan>(Plans.class, "plan"));
    m.addSerializer(RecurlyErrors.class,
            new RecurlyObjectsSerializer<RecurlyErrors, RecurlyError>(RecurlyErrors.class, "error"));
    m.addSerializer(SubscriptionAddOns.class,
            new RecurlyObjectsSerializer<SubscriptionAddOns, SubscriptionAddOn>(SubscriptionAddOns.class,
                    "subscription_add_on"));
    m.addSerializer(Subscriptions.class,
            new RecurlyObjectsSerializer<Subscriptions, Subscription>(Subscriptions.class, "subscription"));
    m.addSerializer(Transactions.class,
            new RecurlyObjectsSerializer<Transactions, Transaction>(Transactions.class, "transaction"));
    xmlMapper.registerModule(m);/*from ww w .  java  2s.co  m*/

    return xmlMapper;
}

From source file:org.wisdom.content.jackson.JacksonSingleton.java

private void applyMapperConfiguration(ObjectMapper mapper, XmlMapper xml) {
    Configuration conf = null;/*from   ww  w .j  av a 2  s .  c  o m*/

    // Check for test.
    if (configuration != null) {
        conf = configuration.getConfiguration("jackson");
    }

    if (conf == null) {
        LOGGER.info("Using default (Wisdom) configuration of Jackson");
        LOGGER.info("FAIL_ON_UNKNOWN_PROPERTIES is disabled");
        mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
        xml.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    } else {
        LOGGER.info("Applying custom configuration on Jackson mapper");
        Set<String> keys = conf.asMap().keySet();
        for (String key : keys) {
            setFeature(mapper, xml, key, conf.getBoolean(key));
        }
    }
}