Jun 27th, 2012, 12:00 AM
Reading properties from database
Our application has many property files due to extensibility and becomes a nightmare managing them. I would like to know if there is any suggestion about how I could unify all the properties into a database (obviously excluding the database connection properties). This way, managing it can be easy by snapping a UI on top of the database table containing the properties. This is what I would like to know:
1. How can I direct my propertyplaceholderconfiguration class to load the properties from database based on a query?
2. Once it is loaded, obviously, one of the advantages is that we would be able to update the database without shutting down the server. How can I propogate the new changes to my beans already referencing the properties without restart?
3. I would not like to be hitting the database all times for getting the properties, so will it be cached and if so, how can I specify the time to live?
Any help greatly appreciated!
Jun 27th, 2012, 01:15 AM
1) Read the properties from a database and simply pass them to the PropertyPlaceHolderConfigurer. (Examples can be found on the forum)
2) You cannot, the context is static
3) As the context is static this is only going to happen once
Jun 27th, 2012, 08:50 AM
Thank you, but could you please elaborate?
1. Would appreciate if you could provide the link to the forum that has this example.
2. The context would be static, I agree, but couldnt we refresh the applicationcontext and wouldnt that get the fresh properties from the database? (AbstractApplicationContext#refresh())
3. This I agree does not tie very well.
Jun 27th, 2012, 10:55 AM
Try google before asking! The first result looks like a solution.
Originally Posted by anoop2811
Jun 27th, 2012, 11:14 AM
Andrie, thanks for sharing the same minus the sarcasm (if there was none, please forgive). I did find that post earlier, but as you can see that it is a 6 year old solution. What I wanted to know is if the latest release of spring has any solution out of the box. If not, as you suggested, that post has a possible solution. Thanks.
Nov 15th, 2012, 09:59 AM
Could you post your solution?
What would be a possible solution to access the stored properties from my applicationContext.xml?I need to access, for example, the ldap url property to set LdapContextSource within my applicationContext.xml.
Tags for this Thread