<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    gembin

    OSGi, Eclipse Equinox, ECF, Virgo, Gemini, Apache Felix, Karaf, Aires, Camel, Eclipse RCP

    HBase, Hadoop, ZooKeeper, Cassandra

    Flex4, AS3, Swiz framework, GraniteDS, BlazeDS etc.

    There is nothing that software can't fix. Unfortunately, there is also nothing that software can't completely fuck up. That gap is called talent.

    About Me

     

    Spring AOP: JDK Dynamic Proxy vs. CGLib proxy

    Spring's AOP is proxy-based. Spring provides two different options to create the proxies. One is based on JDK dynamic proxies and works with interfaces, the other one utilizes CGLib and is based on classes. (That's why the property is called proxyTargetClass respectively proxy-target-class.) For the moment I just want to provide a quick summary on the pros and cons of both options:

    JDK dynamic proxies:

    • The class has to implement interfaces. Otherwise you will get ClassCastExceptions saying that $Proxy0 can not be casted to the particular class.

    • Eventually dynamic proxies force you to program to interfaces since you can not cast the proxy to the class - a feature I really like about them.


    CGLib proxies:

    • The proxies are created by sub-classing the actual class. This means wherever an instance of the class is used it is also possible to use the CGLib proxy.

    • The class needs to provide a default constructor, i.e. without any arguments. Otherwise you'll get an IllegalArgumentException: "Superclass has no null constructors but no arguments were given." This makes constructor injection impossible.

    • The proxying does not work with final methods since the proxy sub class can not override the class' implementation.

    • The CGLib proxy is final, so proxying a proxy does not work. You will get an IllegalArgumentException saying "Cannot subclass final class $Proxy0". But this feature is usually not needed anyway. 

    • Since two objects are created (the instance of the class and the proxy as instance of a sub class) the constructor is called twice. In general this should not matter. I consider changing the class' state based on constructor calls a code smell anyway.

    • You have CGLib as additional dependency.

      ref:  http://static.springsource.org/spring/docs/3.1.1.RELEASE/spring-framework-reference/htmlsingle/spring-framework-reference.html#aop-introduction-proxies 


    posted on 2012-05-03 13:16 gembin 閱讀(1343) 評論(0)  編輯  收藏 所屬分類: Spring


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


    網站導航:
     

    導航

    統計

    常用鏈接

    留言簿(6)

    隨筆分類(440)

    隨筆檔案(378)

    文章檔案(6)

    新聞檔案(1)

    相冊

    收藏夾(9)

    Adobe

    Android

    AS3

    Blog-Links

    Build

    Design Pattern

    Eclipse

    Favorite Links

    Flickr

    Game Dev

    HBase

    Identity Management

    IT resources

    JEE

    Language

    OpenID

    OSGi

    SOA

    Version Control

    最新隨筆

    搜索

    積分與排名

    最新評論

    閱讀排行榜

    評論排行榜

    free counters
    主站蜘蛛池模板: 精品国产sm捆绑最大网免费站| 国产zzjjzzjj视频全免费| 最近2019中文字幕免费大全5 | 亚洲精品成人区在线观看| 亚洲欧洲自拍拍偷午夜色无码| 亚洲一区精品视频在线| 成人一级免费视频| 国产va免费精品观看精品| 亚洲一区AV无码少妇电影☆| 日韩精品无码免费视频| 免费看韩国黄a片在线观看| 亚洲午夜福利在线观看| 国产免费人成视频在线播放播| 性感美女视频在线观看免费精品| 亚洲av之男人的天堂网站| 国产亚洲情侣久久精品| 手机在线看永久av片免费| 亚洲人AV在线无码影院观看| 一个人免费日韩不卡视频| 亚洲人成网站在线观看青青| 在线综合亚洲中文精品| 99re热精品视频国产免费| 亚洲精品二区国产综合野狼| 狼色精品人妻在线视频免费| 大学生一级特黄的免费大片视频| 亚洲国产无线乱码在线观看 | 亚洲免费视频观看| 91av免费观看| 中国亚洲呦女专区| 999国内精品永久免费观看| 午夜亚洲www湿好大| 成年免费a级毛片免费看无码| 亚洲av无码不卡私人影院| 亚洲成AV人片高潮喷水| 亚洲精品视频在线看| 午夜爽爽爽男女免费观看影院| 亚洲一区欧洲一区| 亚洲中文字幕久久精品无码APP | 99精品视频在线免费观看| 亚洲中文无码永久免费| 无限动漫网在线观看免费|