Skip to content

Commit 5d1458e

Browse files
committed
add FlowSessionBeanRegister
1 parent 0258cf0 commit 5d1458e

File tree

8 files changed

+57
-38
lines changed

8 files changed

+57
-38
lines changed

example/example-application/src/main/java/com/codingapi/example/runner/FlowHolderRegister.java

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
package com.codingapi.springboot.flow;
22

3+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
4+
import org.springframework.context.ApplicationContext;
5+
import org.springframework.context.annotation.Bean;
36
import org.springframework.context.annotation.Configuration;
47

58
@Configuration
69
public class FlowConfiguration {
710

811

12+
@Bean
13+
@ConditionalOnMissingBean
14+
public FlowSessionBeanRegister flowHolderRegister(ApplicationContext spring) {
15+
return new FlowSessionBeanRegister(spring);
16+
}
917

1018
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.codingapi.springboot.flow;
2+
3+
import com.codingapi.springboot.flow.content.FlowSessionBeanProvider;
4+
import lombok.AllArgsConstructor;
5+
import org.springframework.beans.factory.InitializingBean;
6+
import org.springframework.context.ApplicationContext;
7+
8+
@AllArgsConstructor
9+
public class FlowSessionBeanRegister implements InitializingBean {
10+
11+
private final ApplicationContext application;
12+
13+
@Override
14+
public void afterPropertiesSet() throws Exception {
15+
FlowSessionBeanProvider.getInstance().register(application);
16+
}
17+
}

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/content/FlowSession.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,20 @@
1212

1313
import java.util.List;
1414

15+
/**
16+
* 流程groovy脚本回话对象
17+
*/
1518
@Getter
1619
public class FlowSession {
1720

18-
private FlowWork flowWork;
19-
private FlowNode flowNode;
20-
private IFlowOperator createOperator;
21-
private IFlowOperator currentOperator;
22-
private IBindData bindData;
23-
private Opinion opinion;
24-
private List<FlowRecord> historyRecords;
25-
private FlowSessionBeanRegister holder;
26-
21+
private final FlowWork flowWork;
22+
private final FlowNode flowNode;
23+
private final IFlowOperator createOperator;
24+
private final IFlowOperator currentOperator;
25+
private final IBindData bindData;
26+
private final Opinion opinion;
27+
private final List<FlowRecord> historyRecords;
28+
private final FlowSessionBeanProvider provider;
2729

2830
public FlowSession(FlowWork flowWork, FlowNode flowNode, IFlowOperator createOperator, IFlowOperator currentOperator, IBindData bindData, Opinion opinion, List<FlowRecord> historyRecords) {
2931
this.flowWork = flowWork;
@@ -33,16 +35,17 @@ public FlowSession(FlowWork flowWork, FlowNode flowNode, IFlowOperator createOpe
3335
this.bindData = bindData;
3436
this.opinion = opinion;
3537
this.historyRecords = historyRecords;
36-
this.holder = FlowSessionBeanRegister.getInstance();
38+
this.provider = FlowSessionBeanProvider.getInstance();
3739
}
3840

3941

4042
public Object getBean(String beanName) {
41-
return holder.getBean(beanName);
43+
return provider.getBean(beanName);
4244
}
4345

4446
/**
4547
* 创建节点结果
48+
*
4649
* @param nodeCode 节点code
4750
* @return 节点结果
4851
*/
@@ -52,6 +55,7 @@ public NodeResult createNodeErrTrigger(String nodeCode) {
5255

5356
/**
5457
* 创建操作者结果
58+
*
5559
* @param operatorIds 操作者id
5660
* @return 操作者结果
5761
*/
@@ -61,6 +65,7 @@ public OperatorResult createOperatorErrTrigger(List<Long> operatorIds) {
6165

6266
/**
6367
* 创建操作者结果
68+
*
6469
* @param operatorIds 操作者id
6570
* @return 操作者结果
6671
*/
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
import org.springframework.context.ApplicationContext;
55

66
/**
7-
* 流程回话 spring bean 注册对象
7+
* 流程回话 spring bean 提供者
88
*/
9-
public class FlowSessionBeanRegister {
9+
public class FlowSessionBeanProvider {
1010

1111
@Getter
12-
private static final FlowSessionBeanRegister instance = new FlowSessionBeanRegister();
12+
private static final FlowSessionBeanProvider instance = new FlowSessionBeanProvider();
1313

14-
private FlowSessionBeanRegister() {
14+
private FlowSessionBeanProvider() {
1515
}
1616

1717
private ApplicationContext spring;

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/service/FlowDirectionService.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,23 @@ public boolean hasCurrentFlowIsFinish() {
102102
}
103103

104104

105+
/**
106+
* 判断当前流程是否为默认的驳回流程
107+
*/
105108
public boolean isDefaultBackRecord() {
106109
return flowSourceDirection == FlowSourceDirection.REJECT && !flowWork.hasBackRelation();
107110
}
108111

112+
/**
113+
* 判断当前流程是否为通过流程
114+
*/
109115
public boolean isPassBackRecord() {
110116
return flowSourceDirection == FlowSourceDirection.PASS;
111117
}
112118

119+
/**
120+
* 判断当前流程是否为自定义的驳回流程
121+
*/
113122
public boolean isCustomBackRecord() {
114123
return flowSourceDirection == FlowSourceDirection.REJECT && flowWork.hasBackRelation();
115124
}

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/trigger/OutTrigger.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
/**
1010
* 出口触发器
1111
*/
12-
1312
public class OutTrigger {
1413

1514
@Getter

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/user/IFlowOperator.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.codingapi.springboot.flow.user;
22

3+
/**
4+
* 流程参与用户
5+
*/
36
public interface IFlowOperator {
47

58
/**

0 commit comments

Comments
 (0)