@Pointcut("execution(* package.method(..))")
public void onComplete() {
}
鉴于上述情况,我试图通过以下方式声明@AfterReturning
建议:
//Sample 1
@AfterReturning(value="onComplete()",
returning="returnValue")
public void callOnCompletion(Object returnValue){
// aditional code here ..
}
//Sample 2
@AfterReturning(pointcut="onComplete()",
returning="returnValue")
public void callOnCompletion(Object returnValue){
// aditional code here ..
}
//Sample 1 with JoinPoint
@AfterReturning(value="onComplete()",
returning="returnValue")
public void callOnCompletion(JoinPoint jp, Object returnValue){
// aditional code here ..
}
//Sample 2 with JoinPoint
@AfterReturning(pointcut="onComplete()",
returning="returnValue")
public void callOnCompletion(JoinPoint jp, Object returnValue){
// aditional code here ..
}
我的怀疑如下:
value
的{{1}}和pointcut
属性之间的区别是什么?@AfterReturning
和value
)是默认的? pointcut
参数传递给建议并何时不通过?有规则或情况吗?我见过用JoinPoint
定义的例子。但是当我尝试将JoinPoint
传递给JoinPoint
方法时,初始化时出现callOnCompletion(..)
错误。 formal unbound in pointcut ...
返回类型需要参数returnValue
吗?void
是否必需?