|
From: Farhan K. <ka...@gm...> - 2005-10-02 23:15:46
|
Sorry I somehow clicked send without finishing my thoughts:
ruwBeanRefContext.xml:
<bean id=3D"base.application.context" class=3D"
org.springframework.context.ApplicationContextFactory">
<property name=3D"implementationClass">
<value>org....ClassPathXmlApplicationContext</value>
</property>
<property name=3D"defaultIncludes">
<list>
<value>someContext1.xml</value>
<value>someContext2.xml</value>
</list>
</property>
<property name=3D"conditionalIncludes">
<list>
<ref bean=3D"integration-sales"/>
<ref bean=3D"integration-accountmanagement"/>
</list>
</property>
</bean>
<bean id=3D"intgeration-sales" class=3D"
org.springframework.context.SystemConditionalInclude">
<property name=3D"key" value=3D"sales"/>
<property name=3D"liveDefinitionFiles">
<list><value>IntegrationContext-sales.xml</value></list>
</property>
<property name=3D"stubbedFiles">
<list><value>integrationContext-sales-stubbed</value</list>
</property>
</bean>
The SystemConditionalInclude would look for "sales" property as a System
Property to be set to true/live or not. It would implement
ConditionalInclude. Other implementations of ConditionalInclude could look
for keys in other ways.
On 10/1/05, Farhan Kazmi <ka...@gm...> wrote:
>
> 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 probabl=
y
> want this interface stubbed during development. One option is to have 2 s=
ets
> of bean definition files i.e. ApplicationContext-Integration.xml and
> ApplicationContext-Stubbed.xml. You could have ANT build tasks that
> included either the development (stubbed) version or the unstubbed versio=
n.
> 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 differ=
ent
> 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 way=
s
> 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 verbo=
se)
> 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
> >
>
>
|