AspectJ注解各类型通知

<?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" xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- bean definitions here -->


    <aop:aspectj-autoproxy/>


    <bean id="custmoer"  class="com.snow.demo8.CustomerDaoImpl"/>


    <bean  id="myAspectXml"  class="snow.imooc.demo8.MyAspectXml"/>

    <aop:config>

        <aop:pointcut id="pointcut1" expression="execution(* com.snow.demo8.CustomerDao.delete(..))"/>
        <aop:pointcut id="pointcut2" expression="execution(* com.snow.demo8.CustomerDao.delete(..))"/>
        <aop:aspect  ref="myAspectXml">

            <aop:before method="before"  pointcut-ref="pointcut1"/>

            <aop:after-returning method="after"  pointcut-ref="pointcut2"  returning="result"/>

            <aop:around method="around"  pointcut-ref="pointcut2"/>
            <aop:after-throwing method="afterThrowing"  pointcut-ref="pointcut2"/>

            <aop:after method="afterFinal"  pointcut-ref="pointcut2"/>

        </aop:aspect>

    </aop:config>

</beans>
发布了303 篇原创文章 · 获赞 179 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/qq_27248989/article/details/103992405