I’ve got two beans, and I’d like to wire the String property of one bean to the String value of the property of another (which is computed from the environment of the program). What is the best way to wire these together?
The best solution I can think of is:
<bean id="thisBean">
<property name="foo">
<bean factory-bean="otherBean" factory-method="getStringForThisBean" />
</property>
</bean>
There are other ways to do it, like using SpringEL or working inside Spring’s property system, but this is the easiest. It just doesn’t feel right creating a heavy-weight bean to store a String value.
Is there a better way?
I feel Spring-EL would be a much better fit, it would be this way with Spring-EL: