如何检测Java System属性是否已更改? [英] How to detect if a Java System property has changed?
本文介绍了如何检测Java System属性是否已更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道何时更改系统属性.我在应用程序服务器中有一个应用程序,它某种程度上正在更改系统属性(我认为是System.setProperty()
).我看了一下,发现了不同的方法:
I would like to know when a System property is changed. I have an application, in an application server, that somehow is changing a system property (System.setProperty()
I think). I was taking a look and I have found different approaches:
- JPDA?
- Observer & Observable?
- Property change listener?
- JMX?
有什么建议吗?预先感谢.
Any suggestions? Thanks in advance.
推荐答案
您可以使用自己的自定义子类替换系统属性.
You can replace the system Properties with your own custom subclass.
MyProperties newProps = new MyProperties(System.getProperties());
System.setProperties(newProps);
然后,只需编写一个Properties的子类,该子类会钩住相关方法.
Then, just write a subclass of Properties which hooks the relevant methods.
这篇关于如何检测Java System属性是否已更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文