spring-jpetstore 学习整理(二)

来源:互联网 发布:淘宝店铺微信营销 编辑:程序博客网 时间:2024/06/05 00:28

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">


<beans>

 <!-- ========================= GENERAL DEFINITIONS ========================= -->

<!--

定义了一个PropertyPlaceholderConfigurer,把一些配置信息放在*.properties的文件里,在以后的调用中

可以使用"${名称}"的方式,进行调用(仅限制在配置文件中调用)

-->
 <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="locations">
   <list>
    <value>WEB-INF/mail.properties</value>
    <value>WEB-INF/jdbc.properties</value>
   </list>
  </property>
 </bean>
 
 <!-- MailSender used by EmailAdvice -->
 <!--
 <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
  <property name="host"><value>${mail.host}</value></property>
 </bean>
 -->

 <!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->

 <!-- Generic validator for Account objects, to be used for example by the Spring web tier -->
 <bean id="accountValidator" class="org.springframework.samples.jpetstore.domain.logic.AccountValidator"/>

 <!-- Generic validator for Order objects, to be used for example by the Spring web tier -->
 <bean id="orderValidator" class="org.springframework.samples.jpetstore.domain.logic.OrderValidator"/>

 <!-- JPetStore primary business object: default implementation -->
 <bean id="petStoreTarget" class="org.springframework.samples.jpetstore.domain.logic.PetStoreImpl">
  <property name="accountDao"><ref bean="accountDao"/></property>
  <property name="categoryDao"><ref bean="categoryDao"/></property>
  <property name="productDao"><ref bean="productDao"/></property>
  <property name="itemDao"><ref bean="itemDao"/></property>
  <property name="orderDao"><ref bean="orderDao"/></property>
 </bean>

 <!-- AOP advice used to send confirmation email after order has been submitted -->
 <!--
 <bean id="emailAdvice" class="org.springframework.samples.jpetstore.domain.logic.SendOrderConfirmationEmailAdvice">
  <property name="mailSender"><ref local="mailSender"/></property>
 </bean>
 -->

 <!-- Advisor encapsulating email advice -->
 <!--
 <bean id="emailAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
  <constructor-arg><ref local="emailAdvice"/></constructor-arg>
  <property name="pattern"><value>.*insertOrder.*</value></property>
 </bean>
 -->

 <!--

 定义了一个事物管理

设置了相关的属性

 -->
 <bean id="petStore" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
  <property name="transactionManager"><ref bean="transactionManager"/></property>
  <property name="target"><ref local="petStoreTarget"/></property>
  <property name="transactionAttributes">
   <props>
    <prop key="insert*">PROPAGATION_REQUIRED</prop>
    <prop key="update*">PROPAGATION_REQUIRED</prop>
    <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
   </props>
  </property>
  <!-- Uncomment the following in order to enable mail sending aspect -->
  <!--
  <property name="postInterceptors">
   <list>
    <ref local="emailAdvisor"/>
   </list>
  </property>
   -->
 </bean>

 <!-- ========================= REMOTE EXPORTER DEFINITIONS ========================= -->

 <!-- RMI exporter for the JPetStore OrderService -->
 <!-- Commented out by default to avoid conflicts with EJB containers -->
 <!--
 <bean id="order-rmi" class="org.springframework.remoting.rmi.RmiServiceExporter">
  <property name="service"><ref local="petStore"/></property>
  <property name="serviceInterface">
   <value>org.springframework.samples.jpetstore.domain.logic.OrderService</value>
  </property>
  <property name="serviceName"><value>order</value></property>
  <property name="registryPort"><value>1099</value></property>
 </bean>
 -->

</beans>

 
原创粉丝点击