<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
    主站蜘蛛池模板: 日韩av无码久久精品免费| 国产成人无码精品久久久久免费| 亚洲精品亚洲人成人网| 老司机福利在线免费观看| 性xxxx视频播放免费| 亚洲日韩精品无码专区加勒比| 亚洲AV无码XXX麻豆艾秋| 免费H网站在线观看的| 亚洲精品第一国产综合野| 野花高清在线电影观看免费视频 | 皇色在线免费视频| 亚洲五月午夜免费在线视频| 久久毛片免费看一区二区三区| 最近免费中文字幕大全高清大全1 最近免费中文字幕mv在线电影 | 91禁漫免费进入| 亚洲一区二区影院| 国产一卡二卡3卡四卡免费| 亚洲国产精品无码中文lv| 免费看一级做a爰片久久| 久久久久久久久久免免费精品| 成人爽A毛片免费看| 亚洲AV无码成人精品区日韩| 亚洲男女内射在线播放| a级毛片高清免费视频就| 亚洲色图.com| 四虎永久免费影院在线| 成在人线av无码免费高潮喷水| 午夜免费福利影院| 免费人成大片在线观看播放电影 | 无码国产精品一区二区免费I6| 国产精品亚洲美女久久久| 黄页免费在线观看| 亚洲午夜精品国产电影在线观看| a级日本高清免费看| 亚洲第一页在线播放| 国产一级做a爱免费视频| 无码日韩精品一区二区三区免费| 亚洲AV无码专区日韩| 久久精品免费电影| 亚洲乱色熟女一区二区三区蜜臀| 成年人免费的视频|