I've been using the reload feature of Commons Configuration v1 without any extra coding when exposing a Configuration object as a Spring @Bean, because the reload check was performed every time the Configuration was accessed.
I'm now trying to migrate to Commons Configuration v2 and I read that reload is only effective on new Configuration objects created by the builder.
In other words, while in v1 I could do something like
@Bean
public Configuration config() {
...
return builder.getConfiguration();
}
then inject the configuration with
@Autowired Configuration config;
and expect it to reload (when needed) on a
config.getString("somepath");
now I should call
builder.getConfiguration()
again each time I want a fresh configuration.
So how do I go about it? Can anything in Spring help me "refresh" a @Bean that has already been injected in many @Controllers? It doesn't have to be automatic: I could implement a "reload" button in the admin console to trigger it.