I was recently searching for an answer to a different question about load-time-weaving and autowiring and I remember coming across something like this, but I’m not sure how to configure it. Essentially, I have class instances created outside of my control, so I need load-time weaving in order to wire my dependencies automatically as instances are created. I’d like to configure the dependencies in XML, though, as it’s not able to autowire a certain List field.
Here’s what I’d like to do:
@Configurable
public class RuntimeCreatedBean {
private List<RuntimeDependency> runtimeDependencies;
// setters omitted for brevity
}
XML:
<beans>
<bean class="RuntimeCreatedBean">
<property name="runtimeDependencies">
<list>
<bean class="RuntimeDependencyOne"/>
</list>
</property>
</bean>
</beans>
Is there a way to do this, where the bean definition is used to wire the RuntimeCreatedBean?
I haven’t tried exactly like that, but I believe it will work exactly as you posted it. Have you tried it?
Edit: Yes, I just tried it in a sample project, and it works as expected.