List of usage examples for org.apache.commons.configuration ConfigurationConverter getProperties
public static Properties getProperties(Configuration config)
From source file:io.s4.meter.generator.GeneratorModule.java
/** * Loads properties.//from w w w.j a v a2s . co m * * @param binder * the Guice binder. */ private void loadProperties(Binder binder) { try { InputStream is = this.getClass().getResourceAsStream("/generator.properties"); config = new PropertiesConfiguration(); config.load(is); // System.out.println(ConfigurationUtils.toString(config)); logger.info(ConfigurationUtils.toString(config)); /* Make all properties injectable. Do we need this? */ Names.bindProperties(binder, ConfigurationConverter.getProperties(config)); } catch (ConfigurationException e) { binder.addError(e); e.printStackTrace(); } }
From source file:io.s4.comm.Module.java
private void loadProperties(Binder binder) { try {/*from w w w . j a va 2 s .co m*/ InputStream is = this.getClass().getResourceAsStream("/s4-comm.properties"); config = new PropertiesConfiguration(); config.load(is); System.out.println(ConfigurationUtils.toString(config)); // TODO - validate properties. /* Make all properties injectable. Do we need this? */ Names.bindProperties(binder, ConfigurationConverter.getProperties(config)); } catch (ConfigurationException e) { binder.addError(e); e.printStackTrace(); } }
From source file:io.s4.example.counter.Module.java
private void loadProperties(Binder binder) { try {//from www .ja v a 2 s . co m InputStream is = this.getClass().getResourceAsStream("/s4-piper-example.properties"); config = new PropertiesConfiguration(); config.load(is); System.out.println(ConfigurationUtils.toString(config)); // TODO - validate properties. /* Make all properties injectable. Do we need this? */ Names.bindProperties(binder, ConfigurationConverter.getProperties(config)); } catch (ConfigurationException e) { binder.addError(e); e.printStackTrace(); } }
From source file:io.s4.S4Module.java
private void loadProperties(Binder binder) { try {/* www .j ava2 s .c o m*/ InputStream is = this.getClass().getResourceAsStream(S4_PROPERTIES_FILE); config = new PropertiesConfiguration(); config.load(is); System.out.println(ConfigurationUtils.toString(config)); // TODO - validate properties. /* Make all properties injectable. Do we need this? */ Names.bindProperties(binder, ConfigurationConverter.getProperties(config)); } catch (ConfigurationException e) { binder.addError(e); e.printStackTrace(); } }
From source file:de.kaiserpfalzEdv.commons.jee.spring.CommonsConfigurationConfigurer.java
/** * Apply the given Properties to the given BeanFactory. * * @param beanFactory the BeanFactory used by the application context * @param props the Properties to apply * @throws org.springframework.beans.BeansException * in case of errors/*from www . j av a 2 s . c o m*/ */ @Override protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props) throws BeansException { Properties commonsProperties = ConfigurationConverter.getProperties(configuration); log.debug("got properties " + commonsProperties); super.processProperties(beanFactory, commonsProperties); }
From source file:com.nesscomputing.service.discovery.server.zookeeper.ZookeeperModule.java
private QuorumPeerConfig getQuorumPeerConfig() { final Configuration zookeeperConfig = config.getConfiguration("ness.zookeeper"); final QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); try {/*from w ww. j av a2 s . co m*/ quorumPeerConfig.parseProperties(ConfigurationConverter.getProperties(zookeeperConfig)); } catch (IOException ioe) { throw new ProvisionException("while creating the QuorumPeerConfig", ioe); } catch (ConfigException ce) { throw new ProvisionException("while creating the QuorumPeerConfig", ce); } return quorumPeerConfig; }
From source file:io.fluo.stress.trie.Load.java
@Override public int run(String[] args) throws Exception { if (args.length != 2) { log.error("Usage: " + this.getClass().getSimpleName() + "<fluoProps> <input dir>"); System.exit(-1);// w w w. jav a 2s .com } FluoConfiguration props = new FluoConfiguration(new File(args[0])); Path input = new Path(args[1]); Job job = Job.getInstance(getConf()); job.setJobName(Load.class.getName()); job.setJarByClass(Load.class); job.setInputFormatClass(SequenceFileInputFormat.class); SequenceFileInputFormat.addInputPath(job, input); job.setMapperClass(LoadMapper.class); job.setNumReduceTasks(0); job.setOutputFormatClass(FluoOutputFormat.class); FluoOutputFormat.configure(job, ConfigurationConverter.getProperties(props)); job.getConfiguration().setBoolean("mapreduce.map.speculative", false); boolean success = job.waitForCompletion(true); return success ? 0 : 1; }
From source file:io.s4.example.twittertopiccount.Module.java
private void loadProperties(Binder binder) { try {/*from ww w . java2s. c om*/ InputStream is = this.getClass().getResourceAsStream("/s4-example-twittertopiccount.properties"); config = new PropertiesConfiguration(); config.load(is); System.out.println(ConfigurationUtils.toString(config)); // TODO - validate properties. /* Make all properties injectable. Do we need this? */ Names.bindProperties(binder, ConfigurationConverter.getProperties(config)); } catch (ConfigurationException e) { binder.addError(e); e.printStackTrace(); } }
From source file:com.dattack.naming.loader.factory.DataSourceFactory.java
@Override public DataSource getObjectInstance(final Properties properties, final Collection<File> extraClasspath) throws NamingException { final CompositeConfiguration configuration = new CompositeConfiguration(); configuration.addConfiguration(new SystemConfiguration()); configuration.addConfiguration(new EnvironmentConfiguration()); configuration.addConfiguration(new MapConfiguration(properties)); final String driver = configuration.getString(DRIVER_KEY); if (driver == null) { throw new ConfigurationException(String.format("Missing property '%s'", DRIVER_KEY)); }//from ww w . java 2 s.co m final String url = configuration.getString(URL_KEY); if (url == null) { throw new ConfigurationException(String.format("Missing property '%s'", URL_KEY)); } final String user = configuration.getString(USERNAME_KEY); final String password = configuration.getString(PASSWORD_KEY); DataSource dataSource = null; try { final Properties props = ConfigurationConverter.getProperties(configuration); dataSource = BasicDataSourceFactory.createDataSource(props); } catch (final Exception e) { // NOPMD by cvarela on 8/02/16 22:28 // we will use a DataSource without a connection pool LOGGER.info(e.getMessage()); dataSource = new SimpleDataSource(driver, url, user, password); } return new DataSourceClasspathDecorator(dataSource, extraClasspath); }
From source file:com.nesscomputing.quartz.NessQuartzModule.java
@Provides @Singleton//from w w w . j av a 2s . c o m SchedulerFactory getSchedulerFactory(final Config config) throws SchedulerException { final Properties quartzProperties = ConfigurationConverter.getProperties(config.getConfiguration()); return new StdSchedulerFactory(quartzProperties); }