org.seasar.groovy
クラス ClosureAroundAdvice
java.lang.Object
org.seasar.groovy.ClosureAroundAdvice
- すべての実装インタフェース:
- org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor
- public class ClosureAroundAdvice
- extends java.lang.Object
- implements org.aopalliance.intercept.MethodInterceptor
Groovyのクロージャを呼びだすMethodInterceptor。
MethodInvocationはClosureAroundAdviceのコンストラクターに渡されたClosureへと
引数としてそのまま渡される。
Closureの戻り値はそのままMethodInterceptorの戻り値として扱われるので、
なんらかの値を返さなくてはならない場合は、Closure内で値を返すこと。
サンプル:
closure = {invocation|
invocation.getArgs()[1][0] // => 1
invocation.getArgs()[1][1] // => 2
result = invocation.proceed() // => 3
return result + 1 // => 4
}
pointcut = new PointcutImpl(Calc)
aspect = new AspectImpl(new ClosureAroundAdvice(closure), pointcut);
proxy = new AopProxy(Calc, new Aspect[]{ aspect })
calc = proxy.create()
println calc.plus(1, 2)
- 導入されたバージョン:
- 0.2
- 作成者:
- takai
メソッドの概要 |
java.lang.Object |
invoke(org.aopalliance.intercept.MethodInvocation invocation)
|
クラス java.lang.Object から継承したメソッド |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ClosureAroundAdvice
public ClosureAroundAdvice(groovy.lang.Closure closure)
- コンストラクター。
コンストラクターに渡されたクロージャがJoinPointを処理する。
- パラメータ:
closure
- JoinPointが渡されるクロージャ。
invoke
public java.lang.Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
throws java.lang.Throwable
- 定義:
- インタフェース
org.aopalliance.intercept.MethodInterceptor
内の invoke
- パラメータ:
invocation
- ジョインポイント。
- 戻り値:
- クロージャの戻り値。
- 例外:
java.lang.Throwable
Copyright © 2004 The Seasar Project. All Rights Reserved.