|
From: Farhan K. <ka...@gm...> - 2005-10-02 22:38:25
|
There are times when real conditional configuration is helpful. Consider an
application that integrates with external systems with JMS.
If the integration module is not central to the application, you probably
want this interface stubbed during development. One option is to have 2 set=
s
of bean definition files i.e. ApplicationContext-Integration.xml and
ApplicationContext-Stubbed.xml. You could have ANT build tasks that include=
d
either the development (stubbed) version or the unstubbed version.
But what if you have not one, but many different interfaces to external
systems. Any one of these may or may not be stubbed. We would need differen=
t
builds for each environment.
It is sometimes easier to have a single build of an ear file. The same EAR
file goes to all environments. This makes life easier for in many ways and
for many teams.
Right now, this capability is not provided with Spring, and is something
you have to build yourself. I have an initial, very rough (and very verbose=
)
idea of how this could be done. How about something like this:
beanRefContext.xml file:
<bean id=3D"base.application.context"
On 9/27/05, Rob Butler <cro...@ya...> wrote:
>
> Excellent!
>
> Thank you.
> Rob
>
> --- Juergen Hoeller <ju...@in...> wrote:
>
> > Actually, if you define two different
> > implementations as lazy-init=3D"true",
> > including all beans that they depend on, you will
> > only actually instantiate
> > the beans that you explicitly refer to. If you have
> > a placeholder a la <ref
> > bean=3D"${myTarget}"/>, only the actually referenced
> > target bean and its
> > dependencies will get instantiated.
> >
> > See the LobHandler definitions in our Image Database
> > sample application for
> > an example: The lazy-init flags there avoid to
> > instantiate OracleLobHandler
> > unless it is actually referenced by the DAO. That
> > reference is expressed
> > using a placeholder, so the actual choice can be
> > driven by a properties
> > file.
> >
> > If such lazy initialization becomes common in your
> > bean definition file,
> > consider setting default-lazy-init=3D"true" at the
> > <beans> level, only
> > selectively turning off the lazy-init flag for
> > specific beans that you want
> > to have eagerly instantiated at startup.
> >
> > Juergen
> >
> >
> > -----Original Message-----
> > From:
> >
> spr...@li...
> >
> [mailto:spr...@li...]
> > On Behalf Of
> > Rob Butler
> > Sent: Saturday, September 24, 2005 4:32 AM
> > To: spr...@li...
> > Subject: [Springframework-developer] Conditional
> > configuration
> >
> > 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=3D"true"
> > then the bean is
> > loaded.
> > In this way Impl1 could be keyed to
> > load=3D"${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=3D"${someProperty}" and Impl1
> > load=3D"false"
> > then spring should not error if "someProperty" is
> > not provided.
> >
> > Thoughts?
> >
> > Rob
> >
> >
> >
> > __________________________________
> > Yahoo! Mail - PC Magazine Editors' Choice 2005
> > http://mail.yahoo.com
> >
> >
> >
> -------------------------------------------------------
> > SF.Net email is sponsored by:
> > Tame your development challenges with Apache's
> > Geronimo App Server. Download
> > it for free - -and be entered to win a 42" plasma tv
> > or your very own
> > Sony(tm)PSP. Click here to play:
> > http://sourceforge.net/geronimo.php
> > _______________________________________________
> > Springframework-developer mailing list
> > Spr...@li...
> >
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
> >
> >
> >
> >
> >
> -------------------------------------------------------
> > SF.Net email is sponsored by:
> > Tame your development challenges with Apache's
> > Geronimo App Server. Download
> > it for free - -and be entered to win a 42" plasma tv
> > or your very own
> > Sony(tm)PSP. Click here to play:
> > http://sourceforge.net/geronimo.php
> > _______________________________________________
> > Springframework-developer mailing list
> > Spr...@li...
> >
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads, discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
|