Normalmente las dependencias se inyectan a través de setters mediante la siguiente configuración ( http://static.springsource.org/sprin...beans-beanname ) :
<bean id="exampleBean" class="examples.ExampleBean">
<!-- setter injection using the nested <ref/> element -->
<property name="beanOne"><ref bean="anotherExampleBean"/></property>
<!-- setter injection using the neater 'ref' attribute -->
<property name="beanTwo" ref="yetAnotherBean"/>
<property name="integerProperty" value="1"/>
</bean>
<bean id="anotherExampleBean" class="examples.AnotherBean"/>
<bean id="yetAnotherBean" class="examples.YetAnotherBean"/>
Digamos que la clase examples.ExampleBean
tiene una colección de objetos oyentes, y el método addListener(SomeListenerInterface)
es la única forma posible de añadir oyentes. ¿Puedo inyectar oyentes de forma declarativa en xml como se hace con los definidores de propiedades?