Java 类org.apache.commons.configuration.reloading.FileChangedReloadingStrategy 实例源码

项目:distributedlog    文件:ConfigurationSubscription.java   
private boolean initConfig() {
    if (fileConfigs.isEmpty()) {
        try {
            for (FileConfigurationBuilder fileConfigBuilder : fileConfigBuilders) {
                FileConfiguration fileConfig = fileConfigBuilder.getConfiguration();
                FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy();
                reloadingStrategy.setRefreshDelay(0);
                fileConfig.setReloadingStrategy(reloadingStrategy);
                fileConfigs.add(fileConfig);
            }
        } catch (ConfigurationException ex) {
            if (!fileNotFound(ex)) {
                LOG.error("Config init failed {}", ex);
            }
        }
    }
    return !fileConfigs.isEmpty();
}
项目:JForum    文件:JForumConfig.java   
public JForumConfig(ServletContext servletContext, SessionFactory sessionFactory) {
    this.sessionFactory = sessionFactory;
    this.setReloadingStrategy(new FileChangedReloadingStrategy());
    this.setDelimiterParsingDisabled(true);

    try {
        loadProps();
        if (servletContext != null) {
            setProperty(ConfigKeys.APPLICATION_PATH, servletContext.getRealPath(""));
        }
        loadDatabaseProperties();
        normalizeTemplateDirectory();
    }
    catch (Exception e) {
        throw new ForumException(e);
    }
}
项目:opennms-provisioning-integration-server    文件:InstanceApacheConfiguration.java   
private static org.apache.commons.configuration.Configuration createConfig(final Path basePath) {
    final Path path = basePath.resolve("requisition.properties");

    // Raise wrapped file not found exception if the config file does not exist
    if (!Files.exists(path)) {
        throw new RuntimeException("Config file not found: " + path);
    }

    // Load system and file properties
    try {
        return new org.apache.commons.configuration.PropertiesConfiguration(path.toFile()) {
            {
                setThrowExceptionOnMissing(true);
                setReloadingStrategy(new FileChangedReloadingStrategy());
            }
        };

    } catch (final ConfigurationException ex) {
        throw new RuntimeException(ex);
    }
}
项目:TNT4J    文件:FileTokenRepository.java   
@Override
public void open() throws IOException {
    if (isOpen() || (configName == null)) {
        return;
    }
    try {
        initConfig();
        if (refDelay > 0) {
            FileChangedReloadingStrategy reloadConfig = new FileChangedReloadingStrategy();
            reloadConfig.setRefreshDelay(refDelay);
            config.setReloadingStrategy(reloadConfig);
        }
    } catch (Throwable e) {
        IOException ioe = new IOException(e.toString());
        ioe.initCause(e);
        throw ioe;
    }
}
项目:MOCHA    文件:Configuration.java   
/**
 * Load the current system configuration file. The file is automatically reloaded if changed.
 * 
 * @return configuration
 */
