Search in sources :

Example 11 with JacksonJaxbJsonProvider

use of com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider in project syncope by apache.

the class SyncopeClientFactoryBean method defaultJsonProvider.

protected JacksonJaxbJsonProvider defaultJsonProvider() {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new JodaModule());
    objectMapper.configure(com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    return new JacksonJaxbJsonProvider(objectMapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS);
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) JacksonJaxbJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 12 with JacksonJaxbJsonProvider

use of com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider in project incubator-pulsar by apache.

the class ProxyServer method addRestResources.

public void addRestResources(String basePath, String javaPackages, String attribute, Object attributeValue) {
    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
    provider.setMapper(ObjectMapperFactory.create());
    ResourceConfig config = new ResourceConfig();
    config.packages("jersey.config.server.provider.packages", javaPackages);
    config.register(provider);
    ServletHolder servletHolder = new ServletHolder(new ServletContainer(config));
    servletHolder.setAsyncSupported(true);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath(basePath);
    context.addServlet(servletHolder, "/*");
    context.setAttribute(attribute, attributeValue);
    handlers.add(context);
}
Also used : ServletHolder(org.eclipse.jetty.servlet.ServletHolder) ServletContainer(org.glassfish.jersey.servlet.ServletContainer) JacksonJaxbJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 13 with JacksonJaxbJsonProvider

use of com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider in project incubator-pulsar by apache.

the class WebService method addRestResources.

public void addRestResources(String basePath, String javaPackages, boolean requiresAuthentication, Map<String, Object> attributeMap) {
    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
    provider.setMapper(ObjectMapperFactory.create());
    ResourceConfig config = new ResourceConfig();
    config.packages("jersey.config.server.provider.packages", javaPackages);
    config.register(provider);
    config.register(MultiPartFeature.class);
    ServletHolder servletHolder = new ServletHolder(new ServletContainer(config));
    servletHolder.setAsyncSupported(true);
    addServlet(basePath, servletHolder, requiresAuthentication, attributeMap);
}
Also used : ServletHolder(org.eclipse.jetty.servlet.ServletHolder) ServletContainer(org.glassfish.jersey.servlet.ServletContainer) JacksonJaxbJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider) ResourceConfig(org.glassfish.jersey.server.ResourceConfig)

Example 14 with JacksonJaxbJsonProvider

use of com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider in project kylo by Teradata.

the class NiFiRestClientV1 method registerClientFeatures.

@Override
protected void registerClientFeatures(Client client) {
    JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    client.register(jacksonJsonProvider);
    client.register(JacksonFeature.class);
}
Also used : JacksonJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider) JacksonJaxbJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider)

Example 15 with JacksonJaxbJsonProvider

use of com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider in project athenz by yahoo.

the class ZMSClient method initClient.

/**
 * Initialize the client for class constructors
 *
 * @param url        ZMS Server url
 * @param sslContext SSLContext for service authentication
 */
private void initClient(String url, SSLContext sslContext) {
    if (url == null) {
        zmsUrl = lookupZMSUrl();
    } else {
        zmsUrl = url;
    }
    if (zmsUrl != null && !zmsUrl.isEmpty()) {
        if (!zmsUrl.endsWith("/zms/v1")) {
            if (zmsUrl.charAt(zmsUrl.length() - 1) != '/') {
                zmsUrl += '/';
            }
            zmsUrl += "zms/v1";
        }
    }
    /* determine our read and connect timeouts */
    int readTimeout = Integer.parseInt(System.getProperty(ZMS_CLIENT_PROP_READ_TIMEOUT, "30000"));
    int connectTimeout = Integer.parseInt(System.getProperty(ZMS_CLIENT_PROP_CONNECT_TIMEOUT, "30000"));
    if (sslContext == null) {
        sslContext = createSSLContext();
    }
    ClientBuilder builder = getClientBuilder();
    if (sslContext != null) {
        builder = builder.sslContext(sslContext);
    }
    final JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    ClientConfig clientConfig = new ClientConfig(jacksonJsonProvider);
    clientConfig.connectorProvider(new ApacheConnectorProvider());
    // JerseyClientBuilder::withConfig() replaces the existing config with the new client
    // config. Hence the client config should be added to the builder before the timeouts.
    // Otherwise the timeout settings would be overridden.
    Client rsClient = builder.withConfig(clientConfig).connectTimeout(connectTimeout, TimeUnit.MILLISECONDS).readTimeout(readTimeout, TimeUnit.MILLISECONDS).build();
    client = new ZMSRDLGeneratedClient(zmsUrl, rsClient);
}
Also used : JacksonJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider) ApacheConnectorProvider(org.glassfish.jersey.apache.connector.ApacheConnectorProvider) JacksonJaxbJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider) ClientConfig(org.glassfish.jersey.client.ClientConfig) Client(javax.ws.rs.client.Client) ClientBuilder(javax.ws.rs.client.ClientBuilder)

Aggregations

JacksonJaxbJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider)35 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 URI (java.net.URI)3 Response (javax.ws.rs.core.Response)3 JacksonJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider)2 Provides (com.google.inject.Provides)2 Singleton (com.google.inject.Singleton)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Annotation (java.lang.annotation.Annotation)2 ElementType (java.lang.annotation.ElementType)2 Retention (java.lang.annotation.Retention)2 RetentionPolicy (java.lang.annotation.RetentionPolicy)2 Target (java.lang.annotation.Target)2 Method (java.lang.reflect.Method)2 Type (java.lang.reflect.Type)2