本文整理汇总了Java中io.dropwizard.jersey.jackson.JacksonMessageBodyProvider类的典型用法代码示例。如果您正苦于以下问题:Java JacksonMessageBodyProvider类的具体用法?Java JacksonMessageBodyProvider怎么用?Java JacksonMessageBodyProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JacksonMessageBodyProvider类属于io.dropwizard.jersey.jackson包,在下文中一共展示了JacksonMessageBodyProvider类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: run
import io.dropwizard.jersey.jackson.JacksonMessageBodyProvider; //导入依赖的package包/类
@Override
public void run(CoreServiceConfig t, Environment e) throws Exception {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(CoreOAuth2ServiceLoader.class);
ctx.registerShutdownHook();
ctx.start();
e.jersey().register(new JacksonMessageBodyProvider(new GPJacksonSupport().getDefaultMapper()));
e.jersey().register(new OAuth2ExceptionProvider());
e.jersey().register(new AuthDynamicFeature(
new OAuthCredentialAuthFilter.Builder<GPAuthenticatedPrincipal>()
.setAuthenticator(new CoreOAuthAuthenticator(t))
.setPrefix("Bearer")
.buildAuthFilter()));
e.jersey().register(RolesAllowedDynamicFeature.class);
e.jersey().register(new AuthValueFactoryProvider.Binder<>(Principal.class));
e.healthChecks().register("service-health-check",
new CoreServiceHealthCheck());
Map<String, Object> resources = ctx.getBeansWithAnnotation(Path.class);
for (Map.Entry<String, Object> entry : resources.entrySet()) {
e.jersey().register(entry.getValue());
}
}
开发者ID:geosdi,项目名称:geoplatform-oauth2-extensions,代码行数:27,代码来源:CoreServiceApp.java
示例2: beforeTestCase
import io.dropwizard.jersey.jackson.JacksonMessageBodyProvider; //导入依赖的package包/类
@BeforeMethod
protected void beforeTestCase() throws Exception {
singletons.clear();
providers.clear();
features.clear();
properties.clear();
setupResources();
test = new JerseyTest() {
@Override
protected AppDescriptor configure() {
final DropwizardResourceConfig config = DropwizardResourceConfig.forTesting(metricRegistry);
for (Class<?> provider : providers)
config.getClasses().add(provider);
for (Map.Entry<String, Boolean> feature : features.entrySet())
config.getFeatures().put(feature.getKey(), feature.getValue());
for (Map.Entry<String, Object> property : properties.entrySet())
config.getProperties().put(property.getKey(), property.getValue());
config.getSingletons().add(new JacksonMessageBodyProvider(objectMapper, validator));
config.getSingletons().addAll(singletons);
return new LowLevelAppDescriptor.Builder(config).build();
}
};
test.setUp();
}
开发者ID:openstack,项目名称:monasca-common,代码行数:27,代码来源:AbstractResourceTest.java
示例3: RestClient
import io.dropwizard.jersey.jackson.JacksonMessageBodyProvider; //导入依赖的package包/类
public RestClient (URI baseURI)
{
ObjectMapper mapper = Jackson.newObjectMapper ()
.registerModule (new SupernodeModule ());
Validator validator = Validation.buildDefaultValidatorFactory ().getValidator ();
ClientConfig cc = new DefaultClientConfig (JsonProcessingExceptionMapper.class);
cc.getProperties ().put (ClientConfig.PROPERTY_CONNECT_TIMEOUT, 5000);
cc.getProperties ().put (ClientConfig.PROPERTY_READ_TIMEOUT, 5000);
cc.getSingletons ().add (new JacksonMessageBodyProvider (mapper, validator));
Client client = Client.create (cc);
client.addFilter (new LoggingFilter ());
this.client = client;
this.baseURI = baseURI;
}
开发者ID:bitsofproof,项目名称:btc1k,代码行数:19,代码来源:RestClient.java
示例4: createDefaultJerseyClient
import io.dropwizard.jersey.jackson.JacksonMessageBodyProvider; //导入依赖的package包/类
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);
}
开发者ID:bazaarvoice,项目名称:emodb,代码行数:8,代码来源:BlobStoreClientFactory.java
示例5: createDefaultJerseyClient
import io.dropwizard.jersey.jackson.JacksonMessageBodyProvider; //导入依赖的package包/类
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);
}
开发者ID:bazaarvoice,项目名称:emodb,代码行数:8,代码来源:UserAccessControlClientFactory.java
示例6: createDefaultJerseyClient
import io.dropwizard.jersey.jackson.JacksonMessageBodyProvider; //导入依赖的package包/类
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);
}
开发者ID:bazaarvoice,项目名称:emodb,代码行数:8,代码来源:QueueClientFactory.java
示例7: initJerseyAdmin
import io.dropwizard.jersey.jackson.JacksonMessageBodyProvider; //导入依赖的package包/类
private void initJerseyAdmin(SoaConfiguration configuration, SoaFeaturesImpl features, Ports ports, final Environment environment, AbstractBinder binder)
{
if ( (configuration.getAdminJerseyPath() == null) || !ports.adminPort.hasPort() )
{
return;
}
String jerseyRootPath = configuration.getAdminJerseyPath();
if ( !jerseyRootPath.endsWith("/*") )
{
if ( jerseyRootPath.endsWith("/") )
{
jerseyRootPath += "*";
}
else
{
jerseyRootPath += "/*";
}
}
DropwizardResourceConfig jerseyConfig = new DropwizardResourceConfig(environment.metrics());
jerseyConfig.setUrlPattern(jerseyRootPath);
JerseyContainerHolder jerseyServletContainer = new JerseyContainerHolder(new ServletContainer(jerseyConfig));
environment.admin().addServlet("soa-admin-jersey", jerseyServletContainer.getContainer()).addMapping(jerseyRootPath);
JerseyEnvironment jerseyEnvironment = new JerseyEnvironment(jerseyServletContainer, jerseyConfig);
features.putNamed(jerseyEnvironment, JerseyEnvironment.class, SoaFeatures.ADMIN_NAME);
jerseyEnvironment.register(SoaApis.class);
jerseyEnvironment.register(DiscoveryApis.class);
jerseyEnvironment.register(DynamicAttributeApis.class);
jerseyEnvironment.register(LoggingApis.class);
jerseyEnvironment.register(binder);
jerseyEnvironment.setUrlPattern(jerseyConfig.getUrlPattern());
jerseyEnvironment.register(new JacksonMessageBodyProvider(environment.getObjectMapper()));
checkCorsFilter(configuration, environment.admin());
checkAdminGuiceFeature(environment, jerseyEnvironment);
}
开发者ID:soabase,项目名称:soabase,代码行数:40,代码来源:SoaBundle.java
示例8: configure
import io.dropwizard.jersey.jackson.JacksonMessageBodyProvider; //导入依赖的package包/类
@Override
protected Application configure() {
this.forceSet(TestProperties.CONTAINER_PORT, "0");
final MetricRegistry metricRegistry = new MetricRegistry();
final SessionFactoryFactory factory = new SessionFactoryFactory();
final DataSourceFactory dbConfig = new DataSourceFactory();
this.bundle = mock(RemoteCredentialHibernateBundle.class);
final SessionHolders sessionHolders = mock(SessionHolders.class);
when(this.bundle.getSessionHolders()).thenReturn(sessionHolders);
final Environment environment = mock(Environment.class);
final LifecycleEnvironment lifecycleEnvironment = mock(LifecycleEnvironment.class);
when(environment.lifecycle()).thenReturn(lifecycleEnvironment);
when(environment.metrics()).thenReturn(metricRegistry);
dbConfig.setUrl("jdbc:hsqldb:mem:DbTest-" + System.nanoTime()
+ "?hsqldb.translate_dti_types=false");
dbConfig.setUser("sa");
dbConfig.setDriverClass("org.hsqldb.jdbcDriver");
dbConfig.setValidationQuery("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS");
this.sessionFactory = factory.build(this.bundle,
environment,
dbConfig,
ImmutableList.<Class<?>> of(Person.class),
RemoteCredentialHibernateBundle.DEFAULT_NAME);
when(this.bundle.getSessionFactory()).thenReturn(this.sessionFactory);
when(this.bundle.getCurrentThreadSessionFactory()).thenReturn(this.sessionFactory);
final Session session = this.sessionFactory.openSession();
try {
session.createSQLQuery("DROP TABLE people IF EXISTS").executeUpdate();
session.createSQLQuery(
"CREATE TABLE people (name varchar(100) primary key, email varchar(16), birthday timestamp with time zone)")
.executeUpdate();
session.createSQLQuery(
"INSERT INTO people VALUES ('Coda', '[email protected]', '1979-01-02 00:22:00+0:00')")
.executeUpdate();
} finally {
session.close();
}
final DropwizardResourceConfig config = DropwizardResourceConfig
.forTesting(new MetricRegistry());
config.register(new UnitOfWorkApplicationListener("hr-db", this.bundle));
config.register(new PersonResource(new PersonDAO(this.bundle)));
config.register(new JacksonMessageBodyProvider(Jackson.newObjectMapper(),
Validators.newValidator()));
config.register(new DataExceptionMapper());
return config;
}
开发者ID:mtakaki,项目名称:CredentialStorageService-dw-hibernate,代码行数:55,代码来源:JerseyIntegrationTest.java
示例9: configureClient
import io.dropwizard.jersey.jackson.JacksonMessageBodyProvider; //导入依赖的package包/类
@Override
protected void configureClient(final ClientConfig config) {
config.register(new JacksonMessageBodyProvider(Jackson.newObjectMapper(),
Validators.newValidator()));
}
开发者ID:mtakaki,项目名称:CredentialStorageService-dw-hibernate,代码行数:6,代码来源:JerseyIntegrationTest.java
示例10: configureClient
import io.dropwizard.jersey.jackson.JacksonMessageBodyProvider; //导入依赖的package包/类
@Override
protected void configureClient(ClientConfig config) {
config.register(new JacksonMessageBodyProvider(Jackson.newObjectMapper(),
Validation.buildDefaultValidatorFactory().getValidator()));
}
开发者ID:tbugrara,项目名称:dropwizard-jooq,代码行数:6,代码来源:ExampleResourceTest.java
示例11: configure
import io.dropwizard.jersey.jackson.JacksonMessageBodyProvider; //导入依赖的package包/类
@Override
protected Application configure() {
final MetricRegistry metricRegistry = new MetricRegistry();
final DataSourceFactory dbConfig = new DataSourceFactory();
final Environment environment = mock(Environment.class);
final LifecycleEnvironment lifecycleEnvironment = mock(LifecycleEnvironment.class);
when(environment.lifecycle()).thenReturn(lifecycleEnvironment);
when(environment.metrics()).thenReturn(metricRegistry);
String url = "jdbc:hsqldb:mem:dwtest" + System.nanoTime();
Map<String, String> props = new HashMap<String, String>();
props.put("username", "sa");
props.put("password", "");
props.put("url", url);
try {
HSQLDBInit.initPublic(props);
} catch (Exception e) {
throw new RuntimeException(e);
}
dbConfig.setUrl(props.get("url"));
dbConfig.setUser(props.get("user"));
dbConfig.setDriverClass("org.hsqldb.jdbcDriver");
dbConfig.setValidationQuery("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS");
final DropwizardResourceConfig config = DropwizardResourceConfig.forTesting(new MetricRegistry());
DataSource dataSource = dbConfig.build(metricRegistry, "jooq");
config.register(JooqTransactionalApplicationListener.class);
Configuration configuration = new DefaultConfiguration().set(SQLDialect.HSQLDB);
configuration.set(new DataSourceConnectionProvider(dataSource));
config.register(new ConfigurationFactoryProvider.Binder(configuration, dataSource,
new TestTenantConnectionProvider(dbConfig, metricRegistry, url)));
config.register(ExampleResource.class);
config.register(new JacksonMessageBodyProvider(Jackson.newObjectMapper(),
Validation.buildDefaultValidatorFactory().getValidator()));
return config;
}
开发者ID:tbugrara,项目名称:dropwizard-jooq,代码行数:43,代码来源:ExampleResourceTest.java
注:本文中的io.dropwizard.jersey.jackson.JacksonMessageBodyProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论