public synchronized org.apache.commons.configuration.Configuration load() {
    if (!isLoaded) {
        try {
            config.load(System.getProperty(CONFIG_LOCATION_PROPERTY, filename));
            config.setReloadingStrategy(new FileChangedReloadingStrategy());

            isLoaded = true;
        }
        catch (ConfigurationException e) {
            LOG.error(System.getProperty(CONFIG_LOCATION_PROPERTY, filename));
            LOG.error("Unable to locate the DATUP configuration file in the (1) current directory or (2) classpath.",
                e);
    }
    }
    return config;
}
项目:activecheck    文件:ActivecheckPlugin.java   
public ActivecheckPlugin(PropertiesConfiguration properties) {
    Validate.notNull(properties);
    this.properties = (PropertiesConfiguration) properties.clone();

    // set members
    enabled = properties.getBoolean("enabled", enabled);
    if (properties.getFile() != null) {
        configFile = properties.getFile().getAbsolutePath();
        // configure reloading strategy for the configuration file
        // TODO: does that work?
        this.properties.setReloadingStrategy(new FileChangedReloadingStrategy());
    } else {
        configFile = null;
    }

    // configure listeners for the configuration
    this.properties.addConfigurationListener(this);
}
项目: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    文件: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);
    }
}
项目: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;
}
项目:goobi-viewer-indexer    文件:Configuration.java   
@SuppressWarnings("deprecation")
private Configuration() throws ConfigurationException {
    AbstractConfiguration.setDelimiter('&');
    config = new XMLConfiguration(configPath);
    config.setReloadingStrategy(new FileChangedReloadingStrategy());
    metadataConfigurationManager = new MetadataConfigurationManager(this);
    namespaces = new HashMap<>();
    initNamespaces();
}
项目:xnx3    文件:ConfigManagerUtil.java   
private ConfigManagerUtil(String configFileName) {
    try {
        this.config = null;
        if (configFileName.toLowerCase().endsWith("xml")) {
            this.config = new XMLConfiguration(configFileName);
        } else if (configFileName.toLowerCase().endsWith("properties")) {
            this.config = new PropertiesConfiguration(configFileName);
        }
        this.config.setReloadingStrategy(new FileChangedReloadingStrategy());
        hashMap.put(configFileName, this);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:dpCms    文件:PlatformConfiguration.java   
private PlatformConfiguration(){
    try {
        config = new PropertiesConfiguration("platform.properties");
        config.setReloadingStrategy(new FileChangedReloadingStrategy());            
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }  
}
项目:xtesy-framework    文件:Settings.java   
/**
 * @author Wasiq B
 * @throws ConfigurationException
 * @throws FileNotFoundException
 * @since 04-Jul-2015 6:17:05 pm
 */
private void parseConfig () throws ConfigurationException, FileNotFoundException {
    String file = getString (Constants.TEST_CONFIG_FILE);
    if (file == null) {
        file = "test.properties";
    }
    final URL url = FileUtils.getResource (file);
    if (url == null) throw new FileNotFoundException (file);
    this.prop = new PropertiesConfiguration (url);
    this.prop.setAutoSave (true);
    this.prop.setReloadingStrategy (new FileChangedReloadingStrategy ());
    addConfiguration (this.prop);
}
项目:unitime    文件: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;
}
项目:tajo    文件:TajoSystemMetrics.java   
public TajoSystemMetrics(TajoConf tajoConf, Class clazz, String hostAndPort) {
  super(MetricsUtil.getGroupName(clazz));

  this.hostAndPort = hostAndPort;
  try {
    this.metricsPropertyFileName = tajoConf.getVar(TajoConf.ConfVars.METRICS_PROPERTY_FILENAME);
    this.metricsProps = new PropertiesConfiguration(metricsPropertyFileName);
    this.metricsProps.addConfigurationListener(new MetricsReloadListener());
    FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy();
    reloadingStrategy.setRefreshDelay(5 * 1000);
    this.metricsProps.setReloadingStrategy(reloadingStrategy);
  } catch (ConfigurationException e) {
    LOG.warn(e.getMessage(), e);
  }

  // PropertiesConfiguration fire configurationChanged after getXXX()
  // So neeaded calling getXXX periodically
  propertyChangeChecker = new Thread() {
    public void run() {
      while(!stop.get()) {
        String value = metricsProps.getString("reporter.file");
        try {
          Thread.sleep(10 * 1000);
        } catch (InterruptedException e) {
        }
      }
    }
  };

  propertyChangeChecker.start();
}
项目:incubator-tajo    文件:TajoSystemMetrics.java   
public TajoSystemMetrics(TajoConf tajoConf, String metricsGroupName, String hostAndPort) {
  super(metricsGroupName);

  this.hostAndPort = hostAndPort;
  try {
    this.metricsPropertyFileName = tajoConf.getVar(TajoConf.ConfVars.METRICS_PROPERTY_FILENAME);
    this.metricsProps = new PropertiesConfiguration(metricsPropertyFileName);
    this.metricsProps.addConfigurationListener(new MetricsReloadListener());
    FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy();
    reloadingStrategy.setRefreshDelay(5 * 1000);
    this.metricsProps.setReloadingStrategy(reloadingStrategy);
  } catch (ConfigurationException e) {
    LOG.warn(e.getMessage(), e);
  }

  //PropertiesConfiguration fire configurationChanged after getXXX()
  //So neeaded calling getXXX periodically
  propertyChangeChecker = new Thread() {
    public void run() {
      while(!stop.get()) {
        String value = metricsProps.getString("reporter.file");
        try {
          Thread.sleep(10 * 1000);
        } catch (InterruptedException e) {
        }
      }
    }
  };

  propertyChangeChecker.start();
}
项目:tajo-cdh    文件:TajoSystemMetrics.java   
public TajoSystemMetrics(TajoConf tajoConf, String metricsGroupName, String hostAndPort) {
  super(metricsGroupName);

  this.hostAndPort = hostAndPort;
  try {
    this.metricsPropertyFileName = tajoConf.getVar(TajoConf.ConfVars.METRICS_PROPERTY_FILENAME);
    this.metricsProps = new PropertiesConfiguration(metricsPropertyFileName);
    this.metricsProps.addConfigurationListener(new MetricsReloadListener());
    FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy();
    reloadingStrategy.setRefreshDelay(5 * 1000);
    this.metricsProps.setReloadingStrategy(reloadingStrategy);
  } catch (ConfigurationException e) {
    LOG.warn(e.getMessage(), e);
  }

  //PropertiesConfiguration fire configurationChanged after getXXX()
  //So neeaded calling getXXX periodically
  propertyChangeChecker = new Thread() {
    public void run() {
      while(!stop.get()) {
        String value = metricsProps.getString("reporter.file");
        try {
          Thread.sleep(10 * 1000);
        } catch (InterruptedException e) {
        }
      }
    }
  };

  propertyChangeChecker.start();
}
项目:juddi    文件:ClientConfig.java   
/**
 * Does the actual work of reading the configuration from System
 * Properties and/or uddi.xml file. When the uddi.xml file is updated
 * the file will be reloaded. By default the reloadDelay is set to 1
 * second to prevent excessive date stamp checking.
 */
private void loadConfiguration(String configurationFile, Properties properties) throws ConfigurationException {
        //Properties from system properties
        CompositeConfiguration compositeConfig = new CompositeConfiguration();
        compositeConfig.addConfiguration(new SystemConfiguration());
        //Properties from XML file
        if (System.getProperty(UDDI_CONFIG_FILENAME_PROPERTY) != null) {
                log.info("Using system property config override");
                configurationFile = System.getProperty(UDDI_CONFIG_FILENAME_PROPERTY);
        }
        XMLConfiguration xmlConfig = null;
        if (configurationFile != null) {
                xmlConfig = new XMLConfiguration(configurationFile);
        } else {
                final String filename = System.getProperty(UDDI_CONFIG_FILENAME_PROPERTY);
                if (filename != null) {
                        xmlConfig = new XMLConfiguration(filename);
                } else {
                        xmlConfig = new XMLConfiguration(DEFAULT_UDDI_CONFIG);
                }
        }
        log.info("Reading UDDI Client properties file " + xmlConfig.getBasePath() + " use -D" + UDDI_CONFIG_FILENAME_PROPERTY + " to override");
        this.configurationFile = xmlConfig.getBasePath();
        long refreshDelay = xmlConfig.getLong(Property.UDDI_RELOAD_DELAY, 1000l);
        log.debug("Setting refreshDelay to " + refreshDelay);
        FileChangedReloadingStrategy fileChangedReloadingStrategy = new FileChangedReloadingStrategy();
        fileChangedReloadingStrategy.setRefreshDelay(refreshDelay);
        xmlConfig.setReloadingStrategy(fileChangedReloadingStrategy);
        compositeConfig.addConfiguration(xmlConfig);
        //Making the new configuration globally accessible.
        config = compositeConfig;
        readConfig(properties);

        validateConfig();
}
项目:shenanigans.io    文件:Server.java   
public static void main( String[] args ) throws IOException, InterruptedException, ConfigurationException {     
    PropertiesConfiguration config = new PropertiesConfiguration(CONFIG_FILE_NAME);
    config.setReloadingStrategy(new FileChangedReloadingStrategy());

    g_server = new Server(config);
    g_server.start();
    Runtime.getRuntime().addShutdownHook(new Thread(){
        public void run() {
            LogManager.getLogger(Server.class).info("Shutting down the server.");
            g_server.stop();
            LogManager.getLogger(Server.class).info("Server stopped.");
        }
    }); 
}
项目:appframework    文件:ConfigUtil.java   
/**
 * 每次加载同名配置时,自动移除旧的同名配置
 *
 * @param configFileName
 *            configFileName
 * @return Configuration Configuration
 */
public synchronized static Configuration addConfig(String configFileName) {
    try {

        if (configFileName.toLowerCase().lastIndexOf(SUFFIX_PERPERTIES) == -1) {
            configFileName = configFileName + SUFFIX_PERPERTIES;
        }

        if (null != cfgMap.get(configFileName)) {
            config.removeConfiguration(cfgMap.get(configFileName));
            cfgMap.remove(configFileName);
            log.debug("removing config: " + configFileName);
        }

        PropertiesConfiguration configApp = new PropertiesConfiguration();
        configApp.setEncoding(FILE_ENCODING);
        configApp.load(configFileName);
        configApp.setReloadingStrategy(new FileChangedReloadingStrategy());

        log.debug("adding config file: " + configFileName);
        cfgMap.put(configFileName, configApp);
        config.addConfiguration(configApp);

        log.debug("Config item count: " + cfgMap.size());

    } catch (ConfigurationException e) {
        log.error("load config file failed: " + ExceptionUtils.getFullStackTrace(e));
    }

    return config;
}
项目:overlord-commons    文件:AbstractPropertiesFileConfigurator.java   
/**
 * @see org.overlord.commons.config.configurator.Configurator#provideConfiguration(java.lang.String, java.lang.Long)
 */
@Override
public Configuration provideConfiguration(String configName, Long refreshDelay)
        throws ConfigurationException {
    URL url = findConfigUrl(configName);
    if (url != null) {
        PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(url);
        FileChangedReloadingStrategy fileChangedReloadingStrategy = new FileChangedReloadingStrategy();
        fileChangedReloadingStrategy.setRefreshDelay(refreshDelay);
        propertiesConfiguration.setReloadingStrategy(fileChangedReloadingStrategy);
        return propertiesConfiguration;
    } else {
        return null;
    }
}
项目:Tank    文件:BaseCommonsXmlConfig.java   
/**
     * Constructor pulls file out of the jar or reads from disk and sets up refresh policy.
     * 
     * @param expressionEngine
     *            the expression engine to use. Null results in default expression engine
     */
    protected void readConfig() {
        try {
            ExpressionEngine expressionEngine = new XPathExpressionEngine();
            String configPath = getConfigName();
            FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy();

            File dataDirConfigFile = new File(configPath);
//            LOG.info("Reading settings from " + dataDirConfigFile.getAbsolutePath());
            if (!dataDirConfigFile.exists()) {
                // Load a default from the classpath:
                // Note: we don't let new XMLConfiguration() lookup the resource
                // url directly because it may not be able to find the desired
                // classloader to load the URL from.
                URL configResourceUrl = this.getClass().getClassLoader().getResource(configPath);
                if (configResourceUrl == null) {
                    throw new RuntimeException("unable to load resource: " + configPath);
                }

                XMLConfiguration tmpConfig = new XMLConfiguration(configResourceUrl);
                // Copy over a default configuration since none exists:
                // Ensure data dir location exists:
                if (dataDirConfigFile.getParentFile() != null && !dataDirConfigFile.getParentFile().exists()
                        && !dataDirConfigFile.getParentFile().mkdirs()) {
                    throw new RuntimeException("could not create directories.");
                }
                tmpConfig.save(dataDirConfigFile);
                LOG.info("Saving settings file to " + dataDirConfigFile.getAbsolutePath());
            }

            if (dataDirConfigFile.exists()) {
                config = new XMLConfiguration(dataDirConfigFile);
            } else {
                // extract from jar and write to
                throw new IllegalStateException("Config file does not exist or cannot be created");
            }
            if (expressionEngine != null) {
                config.setExpressionEngine(expressionEngine);
            }
            configFile = dataDirConfigFile;
            // reload at most once per thirty seconds on configuration queries.
            config.setReloadingStrategy(reloadingStrategy);
            initConfig(config);
        } catch (ConfigurationException e) {
            LOG.error("Error reading settings file: " + e, e);
            throw new RuntimeException(e);
        }
    }
项目:Portofino    文件:ResourceBundleManager.java   
public ResourceBundle getBundle(Locale locale) {
    ConfigurationResourceBundle bundle = resourceBundles.get(locale);
    if(bundle == null) {
        CompositeConfiguration configuration = new CompositeConfiguration();
        Iterator<String> iterator = searchPaths.descendingIterator();
        while(iterator.hasNext()) {
            String path = iterator.next();
            int index = path.lastIndexOf('/') + 1;
            String basePath = path.substring(0, index);
            int suffixIndex = path.length() - ".properties".length();
            String resourceBundleBaseName = path.substring(index, suffixIndex);
            String bundleName = getBundleFileName(resourceBundleBaseName, locale);
            PropertiesConfiguration conf;
            try {
                conf = new PropertiesConfiguration();
                conf.setFileName(basePath + bundleName);
                conf.setDelimiterParsingDisabled(true);
                conf.load();
            } catch (ConfigurationException e) {
                logger.debug("Couldn't load resource bundle for locale " + locale + " from " + basePath, e);
                //Fall back to default .properties without _locale
                try {
                    String defaultBundleName = basePath + resourceBundleBaseName + ".properties";
                    conf = new PropertiesConfiguration();
                    conf.setFileName(defaultBundleName);
                    conf.setDelimiterParsingDisabled(true);
                    conf.load();
                } catch (ConfigurationException e1) {
                    logger.debug("Couldn't load default resource bundle from " + basePath, e1);
                    conf = null;
                }
            }
            if(conf != null) {
                FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy();
                conf.setReloadingStrategy(reloadingStrategy);
                configuration.addConfiguration(conf);
            }
        }
        bundle = new ConfigurationResourceBundle(configuration, locale);
        //TODO setParent?
        resourceBundles.put(locale, bundle);
    }
    return bundle;
}
项目:juddi    文件:AppConfig.java   
/**
 * Does the actual work of reading the configuration from System
 * Properties and/or juddiv3.xml file. When the juddiv3.xml
 * file is updated the file will be reloaded. By default the reloadDelay is
 * set to 1 second to prevent excessive date stamp checking.
 */
private void loadConfiguration() throws ConfigurationException
{
    //Properties from system properties
    CompositeConfiguration compositeConfig = new CompositeConfiguration();
    compositeConfig.addConfiguration(new SystemConfiguration());
    //Properties from file
               //changed 7-19-2013 AO for JUDDI-627
    propConfig = null;
        final String filename = System.getProperty(JUDDI_CONFIGURATION_FILE_SYSTEM_PROPERTY);
    if (filename != null) {
                 propConfig = new XMLConfiguration (filename); 
                   try {
                       loadedFrom = new File(filename).toURI().toURL();
                   //   propConfig = new PropertiesConfiguration(filename);
                   } catch (MalformedURLException ex) {
                     try {
                         loadedFrom = new URL("file://" + filename);
                     } catch (MalformedURLException ex1) {
                         log.warn("unable to get an absolute path to " + filename + ". This may be ignorable if everything works properly.", ex1);
                     }
                   }
    } else {
        //propConfig = new PropertiesConfiguration(JUDDI_PROPERTIES);
                   propConfig = new XMLConfiguration(JUDDI_PROPERTIES);
                   loadedFrom = ClassUtil.getResource(JUDDI_PROPERTIES, this.getClass()); 
    }
               //Hey! this may break things
               propConfig.setAutoSave(true);

    log.info("Reading from jUDDI config file from:  " + loadedFrom);
    long refreshDelay = propConfig.getLong(Property.JUDDI_CONFIGURATION_RELOAD_DELAY, 1000l);
    log.debug("Setting refreshDelay to " + refreshDelay);
    FileChangedReloadingStrategy fileChangedReloadingStrategy = new FileChangedReloadingStrategy();
    fileChangedReloadingStrategy.setRefreshDelay(refreshDelay);
    propConfig.setReloadingStrategy(fileChangedReloadingStrategy);
    compositeConfig.addConfiguration(propConfig);


    Properties properties = new Properties();
    if ("Hibernate".equals(propConfig.getString(Property.PERSISTENCE_PROVIDER))) {
        if (propConfig.containsKey(Property.DATASOURCE)) 
            properties.put("hibernate.connection.datasource",propConfig.getString(Property.DATASOURCE));
        if (propConfig.containsKey(Property.HBM_DDL_AUTO))
            properties.put("hibernate.hbm2ddl.auto",propConfig.getString(Property.HBM_DDL_AUTO));
        if (propConfig.containsKey(Property.DEFAULT_SCHEMA))
            properties.put("hibernate.default_schema",propConfig.getString(Property.DEFAULT_SCHEMA));
        if (propConfig.containsKey(Property.HIBERNATE_DIALECT))
            properties.put("hibernate.dialect",propConfig.getString(Property.HIBERNATE_DIALECT));
    }
    // initialize the entityManagerFactory.
    PersistenceManager.initializeEntityManagerFactory(propConfig.getString(Property.JUDDI_PERSISTENCEUNIT_NAME), properties);
    // Properties from the persistence layer 
    MapConfiguration persistentConfig = new MapConfiguration(getPersistentConfiguration(compositeConfig));

    compositeConfig.addConfiguration(persistentConfig);
    //Making the new configuration globally accessible.
    config = compositeConfig;
}
项目:knbnprxy    文件:AppConfig.java   
private AppConfig(final String fileName) {
    super();
    this.setReloadingStrategy(new FileChangedReloadingStrategy());
    this.setDelimiterParsingDisabled(true);
    init(fileName);
}
项目:manydesigns.cn    文件:ResourceBundleManager.java   
public ResourceBundle getBundle(Locale locale) {
    ConfigurationResourceBundle bundle = resourceBundles.get(locale);
    if(bundle == null) {
        CompositeConfiguration configuration = new CompositeConfiguration();
        Iterator<String> iterator = searchPaths.descendingIterator();
        while(iterator.hasNext()) {
            String path = iterator.next();
            int index = path.lastIndexOf('/') + 1;
            String basePath = path.substring(0, index);
            int suffixIndex = path.length() - ".properties".length();
            String resourceBundleBaseName = path.substring(index, suffixIndex);
            String bundleName = getBundleFileName(resourceBundleBaseName, locale);
            PropertiesConfiguration conf;
            try {
                conf = new PropertiesConfiguration();
                conf.setFileName(basePath + bundleName);
                conf.setDelimiterParsingDisabled(true);
                conf.load();
            } catch (ConfigurationException e) {
                logger.debug("Couldn't load resource bundle for locale " + locale + " from " + basePath, e);
                //Fall back to default .properties without _locale
                try {
                    String defaultBundleName = basePath + resourceBundleBaseName + ".properties";
                    conf = new PropertiesConfiguration();
                    conf.setFileName(defaultBundleName);
                    conf.setDelimiterParsingDisabled(true);
                    conf.load();
                } catch (ConfigurationException e1) {
                    logger.debug("Couldn't load default resource bundle from " + basePath, e1);
                    conf = null;
                }
            }
            if(conf != null) {
                FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy();
                conf.setReloadingStrategy(reloadingStrategy);
                configuration.addConfiguration(conf);
            }
        }
        bundle = new ConfigurationResourceBundle(configuration, locale);
        //TODO setParent?
        resourceBundles.put(locale, bundle);
    }
    return bundle;
}
项目:activecheck    文件:ActivecheckConfiguration.java   
public ActivecheckConfiguration(String configFile) throws ConfigurationException {
    propertiesDir = new File(configFile).getAbsoluteFile().getParent();
    properties = new PropertiesConfiguration(configFile);
    properties.setReloadingStrategy(new FileChangedReloadingStrategy());
}
项目:gw2live    文件:AppConfig.java   
private AppConfig(final String fileName) {
    super();
    this.setReloadingStrategy(new FileChangedReloadingStrategy());
    this.setDelimiterParsingDisabled(true);
    init(fileName);
}
项目:pushrouter    文件:AppConfig.java   
private AppConfig(final String fileName) {
    super();
    this.setReloadingStrategy(new FileChangedReloadingStrategy());
    init(fileName);
}