Skip to content

Commit 5fa9c33

Browse files
committed
add GroovyMetadataReloadGateway
1 parent 4807964 commit 5fa9c33

11 files changed

Lines changed: 108 additions & 32 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<groupId>com.codingapi.springboot</groupId>
1717
<artifactId>springboot-parent</artifactId>
18-
<version>2.10.45</version>
18+
<version>2.10.46</version>
1919

2020
<url>https://github.com/codingapi/springboot-framewrok</url>
2121
<name>springboot-parent</name>

springboot-starter-data-authorization/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>2.10.45</version>
9+
<version>2.10.46</version>
1010
</parent>
1111

1212
<name>springboot-starter-data-authorization</name>

springboot-starter-data-fast/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-parent</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>2.10.45</version>
8+
<version>2.10.46</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

springboot-starter-flow/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>2.10.45</version>
9+
<version>2.10.46</version>
1010
</parent>
1111

1212
<name>springboot-starter-flow</name>

springboot-starter-security/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>2.10.45</version>
9+
<version>2.10.46</version>
1010
</parent>
1111

1212
<artifactId>springboot-starter-security</artifactId>

springboot-starter/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.codingapi.springboot</groupId>
77
<artifactId>springboot-parent</artifactId>
8-
<version>2.10.45</version>
8+
<version>2.10.46</version>
99
</parent>
1010
<artifactId>springboot-starter</artifactId>
1111

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.codingapi.springboot.framework.script;
2+
3+
import com.codingapi.springboot.framework.script.gateway.GroovyMetadataReloadGateway;
4+
import com.codingapi.springboot.framework.script.meta.GroovyMetadata;
5+
import lombok.Getter;
6+
7+
import java.util.ArrayList;
8+
import java.util.List;
9+
10+
public class GroovyMetadataReloadGatewayContext {
11+
12+
private final List<GroovyMetadataReloadGateway> gateways;
13+
14+
@Getter
15+
private final static GroovyMetadataReloadGatewayContext instance = new GroovyMetadataReloadGatewayContext();
16+
17+
private GroovyMetadataReloadGatewayContext(){
18+
this.gateways = new ArrayList<>();
19+
}
20+
21+
public void addGateway(GroovyMetadataReloadGateway gateway){
22+
this.gateways.add(gateway);
23+
}
24+
25+
public void reload(GroovyMetadata metadata){
26+
for (GroovyMetadataReloadGateway gateway:gateways){
27+
gateway.reload(metadata);
28+
}
29+
}
30+
31+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.codingapi.springboot.framework.script.gateway;
2+
3+
import com.codingapi.springboot.framework.script.meta.GroovyMetadata;
4+
5+
/**
6+
* 脚本元数据刷新加载对象
7+
*/
8+
public interface GroovyMetadataReloadGateway {
9+
10+
void reload(GroovyMetadata metadata);
11+
12+
}

springboot-starter/src/main/java/com/codingapi/springboot/framework/script/meta/GroovyMetadata.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public GroovyMetadata() {
4545
this.binds = new ArrayList<>();
4646
}
4747

48+
/**
49+
* 通过class构建 脚本类型数据
50+
* @param clazz class类型
51+
*/
4852
public void buildType(Class<?> clazz) {
4953
String dataType = clazz.getSimpleName();
5054
GroovyType groovyType = this.types.get(dataType);
@@ -56,20 +60,42 @@ public void buildType(Class<?> clazz) {
5660
if(scriptType!=null) {
5761
groovyType.setDescription(scriptType.description());
5862
}
59-
this.types.put(dataType, groovyType);
63+
this.put(dataType, groovyType);
6064
}
6165
}
6266

67+
/**
68+
* 增加请求参数数据对象
69+
* @param request 请求参数
70+
*/
6371
public void addRequest(GroovyField request) {
6472
this.requests.add(request);
6573
}
6674

75+
/**
76+
* 更新流程类型数据
77+
* @param dataType 数据类型
78+
* @param groovyType 脚本类型
79+
*/
80+
public void put(String dataType,GroovyType groovyType){
81+
this.types.put(dataType, groovyType);
82+
}
83+
6784

85+
/**
86+
* 获取流程类型数据
87+
* @param dataType 数据类型
88+
* @return 脚本类型
89+
*/
6890
public GroovyType getType(String dataType){
6991
return this.types.get(dataType);
7092
}
7193

7294

95+
/**
96+
* 增加绑定数据对象
97+
* @param bind 绑定数据
98+
*/
7399
public void addBind(GroovyField bind) {
74100
this.binds.add(bind);
75101
}

springboot-starter/src/main/java/com/codingapi/springboot/framework/script/request/GroovyRunningScript.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.codingapi.springboot.framework.script.request;
22

3+
import com.codingapi.springboot.framework.script.GroovyMetadataReloadGatewayContext;
34
import com.codingapi.springboot.framework.script.meta.GroovyMetadata;
45
import com.codingapi.springboot.framework.script.service.GroovyMetadataParserService;
56
import lombok.Getter;
@@ -84,16 +85,22 @@ public Object[] getParams() {
8485
return objects.toArray();
8586
}
8687

88+
/**
89+
* 重新设置脚本元数据信息
90+
* @param metadata 脚本元数据信息
91+
*/
8792
public void resetMetadata(GroovyMetadata metadata) {
8893
this.metadata = metadata;
94+
GroovyMetadataReloadGatewayContext.getInstance().reload(this.metadata);
8995
}
9096

9197
/**
92-
* 构建元数据信息
98+
* 构建脚本元数据信息
9399
*/
94100
public void buildMetadata() {
95101
GroovyMetadataParserService groovyMetaDataParserService = new GroovyMetadataParserService(this);
96102
this.metadata = groovyMetaDataParserService.parser();
103+
GroovyMetadataReloadGatewayContext.getInstance().reload(this.metadata);
97104
}
98105

99106
}

0 commit comments

Comments
 (0)