明月松間照 清泉石上流


                                                  ——— 兵臨城下   貓科動物
          posts - 70, comments - 137, trackbacks - 0, articles - 23
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理
          <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");
          主站蜘蛛池模板: 十堰市| 前郭尔| 蒙自县| 新民市| 肥西县| 佳木斯市| 扎兰屯市| 通渭县| 堆龙德庆县| 岐山县| 阜阳市| 开江县| 兴城市| 威海市| 潮安县| 成都市| 融水| 原平市| 吉安市| 文成县| 阿尔山市| 偏关县| 澄城县| 贞丰县| 裕民县| 蓬安县| 陆川县| 开封市| 乐清市| 古交市| 吉隆县| 庆元县| 林西县| 名山县| 长岭县| 婺源县| 达尔| 太仓市| 常宁市| 兴义市| 明溪县|