|
From: <jue...@we...> - 2003-11-11 08:17:41
|
Colin, =20 I guess a "depends-on" attribute is clearer. <ref> is currently just = used wherever objects can get passed in, i.e. in <property>, = <constructor-arg>, <list>, etc. As dependencies can just be express to = beans and not to values, the explicit <ref> element could be misleading. = Furthermore, <bean>'s "parent" attribute also references another bean = but not via <ref>. A dependency attribute with bean names as values = would be similar. =20 I've just added "depends-on" as attribute for <bean>, managed via = RootBeanDefinitions's new "dependsOn" property. The value can be one or = more bean names, separated by any number of spaces or commas. = AbstractBeanFactory will simply call getBean for each of those names = before creating the bean instance. =20 Note that I do not recommend this for general usage but just for special = cases like depending on prepared statics (*ugh*) or database preparation = on startup. There could be the case of existing classes that work with = statics. And for database preparation, it's hard to see why DAOs should = have to reference that preparator as a bean property - they still depend = on it being initialized and executed first, though. =20 Juergen =20 ________________________________ Von: spr...@li... im Auftrag = von Colin Sampaleanu Gesendet: Di 11.11.2003 00:11 An: spr...@li... Betreff: [[W3-SPAM]] - Re: [Springframework-developer] Forcing = dependencies between singleton beans without one actually being a = property of another - Email found in subject As opposed to an attribute, you could re-use the 'ref' element, directly under the 'bean' element to state a dependency. In fact, my colleage didn't look too carefully at the dtd and tried to do that directly, to get what he wanted. Having a 'dependency' attribute is probably clearer though... j=FCrgen h=F6ller [werk3AT] wrote: >I've been asked that by co-workers too. In all our cases, we managed to = solve the issue by redesigning the application objects so that such = side-effects that other beans depend on are avoided. Nevertheless, I've = repeatedly considered adding Ant-style "depends" support, possibly via a = "depends-on" attribute of the "bean" tag, with a comma-separated list of = bean names as value. > >On bean creation, the bean factory would simply have to call getBean = for those bean names first, before actually creating the bean instance. = That would be easy enough to add (compared to constructor resolution or = such stuff), so I might do this alongside breakfast tomorrow ;-) Are = there any objections to such an option? If not, I suggest to add this = already for 1.0 M3. > >Juergen > >________________________________ > >Von: spr...@li... im Auftrag = von Colin Sampaleanu >Gesendet: Mo 10.11.2003 23:26 >An: spr...@li... >Betreff: [[W3-SPAM]] - [Springframework-developer] Forcing dependencies = between singleton beans without one actually being a property of another = - Email found in subject > > > >I had a co-worker ask me if there was a way to force the creation/usage >of a singleton bean B to first create another bean, A, without A >actually needing to be a property of B. He needs this because A has = some >side-effects which B depends on, to work properly. > >Of course there are some artificial ways to cause this to happen, but I >can't think of anything too clean. Is this worth adding as a built-in >capability? >=20 > ------------------------------------------------------- This SF.Net email sponsored by: ApacheCon 2003, 16-19 November in Las Vegas. Learn firsthand the latest developments in Apache, PHP, Perl, XML, Java, MySQL, WebDAV, and more! http://www.apachecon.com/ _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |