spring中的aspectJ表达式 详解
来源:互联网 发布:python 登入h3c交换机 编辑:程序博客网 时间:2024/06/06 00:26
Spring AOP supports the following AspectJ pointcut designators (PCD) for use in pointcut expressions:
表 达 式
说明
execution
匹配方法执行连接点。我们可以指定包、类或者方法名,以及方法的可见性、返回值和参数类型。这是应用的最为广泛的切入点表达式。例如,execution(* com.apress..TestBean.*(..)表示执行com.apress包中TestBean中的所有方法,无论是何种参数或返回类型
within
匹配那些在已声明的类型中执行的连接点。例如,within(com.apress..TestBean)匹配从TestBean的方法中产生的调用
this
通过用bean引用(即AOP代理)的类型跟指定的类型作比较来匹配连接点。例如,this(SimpleBean)将只会匹配在SimpleBean类型的bean上的调用
target
通过用被调用的bean的类型和指定的类型作比较来匹配连接点。比如target(SimpleBean)将只会匹配在SimpleBean类型bean上方法的调用
args
通过比较方法的参数类型跟指定的参数类型来匹配连接点。例如,args(String, String)将只会匹配那些有两个String类型参数的方法
@target
通过检查调用的目标对象是否具有特定注解来匹配连接点。例如,@target(Magic)将会匹配带有@Magic注解的类中的方法调用
@args
跟args相似,不过@args检查的是方法参数的注解而不是它们的类型。例如,@args(NotNull)会匹配所有那些包含一个被标注了@NotNull注解的参数的方法
@within
跟within相似,这个表达式匹配那些带有特定注解的类中执行的连接点。例如,表达式@within(Magic)将会匹配对带有@Magic注解的类型的bean上方法的调用
@annotation
通过检查将被调用的方法上的注解是否为指定的注解来匹配连接点。例如,@annotation(Magic)将会匹配所有标有@Magic注解的方法调用
bean
通过比较bean的ID(或名称)来匹配连接点。我们也可以在bean名模式中使用通配符。例如,bean("simple")将会匹配ID或名称为simple的bean中的连接点
Other pointcut types
The full AspectJ pointcut language supports additional pointcut designators that are not supported in Spring. These are: call, get, set, preinitialization, staticinitialization, initialization, handler, adviceexecution, withincode, cflow, cflowbelow, if, @this, and @withincode. Use of these pointcut designators in pointcut expressions interpreted by Spring AOP will result in an IllegalArgumentException being thrown.
The set of pointcut designators supported by Spring AOP may be extended in future releases to support more of the AspectJ pointcut designators.
* 匹配任意字符,只能匹配一个元素
.. 匹配任意字符 匹配多个元素,在类的路径中匹配任意数量的子包,表示类时要和*联合使用, 在方法中匹配任意数量的参数
+ 匹配任意类型的子类型,作为后缀用在类后
execution() 和 within() 支持所有通配符
args() this() target()只支持+
@args() @within() @target @annotation不支持通配符
可以使用 '&&', '||' and '!' 在xml中&&需要转义,可以用and代替
java.lang.String 匹配String类型
execution(modifiers-pattern? ret-type-pattern declaring-type-pattern? name-pattern(param-pattern) throws-pattern?)
未完待续
- spring中的aspectJ表达式 详解
- spring中的aspectJ表达式 详解
- spring AspectJ中的Execution表达式详解
- spring中的aspectJ表达式
- Spring AOP详解& AspectJ表达式
- spring AspectJ的Execution表达式
- spring--AspectJ的Execution表达式
- spring AspectJ的Execution表达式
- spring AspectJ的Execution表达式
- spring AspectJ的Execution表达式
- spring AspectJ的Execution表达式
- spring AspectJ的Execution表达式
- spring AspectJ的Execution表达式
- spring AspectJ的Execution表达式
- spring AspectJ的Execution表达式
- spring AspectJ的Execution表达式
- spring AspectJ的Execution表达式
- Spring AspectJ切入点语法详解
- SSL证书与Https应用部署小结
- ExpandableListAdapter
- Github for Windows使用图文教程
- Java WebService 客户端写法
- 内核 BUG_ON 以及WARN_ON 用法作用
- spring中的aspectJ表达式 详解
- 页面自动跳转
- DB2 case when
- apache thrift的不足
- redis 持久化
- linkbutton用法咯
- 容器初级入门
- 每日一Lua(3)-函数
- C#导出Excel后关闭进程(EXCEL.EXE)释放资源的解决方案