當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。