有關spring中的factorybean的深刻理解

          Interface to be implemented by objects used within a BeanFactory that are themselves factories. If a bean implements this interface, it is used as a factory, not directly as a bean.

          NB: A bean that implements this interface cannot be used as a normal bean. A FactoryBean is defined in a bean style, but the object exposed for bean references is always the object that it creates.

          FactoryBeans can support singletons and prototypes, and can either create objects lazily on demand or eagerly on startup.

          This interface is heavily used within the framework, for example for the AOP ProxyFactoryBean or JndiObjectFactoryBean. It can be used for application components, but this is not common outside of infrastructure code.


          可以自己創建FactoryBean,這個時候的類就要當做工廠類來使用。在spring的配置文件中<ref local="factoryBean"/>調用的是getObject()方法,返回是object對象。


          posted on 2007-12-25 15:01 劉錚 閱讀(327) 評論(0)  編輯  收藏 所屬分類: Spring

          <2025年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          導航

          統計

          留言簿(1)

          文章分類(141)

          文章檔案(147)

          搜索

          最新評論

          主站蜘蛛池模板: 安康市| 乌拉特前旗| 通城县| 来凤县| 浦东新区| 儋州市| 资兴市| 望谟县| 大渡口区| 武冈市| 泗水县| 沧州市| 开鲁县| 泸定县| 平陆县| 民勤县| 福建省| 左云县| 蓬安县| 洮南市| 益阳市| 工布江达县| 黔西县| 保亭| 冀州市| 饶平县| 南丹县| 澜沧| 武川县| 马鞍山市| 隆安县| 兴义市| 达孜县| 墨脱县| 大邑县| 南部县| 郑州市| 白山市| 仁布县| 乐清市| 如皋市|