PropertyPathFactoryBean()
FactoryBean that evaluates a property path on a given target object.
The target object can be specified directly or via a bean name.
Usage examples:
<!-- target bean to be referenced by name --> <bean id="tb" class="org.springframework.beans.TestBean" singleton="false"> <property name="age" value="10"/> <property name="spouse"> <bean class="org.springframework.beans.TestBean"> <property name="age" value="11"/> </bean> </property> </bean> <!-- will result in 12, which is the value of property 'age' of the inner bean --> <bean id="propertyPath1" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"> <property name="targetObject"> <bean class="org.springframework.beans.TestBean"> <property name="age" value="12"/> </bean> </property> <property name="propertyPath" value="age"/> </bean> <!-- will result in 11, which is the value of property 'spouse.age' of bean 'tb' --> <bean id="propertyPath2" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"> <property name="targetBeanName" value="tb"/> <property name="propertyPath" value="spouse.age"/> </bean> <!-- will result in 10, which is the value of property 'age' of bean 'tb' --> <bean id="tb.age" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
If you are using Spring 2.0 and XML Schema support in your configuration file(s), you can also use the following style of configuration for property path access. (See also the appendix entitled 'XML Schema-based configuration' in the Spring reference manual for more examples.)
<!-- will result in 10, which is the value of property 'age' of bean 'tb' --> <util:property-path id="name" path="testBean.age"/> Thanks to Matthias Ernst for the suggestion and initial prototype!
Author
Juergen Hoeller
Since
1.1.2