Spring 中的设计模式
特别说明
当前文章内容迁移中,如有问题,请提交 issues 谢谢 ~~
工厂设计模式(Spring IOC DI)
Spring使用工厂模式可以通过 BeanFactory 或 ApplicationContext 创建 bean 对象。
单例设计模式
Spring 中,bean 默认都是单例的。
代理模式(AOP)
模版
如 JDBC template 等 以 template 结尾的类。
观察者模式(Spring 的事件驱动)
适配器模式
Spring 中的 AOP 使用的是代理模式,但是 Spring 的增强通知 使用的是适配器模式。
Spring MVC 中的 Handler 也是。
装饰器模式
Spring中用到的包装器模式在类名上有两种表现:一种是类名中含有Wrapper,另一种是类名中含有Decorator。
策略模式
Source 接口
Resource