In a project, I have a org.apache.commons.configuration.PropertiesConfiguration
object registered as a Bean, to provide configuration values around the application, with hot-reloading capabilities.
Example: I defined a DataSource
singleton Bean. I then created a ReloadingDataSource
object, which wraps and delegate to the "real" DataSource
, and each time the configuration file changes, it is able to recreate it in a thread-safe manner.
I'd like to do something similar for simple properties values.
I'd like to create a simple, Autowire
able object that delegate retrieval to the Apache PropertiesConfiguration
Bean.
The usage should be similar to:
@Property("my.config.database")
private Property<String> database;
And the call site would simply be:
final String databaseValue = database.get()
You'll say, just pass around the PropertiesConfiguration
object. Maybe you're right, but I'd like to provide another abstraction over that, a simpler-to-use one.
I know that with ProxyFactoryBean
it is possible to create an AOP proxy for method calls. Is this the right path, or are there better alternatives? Maybe pure Spring AOP/AspectJ?
I don't want to use Spring Cloud or similar dependencies.