io.dropwizard.jersey.jackson.JacksonMessageBodyProvider Java Examples

The following examples show how to use io.dropwizard.jersey.jackson.JacksonMessageBodyProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractResourceTest.java    From monasca-common with Apache License 2.0 6 votes vote down vote up
@BeforeMethod
protected void beforeTestCase() throws Exception {
  singletons.clear();
  providers.clear();
  features.clear();
  properties.clear();
  setupResources();

  test = new JerseyTest() {
    @Override
    protected AppDescriptor configure() {
      final DropwizardResourceConfig config = DropwizardResourceConfig.forTesting(metricRegistry);
      for (Class<?> provider : providers)
        config.getClasses().add(provider);
      for (Map.Entry<String, Boolean> feature : features.entrySet())
        config.getFeatures().put(feature.getKey(), feature.getValue());
      for (Map.Entry<String, Object> property : properties.entrySet())
        config.getProperties().put(property.getKey(), property.getValue());
      config.getSingletons().add(new JacksonMessageBodyProvider(objectMapper, validator));
      config.getSingletons().addAll(singletons);
      return new LowLevelAppDescriptor.Builder(config).build();
    }
  };

  test.setUp();
}
 
Example #2
Source File: BlobStoreClientFactory.java    From emodb with Apache License 2.0 5 votes vote down vote up
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, MetricRegistry metricRegistry, String serviceName) {
    HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName);
    ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true);
    ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
    config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator()));
    return new ApacheHttpClient4(handler, config);
}
 
Example #3
Source File: PurgeDatabusEventsCommand.java    From emodb with Apache License 2.0 5 votes vote down vote up
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, MetricRegistry metricRegistry, String serviceName) {
    HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName);
    ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true);
    ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
    config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator()));
    return new ApacheHttpClient4(handler, config);
}
 
Example #4
Source File: UserAccessControlClientFactory.java    From emodb with Apache License 2.0 5 votes vote down vote up
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, String serviceName, MetricRegistry metricRegistry) {
    HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName);
    ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true);
    ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
    config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator()));
    return new ApacheHttpClient4(handler, config);
}
 
Example #5
Source File: DataStoreClientFactory.java    From emodb with Apache License 2.0 5 votes vote down vote up
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, String serviceName, MetricRegistry metricRegistry) {
    HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName);
    ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true);
    ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
    config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator()));
    return new ApacheHttpClient4(handler, config);
}
 
Example #6
Source File: QueueClientFactory.java    From emodb with Apache License 2.0 5 votes vote down vote up
static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, String serviceName, MetricRegistry metricRegistry) {
    HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName);
    ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true);
    ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
    config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator()));
    return new ApacheHttpClient4(handler, config);
}
 
Example #7
Source File: DedupQueueClientFactory.java    From emodb with Apache License 2.0 5 votes vote down vote up
static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, String serviceName, MetricRegistry metricRegistry) {
    HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName);
    ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true);
    ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
    config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator()));
    return new ApacheHttpClient4(handler, config);
}
 
Example #8
Source File: DatabusClientFactory.java    From emodb with Apache License 2.0 5 votes vote down vote up
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, MetricRegistry metricRegistry, String serviceName) {
    HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName);
    ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true);
    ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
    config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator()));
    return new ApacheHttpClient4(handler, config);
}
 
Example #9
Source File: SoaBundle.java    From soabase with Apache License 2.0 5 votes vote down vote up
private void initJerseyAdmin(SoaConfiguration configuration, SoaFeaturesImpl features, Ports ports, final Environment environment, AbstractBinder binder)
{
    if ( (configuration.getAdminJerseyPath() == null) || !ports.adminPort.hasPort() )
    {
        return;
    }

    String jerseyRootPath = configuration.getAdminJerseyPath();
    if ( !jerseyRootPath.endsWith("/*") )
    {
        if ( jerseyRootPath.endsWith("/") )
        {
            jerseyRootPath += "*";
        }
        else
        {
            jerseyRootPath += "/*";
        }
    }

    DropwizardResourceConfig jerseyConfig = new DropwizardResourceConfig(environment.metrics());
    jerseyConfig.setUrlPattern(jerseyRootPath);

    JerseyContainerHolder jerseyServletContainer = new JerseyContainerHolder(new ServletContainer(jerseyConfig));
    environment.admin().addServlet("soa-admin-jersey", jerseyServletContainer.getContainer()).addMapping(jerseyRootPath);

    JerseyEnvironment jerseyEnvironment = new JerseyEnvironment(jerseyServletContainer, jerseyConfig);
    features.putNamed(jerseyEnvironment, JerseyEnvironment.class, SoaFeatures.ADMIN_NAME);
    jerseyEnvironment.register(SoaApis.class);
    jerseyEnvironment.register(DiscoveryApis.class);
    jerseyEnvironment.register(DynamicAttributeApis.class);
    jerseyEnvironment.register(LoggingApis.class);
    jerseyEnvironment.register(binder);
    jerseyEnvironment.setUrlPattern(jerseyConfig.getUrlPattern());
    jerseyEnvironment.register(new JacksonMessageBodyProvider(environment.getObjectMapper()));

    checkCorsFilter(configuration, environment.admin());
    checkAdminGuiceFeature(environment, jerseyEnvironment);
}