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' 閱讀(1990) 評論(0)  編輯  收藏

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


          網站導航:
           
          jj
          主站蜘蛛池模板: 故城县| 青海省| 京山县| 抚宁县| 曲阳县| 红河县| 漠河县| 苍山县| 晋宁县| 金湖县| 延津县| 芦溪县| 石泉县| 拉孜县| 同仁县| 青铜峡市| 肥东县| 呼和浩特市| 黄梅县| 宿松县| 凤山市| 青铜峡市| 宜都市| 泰兴市| 南华县| 东海县| 商南县| 宝山区| 布拖县| 河津市| 龙海市| 乌鲁木齐市| 都匀市| 富川| 杨浦区| 定南县| 衡南县| 新津县| 崇州市| 桂阳县| 大足县|