当前位置: 首页>>代码示例>>Java>>正文


Java Environment.getObjectMapper方法代码示例

本文整理汇总了Java中io.dropwizard.setup.Environment.getObjectMapper方法的典型用法代码示例。如果您正苦于以下问题:Java Environment.getObjectMapper方法的具体用法?Java Environment.getObjectMapper怎么用?Java Environment.getObjectMapper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.dropwizard.setup.Environment的用法示例。


在下文中一共展示了Environment.getObjectMapper方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import io.dropwizard.setup.Environment; //导入方法依赖的package包/类
public void run(Configuration configuration, Environment environment) throws Exception {
  final CollectorRegistry collectorRegistry = new CollectorRegistry();
  collectorRegistry.register(new DropwizardExports(environment.metrics()));
  environment.admin()
      .addServlet("metrics", new MetricsServlet(collectorRegistry))
      .addMapping("/metrics");

  final PrometheusMetricsReporter reporter = PrometheusMetricsReporter.newMetricsReporter()
      .withCollectorRegistry(collectorRegistry)
      .withConstLabel("service", getName())
      .build();

  final Tracer tracer = getTracer();
  final Tracer metricsTracer = io.opentracing.contrib.metrics.Metrics.decorate(tracer, reporter);
  GlobalTracer.register(metricsTracer);

  final DynamicFeature tracing = new ServerTracingDynamicFeature.Builder(metricsTracer).build();
  environment.jersey().register(tracing);

  final Properties producerConfigs = new Properties();
  producerConfigs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "tweets-kafka:9092");
  producerConfigs.put(ProducerConfig.ACKS_CONFIG, "all");
  producerConfigs.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true);
  final KafkaProducer<Long, String> kafkaProducer =
      new KafkaProducer<>(producerConfigs, new LongSerializer(), new StringSerializer());
  final Producer<Long, String> tracingKafkaProducer =
      new TracingKafkaProducer<>(kafkaProducer, metricsTracer);
  final ObjectMapper objectMapper = environment.getObjectMapper();
  final TweetEventRepository tweetRepository = new KafkaTweetEventRepository(tracingKafkaProducer, objectMapper);
  final TweetsService tweetsService = new TweetsService(tweetRepository);
  final TweetsResource tweetsResource = new TweetsResource(tweetsService);
  environment.jersey().register(tweetsResource);
}
 
开发者ID:jeqo,项目名称:talk-observing-distributed-systems,代码行数:34,代码来源:WorkerServiceApplication.java

示例2: getMatchingServiceClient

import io.dropwizard.setup.Environment; //导入方法依赖的package包/类
@Provides
@Singleton
@Named("MatchingServiceClient")
public JsonClient getMatchingServiceClient(Environment environment, MatchingServiceAdapterConfiguration configuration) {
    Client matchingServiceClient = new JerseyClientBuilder(environment).using(configuration.getMatchingServiceClientConfiguration()).build("MatchingServiceClient");
    return new JsonClient(new ErrorHandlingClient(matchingServiceClient), new JsonResponseProcessor(environment.getObjectMapper()));
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:8,代码来源:MatchingServiceAdapterModule.java

示例3: run

import io.dropwizard.setup.Environment; //导入方法依赖的package包/类
public void run(final EndpointConfiguration endpointConfiguration, final Environment environment) throws Exception {
  SampleDao sampleDao = new SampleDaoImpl(environment.getObjectMapper(), endpointConfiguration.exportDirectoryPath);
  environment.jersey().register(new SampleResource(sampleDao));

  environment.healthChecks().register("samples", new SampleDaoHealthCheck(sampleDao));
}
 
开发者ID:nblair,项目名称:continuous-performance-testing,代码行数:7,代码来源:EndpointApplication.java

示例4: run

import io.dropwizard.setup.Environment; //导入方法依赖的package包/类
@Override
public void run(ServerConfiguration configuration, Environment environment) throws Exception {

    final DBIFactory factory = new DBIFactory();
    final DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "sapData");

    ObjectMapper objectMapper = environment.getObjectMapper();
    SapConfiguration sapConfiguration = configuration.getSapConfig();
    JobConfiguration jobConfiguration = configuration.getJobConfig();
    NiPingServiceBinder niPingServiceBinder = new NiPingServiceBinder(jdbi, objectMapper, sapConfiguration, jobConfiguration);

    ServiceLocator serviceLocator = ServiceLocatorUtilities.bind(niPingServiceBinder);
    SapBasicAuthenticator sapBasicAuthenticator = ServiceLocatorUtilities.getService(serviceLocator, SapBasicAuthenticator.class
            .getName());
    SapOAuthenticator sapOAuthenticator = ServiceLocatorUtilities.getService(serviceLocator, SapOAuthenticator.class.getName());

    final BasicCredentialAuthFilter basicAuthFilter = new BasicCredentialAuthFilter.Builder<BasicAuthUser>()
            .setAuthenticator(sapBasicAuthenticator)
            .buildAuthFilter();
    final AuthFilter oAuthFilter = new OAuthCredentialAuthFilter.Builder<OAuthUser>()
            .setAuthenticator(sapOAuthenticator)
            .setPrefix("Bearer")
            .buildAuthFilter();

    final PolymorphicAuthDynamicFeature feature = new PolymorphicAuthDynamicFeature<UserPrincipal>(ImmutableMap.of(BasicAuthUser
            .class, basicAuthFilter, OAuthUser.class, oAuthFilter));
    final AbstractBinder binder = new PolymorphicAuthValueFactoryProvider.Binder<>(ImmutableSet.of(BasicAuthUser.class, OAuthUser
            .class));
    environment.jersey().register(new AuthFilterDynamicBinding());
    environment.jersey().register(feature);
    environment.jersey().register(binder);

    environment.jersey().register(niPingServiceBinder);
    environment.jersey().packages("com.cloudwise.sap.niping.auth");
    environment.jersey().packages("com.cloudwise.sap.niping.service");
    environment.jersey().packages("com.cloudwise.sap.niping.dao");
    environment.jersey().packages("com.cloudwise.sap.niping.common.vo.converter");
    environment.jersey().packages("com.cloudwise.sap.niping.resource");

    environment.jersey().register(SessionFactoryProvider.class);
    environment.servlets().setSessionHandler(new SessionHandler());
}
 
