|
From: Steven D. <ste...@gm...> - 2005-01-07 15:41:32
|
When building a hiearchical object graph for configuration purposes it would be nice to be able to reference to other beans that are not at the root level. On the other hand it's also nice to have a strict scope :-) Thanks for your feedback. On Fri, 7 Jan 2005 16:34:10 +0100, Juergen Hoeller <ju...@in...> wrote: > Beans that are supposed to be available for references by name indeed need > to be defined at the root level. Inner beans are always anonymous and > usually don't carry a name. Defining a name for them only adds value if they > are aware of their own name (BeanNameAware). > > Juergen > > > -----Original Message----- > From: spr...@li... > [mailto:spr...@li...]On Behalf > Of Steven Devijver > Sent: Friday, January 07, 2005 4:23 PM > To: spr...@li... > Subject: [Springframework-developer] bean factory scope question > > Hi, > > When I load the application context with the example below I get an > exception because a bean with id "test3" cannot be found. I understand > this bean does not exist in the scope where it's referenced. Is there > a way to make beans with an id or name available in the root scope > apart from defining them there? > > <bean id="test2" class="sandbox.TestObject"> > <property name="value"> > <list> > <bean class="sandbox.TestObject"> > <property name="value"> > <value>a string</value> > </property> > </bean> > <bean class="sandbox.TestObject"> > <property name="value"> > <list> > <bean id="test3" class="sandbox.TestObject"> > <property name="value"> > <value>another string</value> > </property> > </bean> > </list> > </property> > </bean> > <bean class="sandbox.TestObject"> > <property name="value"> > <list> > <ref bean="test3"/> > </list> > </property> > </bean> > </list> > </property> > </bean> > > Steven > > > ------------------------------------------------------- > The SF.Net email is sponsored by: Beat the post-holiday blues > Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. > It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > > ------------------------------------------------------- > The SF.Net email is sponsored by: Beat the post-holiday blues > Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. > It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > > |