Skip to content

设计模式典型案例

javahongxi edited this page Aug 6, 2019 · 12 revisions

设计模式典型案例

  1. 工厂方法/抽象工厂:LoggerFactory.getLogger(clazz); ProxyFactory#getProxy(invoker) (Dubbo)
  2. 单例模式:MQClientManager.getInstance() (RocketMQ)
  3. 模板方法:AbstractQueuedSynchronizer; JdbcTemplate#execute(callback)
  4. 代理模式:RPC接口代理, Spring AOP
  5. 迭代器模式:implements Iterable (Netty)
  6. 责任链模式:Servlet Filter; Netty ChannelHandler
  7. 策略模式:Spring Resource
  8. 观察者模式:Spring事件监听器ApplicationListener
  9. 适配器模式:SocketAdaptor extends Socket (NIO)
  10. 装饰者模式:InvokerWrapper (Dubbo)
  11. 门面模式:RequestFacade (tomcat)
  12. 建造者模式:XMLMapperBuilder (MyBatis)
  13. 组合模式:CompositeByteBuf (Netty)

23种设计模式

创建型

  1. Factory Method(工厂方法)
  2. Abstract Factory(抽象工厂)
  3. Builder(建造者)
  4. Prototype(原型)
  5. Singleton(单例)

结构型

  1. Adapter Class/Object(适配器)
  2. Bridge(桥接)
  3. Composite(组合)
  4. Decorator(装饰)
  5. Facade(外观)
  6. Flyweight(享元)
  7. Proxy(代理)

行为型

  1. Interpreter(解释器)
  2. Template Method(模板方法)
  3. Chain of Responsibility(责任链)
  4. Command(命令)
  5. Iterator(迭代器)
  6. Mediator(中介者)
  7. Memento(备忘录)
  8. Observer(观察者)
  9. State(状态)
  10. Strategy(策略)
  11. Visitor(访问者)

框架中的设计模式

首页

Java核心技术

Netty

RocketMQ深入研究

kafka深入研究

Pulsar深入研究

Dubbo源码导读

微服务架构

Redis

Elasticsearch

其他

杂谈

关于我

Clone this wiki locally