• Spring AOP自动代理创建者


    1. BeanNameAutoProxyCreator示例

    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
    
        <bean id="customerService" class=customer.services.CustomerService">
            <property name="name" value="" />
            <property name="url" value="www.baidu.com" />
        </bean>
    
        <bean id="hijackAroundMethodBeanAdvice" class="com.yiibai.aop.HijackAroundMethod" />
    
        <bean id="customerAdvisor"
            class="org.springframework.aop.support.NameMatchMethodYiibaicutAdvisor">
            <property name="mappedName" value="printName" />
            <property name="advice" ref="hijackAroundMethodBeanAdvice" />
        </bean>
      <!-- BeanNameAutoProoxyCreator -->
        <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
            <property name="beanNames">
                <list>
                    <value>*Service</value>
                </list>
            </property>
            <property name="interceptorNames">
                <list>
                    <value>customerAdvisor</value>
                </list>
            </property>
        </bean>
    </beans>

    2. DefaultAdvisorAutoProxyCreator示例

    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
    
        <bean id="customerService" class="customer.services.CustomerService">
            <property name="name" value="xiaoming" />
            <property name="url" value="www.baidu.com" />
        </bean>
    
        <bean id="hijackAroundMethodBeanAdvice" class="aop.HijackAroundMethod" />
    
        <bean id="customerAdvisor"
            class="org.springframework.aop.support.NameMatchMethodYiibaicutAdvisor">
            <property name="mappedName" value="printName" />
            <property name="advice" ref="hijackAroundMethodBeanAdvice" />
        </bean>
    
           <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" />
    
    </beans>
  • 相关阅读:
    Python基础04_str_方法
    Python基础03_pycharm
    Python基础02_基本数据类型_以及while
    Python基础01_介绍_HelloWorld
    Linux基础知识_Shell编程笔记
    python基础之centos6.5 升级 python2.7, 安装pip, MySQLdb
    不得不补:PHP的JSON, SQL
    JS类小功能
    1083.是否存在相等的差(20)
    c++ 的vector sort遇到栈错误
  • 原文地址:https://www.cnblogs.com/diaoniwa/p/6505440.html
Copyright © 2020-2023  润新知