首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

设计:Spring动态流入implementation 、业务处理过程抽象

2012-11-17 
设计:Spring动态注入implementation 、业务处理过程抽象场景:接口或抽象类,有多个实现/子类。使用Spring,直

设计:Spring动态注入implementation 、业务处理过程抽象

场景:
接口或抽象类,有多个实现/子类。使用Spring,直接注入接口/抽象类,怎么让spring可以在运行时动态注入具体的实现那?

参考:
How to use @Autowired to dynamically inject implementation like a factory pattern
http://stackoverflow.com/questions/5725222/how-to-use-autowired-to-dynamically-inject-implementation-like-a-factory-patter
How to get beans created by FactoryBean spring managed?
http://stackoverflow.com/questions/4970297/how-to-get-beans-created-by-factorybean-spring-managed


上面的场景,是因为我们希望将业务处理过程抽象出来,将各种实现中公共的部分放到一个抽象类中。这种业务处理过程的抽象,用Method chaining,或builder,或结合使用其他的设计模式,哪个比较好那?

参考:
Method chaining with value objects
http://stackoverflow.com/questions/1981769/method-chaining-with-value-objects

热点排行