1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.slc.core.execution.generator;
17
18 import java.util.Map;
19
20 import org.argeo.slc.SlcException;
21 import org.springframework.beans.factory.support.BeanDefinitionRegistry;
22
23
24
25
26
27
28 public class CompositeRunnableFactory implements RunnableFactory {
29
30
31
32
33 private String factoryKey;
34
35
36
37
38 private Map<String, RunnableFactory> factories;
39
40 public void createAndRegisterRunnable(RunnableDataNode node,
41 BeanDefinitionRegistry beanDefinitionRegistry) {
42 findFactory(node).createAndRegisterRunnable(node, beanDefinitionRegistry);
43 }
44
45
46
47
48
49
50 private RunnableFactory findFactory(RunnableDataNode node) {
51
52 Map<String, Object> data = node.getData();
53 if (!data.containsKey(factoryKey)) {
54 throw new SlcException("No data value for key '" + factoryKey + "'");
55 }
56 String factoryId = data.get(factoryKey).toString();
57
58
59 if ((factories != null) && factories.containsKey(factoryId)) {
60 return factories.get(factoryId);
61 }
62
63 else {
64 throw new SlcException("Not implemented");
65 }
66 }
67
68 public void setFactoryKey(String factoryKey) {
69 this.factoryKey = factoryKey;
70 }
71
72 public void setFactories(Map<String, RunnableFactory> factories) {
73 this.factories = factories;
74 }
75
76
77 }