spring 에서 흔히 볼 수 있 는 XML 설정 op 과 트 랜 잭 션

XML - AOP 설정
    <!--  bean-->   
    <bean id="personService" class="com.aop.service.PersonServiceBean"></bean>
    <!--   bean-->    
    <bean id="myInterceptor" class="com.aop.interceptor.MyInterceptor2"></bean>
    <!-- aop   -->
    <aop:config>
      <!-- aspect   ,  myInterceptor-->
      <aop:aspect id="asp" ref="myInterceptor">
        <!--   pointcut,         aop -->
        <aop:pointcut id="mypointcut" expression="execution (* com.aop.service.PersonServiceBean.*(..))"/>
        <!-- before  ,  pointcut  before  -->
        <aop:before pointcut-ref="mypointcut" method="beforeMethod"/>
        <!-- <aop:before pointcut="pointcut   " method="beforeMethod"/> -->
        <aop:after pointcut-ref="mypointcut" method="afterMethod" />
      </aop:aspect>
    </aop:config>

 
XML-transaction
 
<!--       -->
  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost:3306/test" />
    <property name="username" value="root" />
    <property name="password" value="root" />
  </bean>

  <!--         -->
  <bean id="txManage"
    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
  </bean>
  <!--     advice   -->
  <tx:advice id="txAdvice" transaction-manager="txManage">
    <tx:attributes>
      <tx:method name="delete" propagation="NEVER" timeout="-1" isolation="DEFAULT" read-only="false"/>
    </tx:attributes>
  </tx:advice>
  <!-- AOP  ,         aop,  advice      -->
  <aop:config>
    <aop:pointcut id="personPointcut"
      expression="execution(* com.jdbc.service.impl.PersonServiceBean.*(..))" />
    <aop:advisor pointcut-ref="personPointcut" advice-ref="txAdvice" />
  </aop:config>

 

좋은 웹페이지 즐겨찾기