当前位置: 首页>>代码示例>>Java>>正文


Java Environment.addProvider方法代码示例

本文整理汇总了Java中com.yammer.dropwizard.config.Environment.addProvider方法的典型用法代码示例。如果您正苦于以下问题:Java Environment.addProvider方法的具体用法?Java Environment.addProvider怎么用?Java Environment.addProvider使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.yammer.dropwizard.config.Environment的用法示例。


在下文中一共展示了Environment.addProvider方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
 
开发者ID:anastasop,项目名称:dropwizard-jedis,代码行数:20,代码来源:JedisBundle.java

示例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);
}
 
开发者ID:allengeorge,项目名称:libraft,代码行数:25,代码来源:KayVee.java

示例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()) );
}
 
开发者ID:mongodb-labs,项目名称:hvdf,代码行数:16,代码来源:HVDFService.java

示例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));
}
 
开发者ID:ox-it,项目名称:cucm-http-api,代码行数:11,代码来源:CucmHttpApiService.java

示例5: run

import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(Configuration configuration, Environment environment) throws Exception {
    environment.addResource(new PizzaResource());
    environment.addHealthCheck(new PizzaHealthCheck());
    environment.addProvider(new HmacAuthProvider<>(new DefaultRequestHandler<>(new PizzaAuthenticator())));
}
 
开发者ID:bazaarvoice,项目名称:jersey-hmac-auth,代码行数:7,代码来源:PizzaService.java

示例6: run

import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(LocateApiConfiguration configuration, Environment environment) throws Exception {

    /**
     * Mongo set up
     */
    MongoClient mongoClient = configureMongoClient(environment, configuration.getMongoConfiguration());

    DB locateDb = setUpDb(configuration.getMongoConfiguration().getLocateDatabase(), configuration.getMongoConfiguration(), mongoClient);
    DB credentialsDb = setUpDb(configuration.getMongoConfiguration().getCredentialsDatabase(), configuration.getMongoConfiguration(), mongoClient);

    /**
     * Dao layer
     */
    final AuthorizationTokenDao authorizationTokenDao = configureAuthorizationTokenDao(credentialsDb);
    final UsageDao usageDao = configureRateMeterDao(credentialsDb);
    final AddressDao addressDao = configureAddressDao(locateDb);
    final PostcodeToAuthorityDao postcodeToAuthorityDao = configurePostcodeToAuthorityDao(locateDb);

    /**
     * Enable cors support
     */
    environment.addFilter(CrossOriginFilter.class, "*")
            .setInitParam("allowedOrigins", configuration.getAllowedOrigins())
            .setInitParam("allowedHeaders", "X-Requested-With,Content-Type,Accept,Origin,Authorization")
            .setInitParam("allowedMethods", "OPTIONS,GET");

    /**
     * Resources
     */
    environment.addResource(new AddressResource(addressDao, configuration));
    environment.addResource(new PostcodeToAuthorityResource(postcodeToAuthorityDao));

    /**
     * Healthchecks
     */
    environment.addHealthCheck(new MongoHealthCheck(mongoClient));

    /**
     * Exception mapper
     */
    environment.addProvider(new LocateExceptionMapper());

    /**
     * Authentication
     */
    environment.addProvider(new BearerTokenAuthProvider(configuration, usageDao, new BearerTokenAuthenticator(authorizationTokenDao)));

    /**
     * Better exception mappings
     */
    removeDefaultExceptionMappers(environment);

    /**
     * Date serialisation
     */
    environment.getObjectMapperFactory().setDateFormat(internalDateFormatter);

    /**
     * Tasks
     */
    environment.addTask(new MongoIndexTask(authorizationTokenDao, usageDao));

}
 
开发者ID:alphagov,项目名称:locate-api,代码行数:65,代码来源:LocateApiService.java

示例7: 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, "/*");
}
 
开发者ID:Flipkart,项目名称:foxtrot,代码行数:58,代码来源:FoxtrotServer.java

示例8: 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.");
  }
}
 
开发者ID:kijiproject,项目名称:kiji-rest,代码行数:57,代码来源:KijiRESTService.java

示例9: registerProvider

import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
public void registerProvider(Environment environment) {

		registerSpringSecurityFilters(environment);

		environment.addProvider(this);
	}
 
开发者ID:osiris-indoor,项目名称:osiris,代码行数:7,代码来源:SpringSecurityProvider.java

示例10: configure

import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
/**
 * Configures Dropwizard to use OSIAM by adding a custom Authorization Provider.
 *
 * @param env Dropwizard Environment
 */
public void configure(Environment env) {
    env.addProvider(new OsiamRoleAuthOAuthProvider(this, "OSIAM protected"));
    env.addResource(new OsiamResource(config, this));
}
 
开发者ID:osiam,项目名称:osiam-dropwizard,代码行数:10,代码来源:OsiamDropwizard.java


注:本文中的com.yammer.dropwizard.config.Environment.addProvider方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。