Skip to content

Commit 2f5207c

Browse files
committed
flow:优化DefaultServiceEngine
1 parent 00788a8 commit 2f5207c

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

service/src/main/java/org/bekit/service/engine/DefaultServiceEngine.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public <O, R> R execute(String service, O order) {
3434
@Override
3535
public <O, R> R execute(String service, O order, Map<Object, Object> attachment) {
3636
// 获取服务执行器
37-
ServiceExecutor serviceExecutor = serviceRegistrar.get(service);
38-
Assert.notNull(serviceExecutor, String.format("服务[%s]不存在", service));
37+
ServiceExecutor serviceExecutor = getServiceExecutor(service);
3938
// 校验order
4039
checkOrder(order, serviceExecutor);
4140
// 构建服务上下文
@@ -46,6 +45,15 @@ public <O, R> R execute(String service, O order, Map<Object, Object> attachment)
4645
return context.getResult();
4746
}
4847

48+
// 获取服务执行器
49+
private ServiceExecutor getServiceExecutor(String service) {
50+
ServiceExecutor serviceExecutor = serviceRegistrar.get(service);
51+
if (serviceExecutor == null) {
52+
throw new IllegalArgumentException(String.format("服务[%s]不存在", service));
53+
}
54+
return serviceExecutor;
55+
}
56+
4957
// 校验入参order
5058
private void checkOrder(Object order, ServiceExecutor serviceExecutor) {
5159
Assert.notNull(order, "order不能为null");

0 commit comments

Comments
 (0)