Spring的ProxyFactoryBean和BeanNameAutoProxyCreator的配置

<bean id="daoInterceptor" class="com.jask.spring.DiscountMethodInterceptor"></bean>

	<bean id="testService" class="org.springframework.aop.framework.ProxyFactoryBean">
		<property name="target">
			<ref local="chinese" />
		</property>
		<property name="interceptorNames">
			<list>
				<value>daoInterceptor</value>
			</list>
		</property>
	</bean>
	
	<bean name="beanNameAutoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">  
	    <property name="beanNames">
	        <value>target*,*Task,*service</value><!--包含所有带Service的Bean-->
	    </property>  
	    <property name="interceptorNames">  
	        <list> 
	            <value>daoInterceptor</value>
	        </list>  
	    </property>  
	</bean>


这个DiscountMethodInterceptor就是可以实现MethodInterceptor这个接口,来实现对方法的拦截

你可能感兴趣的:(Spring的ProxyFactoryBean和BeanNameAutoProxyCreator的配置)