|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
public interface RequiresNewController
REQUIRES_NEW の属性をもつトランザクションを制御するコントローラです。
REQUIRES_NEW の属性をもつトランザクションの最適な制御方法は、環境ごとに異なります。たとえば、Seasar2.4を利用している場合、 次のような実装がふさわしいでしょう。
import org.seasar.doma.jdbc.RequiresNewController;
import org.seasar.extension.tx.TransactionCallback;
import org.seasar.extension.tx.TransactionManagerAdapter;
import org.seasar.framework.container.SingletonS2Container;
public class S2RequiresNewController implements RequiresNewController {
@SuppressWarnings("unchecked")
@Override
public <R> R requiresNew(final Callback<R> callback) throws Throwable {
TransactionManagerAdapter txAdapter = SingletonS2Container
.getComponent(TransactionManagerAdapter.class);
Object result = txAdapter.requiresNew(new TransactionCallback() {
public Object execute(final TransactionManagerAdapter adapter)
throws Throwable {
return callback.execute();
}
});
return (R) result;
}
}
このインタフェースの実装はスレッドセーフでなければいけません。
| 入れ子のクラスの概要 | |
|---|---|
static interface |
RequiresNewController.Callback<R>
REQUIRES_NEW のトランザクション属性下で実行される処理です。 |
| メソッドの概要 | ||
|---|---|---|
|
requiresNew(RequiresNewController.Callback<R> callback)
REQUIRES_NEW の属性をもつトランザクションを実行します。 |
|
| メソッドの詳細 |
|---|
<R> R requiresNew(RequiresNewController.Callback<R> callback)
throws Throwable
R - 戻り値の型callback - REQUIRES_NEW のトランザクション属性下で扱いたい処理
DomaNullPointerException - {@code callback} が null の場合
Throwable - {@code callback} の処理中に何らかの例外が発生した場合
|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||