本文整理汇总了Java中com.yammer.dropwizard.config.Environment.manage方法的典型用法代码示例。如果您正苦于以下问题:Java Environment.manage方法的具体用法?Java Environment.manage怎么用?Java Environment.manage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.yammer.dropwizard.config.Environment
的用法示例。
在下文中一共展示了Environment.manage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(T configuration, Environment environment) throws Exception {
JedisConfiguration conf = getJedisConfiguration(configuration);
jedisPoolConfig = conf.poolConfig;
jedisPool = new JedisPool(jedisPoolConfig, conf.getHost(), conf.getPort());
environment.addHealthCheck(new JedisPoolHealthCheck("jedis-pool", jedisPool));
environment.manage(new Managed() {
@Override
public void start() throws Exception {
}
@Override
public void stop() throws Exception {
jedisPool.destroy();
}
});
environment.addProvider(new JedisPoolProvider(jedisPool));
}
示例2: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(KayVeeConfiguration configuration, Environment environment) throws Exception {
// create the local store
LocalStore localStore = new LocalStore();
// create and setup the distributed store
RaftConfiguration raftConfiguration = createRaftConfiguration(configuration);
DistributedStore distributedStore = new DistributedStore(localStore);
RaftAgent raftAgent = RaftAgent.fromConfigurationObject(raftConfiguration, distributedStore); // create the agent
raftAgent.setupJacksonAnnotatedCommandSerializationAndDeserialization(KayVeeCommand.class); // setup the agent to deal with our Command subclasses
distributedStore.setRaftAgent(raftAgent);
distributedStore.initialize();
environment.manage(distributedStore);
// setup our health checks
environment.addHealthCheck(new DistributedStoreCheck(distributedStore));
// setup the resources by which kayvee is accessed
environment.addResource(new KeysResource(configuration.getClusterConfiguration().getMembers(), distributedStore));
// setup our exception mappers
environment.addProvider(IllegalArgumentExceptionMapper.class);
environment.addProvider(KayVeeExceptionMapper.class);
}
示例3: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(HVDFConfiguration config, Environment environment) throws Exception {
// Get the configured default MongoDB URI
MongoClientURI default_uri = config.mongodb.default_database_uri;
// Initialize the services as per configuration
ServiceManager services = new ServiceManager(config.services, default_uri);
environment.manage(services);
// Register the custom ExceptionMapper to handle ServiceExceptions
environment.addProvider(new ServiceExceptionMapper());
environment.addResource( new FeedResource( services.getChannelService()) );
}
示例4: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(AppConfiguration configuration, Environment environment) throws Exception {
AXLPort axl = initAxlService(configuration.getCucm());
environment.manage(new CucmAxlService(axl));
environment.addProvider(new BasicAuthProvider<User>(new AppAuthenticator(configuration.getApiauth()), "PROTECTED"));
environment.addHealthCheck(new CucmAxlServiceHealthCheck(axl));
environment.addResource(new PhoneResource(axl));
environment.addResource(new SpeeddialsResource(axl));
}
示例5: configureMongoClient
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
private MongoClient configureMongoClient(Environment environment, MongoConfiguration config) throws UnknownHostException {
MongoClient mongoClient = new MongoClient(config.getHosts(), config.getPort());
environment.manage(new ManagedMongo(mongoClient));
return mongoClient;
}
示例6: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(FoxtrotServerConfiguration configuration, Environment environment) throws Exception {
configuration.getHttpConfiguration().setRootPath("/foxtrot/*");
configureObjectMapper(environment);
ObjectMapper objectMapper = environment.getObjectMapperFactory().build();
ExecutorService executorService = environment.managedExecutorService("query-executor-%s", 20, 40, 30, TimeUnit.SECONDS);
HbaseTableConnection HBaseTableConnection = new HbaseTableConnection(configuration.getHbase());
ElasticsearchConnection elasticsearchConnection = new ElasticsearchConnection(configuration.getElasticsearch());
HazelcastConnection hazelcastConnection = new HazelcastConnection(configuration.getCluster());
ElasticsearchUtils.setTableNamePrefix(configuration.getElasticsearch());
TableMetadataManager tableMetadataManager = new DistributedTableMetadataManager(hazelcastConnection, elasticsearchConnection);
DataStore dataStore = new HBaseDataStore(HBaseTableConnection,
objectMapper, new DocumentTranslator(configuration.getHbase()));
QueryStore queryStore = new ElasticsearchQueryStore(tableMetadataManager, elasticsearchConnection, dataStore, objectMapper);
FoxtrotTableManager tableManager = new FoxtrotTableManager(tableMetadataManager, queryStore, dataStore);
CacheManager cacheManager = new CacheManager(new DistributedCacheFactory(hazelcastConnection, objectMapper));
AnalyticsLoader analyticsLoader = new AnalyticsLoader(tableMetadataManager, dataStore, queryStore, elasticsearchConnection, cacheManager, objectMapper);
QueryExecutor executor = new QueryExecutor(analyticsLoader, executorService);
DataDeletionManagerConfig dataDeletionManagerConfig = configuration.getTableDataManagerConfig();
DataDeletionManager dataDeletionManager = new DataDeletionManager(dataDeletionManagerConfig, queryStore);
List<HealthCheck> healthChecks = new ArrayList<>();
healthChecks.add(new ElasticSearchHealthCheck("ES Health Check", elasticsearchConnection));
ClusterManager clusterManager = new ClusterManager(hazelcastConnection, healthChecks, configuration.getHttpConfiguration());
environment.manage(HBaseTableConnection);
environment.manage(elasticsearchConnection);
environment.manage(hazelcastConnection);
environment.manage(tableMetadataManager);
environment.manage(analyticsLoader);
environment.manage(dataDeletionManager);
environment.manage(clusterManager);
environment.addResource(new DocumentResource(queryStore));
environment.addResource(new AsyncResource(cacheManager));
environment.addResource(new AnalyticsResource(executor));
environment.addResource(new TableManagerResource(tableManager));
environment.addResource(new TableFieldMappingResource(queryStore));
environment.addResource(new ConsoleResource(
new ElasticsearchConsolePersistence(elasticsearchConnection, objectMapper)));
FqlEngine fqlEngine = new FqlEngine(tableMetadataManager, queryStore, executor, objectMapper);
environment.addResource(new FqlResource(fqlEngine));
environment.addResource(new ClusterInfoResource(clusterManager));
environment.addResource(new UtilResource(configuration));
environment.addResource(new ClusterHealthResource(queryStore));
healthChecks.forEach(environment::addHealthCheck);
environment.addProvider(new FoxtrotExceptionMapper());
environment.addProvider(new FlatResponseTextProvider());
environment.addProvider(new FlatResponseCsvProvider());
environment.addProvider(new FlatResponseErrorTextProvider());
environment.addFilter(CrossOriginFilter.class, "/*");
}
示例7: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*
* @throws IOException when instance in configuration can not be opened and closed.
*/
@Override
public final void run(final KijiRESTConfiguration configuration, final Environment environment)
throws IOException {
final KijiURI clusterURI = KijiURI.newBuilder(configuration.getClusterURI()).build();
final ManagedKijiClient managedKijiClient = new ManagedKijiClient(configuration);
environment.manage(managedKijiClient);
// Setup the health checker for the KijiClient
environment.addHealthCheck(new KijiClientHealthCheck(managedKijiClient));
// Remove all built-in Dropwizard ExceptionHandler.
// Always depend on custom ones.
// Inspired by Jeremy Whitlock's suggestion on thoughtspark.org.
Set<Object> jerseyResources = environment.getJerseyResourceConfig().getSingletons();
Iterator<Object> jerseyResourcesIterator = jerseyResources.iterator();
while (jerseyResourcesIterator.hasNext()) {
Object jerseyResource = jerseyResourcesIterator.next();
if (jerseyResource instanceof ExceptionMapper
&& jerseyResource.getClass().getName().startsWith("com.yammer.dropwizard.jersey")) {
jerseyResourcesIterator.remove();
}
}
// Load admin task to manually refresh instances.
environment.addTask(new RefreshInstancesTask(managedKijiClient));
// Load admin task to manually close instances and tables.
environment.addTask(new CloseTask(managedKijiClient));
// Load admin task to manually shutdown the system.
environment.addTask(new ShutdownTask(managedKijiClient, configuration));
// Adds custom serializers.
registerSerializers(environment.getObjectMapperFactory());
// Adds exception mappers to print better exception messages to the client than what
// Dropwizard does by default.
environment.addProvider(new GeneralExceptionMapper());
// Load resources.
for (KijiRestPlugin plugin : Lookups.get(KijiRestPlugin.class)) {
LOG.info("Loading plugin {}", plugin.getClass());
plugin.install(managedKijiClient, configuration, environment);
}
// Allow global CORS filter. CORS off by default.
if (configuration.getCORS()) {
environment.addFilter(
CrossOriginFilter.class,
configuration.getHttpConfiguration().getRootPath());
LOG.info("Global cross-origin resource sharing is allowed.");
}
}