1 package org
.argeo
.slc
.runtime
;
5 import org
.apache
.commons
.logging
.Log
;
6 import org
.apache
.commons
.logging
.LogFactory
;
7 import org
.argeo
.slc
.execution
.ExecutionContext
;
8 import org
.argeo
.slc
.execution
.ExecutionFlow
;
9 import org
.argeo
.slc
.execution
.ExecutionFlowDescriptorConverter
;
10 import org
.argeo
.slc
.execution
.ExecutionModulesManager
;
11 import org
.argeo
.slc
.execution
.RealizedFlow
;
13 /** Provides the base feature of an execution module manager. */
14 public abstract class AbstractExecutionModulesManager
implements
15 ExecutionModulesManager
{
16 private final static Log log
= LogFactory
17 .getLog(AbstractExecutionModulesManager
.class);
19 // private List<FilteredNotifier> filteredNotifiers = Collections
20 // .synchronizedList(new ArrayList<FilteredNotifier>());
22 protected abstract ExecutionFlow
findExecutionFlow(String moduleName
,
23 String moduleVersion
, String flowName
);
25 protected abstract ExecutionContext
findExecutionContext(String moduleName
,
26 String moduleVersion
);
28 protected abstract ExecutionFlowDescriptorConverter
getExecutionFlowDescriptorConverter(
29 String moduleName
, String moduleVersion
);
31 public void execute(RealizedFlow realizedFlow
) {
32 if (log
.isTraceEnabled())
33 log
.trace("Executing " + realizedFlow
);
35 String moduleName
= realizedFlow
.getModuleName();
36 String moduleVersion
= realizedFlow
.getModuleVersion();
38 Map
<?
extends String
, ?
extends Object
> variablesToAdd
= getExecutionFlowDescriptorConverter(
39 moduleName
, moduleVersion
).convertValues(
40 realizedFlow
.getFlowDescriptor());
41 ExecutionContext executionContext
= findExecutionContext(moduleName
,
43 for (String key
: variablesToAdd
.keySet())
44 executionContext
.setVariable(key
, variablesToAdd
.get(key
));
46 ExecutionFlow flow
= findExecutionFlow(moduleName
, moduleVersion
,
47 realizedFlow
.getFlowDescriptor().getName());
50 // Actually runs the flow, IN THIS THREAD
52 executionContext
.beforeFlow(flow
);
56 executionContext
.afterFlow(flow
);
63 // public void dispatchUpdateStatus(ExecutionProcess process,
64 // String oldStatus, String newStatus) {
65 // // filtered notifiers
66 // for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
68 // FilteredNotifier filteredNotifier = it.next();
69 // if (filteredNotifier.receiveFrom(process))
70 // filteredNotifier.getNotifier().updateStatus(process, oldStatus,
76 // public void dispatchAddSteps(ExecutionProcess process,
77 // List<ExecutionStep> steps) {
78 // process.addSteps(steps);
79 // for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
81 // FilteredNotifier filteredNotifier = it.next();
82 // if (filteredNotifier.receiveFrom(process))
83 // filteredNotifier.getNotifier().addSteps(process, steps);
87 // public void registerProcessNotifier(ExecutionProcessNotifier notifier,
88 // Map<String, String> properties) {
89 // filteredNotifiers.add(new FilteredNotifier(notifier, properties));
92 // public void unregisterProcessNotifier(ExecutionProcessNotifier notifier,
93 // Map<String, String> properties) {
94 // filteredNotifiers.remove(notifier);
97 // protected class FilteredNotifier {
98 // private final ExecutionProcessNotifier notifier;
99 // private final String processId;
101 // public FilteredNotifier(ExecutionProcessNotifier notifier,
102 // Map<String, String> properties) {
104 // this.notifier = notifier;
105 // if (properties == null)
106 // properties = new HashMap<String, String>();
107 // if (properties.containsKey(SLC_PROCESS_ID))
108 // processId = properties.get(SLC_PROCESS_ID);
114 // * Whether event from this process should be received by this listener.
116 // public Boolean receiveFrom(ExecutionProcess process) {
117 // if (processId != null)
118 // if (process.getUuid().equals(processId))
126 // public int hashCode() {
127 // return notifier.hashCode();
131 // public boolean equals(Object obj) {
132 // if (obj instanceof FilteredNotifier) {
133 // FilteredNotifier fn = (FilteredNotifier) obj;
134 // return notifier.equals(fn.notifier);
135 // } else if (obj instanceof ExecutionProcessNotifier) {
136 // ExecutionProcessNotifier epn = (ExecutionProcessNotifier) obj;
137 // return notifier.equals(epn);
142 // public ExecutionProcessNotifier getNotifier() {