本文整理了Java中io.dropwizard.jackson.Jackson.newObjectMapper()
方法的一些代码示例,展示了Jackson.newObjectMapper()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jackson.newObjectMapper()
方法的具体详情如下:
包路径:io.dropwizard.jackson.Jackson
类名称:Jackson
方法名:newObjectMapper
[英]Creates a new ObjectMapper with Guava, Logback, and Joda Time support, as well as support for JsonSnakeCase. Also includes all Discoverable interface implementations.
[中]创建一个新的ObjectMapper,它支持Guava、Logback和Joda时间,并支持JsonSnakeCase。还包括所有可发现的接口实现。
代码示例来源:origin: dropwizard/dropwizard
@SuppressWarnings("unchecked")
public POJOConfigurationFactory(C cfg) {
super((Class<C>) cfg.getClass(), null, Jackson.newObjectMapper(), "dw");
configuration = cfg;
}
代码示例来源:origin: dropwizard/dropwizard
/**
* Creates a new {@link Bootstrap} for the given application.
*
* @param application a Dropwizard {@link Application}
*/
public Bootstrap(Application<T> application) {
this.application = application;
this.objectMapper = Jackson.newObjectMapper();
this.configuredBundles = new ArrayList<>();
this.commands = new ArrayList<>();
this.validatorFactory = Validators.newValidatorFactory();
this.metricRegistry = new MetricRegistry();
this.configurationSourceProvider = new FileConfigurationSourceProvider();
this.classLoader = Thread.currentThread().getContextClassLoader();
this.configurationFactoryFactory = new DefaultConfigurationFactoryFactory<>();
this.healthCheckRegistry = new HealthCheckRegistry();
}
代码示例来源:origin: dropwizard/dropwizard
protected JsonFormatter createDropwizardJsonFormatter() {
return new JsonFormatter(Jackson.newObjectMapper(), isPrettyPrint(), isAppendLineSeparator());
}
代码示例来源:origin: spotify/helios
protected static Environment createEnvironment(final String name) {
final Validator validator = Validation
.byProvider(HibernateValidator.class)
.configure()
.addValidatedValueHandler(new OptionalValidatedValueUnwrapper())
.buildValidatorFactory()
.getValidator();
return new Environment(name,
Jackson.newObjectMapper(),
validator,
new MetricRegistry(),
Thread.currentThread().getContextClassLoader());
}
代码示例来源:origin: dropwizard/dropwizard
configuration = Jackson.newObjectMapper().treeToValue(jsonNode, LoggerConfiguration.class);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException("Wrong format of logger '" + entry.getKey() + "'", e);
代码示例来源:origin: io.dropwizard/dropwizard-core
/**
* Creates a new {@link Bootstrap} for the given application.
*
* @param application a Dropwizard {@link Application}
*/
public Bootstrap(Application<T> application) {
this.application = application;
this.objectMapper = Jackson.newObjectMapper();
this.bundles = new ArrayList<>();
this.configuredBundles = new ArrayList<>();
this.commands = new ArrayList<>();
this.validatorFactory = Validators.newValidatorFactory();
this.metricRegistry = new MetricRegistry();
this.configurationSourceProvider = new FileConfigurationSourceProvider();
this.classLoader = Thread.currentThread().getContextClassLoader();
this.configurationFactoryFactory = new DefaultConfigurationFactoryFactory<>();
this.healthCheckRegistry = new HealthCheckRegistry();
}
代码示例来源:origin: HubSpot/Singularity
@Test
public void testSingularityTaskIdSerialization() throws Exception {
ObjectMapper om = Jackson.newObjectMapper()
.setSerializationInclusion(Include.NON_NULL)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.registerModule(new ProtobufModule());
SingularityTaskId taskId = new SingularityTaskId("rid", "did", 100, 1, "host", "rack");
String id = taskId.getId();
SingularityTaskId fromId = SingularityTaskId.valueOf(id);
SingularityTaskId fromJson = om.readValue(om.writeValueAsBytes(taskId), SingularityTaskId.class);
assertEquals(taskId, fromId);
assertEquals(taskId, fromJson);
assertEquals(fromId, fromJson);
}
代码示例来源:origin: io.dropwizard/dropwizard-testing
@SuppressWarnings("unchecked")
public POJOConfigurationFactory(C cfg) {
super((Class<C>) cfg.getClass(), null, Jackson.newObjectMapper(), "dw");
configuration = cfg;
}
代码示例来源:origin: org.sonatype.goodies.dropwizard/dropwizard-support-client
/**
* Create default (lax) {@link ObjectMapper} for clients.
*
* To override see {@link ClientCustomizer}.
*/
public static ObjectMapper createObjectMapper() {
ObjectMapper objectMapper = Jackson.newObjectMapper();
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return objectMapper;
}
}
代码示例来源:origin: com.hubspot/BlazarData
private ObjectMapper buildObjectMapper() {
return Jackson.newObjectMapper()
.registerModule(new ProtobufModule())
.setSerializationInclusion(Include.NON_NULL)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
}
代码示例来源:origin: com.bazaarvoice.emodb/emodb-blob-client
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);
}
代码示例来源:origin: bazaarvoice/emodb
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);
}
代码示例来源:origin: com.bazaarvoice.emodb/emodb-sor-client
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);
}
代码示例来源:origin: bazaarvoice/emodb
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);
}
代码示例来源:origin: bazaarvoice/emodb
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);
}
代码示例来源:origin: bazaarvoice/emodb
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);
}
代码示例来源:origin: bazaarvoice/emodb
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);
}
}
代码示例来源:origin: bazaarvoice/emodb
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);
}
代码示例来源:origin: com.hubspot.dropwizard/dropwizard-guicier
@Before
public void setUp() throws Exception {
ObjectMapper objectMapper = Jackson.newObjectMapper();
environment = new Environment("test env", objectMapper, null, new MetricRegistry(), null);
guiceBundle = GuiceBundle.defaultBuilder(Configuration.class)
.modules(new TestModule())
.build();
Bootstrap bootstrap = mock(Bootstrap.class);
when(bootstrap.getObjectMapper()).thenReturn(objectMapper);
guiceBundle.initialize(bootstrap);
guiceBundle.run(new Configuration(), environment);
}
代码示例来源:origin: com.hubspot.dropwizard/dropwizard-guice
@Before
public void setUp() {
//given
environment = new Environment("test env", Jackson.newObjectMapper(), null, new MetricRegistry(), null);
guiceBundle = GuiceBundle.newBuilder()
.addModule(new TestModule())
.build();
Bootstrap bootstrap = mock(Bootstrap.class);
guiceBundle.initialize(bootstrap);
guiceBundle.run(new Configuration(), environment);
}
内容来源于网络,如有侵权,请联系作者删除!