本篇文章,按照不同的方式,整理了设计模式在spring中的应用。
Spring 中常见的设计模式
- 工厂模式 :BeanFactory
- 装饰器模式:BeanWrapper
- 代理模式:AopProxy
- 单例模式:ApplicationContext
- 委派模式:DispatcherServlet
- 策略模式:SimpleInstantiationStrategy
- 适配器模式:HandlerApdapter
- 模板方法模式:JdbcTemplate
- 观察者模式:ContextLoaderListener
Spring 四大模块中的典型的设计模式
- Spring IOC 工厂模式、单例模式、装饰器模式
- Spring AOP 代理模式、观察者模式
- Spring MVC 委派模式、适配器模式
- Spring JDBC 模板方法模式
Spring 中常见设计模式分类
各个模式对应的分析链接:
工厂模式在BeanFactory中:
Cloudistory:设计模式及其在Spring中的应用——工厂模式在BeanFactory中zhuanlan.zhihu.com单例模式在ApplicationContext中:
Cloudistory:设计模式及其在Spring中的应用——单例模式在ApplicationContext中zhuanlan.zhihu.com模板模式在JdbcTemplate中:
Cloudistory:设计模式及其在Spring中的应用——模板模式 在JdbcTemplate中zhuanlan.zhihu.com