TransactionProxyFactoryBean의
문제는 장황한 설정 파일이 필요하다는 것인데 Spring2.0의
새로은 Element에
의해 Transaction의
선언부분이 개선되었다.
아래와
같이 XML
설정
파일에 spring-tx-2.0.xsd를
추가해야 한다.
오라클자바커뮤니티에서 설립한 오엔제이프로그래밍 실무교육센터
(오라클SQL, 튜닝, 힌트,자바프레임워크, 안드로이드, 아이폰, 닷넷 실무전문 강의)
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd”>
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd”>
aop
네임스페이스도
같이 필요한데 tx의
선언적 트랜잭션 설정용 앨리먼트가 Spring
2.0에서
추가된 AOP
설정
앨리먼트를
필요로 하기 때문이다.
tx
네임스페이스에서
tx:advice가
가장 중요한데 사용예는 다음과 같다.
<tx:advice
id=“txAdvice”>
<tx:attributes>
<tx:method
name=“add*” propagation=“REQUIRED”/>
<tx:method
name=“*” propagation=“REQUIRED”read-only=“true”/>
</tx:attributes>
</tx:advice>
tx:method의
필요한 attribute
isolation
: 트랜잭션
격리 수준
no-rollback-for
: Transaction을
롤백하지 않고 계속 진행할 예외를 지정
propagation
: Transaction 전파방식
지정
read-only
: 트랜잭션이
읽기 전용인지
rollback-for
: 트랜잭션이
롤백되어야
할 Checked
Exception을
정의
timeout
: 트랜잭션
타임아웃을 지정
<tx:advice>
자체만
보았을 때는 어느 빈에 advice가
적용되어야 하는지 알수 없다.
그러므로
PointCut이
필요하다.(
AOP의
Advice에
지나지 않는다.
)
<aop:config>
<aop:advisor
pointcut=“execution(*
*..UpdateSale.*(..))”
advice-ref=“txAdvice”/>
</aop:config>
댓글 없음:
댓글 쓰기