Consider the following scenario. I have a Spring application context with a bean whose properties should be configurable, think DataSource
or MailSender>
Option 1 :
configurable
bean into the DataSource
or MailSender
. Always get the configurable values from the configuration bean from within these beans.configurable
bean run a thread to read the externally configurable properties (file etc..) periodically. This way the configurable
bean will refresh itself after the admin had changed the properties and so the DataSource
will get the updated values automatically.
Option 2 (bad, i think, but maybe not - depends on use case) :
DataSource
/ MailSender
- using prototype
scope. In the init of the bean, read the properties afresh.Option 3 : I think, @mR_fr0g suggestion on using JMX might not be a bad idea. What you could do is :
HTH!