Best way to remove duplicate code with JmsTemplate
Currently i have redundant code in each of my beans but i'm not sure what the best way to abstract this out, where only the queue name changes from queue1, 2, 3.
Code:
<bean id="bean1" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="wlConnectionFactory"/>
<property name="defaultDestination">
<bean class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="jndiTemplate"/>
<property name="jndiName" value="queue1"/>
</bean>
</property>
</bean>
<bean id="bean2" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="wlConnectionFactory"/>
<property name="defaultDestination">
<bean class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="jndiTemplate"/>
<property name="jndiName" value="queue2"/>
</bean>
</property>
</bean>
<bean id="bean3" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="wlConnectionFactory"/>
<property name="defaultDestination">
<bean class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="jndiTemplate"/>
<property name="jndiName" value="queue3"/>
</bean>
</property>
</bean>