本文整理汇总了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);
}
}
示例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);
}
}
示例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;
}