This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-jci.git
commit e052697b9f0e45d66891997d62e07a2855c9924e Author: Gary D. Gregory <[email protected]> AuthorDate: Sun Mar 16 10:25:05 2025 -0400 Fix indentation --- .../configuration/ConfigurationReloading.java | 30 +++++++--------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/examples/src/main/java/org/apache/commons/jci2/examples/configuration/ConfigurationReloading.java b/examples/src/main/java/org/apache/commons/jci2/examples/configuration/ConfigurationReloading.java index 44c5b13..8971ed0 100644 --- a/examples/src/main/java/org/apache/commons/jci2/examples/configuration/ConfigurationReloading.java +++ b/examples/src/main/java/org/apache/commons/jci2/examples/configuration/ConfigurationReloading.java @@ -39,52 +39,40 @@ public final class ConfigurationReloading { private final FilesystemAlterationMonitor fam = new FilesystemAlterationMonitor(); private void run(final String[] args) { - final File configFile = new File("some.properties"); - System.out.println("Watching " + configFile.getAbsolutePath()); - final Collection<Configurable> configurables = new ArrayList<>(); - final FilesystemAlterationListener listener = new FileChangeListener() { + @Override public void onStop(final FilesystemAlterationObserver pObserver) { super.onStop(pObserver); - if (hasChanged()) { System.out.println("Configuration change detected " + configFile); - final Properties props = new Properties(); InputStream is = null; try { - is = new FileInputStream(configFile); + is = new FileInputStream(configFile); props.load(is); - System.out.println("Notifying about configuration change " + configFile); - for (final Configurable configurable : configurables) { configurable.configure(props); } - } catch (final Exception e) { System.err.println("Failed to load configuration " + configFile); } finally { - try { - is.close(); - } catch (final IOException e) { - } + try { + is.close(); + } catch (final IOException e) { + } } - } } }; - fam.addListener(configFile, listener); - fam.start(); - - configurables.add(new Something()); - - while(true) { + fam.start(); + configurables.add(new Something()); + while (true) { try { Thread.sleep(1000); } catch (final InterruptedException e) {
