Come aggiungere più HBM a MappingSorces esistenti o Elenco HBM esistente in primavera
Domanda
Ho un'app genitori, che include sottomarine. La mia app padre ha il suo elenco incluso di HBMS
<bean name="mappingResources"
class="my.xxx.MyListFactoryBean">
<property name="sourceList">
<list>
<value>aaa/bbb/aa.hbm.xml</value>
<value>aaa/bbb/bb.hbm.xml</value>
<value>aaa/bbb/cc.hbm.xml</value>
</list>
</property>
</bean>
.
Le mie Sub-app vogliono aggiungere la propria lista di HBMS dipendenti all'APP. Il modo in cui dovrebbe funzionare è, se include questa Sub-app quindi includerebbe anche il nuovo HBMS e l'App Child-App avrebbe iniziato l'inclusione.
Nuovi HBMS da includere potrebbero sembrare
xx / dd.hbm.xml xx / ee.hbm.xml
Come possiamo farlo?
Soluzione
La tua soluzione potrebbe essere:
Dividere i "Mappingresurces" a
<bean name="mappingResources" class="my.xxx.MyListFactoryBean">
<property name="sourceList" ref="hbmSourceList" />
</bean>
<bean id="hbmSourceList" class="java.util.ArrayList">
<constructor-arg>
<list>
<value>aaa/bbb/aa.hbm.xml</value>
<value>aaa/bbb/bb.hbm.xml</value>
<value>aaa/bbb/cc.hbm.xml</value>
</list>
</constructor-arg>
</bean>
.
Nell'app per bambini Fare riferimento al fagiolo "HbmSourcelist" e invocare un "addall" su di esso con un altro elenco tramite "MethodInVokingFactoryBean"
<bean id="hbmSourceListExtender" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject"><ref bean="hbmSourceList"/></property>
<property name="targetMethod"><value>addAll</value></property>
<property name="arguments">
<ref local="childAppHbmSourceList"/>
</property>
</bean>
<bean id="childAppHbmSourceList" class="java.util.ArrayList">
<constructor-arg>
<list>
<value>xx/dd.hbm.xml</value>
<value>xx/ee.hbm.xml</value>
</list>
</constructor-arg>
</bean>
. Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow