Wednesday, 18 May 2011

I want spring's <util:property-path path="..."/> to become simply path="..."


I have recently discovered a great feature in Spring:
    <property name="propertyToSet">
<util:property-path path="aBean.aProperty"/>
This is much nicer in my opinion than
    <property name="propertyToSet">
<bean factory-bean="aBean" factory-method="getAProperty"/>
It is also more powerful because you can do things like
    <property name="propertyToSet">
<util:property-path path="aBean.aProperty.aNestedProperty"/>
which otherwise would have been awkward.

However I do want an improvement. I want a yet more concise syntax for this. Spring can already do this:
    <property name="aPropertyToSet" value="true"/>
<property name="aPropertyToSet" ref="anotherBean"/>
So it would only be logical (and very-very nice!) if it could also do this:
    <property name="propertyToSet" path="aBean.aProperty"/>