Reloading a Commons Configuration 2 Spring bean -
i've been using reload feature of commons configuration v1 without coding when exposing configuration object spring @bean, because reload check performed every time configuration accessed.
i'm trying migrate commons configuration v2 , read reload effective on new configuration objects created builder.
in other words, while in v1 like
@bean public configuration config() { ... return builder.getconfiguration(); }
then inject configuration with
@autowired configuration config;
and expect reload (when needed) on
config.getstring("somepath");
now should call
builder.getconfiguration()
again each time want fresh configuration.
so how go it? can in spring me "refresh" @bean has been injected in many @controllers? doesn't have automatic: implement "reload" button in admin console trigger it.
maybe have wrap configuration in myconfiguration class, exposed @bean, method rebuilds configuration, called console. like:
public class myconfiguration { private configuration configuration; ... inject builder somehow here public void reload() { builder.getreloadingcontroller().checkforreloading(null); configuration = builder.getconfiguration(); } public string getstring(string key) { return configuration.getstring(key); } ... other delegated methods follow }