Example usage for com.fasterxml.jackson.jaxrs.json JacksonJsonProvider JacksonJsonProvider

List of usage examples for com.fasterxml.jackson.jaxrs.json JacksonJsonProvider JacksonJsonProvider

Introduction

In this page you can find the example usage for com.fasterxml.jackson.jaxrs.json JacksonJsonProvider JacksonJsonProvider.

Prototype

public JacksonJsonProvider(ObjectMapper mapper, Annotations[] annotationsToUse) 

Source Link

Document

Constructor to use when a custom mapper (usually components like serializer/deserializer factories that have been configured) is to be used.

Usage

From source file:org.killbill.commons.skeleton.modules.JaxrsJacksonModule.java

@Override
protected void configure() {
    bind(JacksonJsonProvider.class).toInstance(new JacksonJsonProvider(mapper, annotationsToUse));
}

From source file:com.ning.jetty.core.modules.ServerModule.java

protected void installJackson() {
    final ObjectMapper mapper = getJacksonProvider().get();

    bind(ObjectMapper.class).toInstance(mapper);
    bind(JacksonJsonProvider.class).toInstance(
            new JacksonJsonProvider(mapper, new Annotations[] { Annotations.JACKSON, Annotations.JAXB }));
}

From source file:org.usrz.libs.httpd.handlers.RestHandlerProvider.java

@Override
protected HttpHandler get(Injector injector, Configurations configurations) {

    /* Setup our object mapper (could be qualified with path) */
    final ObjectMapper mapper = getInstance(injector, ObjectMapper.class, path);

    final Map<Class<?>, Integer> contractPriorities = new HashMap<>();
    contractPriorities.put(MessageBodyWriter.class, Integer.MIN_VALUE);
    contractPriorities.put(MessageBodyReader.class, Integer.MIN_VALUE);
    config.register(/*from   w ww .  jav  a 2 s.  c om*/
            new JacksonJsonProvider(mapper, new Annotations[] { Annotations.JACKSON, Annotations.JAXB }),
            Collections.unmodifiableMap(contractPriorities));

    /* Create a ServiceLocator parent of all locators and inject the configurations */
    final ServiceLocator locator = ServiceLocatorFactory.create(injector, path);

    /* Set up the ObjectMapper that will be used by this application */
    ServiceLocatorUtilities.addOneConstant(locator, mapper, null, ObjectMapper.class);

    /* Create a brand new Grizzly HTTP container from Jersey */
    log.debug("Jersey application at \"%s\" initializing", path.value());
    GrizzlyHttpContainer container = GrizzlyHttpContainerFactory.create(config, locator);
    log.info("Jersey application at \"%s\" initialized successfully", path.value());

    /* Create our handler and add it to our server configuration  */
    final HttpServer server = injector.getInstance(HttpServer.class);
    server.getServerConfiguration().addHttpHandler(container, path.value());
    log.info("Serving \"%s\" using Jersey application \"%s\"", path.value(), config.getApplicationName());

    /* All done! */
    return container;
}