论坛首页 综合技术论坛

Spring ProxyFactoryBean 的属性 interceptorNames 的属性值

浏览 3563 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2010-02-07   最后修改:2010-02-07
ProxyFactoryBean 代理工厂的属性 interceptorNames的值的范围 例子如下:

<bean id="roleService"
		class="org.springframework.aop.framework.ProxyFactoryBean">
		<property name="proxyInterfaces"
			value="com.future.egov.zhengxeq.zyxt.business.service.orm.RoleService" />
		<property name="target">
			<bean
				class="com.future.egov.zhengxeq.zyxt.business.service.orm.OrmServiceImpl" />
		</property>
		<property name="interceptorNames">
			<list>
				<value>decorateBeforeAdvice</value>
				<value>transactionAdvisor</value>
				<value>roleDecorateInterceptor</value>
			</list>
		</property>
	</bean>


interceptorNames 属性的list集合里面只能放 通知/通知者 。
通知/通知者被称为拦截者(拦截器)。
spring in action 翻译的书里面说集合成员是拦截者/通知者 这是错误的。概念不清晰,希望大家注意一下。


以下是源码里面的解释如下:
/**
	 * Set the list of Advice/Advisor bean names. This must always be set
	 * to use this factory bean in a bean factory.
	 * <p>The referenced beans should be of type Interceptor, Advisor or Advice
	 * The last entry in the list can be the name of any bean in the factory.
	 * If it's neither an Advice nor an Advisor, a new SingletonTargetSource
	 * is added to wrap it. Such a target bean cannot be used if the "target"
	 * or "targetSource" or "targetName" property is set, in which case the
	 * "interceptorNames" array must contain only Advice/Advisor bean names.
	 * @see org.aopalliance.intercept.MethodInterceptor
	 * @see org.springframework.aop.Advisor
	 * @see org.aopalliance.aop.Advice
	 * @see org.springframework.aop.target.SingletonTargetSource
	 */
	public void setInterceptorNames(String[] interceptorNames) {
		this.interceptorNames = interceptorNames;
	}
论坛首页 综合技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics