I need to configure quite a lot of data access object (DAO) beans in my applicationContext.xml file:
<bean id="addressDAO" class="mypackage.dao.AddressDAOImpl">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<bean id="userDAO" class="mypackage.dao.UserDAOImpl">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
etc.
I was wondering whether there were any shortcuts for configuring multiple beans with the same properties? For example, it might be done like this:
<property-applicator>
<property name="sessionFactory"><ref local="sessionFactory"/></property>
<property name="otherProperty"><ref local="otherBean"/></property>
<bean id="userDAO" class="mypackage.dao.UserDAOImpl"/>
<bean id="otherDAO" class="mypackage.dao.OtherDAOImpl"/>
<bean id="anotherDAO" class="mypackage.dao.AnotherDAOImpl"/>
</property-applicator>
It might come in handy if it doesn't already exist.


Reply With Quote