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


Java Environment类代码示例

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


Environment类属于com.yammer.dropwizard.config包,在下文中一共展示了Environment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import com.yammer.dropwizard.config.Environment; //导入依赖的package包/类
@Override
public void run(ServiceConfiguration configuration, Environment environment) throws Exception {
	
	try {
		ZooKeeperConfiguration zkConfig = configuration.getZooKeeperConfiguration();
		String zkHost = zkConfig.getHost();
		String zkPort = zkConfig.getPort();
		String zkHostPort = String.format("%s:%s", zkHost, zkPort);
		
		LOG.info("Connecting to ZooKeeper " + zkHostPort);
		zookeeper = new ZooKeeper(zkHostPort, 3000, new ZooKeeperMonitor());
	} catch (IOException e) {
		LOG.error(e.getMessage(), e);
	}		
	
	environment.addHealthCheck(new ZooPeekerHealthCheck());
	environment.addResource(new NodeResource(zookeeper));
}
 
开发者ID:kiblerdude,项目名称:zoopeeker,代码行数:19,代码来源:ZooPeekerService.java

示例2: install

import com.yammer.dropwizard.config.Environment; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void install(
    final KijiClient kijiClient,
    final KijiRESTConfiguration configuration,
    final Environment environment) {

  // Adds resources.
  environment.addResource(new KijiRESTResource());
  environment.addResource(new InstancesResource(kijiClient));
  environment.addResource(new InstanceResource(kijiClient));
  environment.addResource(new TableResource(kijiClient));
  environment.addResource(new TablesResource(kijiClient));
  environment.addResource(new RowsResource(kijiClient,
      environment.getObjectMapperFactory().build(),
      configuration.getFresheningConfiguration()));
}
 
开发者ID:kijiproject,项目名称:kiji-rest,代码行数:18,代码来源:StandardKijiRestPlugin.java

示例3: 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

示例4: run

import com.yammer.dropwizard.config.Environment; //导入依赖的package包/类
@Override
protected void run(Environment environment, Namespace namespace, T configuration) throws Exception {
    this.startUpEnvironment = new EnvironmentFriend(environment); // remember the startup environment to enable full shutdown

    this.server = new ServerFactory(configuration.getHttpConfiguration(),
            environment.getName()).buildServer(environment);

    try {
        server.start();
        for (ServerLifecycleListener listener : environment.getServerListeners()) {
            listener.serverStarted(server);
        }
    } catch (Exception e) {
        logger.error("Unable to start server, shutting down", e);
        server.stop();
    }
}
 
开发者ID:yammer,项目名称:dropwizard-testing-integration,代码行数:18,代码来源:LifecycleServerCommand.java

示例5: run

import com.yammer.dropwizard.config.Environment; //导入依赖的package包/类
@Override
public void run(XpressConfiguration configuration, Environment environment) {
    ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
    Repository repository = ac.getBean(Repository.class);
    TagRetriever tagRetriever = ac.getBean(TagRetriever.class);
    PieChartGenerator pieChartGenerator = ac.getBean(PieChartGenerator.class);

    environment.addResource(new TagCloudResource(new TagCloudRetriever(repository)));
    environment.addResource(new VoteResource(repository));
    environment.addResource(new MoodGraphResource(new MoodGraphGenerator(repository)));
    final GraphTagsResource resource = new GraphTagsResource();
    resource.setTagRetriever(tagRetriever);
    resource.setPieChartGenerator(pieChartGenerator);
    environment.addResource(resource);

}
 
开发者ID:mihai-chezan,项目名称:xpress,代码行数:17,代码来源:XpressService.java

示例6: 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

示例7: run

import com.yammer.dropwizard.config.Environment; //导入依赖的package包/类
@Override
public void run(final T configuration, final Environment environment)
{
    final Iterable<Module> configedModules = configureModules(configuration, modules);
    final DropwizardModule<T> dwModule = new DropwizardModule<T>(configuration, environment);

    final Injector injector = parentInjector.or(Guice.createInjector())
            .createChildInjector(Iterables.concat(of(dwModule), configedModules));

    environment.addFilter(injector.getInstance(GuiceFilter.class), "*");

    // Support Module definition of health checks
    if (!injector.findBindingsByType(healthChecksKey.getTypeLiteral()).isEmpty()) {
        final Set<HealthCheck> healthChecks = injector.getInstance(healthChecksKey);
        for (HealthCheck hc : healthChecks) {
            environment.addHealthCheck(hc);
        }
    }

}
 
开发者ID:fizmo,项目名称:dropwizard-bundle-guice,代码行数:21,代码来源:GuiceBundle.java

示例8: runContainer

import com.yammer.dropwizard.config.Environment; //导入依赖的package包/类
private void runContainer(ConfiguredBundle<TestConfig> bundle, Environment environment) throws Exception {
    ResourceConfig resourceConfig = new DefaultResourceConfig();
    when(environment.getJerseyResourceConfig()).thenReturn(resourceConfig);

    bundle.run(new TestConfig(), environment);

    ArgumentCaptor<GuiceContainer> captor = ArgumentCaptor.forClass(GuiceContainer.class);
    verify(environment).setJerseyServletContainer(captor.capture());

    GuiceContainer container = captor.getValue();
    ServletConfig config = mock(ServletConfig.class);
    when(config.getInitParameterNames()).thenReturn(Collections.enumeration(Collections.<String>emptyList()));
    ServletContext context = mock(ServletContext.class);
    when(config.getServletContext()).thenReturn(context);

    container.init(config);
}
 
开发者ID:fizmo,项目名称:dropwizard-bundle-guice,代码行数:18,代码来源:TestGuiceBundle.java

示例9: register

import com.yammer.dropwizard.config.Environment; //导入依赖的package包/类
/**
 * Init the local registry and the JDBI mappers.
 *
 * @param configuration
 *            the configuration
 * @param environment
 *            the environment
 * @throws ClassNotFoundException
 *             the class not found exception
 */
private void register(final ExampleConfigurations configuration, final Environment environment)
		throws ClassNotFoundException {
	final DBIFactory factory = new DBIFactory();

	final DBI dbi = factory.build(environment, configuration.getDatabase(), "h2");
	dbi.registerMapper(new User());
	dbi.registerMapper(new UserVisitLog());

	LocalRegistry.setDbi(dbi);
	LocalRegistry.setEnvironment(environment);
	LocalRegistry.setConfigurations(configuration);
}
 
开发者ID:kiswanij,项目名称:jk-drop-wizard-full-example,代码行数:23,代码来源:ExampleService.java

示例10: run

import com.yammer.dropwizard.config.Environment; //导入依赖的package包/类
/**
 * Establishes an environment and configures resources need to
 * execute service. Optional service health checks.
 */
@Override
public void run(DataConfiguration configuration, Environment environment) {
  final LensEndpoint restResource = new LensEndpoint();
  environment.addResource(restResource);
  /*final JsonLensEndpoint jsonResource = new JsonLensEndpoint();
  environment.addResource(jsonResource);*/

  // Application complains if health check not included. Can add more robust
  // service tests later for more complete code base.
  environment.addHealthCheck(new ServiceHealthCheck());
}
 
开发者ID:boozallen,项目名称:cognition,代码行数:16,代码来源:DataService.java

示例11: run

import com.yammer.dropwizard.config.Environment; //导入依赖的package包/类
@Override
public void run(SampleConfiguration configuration, Environment environment) {
    overrideLogging();
    Injector injector = Guice.createInjector();
    environment.addResource(injector.getInstance(GadgetResource.class));
    environment.addResource(injector.getInstance(StaticTypesResource.class));
    environment.addResource(injector.getInstance(CustomHeadersResource.class));
    environment.addResource(injector.getInstance(MultipartResource.class));
    environment.addResource(injector.getInstance(BinaryStreamResource.class));
    environment.addHealthCheck(injector.getInstance(SampleHealthCheck.class));
}
 
开发者ID:ctco,项目名称:cukes,代码行数:12,代码来源:SampleApplication.java

示例12: run

import com.yammer.dropwizard.config.Environment; //导入依赖的package包/类
@Override
public void run(final Config configuration, final Environment environment) {
    environment.addHealthCheck(new Health());
    BookResource br = new BookResource(hibernate.getSessionFactory());
    environment.addResource(br);

}
 
开发者ID:mley,项目名称:dwdemo,代码行数:8,代码来源:DropwizardDemo.java

示例13: 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

示例14: run

import com.yammer.dropwizard.config.Environment; //导入依赖的package包/类
@Override
public void run(GreenfieldConfiguration configuration,
                Environment environment) {
    String template = configuration.getTemplate();
    String defaultName = configuration.getDefaultName();
    environment.addResource(new GreenfieldResource(template, defaultName));
    environment.addHealthCheck(new GreenfieldHealthCheck(template));
}
 
开发者ID:dev9com,项目名称:greenfield,代码行数:9,代码来源:GreenfieldService.java

示例15: run

import com.yammer.dropwizard.config.Environment; //导入依赖的package包/类
@Override
public void run(PassbookConfiguration configuration, Environment environment) throws Exception {
    final DeviceDAO deviceDAO = new DeviceDAO(hibernate.getSessionFactory());
    final RegistrationDAO registrationDAO = new RegistrationDAO(hibernate.getSessionFactory());

    environment.addResource(new PassbookDevicesResource(deviceDAO, registrationDAO));
    environment.addResource(new PassbookPassesResource(deviceDAO));
    environment.addResource(new PassbookLogResource());
}
 
开发者ID:JanGorman,项目名称:jersey-passbook,代码行数:10,代码来源:PassbookService.java


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