zoukankan      html  css  js  c++  java
  • 三种顾问,增强及Aspectj 的详解

    ///通知

    此处的是实现类作为方法的增强

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
    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 http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
    <!--添加AOP命名空间在AOP这个空间下-->

    <!--1.目标对象--><!--2.要匹配的通知-->
    <bean id="someservice" class="cn.spring09aop01.Someservice"></bean>
    <bean id="beforeAdvice" class="cn.spring09aop01.MyBeforeAdvice"></bean>

    <!--3经典 aop的 代理工厂bean-->
    <bean id="proxyService" class="org.springframework.aop.framework.ProxyFactoryBean">
    <!--配置需要增强的目标对象-->
    <property name="target" ref="someservice"></property>
    <!--拦截的名称类型是字符串类型的 value=“beforeAdvice” 做怎么样的增强-->
    <property name="interceptorNames" value="beforeAdvice"></property>
    </bean>


    </beans>

    <!--02.增强:顾问正则匹配切入点-->
    <bean id="beforeAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
    <property name="advice" ref="beforeAdvice"></property>
    <property name="pattern" value=".*d.*"></property>
    </bean>
    
    
    BeanName
    <!--aop-->
    <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">

    <property name="beanNames" value="someservice"></property>
    <property name="interceptorNames" value="beforeAdvice"></property>
    </bean>

    <!--02.增强:顾问正则匹配切入点-->
    <bean id="beforeAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
    <property name="advice" ref="beforeAdvice"></property>
    <property name="pattern" value=".*d.*"></property>
    </bean>
    在Xml中配置一个这个就是默认的自动代理自动代理生成器
    <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/>
    @Test
    public void ddaq() {
    //正则表达式匹配方法切入点
    ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext0.xml");
    ISomeService service = (ISomeService) ctx.getBean("proxyService");

    service.doSome();


    }
    这是我们昨天学习的,我也不知道怎么说。。。。
  • 相关阅读:
    Makefile编写
    C++静态库与动态库
    C语言编译过程详解
    Fiddler抓HTTPS
    web测试的一些关注点
    Appium使用过程中的一些坑
    Jmeter+Maven+Jenkins的搭建笔记
    华为DHCP+VLANDHCP RELAY配置重点
    华为GVRP配置重点
    802.11协议总结
  • 原文地址:https://www.cnblogs.com/hualishu/p/7268800.html
Copyright © 2011-2022 走看看