我有一个@Before方法,它返回一些我希望在切入点中使用的标记。
@Pointcut("execution(getData())")
private void selectAll(){}
@Before("selectAll()")
public void beforeAdvice(ProceedingJoinPoint joinPoint) throws Throwable{
//Return the token
}
public void getData(){
//Is there a way I can use the token returned by before??
}
@After("selectAll()")
public void afterAdvice(ProceedingJoinPoint joinPoint) throws Throwable{
//destroy the token
}
有没有办法可以在getData()内部使用之前返回的标记?
答案 0 :(得分:1)
不,你不能,因为你想做的事情没有任何逻辑意义:
@Before
建议在执行目标方法之前运行。@After
或@Around
建议中的返回值,而后一种情况则是proceed()
的结果。@Before
建议有一个void
返回类型,即它不返回任何内容。那么你想用什么?如果您需要一些示例代码,请与我们联系。