Discuss / 编程 / ExceptionAdvisor的XML配置如下

ExceptionAdvisor的XML配置如下

Topic source
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
 "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    <bean id="serviceTarget" class="com.crackj2ee.example.spring.MyServiceBean" />

    <bean id="logAdvisor" class="com.crackj2ee.example.spring.LogAdvisor" />

    <bean id="passwordAdvisorTarget" class="com.crackj2ee.example.spring.PasswordAdvisor" />

    <bean id="exceptionAdvior" class="com.crackj2ee.example.spring.ExceptionAdvisor"/>

    <bean id="passwordAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
        <property name="advice">
            <ref local="passwordAdvisorTarget"/>
        </property>
        <property name="patterns">
            <list>
                <value>.*getPassword</value>
            </list>
        </property>
    </bean>

    <bean id="service" class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="proxyInterfaces"><value>com.crackj2ee.example.spring.ServiceBean</value></property>
        <property name="target"><ref local="serviceTarget"/></property>
        <property name="interceptorNames">
            <list>
                <value>logAdvisor</value>
                <value>passwordAdvisor</value>
                <value>exceptionAdvior</value>
            </list>
        </property>
    </bean>

</beans>


  • 1

Reply