|
From: Alef A. \(JTeam\) <al...@jt...> - 2003-11-09 22:22:54
|
Hmm, this looks promising. I don't want to get to deep in the source now, so two basic questions (so I can immediately put this in the docs as well): I was wondering how multiple autowire types are supported. Is it possible to use both constructor autowiring and byType autowiring (in order to get both constructors have arguments as well as beanstyle setters)? Then, I assume any constructor arguments specified by a constructor-arg will not be included in the autowiring process? Alef > -----Oorspronkelijk bericht----- > Van: spr...@li...=20 > [mailto:spr...@li...] > Namens j=FCrgen h=F6ller [werk3AT] > Verzonden: Sunday, November 09, 2003 10:48 PM > Aan: spr...@li... > Onderwerp: [Springframework-developer] Type 3 IoC support >=20 >=20 > Everybody, > =20 > I'm pleased to announce that a Spring bean factory is now=20 > capable of handling Type 3 IoC components! As the most=20 > important feature, I've introduced autowire=3D"constructor" for=20 > autowiring constructor arguments by type, just like=20 > autowire=3D"byType" does for bean properties.=20 > =20 > Furthermore, there is a "constructor-arg" tag within the=20 > "bean" tag now, to pass specific beans or values to=20 > constructor arguments. "constructor-arg" can specify generic=20 > values that get matched by type, or values for a specific=20 > argument via its "index" attribute. This means that we can=20 > handle any kind of constructor, be it with bean references,=20 > simple values, lists, maps, etc. We can also easily handle=20 > multiple constructor arguments of the same type, i.e. 2=20 > DataSource arguments or 2 String values (in contrast to the=20 > current Pico version)! > =20 > The only limitation is that constructor-wired components are=20 > just allowed to have one single constructor. This is also=20 > what Pico recommends, although they have some heuristic kind=20 > of constructor choice in case of multiple constructors now. I=20 > guess we can limit this to one single constructor for the=20 > time being. Of course, standard beans defined without=20 > autowire=3D"constructor" or "constructor-arg" tags can still=20 > have any number of constructors, the only requirement being=20 > that they must provide a no-arg constructor. > =20 > As an example, the XML bean definition from the test case: > =20 > <beans> > =20 > <bean id=3D"rod1"=20 > class=3D"org.springframework.beans.factory.xml.ConstructorDepend > enciesBean"> > <constructor-arg><ref bean=3D"other"/></constructor-arg> > <constructor-arg><ref bean=3D"kerry2"/></constructor-arg> </bean> > =20 > <bean id=3D"rod2"=20 > class=3D"org.springframework.beans.factory.xml.ConstructorDepend > enciesBean"> > <constructor-arg index=3D"1"><ref = bean=3D"kerry1"/></constructor-arg> > <constructor-arg index=3D"0"><ref = bean=3D"kerry2"/></constructor-arg> > <constructor-arg><ref bean=3D"other"/></constructor-arg> </bean> > =20 > <bean id=3D"rod3"=20 > class=3D"org.springframework.beans.factory.xml.ConstructorDepend > enciesBean" > autowire=3D"constructor"> > <constructor-arg><ref bean=3D"kerry2"/></constructor-arg> </bean> > =20 > <bean id=3D"rod4"=20 > class=3D"org.springframework.beans.factory.xml.DerivedConstructo > rDependenciesBean"> > <constructor-arg index=3D"1"><ref = bean=3D"kerry1"/></constructor-arg> > <constructor-arg index=3D"3"><value>99</value></constructor-arg> > <constructor-arg><ref bean=3D"other"/></constructor-arg> > <constructor-arg index=3D"4"><value>myname</value></constructor-arg> > <constructor-arg index=3D"0"><ref=20 > bean=3D"kerry2"/></constructor-arg> </bean> > =20 > <bean id=3D"kerry1" class=3D"org.springframework.beans.TestBean"> > <property name=3D"name"> > <value>Kerry</value> > </property> > </bean> > =20 > <bean id=3D"kerry2" class=3D"org.springframework.beans.TestBean"> > <property name=3D"name"> > <value>Kerry</value> > </property> > </bean> > =20 > <bean id=3D"other"=20 > class=3D"org.springframework.beans.factory.LifecycleBean"/> > =20 > </beans> >=20 > Juergen >=20 >=20 > ------------------------------------------------------- > This SF.Net email sponsored by: ApacheCon 2003, > 16-19 November in Las Vegas. Learn firsthand the latest=20 > developments in Apache, PHP, Perl, XML, Java, MySQL, WebDAV,=20 > and more! http://www.apachecon.com/=20 > _______________________________________________ > Springframework-developer mailing list=20 > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer >=20 |