Java 类org.apache.commons.configuration.PropertiesConfiguration 实例源码

项目:hadoop-oss    文件:MetricsConfig.java   
/**
 * 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);
}
项目:YiDu-Novel    文件:LanguageEditAction.java   
@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);
    }
}
项目:irc-helper    文件:MyRecord.java   
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();

}
项目:irc-helper    文件:MyConfig.java   
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();
}
项目:Equella    文件:RemoveClusterGroupName.java   
@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();
}
项目:Yidu    文件:LanguageEditAction.java   
@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);
    }
}
项目:hdt-gremlin    文件:HDTtoGremlin.java   
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);
    }
项目:momo-2    文件:CommandHandler.java   
/**
 * 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();
        }
    }
}
项目:hadoop    文件:MetricsConfig.java   
/**
 * 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);
}
项目:loom    文件:FakeAdapterTest.java   
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);
    // }
}
项目:loom    文件:AdapterConfigTest.java   
/**
 * 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");
    }
}
项目:loom    文件:AdapterConfigTest.java   
/**
 * 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;
}
项目:dataSqueeze    文件:CompactionManagerFactory.java   
/**
 * 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);
}
项目:happylifeplat-transaction    文件:ConfigHelper.java   
public ConfigHelper(String propertyPath) {
    try {
        propertiesConfiguration = new PropertiesConfiguration(propertyPath);
    } catch (Exception e) {
        throw new RuntimeException(
                "Please configure check  file: " + propertyPath);
    }
}
项目:nightwatch    文件:Configuration.java   
public static void init(String configFilePath) {
    try {
        defultConfigFilePath = configFilePath;
        config = new PropertiesConfiguration(defultConfigFilePath);
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
}
项目:java-market-maker    文件:MarketMakerConfiguration.java   
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())
    );
}
项目:hadoop-oss    文件:MetricsSystemImpl.java   
@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();
}
项目:hadoop-oss    文件:MetricsConfig.java   
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);
  }
}
项目:hadoop-oss    文件:ConfigUtil.java   
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);
  }
}
项目:newblog    文件:HttpHelper.java   
/**
 * 描述:创建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();
}
项目:YiDu-Novel    文件:InitializerListener.java   
@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);
    }
}
项目:YiDu-Novel    文件:LanguageEditAction.java   
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;

    }
项目:YiDu-Novel    文件:IndexAction.java   
@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;
}
项目:irc-helper    文件:MyRecord.java   
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();
}
项目:KernelHive    文件:RepositoryConfiguration.java   
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);
    }
}
项目:Equella    文件:RenameBehindProxyConfig.java   
@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();
}
项目:Equella    文件:UpdateLog4jConfigForTomcatLog.java   
@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();
}
项目:Equella    文件:UpgradeToEmbeddedTomcat.java   
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();
}
项目:Equella    文件:UpgradeToEmbeddedTomcat.java   
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();
}
项目:Equella    文件:UpdateClusterConfig.java   
@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;
}
项目:Equella    文件:UpdateHibernateProperties.java   
@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();
}
项目:Equella    文件:PropertyFileModifier.java   
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);
    }
}
项目:soundwave    文件:Configuration.java   
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));
    }
  }
项目:Yidu    文件:InitializerListener.java   
@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);
    }
}
项目:Yidu    文件:LanguageEditAction.java   
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;

    }
项目:Yidu    文件:IndexAction.java   
@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;
}
项目:unitimes    文件:MessageResources.java   
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;
}
项目:janusgraph_tutorial    文件:ComputeWeight.java   
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);
}
项目:momo-2    文件:Bot.java   
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;
    }
}
项目:hadoop    文件:MetricsSystemImpl.java   
@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();
}