本文整理汇总了Java中io.dropwizard.setup.Environment.metrics方法的典型用法代码示例。如果您正苦于以下问题:Java Environment.metrics方法的具体用法?Java Environment.metrics怎么用?Java Environment.metrics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.dropwizard.setup.Environment
的用法示例。
在下文中一共展示了Environment.metrics方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: metricsCollector
import io.dropwizard.setup.Environment; //导入方法依赖的package包/类
@Provides
@Singleton
private IdpAssertionMetricsCollector metricsCollector(Environment environment) {
return new IdpAssertionMetricsCollector(environment.metrics());
}
示例2: metricRegistry
import io.dropwizard.setup.Environment; //导入方法依赖的package包/类
@Provides
@Singleton
public MetricRegistry metricRegistry(Environment environment) {
return environment.metrics();
}
示例3: run
import io.dropwizard.setup.Environment; //导入方法依赖的package包/类
@Override
public void run(RufusConfiguration conf, Environment env) throws Exception {
final DBIFactory factory = new DBIFactory();
final DBI jdbi = factory.build(env, conf.getDataSourceFactory(), DB_SOURCE);
final UserDao userDao = jdbi.onDemand(UserDao.class);
final ArticleDao articleDao = jdbi.onDemand(ArticleDao.class);
final FeedProcessorImpl processor = FeedProcessorImpl.newInstance(articleDao);
final FeedParser parser = new FeedParser(articleDao, processor);
final JwtConsumer jwtConsumer = new JwtConsumerBuilder()
.setAllowedClockSkewInSeconds(30)
.setRequireExpirationTime()
.setRequireSubject()
.setVerificationKey(new HmacKey(VERIFICATION_KEY))
.setRelaxVerificationKeyValidation()
.build();
final CachingJwtAuthenticator<User> cachingJwtAuthenticator = new CachingJwtAuthenticator<>(
env.metrics(),
new JwtAuthenticator(userDao),
conf.getAuthenticationCachePolicy()
);
env.jersey().register(new ArticleResource(userDao, articleDao, processor, parser));
env.jersey().register(
new UserResource(
new BasicAuthenticator(userDao),
new TokenGenerator(VERIFICATION_KEY),
userDao,
articleDao
)
);
//route source
env.jersey().setUrlPattern(ROOT_PATH);
env.jersey().register(new AuthValueFactoryProvider.Binder<>(User.class));
env.jersey().register(new AuthDynamicFeature(
new JwtAuthFilter.Builder<User>()
.setJwtConsumer(jwtConsumer)
.setRealm(REALM)
.setPrefix(BEARER)
.setAuthenticator(cachingJwtAuthenticator)
.buildAuthFilter()
));
}