Java Code Examples for org.apache.commons.configuration.PropertiesConfiguration

The following are top voted examples for showing how to use org.apache.commons.configuration.PropertiesConfiguration. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: YiDu-Novel   File: LanguageEditAction.java   Source Code and License 6 votes vote down vote up
@Override
protected void loadData() {
    // 设定文件初期读入
    try {
        PropertiesConfiguration languageConf = new PropertiesConfiguration(Thread.currentThread()
                .getContextClassLoader().getResource("language/package.properties"));
        title = languageConf.getString(YiDuConfig.TITLE);
        siteKeywords = languageConf.getString(YiDuConfig.SITEKEYWORDS);
        siteDescription = languageConf.getString(YiDuConfig.SITEDESCRIPTION);
        name = languageConf.getString(YiDuConfig.NAME);
        url = languageConf.getString(YiDuConfig.URL);
        copyright = languageConf.getString(YiDuConfig.COPYRIGHT);
        beianNo = languageConf.getString(YiDuConfig.BEIANNO);
        analyticscode = languageConf.getString(YiDuConfig.ANALYTICSCODE);
        analyticscode = languageConf.getString(YiDuConfig.ANALYTICSCODE);
        category = languageConf.getString(YiDuConfig.CATEGORY);
    } catch (ConfigurationException e) {
        logger.error(e);
    }
}
 
Example 2
Project: irc-helper   File: MyRecord.java   Source Code and License 6 votes vote down vote up
public void saveRecord() throws Exception {
	if (file.exists()) {
		// file.renameTo(new File(Configs.recordFileName+".bak"));
		file.delete();
	}
	file.createNewFile();
	PropertiesConfiguration record = new PropertiesConfiguration(
			Configs.recordFileName);

	record.addProperty("verifiedUsers", Records.verifiedUsers.toArray());

	// record.addProperty("records", Records.records);

	Object[] usrEntries = Records.records.keySet().toArray();
	record.addProperty("usrEntries", usrEntries);
	for (Object usr : usrEntries) {
		record.addProperty((String) usr, Records.records.get(usr).toArray());
	}
	record.save();

}
 
Example 3
Project: irc-helper   File: MyConfig.java   Source Code and License 6 votes vote down vote up
public void createDefault() throws Exception {
	if (file.exists()) {
		file.renameTo(new File(Enterence.propFileName + ".bak"));
	}
	file.createNewFile();
	PropertiesConfiguration config = new PropertiesConfiguration(
			Enterence.propFileName);
	config.setProperty("sudoers", Configs.sudoers);
	config.setProperty("sudoPwd", Configs.sudoPwd);
	config.setProperty("server", Configs.server);
	config.setProperty("name", Configs.name);
	config.setProperty("pwd", Configs.pwd);
	config.setProperty("channels", Configs.channels);
	config.setProperty("preffix", Configs.preffix);
	config.setProperty("sudoers", Configs.sudoers);
	config.setProperty("recordFileName", Configs.recordFileName);
	config.setProperty("useProxy", Configs.useProxy);
	config.setProperty("Proxy", Configs.Proxy);
	config.save();
}
 
Example 4
Project: Equella   File: RemoveClusterGroupName.java   Source Code and License 6 votes vote down vote up
@Override
public void upgrade(final UpgradeResult result, File tleInstallDir) throws Exception
{
	new PropertyFileModifier(
		new File(new File(tleInstallDir, CONFIG_FOLDER), PropertyFileModifier.MANDATORY_CONFIG))
	{
		@Override
		protected boolean modifyProperties(PropertiesConfiguration props)
		{
			if( props.containsKey("cluster.group.name") )
			{
				result.addLogMessage("Removing cluster.group.name property");
				props.clearProperty("cluster.group.name");
				return true;
			}
			return false;
		}
	}.updateProperties();
}
 
Example 5
Project: Yidu   File: LanguageEditAction.java   Source Code and License 6 votes vote down vote up
@Override
protected void loadData() {
    // 设定文件初期读入
    try {
        PropertiesConfiguration languageConf = new PropertiesConfiguration(Thread.currentThread()
                .getContextClassLoader().getResource("language/package.properties"));
        title = languageConf.getString(YiDuConfig.TITLE);
        siteKeywords = languageConf.getString(YiDuConfig.SITEKEYWORDS);
        siteDescription = languageConf.getString(YiDuConfig.SITEDESCRIPTION);
        name = languageConf.getString(YiDuConfig.NAME);
        url = languageConf.getString(YiDuConfig.URL);
        copyright = languageConf.getString(YiDuConfig.COPYRIGHT);
        beianNo = languageConf.getString(YiDuConfig.BEIANNO);
        analyticscode = languageConf.getString(YiDuConfig.ANALYTICSCODE);
        analyticscode = languageConf.getString(YiDuConfig.ANALYTICSCODE);
        category = languageConf.getString(YiDuConfig.CATEGORY);
    } catch (ConfigurationException e) {
        logger.error(e);
    }
}
 
Example 6
Project: hdt-gremlin   File: HDTtoGremlin.java   Source Code and License 6 votes vote down vote up
public static void main(String[] args) throws Exception {		
		if(args.length!=2) {
			System.out.println("Usage: hdt2gremlin <file.hdt> <Gremlin Graph Config File>");
			System.out.println(" The config follows the syntax of gremlins factory Graph.open().");
			System.exit(-1);
		}
		
		// Create Graph
		Configuration p = new PropertiesConfiguration(args[1]);
		try(Graph gremlinGraph = GraphFactory.open(p)){
			
			// Open HDT
			try(HDT hdt = HDTManager.mapHDT("args[0]")){

				// Import HDT into Graph
				StopWatch st = new StopWatch();
				importGraph(hdt, gremlinGraph);
				System.out.println("Took "+st.stopAndShow());
			}
				
//			smallTest(gremlinGraph);
		}
		
		System.exit(0);
	}
 
Example 7
Project: momo-2   File: CommandHandler.java   Source Code and License 6 votes vote down vote up
/**
 * Normalize all guild commands
 * @param collection All commands
 * @throws ConfigurationException If apache config throws an exception
 */
