标签:
execution用于匹配方法执行的连接点
举几个例子:
其他
基于注解的匹配
实现:
<aop:config> <aop:pointcut id="businessService" expression="execution(* com.aop.schema..(..))"> </aop:pointcut> </aop:config>
例子:
新建两个类
package com.aop.schema; /** * * 切面类 * */ public class MyAspect { }
package com.aop.schema; /** * * 业务类 * */ public class ApsectBiz { }
XML配置:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> <bean id="myAspect" class="com.aop.schema.MyAspect"></bean> <bean id="apsectBiz" class="com.aop.schema.ApsectBiz"></bean> <aop:config> <aop:aspect id="myAspectAOP" ref="myAspect"> <aop:pointcut id="myPointcut" expression="execution(* com.aop.schema.ApsectBiz.*(..))" /> </aop:aspect> </aop:config> </beans>
Spring学习(20)--- Schema-based AOP(基于配置的AOP实现) -- 配置切入点pointcut
标签:
原文地址:http://www.cnblogs.com/JsonShare/p/4633564.html