Spring 中的特殊advice-intruduction advice
- intruduction advice這里沒有MethodMatcher接口,因此也就沒有 Pointcut接口與引入通知相關聯。這里只進行類過濾。
- 與DefaultPointcutAdvisor不同,由于DefaultPointcutAdvisor有Pointcut,可以在class一級和method一級上進行控制。
- 一般使用DelegatingIntroductionInterceptor 作為攔截器,需要編寫攔截的類必須繼承DelegatingIntroductionInterceptor ,在這個繼承了DelegatingIntroductionInterceptor 的類中不再使用MethodInvocation的process()方法,使用super.invoke(methodinvocation),這樣做的原因是父類DelegatingIntroductionInterceptor 能夠決定什么class負責處理方法的調用
- advisor一般使用繼承了DefaultIntroductionAdvisor 的類,創建的簡單方法就是利用
DefaultIntroductionAdvisor(DynamicIntroductionAdvice advice, Class clazz)這個構造函數。
- 在appplicationcontext-config.xml中就只需要加入<bean id="" class=""></bean>就可以了,不需要進行其它配置
posted on 2007-09-07 09:46 劉錚 閱讀(242) 評論(0) 編輯 收藏 所屬分類: Spring