1 package org
.argeo
.slc
.runtime
;
5 import org
.argeo
.slc
.execution
.ExecutionContext
;
6 import org
.argeo
.slc
.execution
.ExecutionFlow
;
7 import org
.argeo
.slc
.execution
.ExecutionFlowDescriptorConverter
;
8 import org
.argeo
.slc
.execution
.ExecutionModulesManager
;
9 import org
.argeo
.slc
.execution
.RealizedFlow
;
11 /** Provides the base feature of an execution module manager. */
12 public abstract class AbstractExecutionModulesManager
implements
13 ExecutionModulesManager
{
15 // private List<FilteredNotifier> filteredNotifiers = Collections
16 // .synchronizedList(new ArrayList<FilteredNotifier>());
18 protected abstract ExecutionFlow
findExecutionFlow(String moduleName
,
19 String moduleVersion
, String flowName
);
21 protected abstract ExecutionContext
findExecutionContext(String moduleName
,
22 String moduleVersion
);
24 protected abstract ExecutionFlowDescriptorConverter
getExecutionFlowDescriptorConverter(
25 String moduleName
, String moduleVersion
);
27 public void execute(RealizedFlow realizedFlow
) {
28 String moduleName
= realizedFlow
.getModuleName();
29 String moduleVersion
= realizedFlow
.getModuleVersion();
31 Map
<?
extends String
, ?
extends Object
> variablesToAdd
= getExecutionFlowDescriptorConverter(
32 moduleName
, moduleVersion
).convertValues(
33 realizedFlow
.getFlowDescriptor());
34 ExecutionContext executionContext
= findExecutionContext(moduleName
,
36 for (String key
: variablesToAdd
.keySet())
37 executionContext
.setVariable(key
, variablesToAdd
.get(key
));
39 ExecutionFlow flow
= findExecutionFlow(moduleName
, moduleVersion
,
40 realizedFlow
.getFlowDescriptor().getName());
43 // Actually runs the flow, IN THIS THREAD
45 executionContext
.beforeFlow(flow
);
49 executionContext
.afterFlow(flow
);
56 // public void dispatchUpdateStatus(ExecutionProcess process,
57 // String oldStatus, String newStatus) {
58 // // filtered notifiers
59 // for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
61 // FilteredNotifier filteredNotifier = it.next();
62 // if (filteredNotifier.receiveFrom(process))
63 // filteredNotifier.getNotifier().updateStatus(process, oldStatus,
69 // public void dispatchAddSteps(ExecutionProcess process,
70 // List<ExecutionStep> steps) {
71 // process.addSteps(steps);
72 // for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
74 // FilteredNotifier filteredNotifier = it.next();
75 // if (filteredNotifier.receiveFrom(process))
76 // filteredNotifier.getNotifier().addSteps(process, steps);
80 // public void registerProcessNotifier(ExecutionProcessNotifier notifier,
81 // Map<String, String> properties) {
82 // filteredNotifiers.add(new FilteredNotifier(notifier, properties));
85 // public void unregisterProcessNotifier(ExecutionProcessNotifier notifier,
86 // Map<String, String> properties) {
87 // filteredNotifiers.remove(notifier);
90 // protected class FilteredNotifier {
91 // private final ExecutionProcessNotifier notifier;
92 // private final String processId;
94 // public FilteredNotifier(ExecutionProcessNotifier notifier,
95 // Map<String, String> properties) {
97 // this.notifier = notifier;
98 // if (properties == null)
99 // properties = new HashMap<String, String>();
100 // if (properties.containsKey(SLC_PROCESS_ID))
101 // processId = properties.get(SLC_PROCESS_ID);
107 // * Whether event from this process should be received by this listener.
109 // public Boolean receiveFrom(ExecutionProcess process) {
110 // if (processId != null)
111 // if (process.getUuid().equals(processId))
119 // public int hashCode() {
120 // return notifier.hashCode();
124 // public boolean equals(Object obj) {
125 // if (obj instanceof FilteredNotifier) {
126 // FilteredNotifier fn = (FilteredNotifier) obj;
127 // return notifier.equals(fn.notifier);
128 // } else if (obj instanceof ExecutionProcessNotifier) {
129 // ExecutionProcessNotifier epn = (ExecutionProcessNotifier) obj;
130 // return notifier.equals(epn);
135 // public ExecutionProcessNotifier getNotifier() {