|
From: <jue...@we...> - 2004-10-04 16:15:25
|
I've just added a PropertyPathFactoryBean, following this suggestion: http://opensource.atlassian.com/projects/spring/browse/SPR-343 Usage examples: // target bean to be referenced by name <bean id=3D"tb" class=3D"org.springframework.beans.TestBean" = singleton=3D"false"> <property name=3D"age"><value>10</value></property> <property name=3D"spouse"> <bean class=3D"org.springframework.beans.TestBean"> <property name=3D"age"><value>11</value></property> </bean> </property> </bean> // will result in 12, which is the value of property 'age' of the inner = bean <bean id=3D"propertyPath1" = class=3D"org.springframework.beans.factory.config.PropertyPathFactoryBean= "> <property name=3D"targetObject"> <bean class=3D"org.springframework.beans.TestBean"> <property name=3D"age"><value>12</value></property> </bean> </property> <property name=3D"propertyPath"><value>age</value></property> </bean> // will result in 11, which is the value of property 'spouse.age' of = bean 'tb' <bean id=3D"propertyPath2" = class=3D"org.springframework.beans.factory.config.PropertyPathFactoryBean= "> <property name=3D"targetBeanName"><value>tb</value></property> <property name=3D"propertyPath"><value>spouse.age</value></property> </bean> // will result in 10, which is the value of property 'age' of bean 'tb' <bean id=3D"tb.age" = class=3D"org.springframework.beans.factory.config.PropertyPathFactoryBean= "/> The last one, interpreting the bean name as 'beanName.property' pattern, = is quite concise... Juergen |