File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 9
9
10
10
![ 分层示例] ( ./resources/java_project_layer.png )
11
11
12
+ 其中各层的引用关系从上到下依次为:
13
+ API层 -> Application层 -> DomainService -> Repository -> DomainModel
14
+
15
+ 引用关系见下图
16
+ ![ 分层示例] ( ./resources/java_layer_depencies.png )
17
+
12
18
## 2. API层
13
19
14
20
API层用来定义对外的接口,对应于SpringMVC的Controller。
@@ -67,4 +73,12 @@ utility层包含一些共用的辅助方法。
67
73
68
74
- 对于比较复杂的项目,每个分层中可以根据模块再分成多个目录,以方便管理。
69
75
- 事务应该在ApplicationService或DomainService中定义,具体位置根据情况决定。
70
- - 事务范围应尽量短,事务中不应包括远程服务调用及消息队列操作。
76
+ - 事务范围应尽量短,事务中不应包括远程服务调用及消息收发操作。
77
+ - 关于消息的发送应遵守以下约定:
78
+ - 消息发送应该封装成独立的类,类名类似于xxxMessageProducer, 类定义放在DomainService目录下。
79
+ - xxxMessageProducer类似DomainService,可以由其他的DomainService或ApplicationService调用。
80
+
81
+ - 关于消息接收应遵守以下约定:
82
+ - 消息接收的类应定义在Infrastructure层中,命名类似于xxxMessageConsumer;
83
+ - xxxMessageConsumer调用ApplicationService来完成实际处理。
84
+ - xxxMessageConsumer类似xxxController,都是由外部调用发起。
You can’t perform that action at this time.
0 commit comments