+ private List<FilteredNotifier> filteredNotifiers = Collections
+ .synchronizedList(new ArrayList<FilteredNotifier>());
+
+ private ThreadGroup processesThreadGroup = new ThreadGroup("SLC Processes");
+
+ protected abstract ExecutionFlow findExecutionFlow(String moduleName,
+ String moduleVersion, String flowName);
+
+ protected abstract ExecutionContext findExecutionContext(String moduleName,
+ String moduleVersion);
+
+ protected abstract ExecutionFlowDescriptorConverter getExecutionFlowDescriptorConverter(
+ String moduleName, String moduleVersion);
+
+ public void execute(RealizedFlow realizedFlow) {
+ if (log.isTraceEnabled())
+ log.trace("Executing " + realizedFlow);
+
+ String moduleName = realizedFlow.getModuleName();
+ String moduleVersion = realizedFlow.getModuleVersion();
+
+ Map<? extends String, ? extends Object> variablesToAdd = getExecutionFlowDescriptorConverter(
+ moduleName, moduleVersion).convertValues(
+ realizedFlow.getFlowDescriptor());
+ ExecutionContext executionContext = findExecutionContext(moduleName,
+ moduleVersion);
+ for (String key : variablesToAdd.keySet())
+ executionContext.setVariable(key, variablesToAdd.get(key));
+
+ ExecutionFlow flow = findExecutionFlow(moduleName, moduleVersion,
+ realizedFlow.getFlowDescriptor().getName());
+
+ //
+ // Actually runs the flow, IN THIS THREAD
+ //
+ flow.run();
+ //
+ //
+ //
+ }
+
+ public void dispatchUpdateStatus(ExecutionProcess process,
+ String oldStatus, String newStatus) {
+ // generic notifiers (notified of everything)
+ for (Iterator<SlcExecutionNotifier> it = getSlcExecutionNotifiers()
+ .iterator(); it.hasNext();) {
+ it.next().updateStatus(process, oldStatus, newStatus);
+ }
+
+ // filtered notifiers
+ for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
+ .hasNext();) {
+ FilteredNotifier filteredNotifier = it.next();
+ if (filteredNotifier.receiveFrom(process))
+ filteredNotifier.getNotifier().updateStatus(process, oldStatus,
+ newStatus);
+ }
+ }
+
+ public void dispatchAddSteps(ExecutionProcess process,
+ List<ExecutionStep> steps) {
+ for (Iterator<SlcExecutionNotifier> it = getSlcExecutionNotifiers()
+ .iterator(); it.hasNext();) {
+ it.next().addSteps(process, steps);
+ }
+
+ for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
+ .hasNext();) {
+ FilteredNotifier filteredNotifier = it.next();
+ if (filteredNotifier.receiveFrom(process))
+ filteredNotifier.getNotifier().addSteps(process, steps);
+ }
+ }
+
+ public void registerProcessNotifier(ExecutionProcessNotifier notifier,
+ Map<String, String> properties) {
+ filteredNotifiers.add(new FilteredNotifier(notifier, properties));