SystemPropertiesUtil { public static synchronized void registerSystemPropertiesListener(PropertiesListener listener) { Properties currentProperties = System.getProperties(); if (!(currentProperties instanceof ListenableProperties)) { ListenableProperties newProperties = new ListenableProperties(currentProperties); System.setProperties(newProperties); currentProperties = newProperties; } ((ListenableProperties) currentProperties).register(listener); }  static Boolean getBoolean(String name); static Boolean getBoolean(String name, Boolean defaultValue); static String getString(String name); static String getString(String name, String defaultValue); static Integer getInteger(String name); static Integer getInteger(String name, Integer defaultValue); static Long getLong(String name); static Long getLong(String name, Long defaultValue); static Double getDouble(String propertyName); static Double getDouble(String propertyName, Double defaultValue); static String getString(String propertyName, String envName, String defaultValue); static Integer getInteger(String propertyName, String envName, Integer defaultValue); static Long getLong(String propertyName, String envName, Long defaultValue); static Double getDouble(String propertyName, String envName, Double defaultValue); static Boolean getBoolean(String propertyName, String envName, Boolean defaultValue); static synchronized void registerSystemPropertiesListener(PropertiesListener listener);  }
@Test public void listenableProperties() { String name = "ss.test" + RandomUtil.nextInt(); TestPropertiesListener listener = new TestPropertiesListener(name); SystemPropertiesUtil.registerSystemPropertiesListener(listener); System.setProperty(name, "haha"); assertThat(listener.newValue).isEqualTo("haha"); }