<beans>
??? <bean id="myDataSource1" class="org.springframework.jndi.JndiObjectFactoryBean">
??????? <property name="jndiName">
??????????? <value>java:comp/env/jdbc/myds1</value>
??????? </property>
??? </bean>
??? <bean id="myDataSource2" class="org.springframework.jndi.JndiObjectFactoryBean">
??????? <property name="jndiName">
??????????? <value>java:comp/env/jdbc/myds2</value>
??????? </property>
??? </bean>
??? <bean id="mySessionFactory1" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
??????? <property name="mappingResources">
??????????? <list>
??????????????? <value>product.hbm.xml</value>
??????????? </list>
??????? </property>
??????? <property name="hibernateProperties">
??????????? <props>
??????????????? <prop key="hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect</prop>
??????????? </props>
??????? </property>
??????? <property name="dataSource">
??????????? <ref bean="myDataSource1"/>
??????? </property>
??? </bean>
??? <bean id="mySessionFactory2" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
??????? <property name="mappingResources">
??????????? <list>
??????????????? <value>inventory.hbm.xml</value>
??????????? </list>
??????? </property>
??????? <property name="hibernateProperties">
??????????? <props>
??????????????? <prop key="hibernate.dialect">net.sf.hibernate.dialect.OracleDialect</prop>
??????????? </props>
??????? </property>
??????? <property name="dataSource">
??????????? <ref bean="myDataSource2"/>
??????? </property>
??? </bean>
??? <bean id="myTransactionManager"
??????? class="org.springframework.transaction.jta.JtaTransactionManager"/>
??? <bean id="myProductDao" class="product.ProductDaoImpl">
??????? <property name="sessionFactory">
??????????? <ref bean="mySessionFactory1"/>
??????? </property>
??? </bean>
??? <bean id="myInventoryDao" class="product.InventoryDaoImpl">
??????? <property name="sessionFactory">
??????????? <ref bean="mySessionFactory2"/>
??????? </property>
??? </bean>
??? <bean id="myProductServiceTarget" class="product.ProductServiceImpl">
??????? <property name="productDao">
??????????? <ref bean="myProductDao"/>
??????? </property>
??????? <property name="inventoryDao">
??????????? <ref bean="myInventoryDao"/>
??????? </property>
??? </bean>
??? <bean id="myProductService"
??????? class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
??????? <property name="transactionManager">
??????????? <ref bean="myTransactionManager"/>
??????? </property>
??????? <property name="target">
??????????? <ref bean="myProductServiceTarget"/>
??????? </property>
??????? <property name="transactionAttributes">
??????????? <props>
??????????????? <prop key="increasePrice*">PROPAGATION_REQUIRED</prop>
??????????????? <prop key="someOtherBusinessMethod">PROPAGATION_MANDATORY</prop>
??????????? </props>
??????? </property>
??? </bean>
???<bean id="productService" class="...">
??????? <property name="myService">
??????????? <ref bean="myProductService"/>
??????? </property>
???</bean>
</beans>
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
ProductService productService = (ProductService) context.getBean("productService");
ApplicationContext context =
new FileSystemXmlApplicationContext("C:/myContext.xml");
ProductService productService =
(ProductService) context.getBean("myProductService");
ApplicationContext context =
new ClassPathXmlApplicationContext("myContext.xml");
ProductService productService =
(ProductService) context.getBean("myProductService");