|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
java.lang.Objectorg.guiceex.jpa.transaction.TransactionPropagator
public abstract class TransactionPropagator
TransactionAttributeType
に応じたトランザクション処理を行います。
このクラスのインスタンスは、TransactionAttributeType
に応じた実装を
伴って作成され、TransactionInterceptor
でプロトタイプとして利用され、
都度作成された複製が実行されます。
Guiceex-0.9.1では、トランザクションはEntityManager
が持つトランザクション
のみ操作ます。このため、「トランザクションを開始する」の意味は、「EntityManager
インスタンスを
新規作成し、EntityTransaction.begin()
の呼び出しによって開始しする」
という事になります。
以下にTransactionAttributeType
毎の振る舞いを説明します。
TransactionAttributeType EntityManagerが作成済みで
トランザクションが開始済みEntityManagerが未作成か、
トランザクションが未開始NOT_SUPPORTED EntityManagerを新規作成する。
トランザクションは開始しない。EntityManager未作成の場合は作成する。
トランザクションは開始しない。SUPPORTS 既存のトランザクションを使用。 EntityManager未作成の場合は作成する。
トランザクションは開始しない。REQUIRED 既存のトランザクションを使用。 EntityManager未作成の場合は作成する。
トランザクションを開始する。REQUIRES_NEW EntityManagerを新規作成する。
トランザクションを開始する。EntityManagerを新規作成する。
トランザクションを開始する。MANDATORY 既存のトランザクションを使用。 NoTransactionExceptionをスローする。 NEVER TransactionActiveException
をスローする。EntityManagerが無い場合は新規作成する。
トランザクションは開始しない。
入れ子のクラスの概要 | |
---|---|
static interface |
TransactionPropagator.Process
トランザクション内で実行される処理を記述するクラスに実装するインターフェイスです。 |
フィールドの概要 | |
---|---|
protected PersistenceContext |
pc
|
コンストラクタの概要 | |
---|---|
TransactionPropagator(TransactionAttributeType type)
|
メソッドの概要 | |
---|---|
TransactionPropagator |
clone()
プロトタイプインスタンスより複製を作成するメソッドです。 |
protected abstract void |
closeProcess()
EntityManager.close() の呼び出しなどを実行します。 |
protected abstract void |
commitProcess()
TransactionPropagator.Process.execute(EntityManager) を呼び出し後に、トランザクションをコミットする際に呼ばれます |
protected void |
exceptionProcess(Throwable t)
例外発生時のコミット/ロールバック処理を行います。 |
static TransactionPropagator |
getTransactionPropagator(TransactionAttributeType type)
TransactionAttributeType に応じたTransactionPropagator インスタンスを取得します。 |
protected abstract void |
prepare()
TransactionPropagator.Process.execute(EntityManager) を呼び出す前の、トランザクション開始などの事前処理を行います。 |
Object |
propagate(TransactionPropagator.Process process)
トランザクション処理を行い、 Process#execute() を実行します。 |
protected abstract void |
rollbackProcess()
TransactionPropagator.Process.execute(EntityManager) を呼び出し後に、トランザクションをロールバックする際に呼ばれます |
void |
setPersistenceContext(PersistenceContext pc)
|
void |
setRollbackFor(Class<? extends Throwable>[] rollbackFor)
トランザクションをロールバックする例外タイプをセットします。 |
クラス java.lang.Object から継承されたメソッド |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
フィールドの詳細 |
---|
protected PersistenceContext pc
コンストラクタの詳細 |
---|
public TransactionPropagator(TransactionAttributeType type)
メソッドの詳細 |
---|
public void setPersistenceContext(PersistenceContext pc)
public static TransactionPropagator getTransactionPropagator(TransactionAttributeType type)
TransactionAttributeType
に応じたTransactionPropagator
インスタンスを取得します。
public Object propagate(TransactionPropagator.Process process) throws Throwable
Process#execute()
を実行します。
Throwable
public void setRollbackFor(Class<? extends Throwable>[] rollbackFor)
@
Transactional.rollbackFor()
属性で指定した例外タイプです。
public TransactionPropagator clone()
Object
内の clone
protected void exceptionProcess(Throwable t) throws Throwable
Throwable
protected abstract void prepare()
TransactionPropagator.Process.execute(EntityManager)
を呼び出す前の、トランザクション開始などの事前処理を行います。
protected abstract void commitProcess()
TransactionPropagator.Process.execute(EntityManager)
を呼び出し後に、トランザクションをコミットする際に呼ばれます
protected abstract void rollbackProcess()
TransactionPropagator.Process.execute(EntityManager)
を呼び出し後に、トランザクションをロールバックする際に呼ばれます
protected abstract void closeProcess()
EntityManager.close()
の呼び出しなどを実行します。
|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |