Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if a Java System property has changed?

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:

  1. JPDA?
  2. Observer & Observable?
  3. Property change listener?
  4. JMX?

Any suggestions? Thanks in advance.

like image 369
Gaucho Avatar asked May 22 '12 21:05

Gaucho


1 Answers

You can replace the system Properties with your own custom subclass.

MyProperties newProps = new MyProperties(System.getProperties());
System.setProperties(newProps);

Then, just write a subclass of Properties which hooks the relevant methods.

like image 96
jtahlborn Avatar answered Sep 22 '22 12:09

jtahlborn