|
From: <jue...@we...> - 2004-07-09 13:49:05
|
Well-spotted. I've just adapted PropertiesBeanDefinitionReader = accordingly. Juergen -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of Tom Turelinckx Sent: Friday, July 09, 2004 2:36 PM To: spr...@li... Subject: Re: [Springframework-developer] Reworked root/child bean definition concept Hello Juergen, > parent can even omit the bean class completely, simply specifying = common > properties for children: >=20 > <bean id=3D"inheritedTestBeanWithoutClass"> > <property name=3D"name"><value>parent</value></property> > <property name=3D"age"><value>1</value></property> > </bean> >=20 > <bean id=3D"inheritsWithClass" > class=3D"org.springframework.beans.DerivedTestBean" > parent=3D"inheritedTestBeanWithoutClass" = init-method=3D"initialize"> > <property name=3D"name"><value>override</value></property> > <!-- age should inherit value of 1 from parent --> > </bean> >=20 > Of course, such a parent bean cannot get instantiated on its own: It's > just a template that serves as parent definition for children. > preInstantiateSingletons will ignore such beans without class and = parent > completely. I've accidentally noticed that this doesn't work when using a PropertiesBeanDefinitionReader. This bean definition file: inheritedTestBeanWithoutClass.name =3D parent inheritedTestBeanWithoutClass.age =3D 1 inheritsWithClass.class =3D org.springframework.beans.DerivedTestBean inheritsWithClass.parent =3D inheritedTestBeanWithoutClass inheritsWithClass.init-method =3D initialize inheritsWithClass.name =3D override # age should inherit value of 1 from parent results in this exception: org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'inheritedTestBeanWithoutClass' defined in file [...]: Either 'class' or 'parent' is required at = org.springframework.beans.factory.support.PropertiesBeanDefinitionReader.= registerBeanDefinition(PropertiesBeanDefinitionReader.java:368) at = org.springframework.beans.factory.support.PropertiesBeanDefinitionReader.= registerBeanDefinitions(PropertiesBeanDefinitionReader.java:269) at = org.springframework.beans.factory.support.PropertiesBeanDefinitionReader.= loadBeanDefinitions(PropertiesBeanDefinitionReader.java:159) at = org.springframework.beans.factory.support.PropertiesBeanDefinitionReader.= loadBeanDefinitions(PropertiesBeanDefinitionReader.java:140) The same configuration in xml does work when using an XmlBeanDefinitionReader. Kind regards, Tom. ------------------------------------------------------- This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 -=20 digital self defense, top technical experts, no vendor pitches,=20 unmatched networking opportunities. Visit www.blackhat.com _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |