kr.co.hit.live.transaction
Class TransactionManager

java.lang.Object
  extended by kr.co.hit.live.transaction.TransactionManager
All Implemented Interfaces:
TransactionManager

public class TransactionManager
extends Object
implements TransactionManager

JTA Spec.을 준수하는 TransactionManager 구현 클래스

Since:
3.0
Author:
김형도

Constructor Summary
TransactionManager(String id, long timeout)
          생성자이다.
 
Method Summary
 void begin()
          새로운 Transaction을 시작하고 이것을 현재 Thread에 연계시킨다.
 void commit()
          현재 Thread에서 진행 중인 트랜잭션을 정상적으로 종료한다.
 int getStatus()
          현재 Thread에서 진행 중인 트랜잭션의 상태 값을 반환한다.
 String getTmId()
          트랜젝션 관리자의 고유 ID를 리턴한다.
 Transaction getTransaction()
          현재 Thread에서 진행 중인 트랜젝션 객체를 반환한다.
 long getTransactionTimeout()
          트랜잭션 메니저에 설정된 트랜잭션 타임아웃 설정값이다.
 void resume(Transaction t)
          파라메터로 전달된 트랜잭션 객체를 사용하여 현재 Thread가 트랜젝션을 진행한다.
 void rollback()
          현재 Thread에서 진행 중인 트랜잭션을 롤백한다.
 void setRollbackOnly()
          현재 Thread에서 진행 중인 트랜잭션를 롤백만 가능한 상태로 지정한다.
 void setTransactionTimeout(int sec)
          트랜젝션의 timeout 값을 지정한다.
 Transaction suspend()
          현재 Thread에서 진행 중인 트랜잭션을 일시적으로 중지하고 해당 트랜젝션 객체를 반환한다.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionManager

public TransactionManager(String id,
                          long timeout)
생성자이다.

Parameters:
id - 트랜젝션 관리자 ID, 고유한 값을 주어야 한다.
Method Detail

getTmId

public String getTmId()
트랜젝션 관리자의 고유 ID를 리턴한다.


begin

public void begin()
           throws NotSupportedException
새로운 Transaction을 시작하고 이것을 현재 Thread에 연계시킨다.

Specified by:
begin in interface TransactionManager
Throws:
NotSupportedException - 쓰레드가 이미 다른 트랜잭션을 시작하였으며 구현된 트랜잭션 메니저가 중복된 트랜젝션을 지원하지 않으므로 발생한다.

commit

public void commit()
            throws RollbackException,
                   HeuristicMixedException,
                   HeuristicRollbackException,
                   SystemException,
                   IllegalStateException
현재 Thread에서 진행 중인 트랜잭션을 정상적으로 종료한다. 이 메소드가 종료되면 현 Thread는 트랜젝션에 연계되지 않는다.

Specified by:
commit in interface TransactionManager
Throws:
IllegalStateException - 현 쓰레드에 진행 중인 트랜젝션이 존재하지 않는다.
RollbackException
HeuristicMixedException
HeuristicRollbackException
SystemException

rollback

public void rollback()
              throws IllegalStateException,
                     SystemException
현재 Thread에서 진행 중인 트랜잭션을 롤백한다. 이 메소드가 종료되면 현 Thread는 트랜젝션에 연계되지 않는다.

Specified by:
rollback in interface TransactionManager
Throws:
IllegalStateException - 현 쓰레드에 진행 중인 트랜젝션이 존재하지 않는다.
SystemException

suspend

public Transaction suspend()
현재 Thread에서 진행 중인 트랜잭션을 일시적으로 중지하고 해당 트랜젝션 객체를 반환한다. 이 메소드가 실행되고 나면 현 Thread는 트랜젝션에 연계되지 않는다. 현재 Thread에 진행 중인 트랜잭션이 없는 경우에는 null 이 리턴된다.

Specified by:
suspend in interface TransactionManager

resume

public void resume(Transaction t)
            throws InvalidTransactionException,
                   IllegalStateException
파라메터로 전달된 트랜잭션 객체를 사용하여 현재 Thread가 트랜젝션을 진행한다.

Specified by:
resume in interface TransactionManager
Throws:
IllegalStateException - 이미 진행 중인 트랜젝션이 존재한다.
InvalidTransactionException - 전달된 트랜잭션 객체가 잘못되었다.

getStatus

public int getStatus()
현재 Thread에서 진행 중인 트랜잭션의 상태 값을 반환한다.

Specified by:
getStatus in interface TransactionManager

setRollbackOnly

public void setRollbackOnly()
                     throws IllegalStateException
현재 Thread에서 진행 중인 트랜잭션를 롤백만 가능한 상태로 지정한다.

Specified by:
setRollbackOnly in interface TransactionManager
Throws:
IllegalStateException - 현 쓰레드에 진행 중인 트랜젝션이 존재하지 않는다.

getTransaction

public Transaction getTransaction()
현재 Thread에서 진행 중인 트랜젝션 객체를 반환한다. 진행 중인 트랜젝션이 없을 경우에는 null을 반환한다.

Specified by:
getTransaction in interface TransactionManager
Returns:
현재 Thread에서 진행 중인 트랜젝션을 표현하는 Transaction 객체를 반환한다.

setTransactionTimeout

public void setTransactionTimeout(int sec)
트랜젝션의 timeout 값을 지정한다.

Specified by:
setTransactionTimeout in interface TransactionManager

getTransactionTimeout

public long getTransactionTimeout()
트랜잭션 메니저에 설정된 트랜잭션 타임아웃 설정값이다.

Returns:
long 트랜잭션 타임아웃(msec)


Copyright © 2014. All Rights Reserved.