【发布时间】:2016-09-23 06:05:53
【问题描述】:
我正在为我的 Controller、Service 和 Dao 层进行审计。我分别为 Controller、Service 和 Dao 提供了三个环绕方面的功能。我使用了一个自定义注解,如果出现在 Controller 方法上,它将调用一个 Around 方面函数。在注释中,我设置了一个属性,我希望将其从 Controller Around 函数传递给 Aspect 类中的 Service around 函数。
public @interface Audit{
String getType();
}
我将从接口设置此 getType 的值。
@Around("execution(* com.abc.controller..*.*(..)) && @annotation(audit)")
public Object controllerAround(ProceedingJoinPoint pjp, Audit audit){
//read value from getType property of Audit annotation and pass it to service around function
}
@Around("execution(* com.abc.service..*.*(..))")
public Object serviceAround(ProceedingJoinPoint pjp){
// receive the getType property from Audit annotation and execute business logic
}
如何在两个 Around 函数之间传递对象?
【问题讨论】:
标签: spring-mvc annotations aspectj spring-aop auditing