KK

          Kim-'s-Blog.Object-Everything.I'm POJO.

          .紀-錄.爲了忘卻的記憶..真的勇士,要敢于直面遇到的問題,敢于正視繁雜的原碼......在實踐中積累!

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            74 Posts :: 1 Stories :: 70 Comments :: 0 Trackbacks

          在使用Spring Aop的時候,有時會攔截不到希望攔截的方法...

          有時2.0可以但2.5卻不可以~

          Spring Aop 代理 有兩種:Java動態代理和Cglib代理

          一般我用的是Cglib代理..<aop:config proxy-target-class="true">

           

          只要在被spring攔截的方法中再調用其他被代理的對象的方法就可以實現嵌套攔截,

          如果調用自己對象的方法(包括繼承的),

          只是普通對象的方法調用(這時自己是被剝去了代理的殼的原始對象),

          是不能被攔截的。

           

          Debug下,看一下是不是proxy的類,被proxy的才有可能被攔截..

           

          另外: 使用groovy時,不能對注入groovy Bean的java類進行AOP.(接口編程)

          會報以下錯誤:

          org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messenger': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class $Proxy74]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Cannot subclass final class class $Proxy74

           

          <lang:groovy id="messenger" refresh-check-delay="5000" script-source="classpath:groovy/Messenger.groovy">
                  <lang:property name="message" value="I Can Do The Frug" />
          </lang:groovy>


          <bean id="testPageAction" class="cn.edu.hust.mes.test.TestPageAction">
            <dwr:remote javascript="test"></dwr:remote>
            <property name="messenger" ref="messenger"></property>
          </bean>

          posted on 2009-04-12 15:25 Kim' 閱讀(1987) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          jj
          主站蜘蛛池模板: 遂川县| 云林县| 渝北区| 河南省| 蒙山县| 墨脱县| 岳普湖县| 嵊州市| 鄂尔多斯市| 全南县| 林口县| 沂源县| 怀仁县| 汉川市| 灵丘县| 凤凰县| 陈巴尔虎旗| 嵩明县| 汤原县| 民丰县| 芮城县| 惠州市| 疏勒县| 方正县| 浦北县| 申扎县| 信宜市| 泗阳县| 盱眙县| 东方市| 茶陵县| 丰城市| 万安县| 洮南市| 闽侯县| 济阳县| 金秀| 民丰县| 丹江口市| 天镇县| 天全县|