zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    3.约束及修改数据表
    RSA总结
    消息队列面试官爱问的问题(一)
    Maven模块化开发
    系统初始化脚本和检查初始化结果脚本(centos7)
    kubectl 命令自动补全
    Kubernetes1.13.1部署Kuberneted-dashboard v1.10.1
    python实现连接MySQL、Redis并获取数据
    shell 脚本实现退点输出
    理论经典:TCP协议的3次握手与4次挥手过程详解
  • 原文地址:https://www.cnblogs.com/diaoniwa/p/6505440.html
Copyright © 2011-2022 走看看