Wednesday, 18 May 2011

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

Hi,

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

1 comment:

Anonymous said...

1/ adding "path" will make Spring beginner confused, and will require significant update to Spring docs, I think.

2/ Spring 3 has introduce "Expression Language" feature, and it is sufficient for such config :)
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/expressions.html

just my 2 cents