private static void normalizeCommands(Collection<Command> collection) throws ConfigurationException {
	Collection<File> found = FileUtils.listFiles(new File("resources/guilds"),
			TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
	found.add(new File("resources/guilds/template.properties"));
	for (File f : found) {
		if (f.getName().equals("GuildProperties.properties") || f.getName().equals("template.properties")) {
			PropertiesConfiguration config = new PropertiesConfiguration(f);
			List<String> enabledCommands = config.getList("EnabledCommands").stream()
					.map(object -> Objects.toString(object, null))
					.collect(Collectors.toList());
			List<String> disabledCommands = config.getList("DisabledCommands").stream()
					.map(object -> Objects.toString(object, null))
					.collect(Collectors.toList());
			for (Command c : collection) {
				if (!enabledCommands.contains(c.toString()) && !disabledCommands.contains(c.toString())) {
					enabledCommands.add(c.toString());
				}
			}
			config.setProperty("EnabledCommands", enabledCommands);
			config.save();
		}
	}
}
 
Example 8
Project: hadoop   File: MetricsConfig.java   Source Code and License 6 votes vote down vote up
/**
 * Load configuration from a list of files until the first successful load
 * @param conf  the configuration object
 * @param files the list of filenames to try
 * @return  the configuration object
 */
static MetricsConfig loadFirst(String prefix, String... fileNames) {
  for (String fname : fileNames) {
    try {
      Configuration cf = new PropertiesConfiguration(fname)
          .interpolatedConfiguration();
      LOG.info("loaded properties from "+ fname);
      LOG.debug(toString(cf));
      MetricsConfig mc = new MetricsConfig(cf, prefix);
      LOG.debug(mc);
      return mc;
    }
    catch (ConfigurationException e) {
      if (e.getMessage().startsWith("Cannot locate configuration")) {
        continue;
      }
      throw new MetricsConfigException(e);
    }
  }
  LOG.warn("Cannot locate configuration: tried "+
           Joiner.on(",").join(fileNames));
  // default to an empty configuration
  return new MetricsConfig(new PropertiesConfiguration(), prefix);
}
 
Example 9
Project: loom   File: FakeAdapterTest.java   Source Code and License 6 votes vote down vote up
private PropertiesConfiguration loadProperties() throws ConfigurationException {
    String deploymentProperties = "src/test/resources/deployment-fakeAdapterTest.properties";
    PropertiesConfiguration props = new PropertiesConfiguration(deploymentProperties);
    return props;
    // try {
    // Properties prop = null;
    // Resource res = appContext.getResource(deploymentProperties);
    // InputStream in = res.getInputStream();
    // if (in == null) {
    // LOG.warn("Failed to locate properties file on classpath: " + deploymentProperties);
    // } else {
    // LOG.info("Found '" + deploymentProperties + "' on the classpath");
    // prop = new Properties();
    // prop.load(in);
    // }
    // return prop;
    // } catch (IOException e) {
    // LOG.error("Failed to load properties file '" + deploymentProperties + "'", e);
    // throw new RuntimeException("Failed to initialise from properties file " +
    // deploymentProperties);
    // }
}
 
Example 10
Project: loom   File: AdapterConfigTest.java   Source Code and License 6 votes vote down vote up
/**
 * Test all the getters
 */
@Test
public void testAllTheGetters() {
    PropertiesConfiguration props = loadProperties();
    try {
        AdapterConfig config = new AdapterConfig(props);
        Assert.assertEquals("adapterClass", config.getAdapterClass());
        Assert.assertEquals("adapterDir", config.getAdapterDir());
        Assert.assertEquals("authEndpoint", config.getAuthEndpoint());
        Assert.assertEquals(1, config.getCollectThreads());
        Assert.assertEquals("providerId", config.getProviderId());
        Assert.assertEquals("providerName", config.getProviderName());
        Assert.assertEquals("providerType", config.getProviderType());
        Assert.assertEquals(2, config.getSchedulingInterval());


    } catch (AdapterConfigException ex) {
        Assert.fail("Expected it to pass");
    }
}
 
Example 11
Project: loom   File: AdapterConfigTest.java   Source Code and License 6 votes vote down vote up
/**
 * Creates a properties config with all the properties set
 *
 * @return
 */
private PropertiesConfiguration loadProperties() {
    PropertiesConfiguration properties = new PropertiesConfiguration();

    properties.addProperty(AdapterConfig.ADAPTER_CLASS, "adapterClass");
    properties.addProperty(AdapterConfig.ADAPTER_DIR, "adapterDir");
    properties.addProperty(AdapterConfig.AUTH_ENDPOINT, "authEndpoint");
    properties.addProperty(AdapterConfig.COLLECT_THREADS, "1");
    properties.addProperty(AdapterConfig.PROVIDER_ID, "providerId");
    properties.addProperty(AdapterConfig.PROVIDER_NAME, "providerName");
    properties.addProperty(AdapterConfig.PROVIDER_TYPE, "providerType");
    properties.addProperty(AdapterConfig.SCHEDULING_INTERVAL, "2");

    properties.addProperty(AdapterConfig.FILE_PATH, "filePath");
    return properties;
}
 
Example 12
Project: dataSqueeze   File: CompactionManagerFactory.java   Source Code and License 6 votes vote down vote up
/**
 * Retrieves {@link CompactionManager}.
 *
 * @param options map of various options keyed by name
 * @return {@link CompactionManager}
 */
public static CompactionManager create(Map<String, String> options) throws Exception {
    final Configuration configuration = new Configuration();
    configuration.addResource(new Path("/etc/hadoop/conf/hdfs-site.xml"));
    configuration.addResource(new Path("/etc/hadoop/conf/core-site.xml"));
    configuration.addResource(new Path("/etc/hadoop/conf/yarn-site.xml"));
    configuration.addResource(new Path("/etc/hadoop/conf/mapred-site.xml"));

    try {
        PropertiesConfiguration config = new PropertiesConfiguration(CONF_PATH);
        DEFAULT_THRESHOLD_IN_BYTES = config.getLong("default.threshold");
    } catch (Exception e) {
        throw new RuntimeException("Exception while loading default threshold in bytes" + e);

    }
    final CompactionCriteria criteria = new CompactionCriteria(options);
    if (StringUtils.isNotBlank(options.get("targetPath"))) {
        return new CompactionManagerImpl(configuration, criteria);
    }
    return new CompactionManagerInPlaceImpl(configuration, criteria);
}
 
Example 13
Project: happylifeplat-transaction   File: ConfigHelper.java   Source Code and License 5 votes vote down vote up
public ConfigHelper(String propertyPath) {
    try {
        propertiesConfiguration = new PropertiesConfiguration(propertyPath);
    } catch (Exception e) {
        throw new RuntimeException(
                "Please configure check  file: " + propertyPath);
    }
}
 
Example 14
Project: nightwatch   File: Configuration.java   Source Code and License 5 votes vote down vote up
public static void init(String configFilePath) {
    try {
        defultConfigFilePath = configFilePath;
        config = new PropertiesConfiguration(defultConfigFilePath);
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
}
 
Example 15
Project: java-market-maker   File: MarketMakerConfiguration.java   Source Code and License 5 votes vote down vote up
public static MarketMakerConfiguration fromPropertiesFile(final String fileName) throws ConfigurationException {
    final Configuration configuration = new PropertiesConfiguration(fileName);
    return new MarketMakerConfiguration(
        configuration.getInt(ConfigKey.TIME_SLEEP_SECONDS.getKey()),
        new BigDecimal(configuration.getString(ConfigKey.SPREAD_FRACTION.getKey())),
        configuration.getDouble(ConfigKey.FAIR_VOLATILITY.getKey()),
        configuration.getDouble(ConfigKey.VOLATILITY_SPREAD_FRACTION.getKey()),
        configuration.getInt(ConfigKey.NUM_LEVELS.getKey()),
        configuration.getInt(ConfigKey.QUANTITY_ON_LEVEL.getKey()),
        configuration.getDouble(ConfigKey.DELTA_LIMIT.getKey()),
        configuration.getDouble(ConfigKey.VEGA_LIMIT.getKey())
    );
}
 
Example 16
Project: hadoop-oss   File: MetricsSystemImpl.java   Source Code and License 5 votes vote down vote up
@Override
public synchronized String currentConfig() {
  PropertiesConfiguration saver = new PropertiesConfiguration();
  StringWriter writer = new StringWriter();
  saver.copy(config);
  try { saver.save(writer); }
  catch (Exception e) {
    throw new MetricsConfigException("Error stringify config", e);
  }
  return writer.toString();
}
 
Example 17
Project: hadoop-oss   File: MetricsConfig.java   Source Code and License 5 votes vote down vote up
/**
 * Load configuration from a list of files until the first successful load
 * @param conf  the configuration object
 * @param files the list of filenames to try
 * @return  the configuration object
 */
static MetricsConfig loadFirst(String prefix, String... fileNames) {
  for (String fname : fileNames) {
    try {
      Configuration cf = new PropertiesConfiguration(fname)
          .interpolatedConfiguration();
      LOG.info("loaded properties from "+ fname);
      LOG.debug(toString(cf));
      MetricsConfig mc = new MetricsConfig(cf, prefix);
      LOG.debug(mc);
      return mc;
    } catch (ConfigurationException e) {
      if (e.getMessage().startsWith("Cannot locate configuration")) {
        continue;
      }
      throw new MetricsConfigException(e);
    }
  }
  LOG.warn("Cannot locate configuration: tried "+
           Joiner.on(",").join(fileNames));
  // default to an empty configuration
  return new MetricsConfig(new PropertiesConfiguration(), prefix);
}
 
Example 18
Project: hadoop-oss   File: MetricsConfig.java   Source Code and License 5 votes vote down vote up
static String toString(Configuration c) {
  ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  try {
    PrintStream ps = new PrintStream(buffer, false, "UTF-8");
    PropertiesConfiguration tmp = new PropertiesConfiguration();
    tmp.copy(c);
    tmp.save(ps);
    return buffer.toString("UTF-8");
  } catch (Exception e) {
    throw new MetricsConfigException(e);
  }
}
 
Example 19
Project: hadoop-oss   File: ConfigUtil.java   Source Code and License 5 votes vote down vote up
static void dump(String header, Configuration c, PrintStream out) {
  PropertiesConfiguration p = new PropertiesConfiguration();
  p.copy(c);
  if (header != null) {
    out.println(header);
  }
  try { p.save(out); }
  catch (Exception e) {
    throw new RuntimeException("Error saving config", e);
  }
}
 
Example 20
Project: newblog   File: HttpHelper.java   Source Code and License 5 votes vote down vote up
/**
 * 描述:创建httpClient连接池,并初始化httpclient
 */
private void initHttpClient() throws ConfigurationException {
    Configuration configuration = new PropertiesConfiguration(CONFIG_FILE);
    //创建httpclient连接池
    PoolingHttpClientConnectionManager httpClientConnectionManager = new PoolingHttpClientConnectionManager();
    httpClientConnectionManager.setMaxTotal(configuration.getInt("http.max.total"));    //设置连接池线程最大数量
    httpClientConnectionManager.setDefaultMaxPerRoute(configuration.getInt("http.max.route"));    //设置单个路由最大的连接线程数量
    //创建http request的配置信息
    RequestConfig requestConfig = RequestConfig.custom()
            .setConnectionRequestTimeout(configuration.getInt("http.request.timeout"))
            .setSocketTimeout(configuration.getInt("http.socket.timeout"))
            .setCookieSpec(CookieSpecs.DEFAULT).build();
    //设置重定向策略
    LaxRedirectStrategy redirectStrategy = new LaxRedirectStrategy() {
        /**
         * false 禁止重定向  true 允许
         */
        @Override
        public boolean isRedirected(HttpRequest request,
                                    HttpResponse response, HttpContext context)
                throws ProtocolException {
            // TODO Auto-generated method stub
            return isRediect ? super.isRedirected(request, response, context) : isRediect;
        }
    };
    //初始化httpclient客户端
    httpClient = HttpClients.custom().setConnectionManager(httpClientConnectionManager)
            .setDefaultRequestConfig(requestConfig)
            //.setUserAgent(NewsConstant.USER_AGENT)
            .setRedirectStrategy(redirectStrategy)
            .build();
}
 
Example 21
Project: YiDu-Novel   File: InitializerListener.java   Source Code and License 5 votes vote down vote up
@Override
public void contextInitialized(ServletContextEvent event) {
    try {
        // 设定文件初期读入
        PropertiesConfiguration yiduConf = new PropertiesConfiguration("yidu.properties");
        // 设定文件自动更新
        FileChangedReloadingStrategy reloadStrategy = new FileChangedReloadingStrategy();
        yiduConf.setReloadingStrategy(reloadStrategy);
        YiDuConstants.yiduConf = yiduConf;

        // 加载伪原创设置
        YiDuConstants.pseudoConf = new PropertiesConfiguration("pseudo.properties");
        YiDuConstants.pseudoConf.setReloadingStrategy(reloadStrategy);

        // 初始化缓存
        CacheManager.initCacheManager();

        if (YiDuConstants.yiduConf.getBoolean(YiDuConfig.ENABLE_CACHE_ARTICLE_COUNT, false)) {
            // 初始化小说件数MAP
            ArticleCountManager.initArticleCountManager();
        }

        if (YiDuConstants.yiduConf.getBoolean(YiDuConfig.ENABLE_SINGLE_BOOK, false)) {
            // 初始化小说拼音和编号映射件数MAP
            SingleBookManager.initSingleBookManager();
        }
        
        // 初始化分类信息MAP
        CategoryCacheManager.initCategoryCacheManager();

        logger.info("Initialize successfully.");
    } catch (Exception e) {
    	e.printStackTrace();
        logger.error(e.getMessage(), e);
    }
}
 
Example 22
Project: YiDu-Novel   File: LanguageEditAction.java   Source Code and License 5 votes vote down vote up
public String save() {

        // 设定文件初期读入
        try {
            PropertiesConfiguration languageConf = new PropertiesConfiguration(Thread.currentThread()
                    .getContextClassLoader().getResource("language/package.properties"));

            languageConf.setProperty(YiDuConfig.TITLE, Utils.escapePropterties(title));
            languageConf.setProperty(YiDuConfig.SITEKEYWORDS, Utils.escapePropterties(siteKeywords));
            languageConf.setProperty(YiDuConfig.SITEDESCRIPTION, Utils.escapePropterties(siteDescription));
            languageConf.setProperty(YiDuConfig.NAME, Utils.escapePropterties(name));
            languageConf.setProperty(YiDuConfig.URL, Utils.escapePropterties(url));
            languageConf.setProperty(YiDuConfig.COPYRIGHT, Utils.escapePropterties(copyright));
            languageConf.setProperty(YiDuConfig.BEIANNO, Utils.escapePropterties(beianNo));
            languageConf.setProperty(YiDuConfig.ANALYTICSCODE, Utils.escapePropterties(analyticscode));
            languageConf.setProperty(YiDuConfig.CATEGORY, Utils.escapePropterties(category));

            File languageFile = new File(languageConf.getPath());
            OutputStream out = new FileOutputStream(languageFile);
            languageConf.save(out);

        } catch (Exception e) {
            addActionError(e.getMessage());
            logger.error(e);
            return ADMIN_ERROR;
        }
        loadData();
        addActionMessage(getText("messages.save.success"));
        return INPUT;

    }
 
Example 23
Project: YiDu-Novel   File: IndexAction.java   Source Code and License 5 votes vote down vote up
@SkipValidation
@Override
public String execute() {
    logger.debug("execute start.");

    File lockFile = new File(LOCK_FILE);
    if (lockFile.exists()) {
        addActionError(getText("errors.install.file.exist", new String[] { LOCK_FILE }));
        return ERROR;
    }

    // 设定文件初期读入
    try {
        PropertiesConfiguration jdbcConf = new PropertiesConfiguration("jdbc.properties");
        String dburl = jdbcConf.getString(YiDuConfig.JDBC_URL).substring(prefixjdbc.length());
        String[] dbinfo = StringUtils.split(dburl, ":");
        dbhost = dbinfo[0];
        dbinfo = StringUtils.split(dbinfo[1], "/");
        dbport = dbinfo[0];
        // 数据库名暂时固定
        dbname = "yidu";
        dbusername = jdbcConf.getString(YiDuConfig.JDBC_USERNAME);
        dbpassword = jdbcConf.getString(YiDuConfig.JDBC_PASSWORD);
        PropertiesConfiguration languageConf = new PropertiesConfiguration(Thread.currentThread()
                .getContextClassLoader().getResource("language/package.properties"));
        title = languageConf.getString(YiDuConfig.TITLE);
        siteKeywords = languageConf.getString(YiDuConfig.SITEKEYWORDS);
        siteDescription = languageConf.getString(YiDuConfig.SITEDESCRIPTION);
        name = languageConf.getString(YiDuConfig.NAME);
        url = languageConf.getString(YiDuConfig.URL);
        copyright = languageConf.getString(YiDuConfig.COPYRIGHT);
        beianNo = languageConf.getString(YiDuConfig.BEIANNO);
        analyticscode = languageConf.getString(YiDuConfig.ANALYTICSCODE);

    } catch (ConfigurationException e) {
        logger.error(e);
    }
    logger.debug("execute normally end.");
    return INPUT;
}
 
Example 24
Project: irc-helper   File: MyRecord.java   Source Code and License 5 votes vote down vote up
public void createDefault() throws Exception {
	if (file.exists()) {
		// file.renameTo(new File(Configs.recordFileName+".bak"));
		file.delete();
	}
	file.createNewFile();
	PropertiesConfiguration record = new PropertiesConfiguration(
			Configs.recordFileName);

	Records.mutedUsers.add("foo_-_");
	Records.records.put("foo_-_", new HashSet<String>() {
		{
			this.add("test");
		}
	});
	Records.verifiedUsers.add("d0048");

	record.addProperty("verifiedUsers", Records.verifiedUsers.toArray());

	// record.addProperty("records", Records.records);

	Object[] usrEntries = Records.records.keySet().toArray();
	record.addProperty("usrEntries", usrEntries);
	for (Object usr : usrEntries) {
		record.addProperty((String) usr, Records.records.get(usr).toArray());
	}
	record.save();
}
 
Example 25
Project: KernelHive   File: RepositoryConfiguration.java   Source Code and License 5 votes vote down vote up
private void reloadConfiguration(final File jarFileLocation)
		throws ConfigurationException {
	try {
		propConfig = new PropertiesConfiguration("jar:"
				+ jarFileLocation.toURI().toURL() + "!/"
				+ "repository.properties");
	} catch (final MalformedURLException e) {
		throw new ConfigurationException(e);
	}
}
 
Example 26
Project: Equella   File: RenameBehindProxyConfig.java   Source Code and License 5 votes vote down vote up
@Override
public void upgrade(UpgradeResult result, File tleInstallDir) throws Exception
{
	new PropertyFileModifier(new File(new File(tleInstallDir, CONFIG_FOLDER), PropertyFileModifier.OPTIONAL_CONFIG))
	{
		@Override
		protected boolean modifyProperties(PropertiesConfiguration props)
		{
			String v = props.getString("loginService.behindProxy");
			if( v == null )
			{
				return false;
			}

			props.setProperty("userService.useXForwardedFor", v);
			props.clearProperty("loginService.behindProxy");
			return true;
		}
	}.updateProperties();
}
 
Example 27
Project: Equella   File: UpdateLog4jConfigForTomcatLog.java   Source Code and License 5 votes vote down vote up
@Override
public void upgrade(UpgradeResult result, File tleInstallDir) throws Exception
{
	final File configFolder = new File(tleInstallDir, CONFIG_FOLDER);
	final File tomcatLogsLocation = new File(new File(tleInstallDir, "logs"), "tomcat");

	if( !tomcatLogsLocation.exists() )
	{
		tomcatLogsLocation.mkdirs();
	}

	// update log4j
	result.info("updating log4j properties");
	new PropertyFileModifier(new File(configFolder, "learningedge-log4j.properties"))
	{
		@Override
		protected boolean modifyProperties(PropertiesConfiguration props)
		{
			if( !props.containsKey("log4j.logger.TomcatLog") )
			{
				props.addProperty("log4j.logger.TomcatLog", "INFO, TOMCAT");
				props.addProperty("log4j.appender.TOMCAT", "com.tle.core.equella.runner.DailySizeRollingAppender");
				props.addProperty("log4j.appender.TOMCAT.File", new File(tomcatLogsLocation, "tomcat.html")
					.getAbsolutePath().replaceAll("\\\\", "/"));
				props.addProperty("log4j.appender.TOMCAT.Threshold", "DEBUG");
				props.addProperty("log4j.appender.TOMCAT.ImmediateFlush", "true");
				props.addProperty("log4j.appender.TOMCAT.Append", "true");
				props.addProperty("log4j.appender.TOMCAT.layout", "com.tle.core.equella.runner.HTMLLayout3");
				props.addProperty("log4j.appender.TOMCAT.layout.title", "Tomcat Logs");
				return true;
			}
			return false;
		}
	}.updateProperties();
}
 
Example 28
Project: Equella   File: UpgradeToEmbeddedTomcat.java   Source Code and License 5 votes vote down vote up
private File getUpgradeZip(Path installPath, File versionProps) throws ConfigurationException
{
	final PropertiesConfiguration props = new PropertiesConfiguration(versionProps);
	final String mmr = (String) props.getProperty("version.mmr");
	final String display = (String) props.getProperty("version.display");
	String filename = MessageFormat.format("tle-upgrade-{0} ({1}).zip", mmr, display);
	return installPath.resolve("manager/updates/" + filename).toFile();
}
 
Example 29
Project: Equella   File: UpgradeToEmbeddedTomcat.java   Source Code and License 5 votes vote down vote up
private void updateMandatoryProperties(final UpgradeResult result, File configDir) throws ConfigurationException,
	IOException
{
	PropertyFileModifier propMod = new PropertyFileModifier(new File(configDir,
		PropertyFileModifier.MANDATORY_CONFIG))
	{
		@Override
		protected boolean modifyProperties(PropertiesConfiguration props)
		{
			// Add Tomcat ports
			String url = (String) props.getProperty("admin.url");
			String port = getPort(url);
			String tomcatComment = System.lineSeparator()
				+ "# Tomcat ports. Specify the ports Tomcat should create connectors for";
			PropertiesConfigurationLayout layout = props.getLayout();
			layout.setLineSeparator(System.lineSeparator());
			if( url.contains("https") )
			{
				String httpsProp = "https.port";
				props.setProperty(httpsProp, port);
				layout.setComment(httpsProp, tomcatComment);
				props.setProperty("#http.port", "");
			}
			else
			{
				String httpProp = "http.port";
				props.setProperty(httpProp, port);
				layout.setComment(httpProp, tomcatComment);
				props.setProperty("#https.port", "");
			}
			props.setProperty("#ajp.port", "8009");

			// Remove Tomcat location
			props.clearProperty("tomcat.location");

			return true;
		}
	};
	propMod.updateProperties();
}
 
Example 30
Project: Equella   File: UpdateClusterConfig.java   Source Code and License 5 votes vote down vote up
@Override
protected boolean modifyProperties(PropertiesConfiguration props)
{
	boolean changed = false;
	changed |= changeKey(props, BIND_ADDRESS);
	changed |= changeKey(props, MULTICAST_ADDRESS);
	changed |= changeKey(props, MULTICAST_PORT);
	changed |= changeKey(props, CONNECTION_STRING, true);
	changed |= changeKey(props, DEBUG);
	changed |= changeKey(props, CLUSTER_NODE_ID);
	return changed;
}
 
Example 31
Project: Equella   File: UpdateHibernateProperties.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("nls")
@Override
public void upgrade(UpgradeResult result, File tleInstallDir) throws Exception
{
	PropertyFileModifier modifier = new PropertyFileModifier(new File(new File(tleInstallDir, CONFIG_FOLDER),
		PropertyFileModifier.HIBERNATE_CONFIG))
	{
		@Override
		protected boolean modifyProperties(PropertiesConfiguration props)
		{
			String dialect = props.getString(HIBERNATE_DIALECT);
			String newdialect = null;
			if( dialect.equals("org.hibernate.dialect.PostgreSQLDialect") )
			{
				newdialect = "com.tle.hibernate.dialect.ExtendedPostgresDialect";
			}
			else if( dialect.equals("org.hibernate.dialect.Oracle10gDialect") )
			{
				newdialect = "com.tle.hibernate.dialect.ExtendedOracle10gDialect";
			}
			else if( dialect.equals("org.hibernate.dialect.Oracle9iDialect")
				|| dialect.equals("org.hibernate.dialect.Oracle9Dialect") )
			{
				newdialect = "com.tle.hibernate.dialect.ExtendedOracle9iDialect";
			}
			if( newdialect != null )
			{
				props.setProperty(HIBERNATE_DIALECT, newdialect);
				return true;
			}
			return false;
		}
	};
	modifier.updateProperties();
}
 
Example 32
Project: Equella   File: PropertyFileModifier.java   Source Code and License 5 votes vote down vote up
public PropertyFileModifier(File propertiesFile) throws ConfigurationException
{
	this.file = propertiesFile;
	props = new PropertiesConfiguration();
	props.setLayout(new ExtendedPropertiesLayout(props));
	props.setEncoding("UTF-8");
	props.setDelimiterParsingDisabled(true);

	if( file.exists() )
	{
		props.load(file);
	}
}
 
Example 33
Project: soundwave   File: Configuration.java   Source Code and License 5 votes vote down vote up
private Configuration() {

    try {
      String file = System.getProperty("config.file", "config/soundwave.properties");
      logger.info("Configuration file is {}", file);
      properties = new PropertiesConfiguration(file);
    } catch (Exception ex) {
      logger.error("Fail to load configuration {}. Error is {}",
          properties == null ? "null" : properties.getFileName(),
          ExceptionUtils.getRootCauseMessage(ex));
    }
  }
 
Example 34
Project: Yidu   File: InitializerListener.java   Source Code and License 5 votes vote down vote up
@Override
public void contextInitialized(ServletContextEvent event) {
    try {
        // 设定文件初期读入
        PropertiesConfiguration yiduConf = new PropertiesConfiguration("yidu.properties");
        // 设定文件自动更新
        FileChangedReloadingStrategy reloadStrategy = new FileChangedReloadingStrategy();
        yiduConf.setReloadingStrategy(reloadStrategy);
        YiDuConstants.yiduConf = yiduConf;

        // 加载伪原创设置
        YiDuConstants.pseudoConf = new PropertiesConfiguration("pseudo.properties");
        YiDuConstants.pseudoConf.setReloadingStrategy(reloadStrategy);

        // 初始化缓存
        CacheManager.initCacheManager();

        if (YiDuConstants.yiduConf.getBoolean(YiDuConfig.ENABLE_CACHE_ARTICLE_COUNT, false)) {
            // 初始化小说件数MAP
            ArticleCountManager.initArticleCountManager();
        }

        if (YiDuConstants.yiduConf.getBoolean(YiDuConfig.ENABLE_SINGLE_BOOK, false)) {
            // 初始化小说拼音和编号映射件数MAP
            SingleBookManager.initSingleBookManager();
        }
        
        // 初始化分类信息MAP
        CategoryCacheManager.initCategoryCacheManager();

        logger.info("Initialize successfully.");
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
Example 35
Project: Yidu   File: LanguageEditAction.java   Source Code and License 5 votes vote down vote up
public String save() {

        // 设定文件初期读入
        try {
            PropertiesConfiguration languageConf = new PropertiesConfiguration(Thread.currentThread()
                    .getContextClassLoader().getResource("language/package.properties"));

            languageConf.setProperty(YiDuConfig.TITLE, Utils.escapePropterties(title));
            languageConf.setProperty(YiDuConfig.SITEKEYWORDS, Utils.escapePropterties(siteKeywords));
            languageConf.setProperty(YiDuConfig.SITEDESCRIPTION, Utils.escapePropterties(siteDescription));
            languageConf.setProperty(YiDuConfig.NAME, Utils.escapePropterties(name));
            languageConf.setProperty(YiDuConfig.URL, Utils.escapePropterties(url));
            languageConf.setProperty(YiDuConfig.COPYRIGHT, Utils.escapePropterties(copyright));
            languageConf.setProperty(YiDuConfig.BEIANNO, Utils.escapePropterties(beianNo));
            languageConf.setProperty(YiDuConfig.ANALYTICSCODE, Utils.escapePropterties(analyticscode));
            languageConf.setProperty(YiDuConfig.CATEGORY, Utils.escapePropterties(category));

            File languageFile = new File(languageConf.getPath());
            OutputStream out = new FileOutputStream(languageFile);
            languageConf.save(out);

        } catch (Exception e) {
            addActionError(e.getMessage());
            logger.error(e);
            return ADMIN_ERROR;
        }
        loadData();
        addActionMessage(getText("messages.save.success"));
        return INPUT;

    }
 
Example 36
Project: Yidu   File: IndexAction.java   Source Code and License 5 votes vote down vote up
@SkipValidation
@Override
public String execute() {
    logger.debug("execute start.");

    File lockFile = new File(LOCK_FILE);
    if (lockFile.exists()) {
        addActionError(getText("errors.install.file.exist", new String[] { LOCK_FILE }));
        return ERROR;
    }

    // 设定文件初期读入
    try {
        PropertiesConfiguration jdbcConf = new PropertiesConfiguration("jdbc.properties");
        String dburl = jdbcConf.getString(YiDuConfig.JDBC_URL).substring(prefixjdbc.length());
        String[] dbinfo = StringUtils.split(dburl, ":");
        dbhost = dbinfo[0];
        dbinfo = StringUtils.split(dbinfo[1], "/");
        dbport = dbinfo[0];
        // 数据库名暂时固定
        dbname = "yidu";
        dbusername = jdbcConf.getString(YiDuConfig.JDBC_USERNAME);
        dbpassword = jdbcConf.getString(YiDuConfig.JDBC_PASSWORD);
        PropertiesConfiguration languageConf = new PropertiesConfiguration(Thread.currentThread()
                .getContextClassLoader().getResource("language/package.properties"));
        title = languageConf.getString(YiDuConfig.TITLE);
        siteKeywords = languageConf.getString(YiDuConfig.SITEKEYWORDS);
        siteDescription = languageConf.getString(YiDuConfig.SITEDESCRIPTION);
        name = languageConf.getString(YiDuConfig.NAME);
        url = languageConf.getString(YiDuConfig.URL);
        copyright = languageConf.getString(YiDuConfig.COPYRIGHT);
        beianNo = languageConf.getString(YiDuConfig.BEIANNO);
        analyticscode = languageConf.getString(YiDuConfig.ANALYTICSCODE);

    } catch (ConfigurationException e) {
        logger.error(e);
    }
    logger.debug("execute normally end.");
    return INPUT;
}
 
Example 37
Project: unitimes   File: MessageResources.java   Source Code and License 5 votes vote down vote up
private Configuration getConfiguration(String name) {
	Configuration configuration = null;
	URL url = Thread.currentThread().getContextClassLoader().getResource(name);
	if (url != null) {
		PropertiesConfiguration pc = new PropertiesConfiguration();
		pc.setURL(url);
		
		// Set reloading strategy 
		String dynamicReload = ApplicationProperties.getProperty("tmtbl.properties.dynamic_reload", null);
		if (dynamicReload!=null && dynamicReload.equalsIgnoreCase("true")) {
			long refreshDelay = Constants.getPositiveInteger(
					ApplicationProperties.getProperty("tmtbl.properties.dynamic_reload_interval"), 15000 );
			
			FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
			strategy.setRefreshDelay(refreshDelay); 
			pc.setReloadingStrategy(strategy);
			
			pc.addConfigurationListener(new MessageResourcesCfgListener(pc.getBasePath()));
		}			
		
		try {
			pc.load();
			configuration = pc;
		} catch (ConfigurationException e) {
			Debug.error("Message Resources configuration exception: " + e.getMessage());
		}
	}

	return configuration;
}
 
Example 38
Project: janusgraph_tutorial   File: ComputeWeight.java   Source Code and License 5 votes vote down vote up
public static void main(String[] argv) throws InterruptedException, IOException {
  Graph hadoopGraph = null;

  try {
    LOGGER.info("Connect to the hadoop graph");
    hadoopGraph = GraphFactory.open(new PropertiesConfiguration(HADOOP_CONFIG_FILE));
    ComputeWeightVertexProgram.Builder builder = ComputeWeightVertexProgram.build().withRwGraphConfig(Schema.CONFIG_FILE);

    ComputerResult result = hadoopGraph.
        compute().
        program(
            builder.create(hadoopGraph)
        ).
        vertices(hasLabel(Schema.USER)).
        submit().get();
    result.close();
    hadoopGraph.close();
    Spark.close();

    hadoopGraph = null;
  } catch (Exception e) {
    e.printStackTrace();
    try {
      if (hadoopGraph != null) {
        hadoopGraph.close();
        Spark.close();
      }
    } catch (Exception e1) {
      System.err.println("Couldn't close graph or spark...");
    }
  }

  // we need to call this one or else the program will be waiting forever
  LOGGER.info("bye bye");
  System.exit(0);
}
 
Example 39
Project: momo-2   File: Bot.java   Source Code and License 5 votes vote down vote up
public boolean loadProperties() {
	try (FileInputStream finput = new FileInputStream("resources/Bot.properties")) {
		PropertiesConfiguration config = new PropertiesConfiguration();
		config.load(finput, "UTF-8");
		config.setEncoding("UTF-8");
		botConfig.setToken(config.getString("BotToken"));
		botConfig.setAvatar(config.getString("Avatar"));
		botConfig.setBotOwnerId(config.getLong("BotOwnerId", 0));
		botConfig.setBotInviteLink(config.getString("InviteLink"));
		botConfig.setMaxSongLength(config.getInt("MaxSongLength", 15));
		botConfig.setCompanionBot(config.getBoolean("MusicCompanion", false));
		botConfig.setDefaultSSLPort(config.getInt("DefaultSSLPort", 8443));
		botConfig.setDefaultInsecurePort(config.getInt("DefaultInsecurePort", 8080));

		Configuration subset = config.subset("apikey");
		Iterator<String> iter = subset.getKeys();
		while(iter.hasNext()) {
			String key = iter.next();
			String val = subset.getString(key);
			if(val.length() > 0) {
				this.apiKeys.put(key, val);
				logger.info("Added API key for: {}", key);
			}
		}
		StatusChangeJob.setStatuses(config.getStringArray("StatusRotation"));
		return true;
	} catch (Exception e) {
		e.printStackTrace();
		return false;
	}
}
 
Example 40
Project: hadoop   File: MetricsSystemImpl.java   Source Code and License 5 votes vote down vote up
@Override
public synchronized String currentConfig() {
  PropertiesConfiguration saver = new PropertiesConfiguration();
  StringWriter writer = new StringWriter();
  saver.copy(config);
  try { saver.save(writer); }
  catch (Exception e) {
    throw new MetricsConfigException("Error stringify config", e);
  }
  return writer.toString();
}
 
Example 41
Project: hadoop   File: MetricsConfig.java   Source Code and License 5 votes vote down vote up
static String toString(Configuration c) {
  ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  try {
    PrintStream ps = new PrintStream(buffer, false, "UTF-8");
    PropertiesConfiguration tmp = new PropertiesConfiguration();
    tmp.copy(c);
    tmp.save(ps);
    return buffer.toString("UTF-8");
  } catch (Exception e) {
    throw new MetricsConfigException(e);
  }
}
 
Example 42
Project: hadoop   File: ConfigUtil.java   Source Code and License 5 votes vote down vote up
static void dump(String header, Configuration c, PrintStream out) {
  PropertiesConfiguration p = new PropertiesConfiguration();
  p.copy(c);
  if (header != null) {
    out.println(header);
  }
  try { p.save(out); }
  catch (Exception e) {
    throw new RuntimeException("Error saving config", e);
  }
}
 
Example 43
Project: obevo   File: DbFileMerger.java   Source Code and License 5 votes vote down vote up
public void execute(DbFileMergerArgs args) {
    try {
        PropertiesConfiguration config = new PropertiesConfiguration(args.getDbMergeConfigFile());
        DbPlatform dialect = DbPlatformConfiguration.getInstance().valueOf(config.getString("dbType"));
        this.generateDiffs(dialect, DbMergeInfo.parseFromProperties(config), args.getOutputDir());
    } catch (ConfigurationException e) {
        throw new DeployerRuntimeException(e);
    }
}
 
Example 44
Project: pds   File: GenUtils.java   Source Code and License 5 votes vote down vote up
/**
 * 获取配置信息
 */
public static Configuration getConfig(){
	try {
		return new PropertiesConfiguration("generator.properties");
	} catch (ConfigurationException e) {
		throw new RRException("获取配置文件失败,", e);
	}
}
 
Example 45
Project: redirector   File: DataServiceInfo.java   Source Code and License 5 votes vote down vote up
private ServiceInfo obtainServiceInfo() {
    try {
        Configuration config = new PropertiesConfiguration(CONFIG_FILE_NAME);
        return new ServiceInfo(config);
    } catch (ConfigurationException ce) {
        log.warn("Failed to load configuration file: {}", CONFIG_FILE_NAME);
    } catch (Exception e) {
        log.warn("Exception appears while configuration file is loading", e);
    }
    return null;
}
 
Example 46
Project: redirector   File: E2EConfigLoader.java   Source Code and License 5 votes vote down vote up
public E2EConfigLoader(String defaultFileName) {
    String fileName = getFileNameFromVmOptions();
    if (fileName == null) {
     fileName = defaultFileName;
    }
    PropertiesConfiguration propCfg = new PropertiesConfiguration();
    try {
        propCfg.load(getClass().getClassLoader().getResourceAsStream(fileName));
    } catch (Exception e) {
        log.error("Failed to load " + fileName, e);
    }
    config = propCfg;
}
 
Example 47
Project: my-spring-boot-project   File: GenUtils.java   Source Code and License 5 votes vote down vote up
/**
 * 获取配置信息
 */
public static Configuration getConfig() {
    try {
        return new PropertiesConfiguration("generator.properties");
    } catch (ConfigurationException e) {
        throw new RRException("获取配置文件失败,", e);
    }
}
 
Example 48
Project: loom   File: AdapterConfig.java   Source Code and License 5 votes vote down vote up
/**
 * Attempts to load a config from a given file path Note throws a runtime exception
 * IllegalArgumentException if config can't be loaded.
 *
 * @param path Location to load the config from
 */
private void loadFromPath(final String filePath) throws AdapterConfigException {
    path = filePath;
    File loc = new File(path);
    if (loc.exists()) {
        try {
            PropertiesConfiguration props = new PropertiesConfiguration(loc);
            loadFromProperties(props);
        } catch (ConfigurationException e) {
            throw new AdapterConfigException("ConfigurationException file at path: " + path, e);
        }
    } else {
        throw new AdapterConfigException("Missing properties file at path: " + path);
    }
}
 
Example 49
Project: loom   File: AdapterConfigTest.java   Source Code and License 5 votes vote down vote up
/**
 * Tests that it handles an empty PropertiesConfiguration
 */
@Test
public void testEmptyProperties() {
    try {
        new AdapterConfig(new PropertiesConfiguration());
        Assert.fail("Expected an IllegalArgumentException");
    } catch (AdapterConfigException ex) {
        Assert.assertEquals("providerType is missing in file null", ex.getMessage());
    }
}
 
Example 50
Project: loom   File: AdapterConfigTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testSuccessProperties() {
    PropertiesConfiguration props = loadProperties();
    try {
        new AdapterConfig(props);

    } catch (AdapterConfigException ex) {
        Assert.fail("Expected it to pass");
    }
}
 
Example 51
Project: loom   File: AdapterConfigTest.java   Source Code and License 5 votes vote down vote up
/**
 * Helper to check for the correct exception and message
 *
 * @param key
 */
private void checkPropertyException(final String key) {
    PropertiesConfiguration props = loadProperties();
    try {
        props.setProperty(key, null);
        new AdapterConfig(props);
        Assert.fail("Expected an IllegalArgumentException");
    } catch (AdapterConfigException ex) {
        Assert.assertEquals(key + " is missing in file filePath", ex.getMessage());
    }
}
 
Example 52
Project: loom   File: AdapterConfigTest.java   Source Code and License 5 votes vote down vote up
/**
 * Test loading from a file vs load the same file into the PropertiesConfiguration the config
 *
 * @throws ConfigurationException
 */
@Test
public void testLoadingViaFileVsProperties() throws ConfigurationException, AdapterConfigException {
    AdapterConfig config = new AdapterConfig("./src/test/resources/test.properties");
    AdapterConfig config2 = new AdapterConfig(new PropertiesConfiguration("./src/test/resources/test.properties"));

    Assert.assertEquals(config.getAdapterClass(), config2.getAdapterClass());
    Assert.assertEquals(config.getAdapterDir(), config2.getAdapterDir());
    Assert.assertEquals(config.getAuthEndpoint(), config2.getAuthEndpoint());
    Assert.assertEquals(config.getProviderId(), config2.getProviderId());
    Assert.assertEquals(config.getProviderName(), config2.getProviderName());
    Assert.assertEquals(config.getProviderType(), config2.getProviderType());
    Assert.assertEquals(config.getCollectThreads(), config2.getCollectThreads());
    Assert.assertEquals(config.getSchedulingInterval(), config2.getSchedulingInterval());
}
 
Example 53
Project: loom   File: FakeConfig.java   Source Code and License 5 votes vote down vote up
public void loadFromProperties(final PropertiesConfiguration props) {
    DataConfiguration config = new DataConfiguration(props);

    projectNbr = config.getIntArray("fake.data.projectNbr");

    // all regions
    regionNbr = config.getIntArray("fake.data.regionNbr");
    // per region per project
    imageNbr = config.getIntArray("fake.data.imageNbr");
    extraVols = config.getIntArray("fake.data.extraVols");
    volSizeMax = config.getIntArray("fake.data.volSizeMax");
    sizeSteps = config.getIntArray("fake.data.sizeSteps");
    extraNets = config.getIntArray("fake.data.extraNets");
    rebootCount = config.getIntArray("fake.data.rebootCount");


    // discover like data generation attrs
    networkNbr = config.getIntArray("fake.data.networkNbr");
    subnetPerNetworkNbr = config.getIntArray("fake.data.subnetPerNetworkNbr");
    vmPerSubnetNbr = config.getIntArray("fake.data.vmPerSubnetNbr");
    vmWithVolumeRatio = config.getIntArray("fake.data.vmWithVolumeRatio");


    // old data generation attrs
    instanceNbr = config.getIntArray("fake.data.instanceNbr");
    volsPerVm = config.getIntArray("fake.data.volsPerVm");
    subsPerVm = config.getIntArray("fake.data.subsPerVm");
    subsPerExtraNets = config.getIntArray("fake.data.subsPerExtraNet");


    instanceQuota = config.getIntArray("fake.quota.instances");
    coreQuota = config.getIntArray("fake.quota.cores");
    volumeQuota = config.getIntArray("fake.quota.volumes");
    gigabyteQuota = config.getIntArray("fake.quota.gigabytes");
    ramQuota = config.getIntArray("fake.quota.ram");

    quotaRepeatNbr = config.getInt("fake.quota.repeatNbr");

    index = config.getInt("fake.index", 0);
}
 
Example 54
Project: loom   File: DiscoverConfig.java   Source Code and License 5 votes vote down vote up
@Override
public void loadFromProperties(final PropertiesConfiguration props) {
    super.loadFromProperties(props);
    DataConfiguration config = new DataConfiguration(props);
    workloadNbrPerType = config.getIntArray("discover.data.workloadNbrPerType");
    workloadTypeNbr = config.getIntArray("discover.data.workloadTypeNbr");
    networkNbr = config.getIntArray("discover.data.networkNbr");
    subnetPerNetworkNbr = config.getIntArray("discover.data.subnetPerNetworkNbr");
    vmPerSubnetNbr = config.getIntArray("discover.data.vmPerSubnetNbr");
    vmWithVolumeRatio = config.getIntArray("discover.data.vmWithVolumeRatio");
}
 
Example 55
Project: Fav-Track   File: GetPropetries.java   Source Code and License 5 votes vote down vote up
private void getSecretValues(){
    String secretConfigFile = "config.properties";
    try {
        PropertiesConfiguration secretConfig = new PropertiesConfiguration(secretConfigFile);
        if (secretConfig != null) {
            //Extract secret credentials
            MyShowsClientId = secretConfig.getString("MyShowsClientId");
            MyShowsSecret = secretConfig.getString("MyShowsSecret");
        } else {
            throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath");
        }
    } catch (Exception e) {
        logger(logger,"error","Exception: " + e);
    }
}
 
Example 56
Project: Fav-Track   File: GetPropetries.java   Source Code and License 5 votes vote down vote up
private void getUserValues(){
    try {
        PropertiesConfiguration config = new PropertiesConfiguration(extFolder+propFileName);
        user_pref_player = config.getString("user_pref_player");
        user_login = config.getString("user_login");
        user_password = config.getString("user_password");
        user_rememberMe = config.getBoolean("user_rememberMe");
        user_autologin = config.getBoolean("user_autologin");
        user_showtime = config.getInt("user_showtime");
        /*logger.info(config.getPath());*/
    } catch (Exception e) {
        System.out.println("Exception: " + e);
    }
}
 
Example 57
Project: Fav-Track   File: GetPropetries.java   Source Code and License 5 votes vote down vote up
private void getPlayerValues(){
    try {
        //getUserValues();
        PropertiesConfiguration config = new PropertiesConfiguration(extFolder+propFileName);
        MPC_host = config.getString("MPC_host");
        MPC_port = config.getString("MPC_port");
        VLC_host = config.getString("VLC_host");
        VLC_port = config.getString("VLC_port");
        VLC_password = config.getString("VLC_password");
        VLC_login = config.getString("VLC_login");
        /*//Extract player setup
        switch (user_pref_player){
            case "MPC":
                MPC_host = config.getString("MPC_host");
                MPC_port = config.getString("MPC_port");
                break;
            case "VLC":
                VLC_host = config.getString("VLC_host");
                VLC_port = config.getString("VLC_port");
                VLC_password = config.getString("VLC_password");
                VLC_login = config.getString("VLC_login");

                break;
        }*/

    } catch (Exception e) {
        System.out.println("Exception: " + e);
    }
}
 
Example 58
Project: Fav-Track   File: GetPropetries.java   Source Code and License 5 votes vote down vote up
private void setUserValues(String propName, String propValue){
    try {
        PropertiesConfiguration config = new PropertiesConfiguration(extFolder+propFileName);
        config.setProperty(propName, propValue);
        config.save();
        //logger.info(config.getPath());
    } catch (Exception e) {
        logger(logger,"error", e.getMessage());
    }
}
 
Example 59
Project: lorne_core   File: ConfigHelper.java   Source Code and License 5 votes vote down vote up
public ConfigHelper(String propertyPath) {
    try {
        propertiesConfiguration = new PropertiesConfiguration(propertyPath);
    } catch (Exception e) {
        throw new RuntimeException(
                "Please configure check  file: " + propertyPath);
    }
}
 
Example 60
Project: renren-msg   File: GenUtils.java   Source Code and License 5 votes vote down vote up
/**
 * 获取配置信息
 */
public static Configuration getConfig(){
	try {
		return new PropertiesConfiguration("generator.properties");
	} catch (ConfigurationException e) {
		throw new RRException("获取配置文件失败,", e);
	}
}