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、知行效果图

  • 相关阅读:
    Maven下Flex国际化配置
    Adobe AIR and Flex
    jQuery: 刨根问底 attr and prop两个函数的区别
    HTML5[8]: 图文混排,图片与文字居中对齐
    HTML5[7]: 实现网页版的加载更多
    HTML5[6]:多行文本显示省略号
    HTML5[5]:在移动端禁用长按选中文本功能
    HTML5[4]:去除不必要的标签,完全使用css实现样式
    HTML5[3]:中文换行
    HTML5[2]:使用viewport控制手机浏览器布局
  • 原文地址:https://www.cnblogs.com/super-admin/p/6431386.html
Copyright © 2011-2022 走看看