本文整理汇总了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);
}
示例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);
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}