Unfortunately the above does not work, because the bean
Code:
<property name="codice">
<bean
id="codice.toString"
class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
</property>
would cause the PropertyPathFactoryBean to call a getter for the property "toString", that is "getToString", which does not exists in java.lang.toString.
I've found a nice-enough solution using the PropertyPlaceholderConfigurer, and setting the value of the shared property in an external properties file:
Code:
<bean
id="PropertyRegistry"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="somewhere/in/classpath/registry.properties"/>
</bean>
<bean
id="pippoBean"
class="test.Pippo">
<property name="codice">
<value>${prop.codice}</value>
</property>
<property name="pluto" ref="plutoBean">
</bean>
<bean
id="plutoBean"
class="test.Pluto">
<property name="codice">
<value>${prop.codice}</value>
</property>
</bean>
where prop.codice is defined in "somewhere/in/classpath/registry.properties".
This works for me, because it allows me to share properties' values among beans.
Any comment is welcome.