|
From: <jue...@we...> - 2003-11-10 23:02:21
|
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. =20 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. =20 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? ------------------------------------------------------- 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 |
|
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 |
|
From: Rod J. <rod...@in...> - 2003-11-11 08:52:49
|
I agree it's not something to encourage, but it's a useful capability. EJB not having such a capability is one of the pains of using EJB. (Of course in a distributed environment things are different, hence the lack of such a feature with EJB.) Regards, Rod ----- Original Message ----- From: "jürgen höller [werk3AT]" <jue...@we...> To: <spr...@li...> Sent: Tuesday, November 11, 2003 8:15 AM Subject: Re: [Springframework-developer] Forcing dependencies between singleton beans without one actually being a property of another Colin, 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. 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. 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. Juergen ________________________________ 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ürgen höller [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? > > ------------------------------------------------------- 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 ------------------------------------------------------- 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 |
|
From: Colin S. <col...@ex...> - 2003-11-11 15:02:51
|
Juergen, How do these dependencies get handled in relation to the existing dependencies. i.e. Will this figure out that there is a problem if the deployer goofs up and for example says (with the new attribute) that bean A depends on bean B, but bean B has a property which refers to bean A? jürgen höller [werk3AT] wrote: >Colin, > >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. > >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. > >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. > >Juergen > > >________________________________ > >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ürgen höller [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? >> >> |
|
From: Colin S. <col...@ex...> - 2003-11-10 23:11:29
|
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ürgen höller [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? > > |