在方面读取注释属性 [英] Reading annotation property in aspect
本文介绍了在方面读取注释属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在aspect中读取注解属性值?
How to read annotation property value in aspect?
我希望对所有用 @Transactional(readonly=false) 注释的关节点执行我的Around 建议强>.
I want my Around advice to be executed for all joint points annotated with @Transactional(readonly=false).
@Around("execution(* com.mycompany.services.*.*(..)) "
+ "&& @annotation(org.springframework.transaction.annotation.Transactional)")
public Object myMethod(ProceedingJoinPoint pjp) throws Throwable {
}
推荐答案
可以不用手动处理签名,这样(argNames
用于在没有调试信息的情况下编译时保留参数名称):
You can do it without manual processing of signature, this way (argNames
is used to keep argument names when compiled without debug information):
@Around(
value = "execution(* com.mycompany.services.*.*(..)) && @annotation(tx)",
argNames = "tx")
public Object myMethod(ProceedingJoinPoint pjp, Transactional tx)
throws Throwable {
...
}
参见 7.2.4.6 建议参数
这篇关于在方面读取注释属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文