您的位置:首页 > 编程语言 > ASP

aspect advice pointcut:xml 方式

2013-02-28 21:09 225 查看
public class testAop {
public void method(){}

public void around(ProceedingJoinPoint p) throws Throwable {
System.out.println("around begin");
p.proceed();
System.out.println("around over");
}
public void begin(){
System.out.println("before");
}
public void after(){
System.out.println("after");
}

}


 

<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd ">
<context:component-scan base-package="com.sl"></context:component-scan>
<bean class="com.sl.aop.testAop" id="aop"></bean>
<aop:config>
<aop:aspect ref="aop">
<aop:pointcut expression="execution(* com.sl.service.*.*(..))" id="cut"/>
<aop:after method="after" pointcut-ref="cut"/>
<aop:before method="begin" pointcut-ref="cut"/>
<aop:around method="around" pointcut="execution(* com.sl.service.*.*(..))"/>
</aop:aspect>
</aop:config>

</beans>


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