ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Transaction 설정 샘플
    Programming/Framework 2012.10.17 18:46

    Anyframe 의 트랜잭션 샘플


    <?xml version="1.0" encoding="UTF-8"?>

    <beans xmlns="http://www.springframework.org/schema/beans"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"

    xmlns:util="http://www.springframework.org/schema/util" xmlns:aop="http://www.springframework.org/schema/aop"

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd

    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd

    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">


    <util:properties id="contextProperties" location="classpath:context.properties" />


    <!-- DataSource JDBC 설정  -->

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"

    destroy-method="close">

    <property name="initialSize" value="2"/>

    <property name="maxActive"  value="5"/>

    <property name="maxIdle" value="2"/>

    <property name="driverClassName" value="#{contextProperties.driver}" />

    <property name="url" value="#{contextProperties.url}" />

    <property name="username" value="#{contextProperties.username}" />

    <property name="password" value="#{contextProperties.password}" />

     </bean>


    <!-- DataSource JNDI 설정  -->

    <!--

    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> 

        <property name="jndiName" value="#{contextProperties.jndiname}" />

        <property name="resourceRef" value="true"/>

    </bean>

     -->


      <bean id="transactionManager"

    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

    <property name="dataSource" ref="dataSource" />

      </bean>


    <!-- 일반 서비스의 트랜잭션  -->

      <tx:advice id="txAdvice" transaction-manager="transactionManager">

    <tx:attributes>

    <tx:method name="*" rollback-for="Exception" propagation="REQUIRED" />

    </tx:attributes>

      </tx:advice>


    <!-- 개별 트랜잭션을 별도로 분리하도록 한다.  -->

     <tx:advice id="txAdviceRequireNew" transaction-manager="transactionManager">

        <tx:attributes>

    <tx:method name="*" rollback-for="Exception" propagation="REQUIRES_NEW" />

        </tx:attributes>

      </tx:advice>


    <aop:config>

    <!-- 일반 Service -->

     <aop:pointcut id="serviceTxPointCut" expression="execution(* com...impl.*ServiceImpl.*(..))" />

     <!--IDgen, logger  -->

    <aop:pointcut id="requiredTxIdgenPointCut"

    expression="execution(* com..impl.IdGenServiceBizImpl.*(..))" />

    <aop:pointcut id="requiredTxUserLogPointCut"

    expression="execution(* com.EventLogger.insertEventLog(..))" />


      <!-- Advisor: Transaction처리용  -->

      <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceTxPointCut" />

      <aop:advisor advice-ref="txAdviceRequireNew" pointcut-ref="requiredTxIdgenPointCut" />

      <aop:advisor advice-ref="txAdviceRequireNew" pointcut-ref="requiredTxUserLogPointCut" />

    </aop:config>

    <!--    트랜잭션 정의             -->

    </beans>


    'Programming > Framework' 카테고리의 다른 글

    Akka  (0) 2014.02.18
    antlr  (0) 2013.04.26
    Transaction 설정 샘플  (0) 2012.10.17
    Anyframe 의 JDBC 실행관련 설정  (0) 2012.10.17

    댓글 0

Designed by Tistory.