Skip to content

Support Property Paths as first class citizens in XML configuration file, i.e. <property name="foo" path="bar[baz].bat"/> [SPR-1391] #6091

Closed
@spring-projects-issues

Description

@spring-projects-issues

Andrew Thompson opened SPR-1391 and commented

I've recently been trying to use property paths as described in section 3.15 of the Spring manual.

Here's the first example quoted from the manual, which, whilst not the most compact of the 3 examples given, it is the most general:

Here's an example where a path is used against another bean, by name:

// target bean to be referenced by name
<bean id="person" class="org.springframework.beans.TestBean" singleton="false">
<property name="age"><value>10</value></property>
<property name="spouse">
<bean class="org.springframework.beans.TestBean">
<property name="age"><value>11</value></property>
</bean>
</property>
</bean>

// will result in 11, which is the value of property 'spouse.age' of bean 'person'
<bean id="theAge" class="org.springframework.beans.factory.config.PropertyPathFactoryBean">
<property name="targetBeanName"><value>person</value></property>
<property name="propertyPath"><value>spouse.age</value></property>
</bean>

Presumably someone would then do

<bean id="..." class="..."/>
<property name="bar" ref="theAge"/>
</bean>

It strikes me that this is a LOT of typing. It should really all boil down to:

<property name="bar" ref="person.spouse.age"/>

Of course, that might be pretty ambiguous, so perhaps some kind of new syntax would be needed:

<property name="bar" ref=">person.spouse.age"/>

Where ">" means follow a path. Or the less pithy but easier to remember and understand:

<property name="bar" path="person.spouse.age"/>
Have I missed some easy, elegant way of doing this?
Has this idea come up before and been rejected for some reason?


No further details from SPR-1391

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions