[cubby-user:181] Action#initialize への Interceptor 適用

Jun Futagawa [E-MAIL ADDRESS DELETED]
2009年 10月 10日 (土) 19:56:58 JST


ふたがわです。

Cubby 2.0.x から initialize は ActionContextImpl が直接実行しているので、
cubby-s2 の ActionMethodCustomizer を使うと、アクションメソッド実行時に
Interceptor が実行される前に initialize が実行されてしまいます。

そのため、cubby-showcase にあるような authActionInterceptor は、
その Interceptor が実行される前に initialize が実行されるので、
未ログイン状態で処理が実行されて困るケースがありました。

Cubby 1.1.x の時は initialize は initializeCustomizer から実行されていたので
Interceptor の適用順で実行順が制御出来ていたので問題になっていませんでした。

他にも、アクションメソッド実行前後のinitialize、prerender、postrender には
j2ee.requiredTx が掛からないので、あまりないと思いますが更新処理があって
ロールバックが必要な時にできなくて困ることがあるかなと思いました。

とりあえずの対応として、ActionMethodPointcutImpl#isApplied で
invokeInitializeMethod を Interceptor 適用対象にしてみましたが
これだと1つのアクションメソッド実行時に Interceptor が2回実行されてしまい、
微妙な気がしています。

@Override
public boolean isApplied(final Method targetMethod) {
	if (targetMethod.getName().equals("invokeInitializeMethod")) {
		return true;
	}
	if (!ActionUtils.isActionMethod(targetMethod)) {
		return false;
	}
	return super.isApplied(targetMethod);
}

何か良い案あれば教えてください。

よろしくお願いします。

-- 
Jun Futagawa


cubby-user メーリングリストの案内