spring&java rest

This commit is contained in:
法然
2022-10-19 15:40:59 +08:00
parent ee17fb0cd2
commit b2216ef815
10 changed files with 373 additions and 9 deletions

View File

@@ -0,0 +1,36 @@
## 1 原理说明
### 事件驱动模型和观察者模式
一下名称具有相同的含义,都是观察着模式在不同场景下的实现。
* Spring的事件驱动模型
* 设计模式中的观察者模式
* jdk中的observable和observer
* ui中事件监听机制
* 注册中心和消息队列的订阅发布机制
先是一种对象间的一对多的关系;最简单的如交通信号灯,信号灯是目标(一方),行人注视着信号灯(多方)。当目标发送改变(发布),观察者(订阅者)就可以接收到改变。 观察者如何处理(如行人如何走,是快走/慢走/不走,目标不会管的), 目标无需干涉;所以就松散耦合了它们之间的关系。
### Spring中实现
![](image/2022-10-18-12-06-37.png)
### 类图关系
* 事件
![](image/2022-10-18-12-07-26.png)
* 发布(动作)
* ApplicationContext 接口继承了 ApplicationEventPublisher并在 AbstractApplicationContext 实现了具体代码实际执行是委托给ApplicationEventMulticaster可以认为是多播
![](image/2022-10-18-12-08-25.png)
* 监听
![](image/2022-10-18-12-08-47.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB