Aug 19th, 2008, 10:34 AM
Database-backed configurations possible?
The problem is thus:
Typical Spring configurations (XML or otherwise) assume that we know at deploy/config time , what the dependency of one bean would be. But in our case we do not know the dependent class until runtime.
I am wondering if we can do Database-backed configurations in a manner similar to PropertyPlaceHolderConfigurer - wherein certain property values are fed in by a field from a particular query instead of .properties file being the source.
For eg consider a Payment Processing Service bean:
<bean id="paymentProcessService" class="com.company.service.PaymentService">
Where "merchant" is an interface with implementation being "merchantClass", merchantClass could be any of
and so on...
We have a case where "PaymentService" depends on a "merchant" interface and there are atleast 5 to 10 different implementations of that interface. Secondly we do not know until runtime(based on certain values retrieved from the DB and user request) which of the above particular implementation of "merchant" interface would be wired in.
We have a home-grown Database-backed way of resolving it. Spring claims that it also has a Database-backed configuration mechanism, but I haven't been able to locate a solution. That is we find out the class from a DB table like this:
"select merchantClass from Merchants where userID = 123"
We would want the query result of the above query to be wired in the bean configuration.
Your answer is greatly appreciated.
Tags for this Thread