-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpringPipelineMain.java
41 lines (36 loc) · 1.23 KB
/
SpringPipelineMain.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package design_pattern.pipeline;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import javax.sound.midi.SoundbankResource;
import java.util.HashMap;
import java.util.Map;
/**
*
* spring 中实现管道(责任链)模式
* 应对代码中有多个子步骤的情况(参考 netty pipeline)
*
*
* @Date 2021/2/19 9:51 下午
* @author: leobhao
*/
public class SpringPipelineMain {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("design_pattern.xml");
InstanceBuildContext data = createPipelineData();
PipelineExecutor executor = context.getBean(PipelineExecutor.class);
boolean success = executor.acceptSync(data);
if (success) {
System.out.println("创建成功");
return;
}
System.out.println("创建失败");
return;
}
public static InstanceBuildContext createPipelineData() {
InstanceBuildContext data = new InstanceBuildContext();
Map<String, Object> inputData = new HashMap<>();
inputData.put("key", "value");
data.setFormInput(inputData);
return data;
}
}