|
From: Rob B. <cro...@ya...> - 2005-09-24 02:32:25
|
Hey all,
I was wondering if Spring could be enhanced to support
"conditional configuration" or if there is a way to do
this already that I haven't thought of.
Let's say your app has a property file bean post
processor. Depending upon a setting in the property
file you want to switch between two different
implementations of some interface - Impl1 & Impl2. No
problem, Spring does this easily.
But let's say those two different implementations also
have a number of Spring managed beans injected into
them. So if your using Impl2 then all the Spring
managed beans that are injected into Impl1 aren't
needed.
Is there a way to have spring _not_ instatiate and
configure some beans depending upon a value obtained
from a bean post processor?
If this doesn't already exit perhaps a new attribute
can be added to the bean tag like "load" or
"configure". If load="true" then the bean is loaded.
In this way Impl1 could be keyed to load="${useImpl1}"
and so could all of the Spring managed beans that
would be injected into it. Thus, if useImpl1 was
false Impl1 and all the objects constructed to support
it would never be instantiated.
It would also be preferable for references to bean
post processor values that used in un-instantiated
objects to no longer be necessary. I.E. if Impl1 has
someSetter="${someProperty}" and Impl1 load="false"
then spring should not error if "someProperty" is not
provided.
Thoughts?
Rob
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
|