commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Garret Wilson <>
Subject detecting file reload in Apache Commons Configuration2
Date Fri, 02 Dec 2016 14:48:36 GMT
Using `org.apache.commons:commons-configuration2:2.1` my application 
needs to know when a configuration file has been reloaded so that it can 
update some things in the program. Apache Commons Configuration2 uses a 
lot of strategies and factories, and usually that's great, but here it's 
getting so complicated I can't figure out where I need to install a 

The application has this:

     configConfigurationBuilder = new 
     final PeriodicReloadingTrigger configReloadingTrigger = new 
         configConfigurationBuilder.getReloadingController(), null, 1, 

Which of these various things can I install a listener on? I just want 
to be notified when the configuration file is reloaded.

I notice that the `ReloadingDetector` interface has a 
`reloadingPerformed()` method, and that sounds like what I want. But how 
do I add my own `ReloadingDetector`? It seems like the 
`ReloadingController` only keeps one `ReloadingDetector` around. Surely 
I don't have to subclass `ReloadingDetector` and install a custom one, 
would I? I'm not wanting to specialize the reloading detection, so 
subclassing would not be appropriate --- I just want to be notified when 
something happens. Besides, it's not obvious to me where I would even 
hook into the `ReloadingFileBasedConfigurationBuilder` chain of events 
where it uses some internal factor to create the detector.

So how can I easily get Apache Commons Configuration2 to notify me when 
it reloads a configuration?


P.S Does no one monitor Stack Overflow? It is a real pain to subscribe 
to this old-fashioned mailing list---a general one for all Apache 
Commons, at that!---just to ask a technical question. Below is the 
unanswered Stack Overflow question I posted.

If you were to answer this question on Stack Overflow it would help a 
lot more people than simply replying on this obscure mailing list. Just 
a suggestion.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message