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


Java JacksonJsonProvider.setMapper方法代码示例

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


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

示例1: HttpElasticDao

import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //导入方法依赖的package包/类
public HttpElasticDao() {

		// Registering the provider for POJO -> JSON
		final ObjectMapper mapper = new ObjectMapper();
		mapper.registerModule(new JavaTimeModule());
		final JacksonJsonProvider provider = new JacksonJsonProvider();
		provider.setMapper(mapper);
		final ClientConfig config = new ClientConfig(provider);

		// End point target root
		this.root = ClientBuilder.newClient(config).target(ELASTIC_ENDPOINT_URL);

		// Registering the provider for POJO -> NDJSON
		final ObjectMapper ndjsonMapper = new ObjectMapper();
		final SimpleModule ndjsonModule = new SimpleModule("Ndjson List Serializer");
		ndjsonModule.addSerializer(new NdjsonListSerializer());
		ndjsonModule.addSerializer(new ElasticSearchBulkApiMetaDataSerializer());
		ndjsonMapper.registerModule(ndjsonModule);
		ndjsonMapper.registerModule(new JavaTimeModule());
		final JacksonJsonProvider ndjsonProvider = new JacksonJsonProvider();
		ndjsonProvider.setMapper(ndjsonMapper);

		final ClientConfig ndjsonConfig = new ClientConfig(ndjsonProvider);

		this.bulkApiRoot = ClientBuilder.newClient(ndjsonConfig).target(ELASTIC_ENDPOINT_URL);
	}
 
开发者ID:CjHare,项目名称:systematic-trading,代码行数:27,代码来源:HttpElasticDao.java

示例2: HttpRequestService

import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //导入方法依赖的package包/类
private HttpRequestService() {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true);
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    JacksonJsonProvider provider = new JacksonJsonProvider();
    provider.setMapper(objectMapper);

    client = ClientBuilder.newClient().register(provider);
}
 
开发者ID:ser316asu,项目名称:SER316-Dresden,代码行数:11,代码来源:HttpRequestService.java

示例3: setup

import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //导入方法依赖的package包/类
public void setup() throws Exception {
  singletons.add(new InternalExceptionMapper());

  test = new JerseyTest() {
    @Override
    protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
      return new InMemoryTestContainerFactory();
    }

    @Override
    protected DeploymentContext configureDeployment() {
      final DropwizardResourceConfig resourceConfig = new DropwizardResourceConfig();

      for (Object singleton : singletons) {
        resourceConfig.register(singleton);
      }

      ServletDeploymentContext deploymentContext = ServletDeploymentContext.builder(resourceConfig)
          .initParam(ServletProperties.JAXRS_APPLICATION_CLASS, DropwizardResourceConfig.class.getName())
          .build();

      return deploymentContext;

    }

    @Override
    protected void configureClient(ClientConfig config) {
      JacksonJsonProvider jsonProvider = new JacksonJsonProvider();
      jsonProvider.setMapper(Jackson.newObjectMapper());
      config.register(jsonProvider);
    }
  };

  test.setUp();
}
 
开发者ID:zeelichsheng,项目名称:auth,代码行数:36,代码来源:ResourceTestHelper.java

示例4: ElasticSearchFacade

import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //导入方法依赖的package包/类
public ElasticSearchFacade( final ElasticSearchConfiguration elasticConfig ) {

		// Registering the provider for POJO -> JSON
		final ObjectMapper jsonMapper = new ObjectMapper();
		jsonMapper.registerModule(new JavaTimeModule());
		final JacksonJsonProvider jsonProvider = new JacksonJsonProvider();
		jsonProvider.setMapper(jsonMapper);
		final ClientConfig jsonConfig = new ClientConfig(jsonProvider);

		this.root = ClientBuilder.newClient(jsonConfig).target(elasticConfig.endpoint());

		// Registering the provider for POJO -> NDJSON
		final ObjectMapper ndjsonMapper = new ObjectMapper();
		final SimpleModule ndjsonModule = new SimpleModule("Ndjson List Serializer");
		ndjsonModule.addSerializer(new NdjsonListSerializer());
		ndjsonModule.addSerializer(new ElasticSearchBulkApiMetaDataSerializer());
		ndjsonMapper.registerModule(ndjsonModule);
		ndjsonMapper.registerModule(new JavaTimeModule());
		final JacksonJsonProvider ndjsonProvider = new JacksonJsonProvider();
		ndjsonProvider.setMapper(ndjsonMapper);

		final ClientConfig ndjsonConfig = new ClientConfig(ndjsonProvider);

		this.bulkApiRoot = ClientBuilder.newClient(ndjsonConfig).target(elasticConfig.endpoint());

		this.numberOfShards = elasticConfig.numberOfShards();
		this.numberOfReplicas = elasticConfig.numberOfReplicas();
	}
 
开发者ID:CjHare,项目名称:systematic-trading,代码行数:29,代码来源:ElasticSearchFacade.java

示例5: jacksonJsonProvider

import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //导入方法依赖的package包/类
@Provides
@Singleton
public JacksonJsonProvider jacksonJsonProvider(ObjectMapper mapper) {
    JacksonJsonProvider p = new JacksonJsonProvider();
    p.setMapper(mapper);
    return p;
}
 
开发者ID:benhardy,项目名称:lilrest,代码行数:8,代码来源:JaxRsServerModule.java

示例6: getJacksonProvider

import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //导入方法依赖的package包/类
private JacksonJsonProvider getJacksonProvider() {
    JacksonJsonProvider jacksonProvider = new JacksonJsonProvider();
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JSR310Module());
    mapper.setSerializationInclusion(Include.NON_EMPTY);
    mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    jacksonProvider.setMapper(mapper);
    return jacksonProvider;
}
 
开发者ID:antoniomaria,项目名称:gazpachoquest,代码行数:10,代码来源:ClientInterceptorTest.java

示例7: createQuestionnairResource

import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //导入方法依赖的package包/类
@Produces
@GazpachoResource
@RequestScoped
public QuestionnaireResource createQuestionnairResource(HttpServletRequest request) {
    RespondentAccount principal = (RespondentAccount) request.getUserPrincipal();
    String apiKey = principal.getApiKey();
    String secret = principal.getSecret();

    logger.info("Getting QuestionnaireResource using api key {}/{} ", apiKey, secret);

    JacksonJsonProvider jacksonProvider = new JacksonJsonProvider();
    ObjectMapper mapper = new ObjectMapper();
    // mapper.findAndRegisterModules();
    mapper.registerModule(new JSR310Module());
    mapper.setSerializationInclusion(Include.NON_EMPTY);
    mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);

    jacksonProvider.setMapper(mapper);

    QuestionnaireResource resource = JAXRSClientFactory.create(BASE_URI, QuestionnaireResource.class,
            Collections.singletonList(jacksonProvider), null);
    // proxies
    // WebClient.client(resource).header("Authorization", "GZQ " + apiKey);

    Client client = WebClient.client(resource);
    ClientConfiguration config = WebClient.getConfig(client);
    config.getOutInterceptors().add(new HmacAuthInterceptor(apiKey, secret));
    return resource;
}
 
开发者ID:antoniomaria,项目名称:gazpachoquest,代码行数:30,代码来源:ResourceProducer.java

示例8: createClient

import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //导入方法依赖的package包/类
private Client createClient() {
    JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider();
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new JodaModule());
    jacksonJsonProvider.setMapper(objectMapper);
    return ClientBuilder.newClient().register(jacksonJsonProvider);
}
 
开发者ID:pjagielski,项目名称:jersey2-starter,代码行数:8,代码来源:TodoEndpointIntegrationTest.java


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