标签:framework rac tst finally exp spec 声明 obj round
声明通知Advice
<aop:config>
<aop:aspect id="ikAspectAop" ref="ikAspect">
<aop:pointcut id="ikPoint" expression="execution(* com.jing.spring.aop.IKAspectBiz.*(..))"></aop:pointcut>
<aop:before method="aspectBefore" pointcut-ref="ikPoint"></aop:before>
</aop:aspect>
</aop:config>
<aop:config>
        <aop:aspect id="ikAspectAop" ref="ikAspect">
                <aop:before method="aspectBefore" pointcut="execution(* com.jing.spring.aop.IKAspectBiz.*(..))"></aop:before>
        </aop:aspect>
</aop:config>
 <aop:config>
     <aop:aspect id="ikAspectAop" ref="ikAspect">
          <aop:pointcut id="ikPoint" expression="execution(* com.jing.spring.aop.IKAspectBiz.*(..))"></aop:pointcut>
          <aop:before method="aspectBefore" pointcut-ref="ikPoint"></aop:before>
     </aop:aspect>
 </aop:config>
 <aop:config>
      <aop:aspect id="ikAspectAop" ref="ikAspect">
           <aop:before method="aspectBefore" pointcut="execution(* com.jing.spring.aop.IKAspectBiz.*(..))"></aop:before>
      </aop:aspect>
 </aop:config>
<aop:config>
     <aop:aspect id="ikAspectAop" ref="ikAspect">
          <aop:pointcut id="ikPoint" expression="execution(* com.jing.spring.aop.IKAspectBiz.*(..))"></aop:pointcut>
          <aop:after-returning method="aspectBefore" pointcut-ref="ikPoint"></aop:before>
     </aop:aspect>
 </aop:config>
<aop:config>
     <aop:aspect id="ikAspectAop" ref="ikAspect">
          <aop:after-returning method="aspectBefore" pointcut="execution(* com.jing.spring.aop.IKAspectBiz.*(..))"></aop:before>
     </aop:aspect>
 </aop:config>
<aop:config>
     <aop:aspect id="ikAspectAop" ref="ikAspect">
          <aop:pointcut id="ikPoint" expression="execution(* com.jing.spring.aop.IKAspectBiz.*(..))"></aop:pointcut>
          <aop:after-throwing method="aspectBefore" pointcut-ref="ikPoint"></aop:before>
     </aop:aspect>
 </aop:config>
<aop:config>
     <aop:aspect id="ikAspectAop" ref="ikAspect">
          <aop:after-throwing method="aspectBefore" pointcut="execution(* com.jing.spring.aop.IKAspectBiz.*(..))"></aop:before>
     </aop:aspect>
 </aop:config>
<aop:config>
     <aop:aspect id="ikAspectAop" ref="ikAspect">
          <aop:pointcut id="ikPoint" expression="execution(* com.jing.spring.aop.IKAspectBiz.*(..))"></aop:pointcut>
          <aop:after method="aspectBefore" pointcut-ref="ikPoint"></aop:before>
     </aop:aspect>
 </aop:config>
<aop:config>
     <aop:aspect id="ikAspectAop" ref="ikAspect">
          <aop:after method="aspectBefore" pointcut="execution(* com.jing.spring.aop.IKAspectBiz.*(..))"></aop:before>
     </aop:aspect>
 </aop:config>
<?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: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.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd" >
        <bean id="ikAspect" class="com.jing.spring.aop.IKAspect"></bean>
        <bean id="ikAspectBiz" class="com.jing.spring.aop.IKAspectBiz"></bean>
        <aop:config>
            <aop:aspect id="ikAspectAop" ref="ikAspect">
                <aop:pointcut id="ikPoint" expression="execution(* com.jing.spring.aop.IKAspectBiz.*(..))"></aop:pointcut>
                <aop:around method="aspectAround" pointcut-ref="ikPoint"></aop:around>
            </aop:aspect>
        </aop:config>
</beans>
package com.jing.spring.aop; import org.aspectj.lang.ProceedingJoinPoint; public class IKAspect { public void aspectAround(ProceedingJoinPoint pj){ System.out.println("IKAspect.aspectAroud,its 环绕通知前"); try { Object proceed = pj.proceed(); } catch (Throwable throwable) { throwable.printStackTrace(); } System.out.println("IKAspect.aspectAroud,its 环绕通知后"); } }
<?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: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.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd" > <bean id="ikAspect" class="com.jing.spring.aop.IKAspect"></bean> <bean id="ikAspectBiz" class="com.jing.spring.aop.IKAspectBiz"></bean> <aop:config> <aop:aspect id="ikAspectAop" ref="ikAspect"> <aop:around method="aspectAround" pointcut="execution(* com.jing.spring.aop.IKAspectBiz.*(..))"></aop:around> </aop:aspect> </aop:config> </beans>
package com.jing.spring.aop; import org.aspectj.lang.ProceedingJoinPoint; public class IKAspect { public void aspectAround(ProceedingJoinPoint pj){ System.out.println("IKAspect.aspectAroud,its 环绕通知前"); try { Object proceed = pj.proceed(); } catch (Throwable throwable) { throwable.printStackTrace(); } System.out.println("IKAspect.aspectAroud,its 环绕通知后"); } }
Spring 学习——Spring AOP——AOP配置篇Advice(无参数传递)
标签:framework rac tst finally exp spec 声明 obj round
原文地址:https://www.cnblogs.com/jixue/p/10432032.html