0

I have such bean declaration:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans SYSTEM "../schemas/spring-beans.dtd">
<beans>
   <import resource="container-*.xml" />
   <bean id="containerCodeStore" class="com.mycompany.ntd.crm.xxx2.container.InMemoryContainerCodeStore">
        <property name="containers">
            <map>
                <entry key="WORKER-ONE" value-ref="workerOneContainer" />
                <entry key="WORKER-TWO" value-ref="workerTwoContainer" />
            </map>
        </property>
    </bean>
</beans>

where beans workerOneContainer and workerTwoContainer declared in container-worker-one.xml and container-worker-two.xml something like this:

<bean id="workerOneContainer" class="com.mycompany.ntd.crm.xxx.container.workerone.WorkerOneContainer">
    <property name="name" value="WORKER-ONE" />
    ...
</bean>

Now it is necessary to reduce map declaration, so containers put into map itself - due to it own declaration. In other words needs to spread map declaration out into containers bean declaration.

PavelPraulov
  • 589
  • 6
  • 18

1 Answers1

0

Finnaly, I've made such changes:

  1. Into the bean cofiguration id="containerCodeStore" added autowire="byType" parameter;
  2. Into class InMemoryContainerCodeStore added field List<WorkerContainerParent> containerList. Now this list filled with containers automatically by Spring;
  3. Also into class InMemoryContainerCodeStore added afterPropertiesSet() method, which to populate map containers from containerList.

And it is allow me to removed all entries from <map>...</map> because map filled automatically.

PavelPraulov
  • 589
  • 6
  • 18