Java Configuration Manager Automatic Reloading
公司一个项目的从另外一个小公司,拷贝了一个PropertyParser的类,实现的有问题,必须重启java应用才能读取新的配置。
简单的解决办法,就是每次读任何配置项时,都重新加载xxx.property文件,但是明显不如当年C#的ConfigurationManager好用。
https://stackoverflow.com/questions/20661612/java-equivalent-for-cs-configurationmanager-appsettingsx
这篇文章,只回答了web的,没有针对desktop和console类型的解答。
http://blog.163.com/s_zhchluo/blog/static/15014708200732191454527/
这篇文章提到了 Apache Commons Configuration项目,也解释了其功能原理,很符合我的要求。
https://commons.apache.org/proper/commons-configuration/
The Commons Configuration software library provides a generic configuration interface which enables a Java application to read configuration data from a variety of sources.
望文生义,就是通用的配置库,很不错。
http://commons.apache.org/proper/commons-configuration/userguide_v1.10/howto_filebased.html
节选Automatic Reloading部分的说明:
Automatic Reloading
A common issue with file-based configurations is to handle the reloading of the data file when it changes. This is especially important if you have long running applications and do not want to restart them when a configuration file was updated. Commons Configuration has the concept of so called reloading strategies that can be associated with a file-based configuration. Such a strategy monitors a configuration file and is able to detect changes. A default reloading strategy is FileChangedReloadingStrategy. It can be set on a file-based configuration as follows:
PropertiesConfiguration config = new PropertiesConfiguration("usergui.properties");
config.setReloadingStrategy(new FileChangedReloadingStrategy());
FileChangedReloadingStrategy works as follows: On every property access the configuration checks its associated reloading strategy. FileChangedReloadingStrategy will then obtain the last modification date of the configuration file and check whether it has changed since the last access. If this is the case, a reload is triggered. To avoid often disk access when multiple properties are queried from the configuration, a refresh delay can be set on the reloading strategy. This is a time in milli seconds with the meaning that the reloading strategy will only once check the file's last modification time in the period specified here.
每一次属性访问时,都会检查文件,如果最后访问时间有变化,则自动重新载入。为了减少硬盘访问频率,又添加了"刷新延迟(设定刷新延迟时间)"机制。上述机制基于commons-configuration/userguide_v1.10。
还有一篇介绍如何实现重载机制的文章,讲解了其他重载机制。
https://commons.apache.org/proper/commons-configuration/userguide/howto_reloading.html
Java Configuration Manager Automatic Reloading的更多相关文章
- Oracle's Business Intelligence Applications Configuration Manager 基本概念
Oracle's Business Intelligence Applications Configuration Manager :BIACM Once the BIAPPS installatio ...
- Spring Security(十二):5. Java Configuration
General support for Java Configuration was added to Spring Framework in Spring 3.1. Since Spring Sec ...
- Windows 8上使用SQL 2012 Configuration Manager
现在使用Windows 8 + Sql Server 2012,而今天想用SQL 2012 Configuraton Manager, 设置别名来访问不同的开发数据库.但发现没能找到SQL 2012 ...
- SQL Server Configuration Manager出错
在 Windows 桌面上,单击“开始”,然后单击“运行”. 在“打开”框中,键入 MMC,然后单击“确定”. 在“控制台”窗口中,单击菜单栏上的“文件”,然后单击“添加/删除管理单元”. 在“ ...
- Sql Server Configuration Manager 网络配置为空,没有实例
新用户一天内不准提问...Sql Server Configuration Manager 网络配置为空,没有实例无法设置ip和端口进行连接..
- Configuration Manager 和内容位置(包源文件)
Configuration Manager 2007 中的内容位置涉及 Configuration Manager 2007 客户端如何查找播发和软件更新的包源文件.当客户端需要查找内容时,它会将内容 ...
- Mybatis Spring multiple databases Java configuration
https://stackoverflow.com/questions/18201075/mybatis-spring-multiple-databases-java-configuration ** ...
- SQL SERVER – Configuration Manager – Cannot Connect to WMI Provider. You Do Not Have Permission or The Server is Unreachable
打开SQL SERVER Configuarion Manger 出现以下错误 SQL Server Configuration Manager—————————Cannot connect to W ...
- System Center Configuration Manager 2016 配置安装篇(Part3)
SCCM 2016 配置管理系列(Part 1- 4) 介绍AD01上配置了Active Directory域服务(ADDS),然后将Configuration Manager服务器(CM16)加入到 ...
随机推荐
- win10系统安装两个版本的python,该怎么安装Django
最近遇到一个问题,系统上安装了python2,7 和python3.5两个版本,然后使用命令:pip install Django 安装Django后却发现以下情况: Traceback (most ...
- UCML JS函数说明
UCML JS函数说明1.调用父窗体函数 window.openerWindow.函数名 2.公用JS存放位置 BPObject\Model\Rule\initvalue.js 3.弹窗JS var ...
- ADB安装及使用
环境安装: 下载.安装和配置ADB https://jingyan.baidu.com/article/22fe7cedf67e353002617f25.html 安装驱动adbdriver ...
- 关于pyquery小知识点
#表示的是取html中的id元素, . 表示的是取html中的class元素. 如果是标签,就直接用标签名 而它们之间的空格,则表示嵌套关系 单冒号(:)用于CSS3伪类,双冒号(::)用于CSS3伪 ...
- PAT A1145 Hashing - Average Search Time (25 分)——hash 散列的平方探查法
The task of this problem is simple: insert a sequence of distinct positive integers into a hash tabl ...
- Html5 标签四 (列表)
1.有序列表 2.无序列表 3.自定义列表 <!DOCTYPE html> <html lang="en"> <head> <meta c ...
- appbar导航
import 'package:flutter/material.dart';import 'dart:ui'; void main()=>runApp(MyApp()); class MyAp ...
- STM32固件库详解
STM32固件库详解 emouse原创文章,转载请注明出处http://www.cnblogs.com/emouse/ 应部分网友要求,最新加入固件库以及开发环境使用入门视频教程,同时提供例程模板 ...
- 【Codeforces 113B】Petr#
Codeforces 113 B 题意:有一个母串\(S\)以及两个串\(S_{begin}\)和\(S_{end}\),问\(S\)中以\(S_{begin}\)为开头并且以\(S_{end}\)为 ...
- docker镜像的创建commit及dockerfile
在docker 1.3版本以前使用attach进入容器会经常出现卡死的情况,之后官方退出了exec命令,从宿主机进入,但是从其他远程主机进入使用ssh服务来维护是用户熟悉的方法.所以这里来创建一个带有 ...