Suppose that in your spring context file you have imported some context files that you cannot modify.
Is there a way to set the properties of the beans imported ? I do not want to copy and paste the bean definition from the imported context files and modify it because this would create a wrong dependency between my code and the external library.
I just need to modify one property of an existing bean.
It should be possible in theory given that I can do it using a custom class that receives the bean to update as a dependency and modify its properties in the init-method.
I am wondering if there is a standard syntax in Spring to do it.
For example in library-context.xml there is the following bean definition:
<bean id="the.message" class="com.someco.SomeClass">
<property name="message" value="default message" />
</bean>
I import this as an external dependency and so I do not have the option to modify this definition.
Of course I can copy and paste this definition in my context and override it. This would be ok with a bean like the one in the example that is very simple. The problem is that often the dependencies are much more complex and they can change in a different version of the library.
What I want is to set a property of the bean "the.message" ignoring all the other details.
I am thinking to use something like:
<bean id="myproxy" class="com.myapp.Proxy" init-method="copyProperties">
<property name="proxied" value="the.message" />
<property name="message" value="my message" />
</bean>
This "proxy" is only used to set the properties of "the.message".