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