1 package org
.argeo
.slc
.core
.execution
;
3 import java
.util
.ArrayList
;
7 import org
.apache
.commons
.logging
.Log
;
8 import org
.apache
.commons
.logging
.LogFactory
;
9 import org
.argeo
.slc
.execution
.ExecutionContext
;
10 import org
.argeo
.slc
.execution
.ExecutionFlow
;
11 import org
.argeo
.slc
.execution
.ExecutionFlowDescriptorConverter
;
12 import org
.argeo
.slc
.execution
.ExecutionModulesListener
;
13 import org
.argeo
.slc
.execution
.ExecutionModulesManager
;
14 import org
.argeo
.slc
.process
.RealizedFlow
;
15 import org
.argeo
.slc
.process
.SlcExecution
;
16 import org
.argeo
.slc
.process
.SlcExecutionNotifier
;
18 public abstract class AbstractExecutionModulesManager
implements
19 ExecutionModulesManager
{
20 private final static Log log
= LogFactory
21 .getLog(AbstractExecutionModulesManager
.class);
23 private List
<SlcExecutionNotifier
> slcExecutionNotifiers
= new ArrayList
<SlcExecutionNotifier
>();
24 private List
<ExecutionModulesListener
> executionModulesListeners
= new ArrayList
<ExecutionModulesListener
>();
26 private ThreadGroup processesThreadGroup
= new ThreadGroup("Processes");
28 protected abstract ExecutionFlow
findExecutionFlow(String moduleName
,
29 String moduleVersion
, String flowName
);
31 protected abstract ExecutionContext
findExecutionContext(String moduleName
,
32 String moduleVersion
);
34 protected abstract ExecutionFlowDescriptorConverter
getExecutionFlowDescriptorConverter(
35 String moduleName
, String moduleVersion
);
37 public void process(SlcExecution slcExecution
) {
38 new ProcessThread(this, slcExecution
).start();
41 public void execute(RealizedFlow realizedFlow
) {
42 if (log
.isTraceEnabled())
43 log
.trace("Executing " + realizedFlow
);
45 String moduleName
= realizedFlow
.getModuleName();
46 String moduleVersion
= realizedFlow
.getModuleVersion();
48 Map
<?
extends String
, ?
extends Object
> variablesToAdd
= getExecutionFlowDescriptorConverter(
49 moduleName
, moduleVersion
).convertValues(
50 realizedFlow
.getFlowDescriptor());
51 ExecutionContext executionContext
= findExecutionContext(moduleName
,
53 for (String key
: variablesToAdd
.keySet())
54 executionContext
.setVariable(key
, variablesToAdd
.get(key
));
56 ExecutionFlow flow
= findExecutionFlow(moduleName
, moduleVersion
,
57 realizedFlow
.getFlowDescriptor().getName());
60 // Actually runs the flow, IN THIS THREAD
68 public void setSlcExecutionNotifiers(
69 List
<SlcExecutionNotifier
> slcExecutionNotifiers
) {
70 this.slcExecutionNotifiers
= slcExecutionNotifiers
;
73 public List
<SlcExecutionNotifier
> getSlcExecutionNotifiers() {
74 return slcExecutionNotifiers
;
77 public ThreadGroup
getProcessesThreadGroup() {
78 return processesThreadGroup
;
81 public List
<ExecutionModulesListener
> getExecutionModulesListeners() {
82 return executionModulesListeners
;
85 public void setExecutionModulesListeners(
86 List
<ExecutionModulesListener
> executionModulesListeners
) {
87 this.executionModulesListeners
= executionModulesListeners
;