zoukankan      html  css  js  c++  java
  • zbb20170216_spring_aop

    1、总体结构图

    2、class文件

    MyLog.java
    package com.zbb.aop;
    
    import com.sun.xml.internal.bind.v2.schemagen.xmlschema.List;
    
    public class MyLog {
        public void printBefore() {
            
            System.out.println("printBefore");
        }
        public void printAfter() {
            System.out.println("printAfter");
        }
    }

    MyPoint.java

    package com.zbb.aop;
    
    public interface MyPoint {
        public void save();
    }

    MyPointImp.java

    package com.zbb.aop;
    
    public class MyPointImp implements MyPoint{
    
        public void save() {
            System.out.println("save");
        }
    
    
    }

    MyTest.java

    package com.zbb.aop;
    
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    public class MyTest {
        public static void main(String[] args) {
            ClassPathXmlApplicationContext bean = new ClassPathXmlApplicationContext("applicationContext.xml");
            MyPoint obj = (MyPoint)bean.getBean("ponit");
            obj.save();
            
        }
    }

    3、配置文件

    applicationContext.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"
        xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
    
        <bean id="myAop" class="com.zbb.aop.MyLog"></bean>
        
        <bean id="ponit" class="com.zbb.aop.MyPointImp"></bean>
        <aop:config>
            <aop:aspect id="myAspect" ref="myAop">
                <aop:pointcut id="businessService" expression="execution(* *.save(..))" />
                <aop:before pointcut-ref="businessService" method="printBefore" />
                <aop:after pointcut-ref="businessService" method="printAfter" />
            </aop:aspect>
        </aop:config>
    
    
    </beans>

    4、知行效果图

  • 相关阅读:
    C语言memmove()函数:复制内存内容(可以处理重叠的内存块)
    boot简介
    MT6753/MT6755 呼吸灯功能添加
    MT6753 使用nt35596s 由于液晶极化出现的闪屏问题解决思路
    MTK平台释疑android M 配置中断相关问题
    MT6755 平台手机皮套驱动实现
    MTK平台 GPU 相关知识
    MTK平台如何定位显示花屏和界面错乱等绘制异常的问题?
    【Python】注释
    【Linux】.gz文件 压缩与解压缩命令
  • 原文地址:https://www.cnblogs.com/super-admin/p/6431386.html
Copyright © 2011-2022 走看看