切面 aop方法拦截处理

来源:互联网 发布:mac上使用搜狗输入法 编辑:程序博客网 时间:2024/06/08 16:17
<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">

       被拦截的java类

    <bean id="customerService" class="com.CustomerService">

        <property name="name" value="LeiOOLei" />
        <property name="url" value="http://www.cnblogs.com/leiOOlei/" />
    </bean>
    
    <bean id="hijackAroundMethodBean" class="com.HijackAroundMethod" />
 

    <bean id="customerServiceProxy" class="org.springframework.aop.framework.ProxyFactoryBean">
 
        <property name="target" ref="customerService" />
 
        <property name="interceptorNames">
            <list>
                <value>customerAdvisor</value>
            </list>
        </property>
    </bean>
 
    <bean id="customerPointcut" class="org.springframework.aop.support.NameMatchMethodPointcut">
        <property name="mappedName" value="printName" />
    </bean>
 
    <bean id="customerAdvisor" class="org.springframework.aop.support.DefaultPointcutAdvisor">
        <property name="pointcut" ref="customerPointcut" />
        <property name="advice" ref="hijackAroundMethodBean" />
    </bean>
</bean
0 0
原创粉丝点击