开发者ID:CloudWise-OpenSource,项目名称:SAPNetworkMonitor,代码行数:43,代码来源:NiPingMonitorApplication.java

示例5: run

import io.dropwizard.setup.Environment; //导入方法依赖的package包/类
@Override
public void run(ServerConfiguration configuration, Environment environment) {
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setSchemes(new String[] { "http" });
    beanConfig.setHost("localhost:8082");
    beanConfig.setBasePath("/api/ga4gh/v1");
    beanConfig.setResourcePackage("io.swagger.server.api");
    beanConfig.setScan(true);

    final DBIFactory factory = new DBIFactory();
    final DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "derby");
    final ToolDAO toolDAO = jdbi.onDemand(ToolDAO.class);
    final ToolVersionDAO toolVersionDAO = jdbi.onDemand(ToolVersionDAO.class);
    final ToolDescriptorDAO toolDescriptorDAO = jdbi.onDemand(ToolDescriptorDAO.class);
    final ToolDockerfileDAO toolDockerfileDAO = jdbi.onDemand(ToolDockerfileDAO.class);
    final ToolTestDAO toolTestDAO = jdbi.onDemand(ToolTestDAO.class);

    String githubToken = System.getenv().getOrDefault("githubToken", configuration.getGithubToken());
    String quayioToken = System.getenv().getOrDefault("quayioToken", configuration.getQuayioToken());

    GitHubBuilder gitHubBuilder = new GitHubBuilder(githubToken);
    QuayIoBuilder quayIoBuilder = new QuayIoBuilder(quayioToken);

    try (Handle h = jdbi.open()) {
        String createdbString = configuration.getDataSourceFactory().getProperties().getOrDefault("createdb", "false");
        boolean freshStart = Boolean.valueOf(createdbString);
        if (freshStart) {
            dropTableQuietly(h, "dockerfile");
            dropTableQuietly(h, "descriptor");
            dropTableQuietly(h, "tooltest");
            dropTableQuietly(h, "toolversion");
            dropTableQuietly(h, "tool");

            toolDAO.createToolTable();
            toolVersionDAO.createToolVersionTable();
            toolDescriptorDAO.createToolDescriptorTable();
            toolDockerfileDAO.createToolDockerfileTable();
            toolTestDAO.createToolTestTable();
        }
    }

    ToolsApiServiceFactory.setToolDAO(toolDAO);
    ToolsApiServiceFactory.setToolVersionDAO(toolVersionDAO);
    ToolsApiServiceFactory.setToolDescriptorDAO(toolDescriptorDAO);
    ToolsApiServiceFactory.setToolDockerfileDAO(toolDockerfileDAO);
    ToolsApiServiceFactory.setGitHubBuilder(gitHubBuilder);
    ToolsApiServiceFactory.setQuayIoBuilder(quayIoBuilder);

    final TemplateHealthCheck healthCheck = new TemplateHealthCheck("Hello %s!");
    environment.healthChecks().register("template", healthCheck);

    environment.jersey().register(new ToolClassesApi());
    environment.jersey().register(new ToolsApi());
    environment.jersey().register(new MetadataApi());

    // extra renderers
    environment.jersey().register(new CharsetResponseFilter());

    // swagger stuff
    // Swagger providers
    environment.jersey().register(ApiListingResource.class);
    environment.jersey().register(SwaggerSerializers.class);

    final ObjectMapper mapper = environment.getObjectMapper();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    mapper.setPropertyNamingStrategy(PropertyNamingStrategy.KEBAB_CASE);

    // optional CORS support
    // Enable CORS headers
    final FilterHolder filterHolder = environment.getApplicationContext().addFilter(CrossOriginFilter.class, "/*", EnumSet.of(REQUEST));
    // Configure CORS parameters
    filterHolder.setInitParameter(ACCESS_CONTROL_ALLOW_METHODS_HEADER, "GET,POST,DELETE,PUT,OPTIONS");
    filterHolder.setInitParameter(ALLOWED_ORIGINS_PARAM, "*");
    filterHolder.setInitParameter(ALLOWED_METHODS_PARAM, "GET,POST,DELETE,PUT,OPTIONS");
    filterHolder.setInitParameter(ALLOWED_HEADERS_PARAM,
            "Authorization, X-Auth-Username, X-Auth-Password, X-Requested-With,Content-Type,Accept,Origin,Access-Control-Request-Headers,cache-control");
}
 
开发者ID:dockstore,项目名称:write_api_service,代码行数:78,代码来源:ServerApplication.java


注:本文中的io.dropwizard.setup.Environment.getObjectMapper方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。