當前位置: 首頁>>代碼示例>>Java>>正文


Java PropertiesConfiguration.setReloadingStrategy方法代碼示例

本文整理匯總了Java中org.apache.commons.configuration.PropertiesConfiguration.setReloadingStrategy方法的典型用法代碼示例。如果您正苦於以下問題:Java PropertiesConfiguration.setReloadingStrategy方法的具體用法?Java PropertiesConfiguration.setReloadingStrategy怎麽用?Java PropertiesConfiguration.setReloadingStrategy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.configuration.PropertiesConfiguration的用法示例。


在下文中一共展示了PropertiesConfiguration.setReloadingStrategy方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: contextInitialized

import org.apache.commons.configuration.PropertiesConfiguration; //導入方法依賴的package包/類
@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);
    }
}
 
開發者ID:luckyyeah,項目名稱:YiDu-Novel,代碼行數:37,代碼來源:InitializerListener.java

示例2: contextInitialized

import org.apache.commons.configuration.PropertiesConfiguration; //導入方法依賴的package包/類
@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);
    }
}
 
開發者ID:Chihpin,項目名稱:Yidu,代碼行數:36,代碼來源:InitializerListener.java

示例3: getConfiguration

import org.apache.commons.configuration.PropertiesConfiguration; //導入方法依賴的package包/類
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;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:31,代碼來源:MessageResources.java


注:本文中的org.apache.commons.configuration.PropertiesConfiguration.setReloadingStrategy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。