import org.apache.commons.logging.LogFactory;
import org.argeo.slc.SlcException;
import org.argeo.slc.build.BasicNameVersion;
+import org.argeo.slc.build.NameVersion;
import org.argeo.slc.core.execution.AbstractExecutionModulesManager;
import org.argeo.slc.core.execution.DefaultExecutionFlowDescriptorConverter;
import org.argeo.slc.deploy.ModuleDescriptor;
import org.argeo.slc.execution.ExecutionFlowDescriptor;
import org.argeo.slc.execution.ExecutionFlowDescriptorConverter;
import org.argeo.slc.execution.ExecutionModuleDescriptor;
+import org.argeo.slc.execution.ExecutionModulesListener;
import org.argeo.slc.process.RealizedFlow;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
// makes it very difficult
// Suggestions welcome!
Properties systemProperties = System.getProperties();
-// if (!systemProperties
-// .containsKey("javax.xml.parsers.DocumentBuilderFactory"))
-// System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
-// "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
-// if (!systemProperties.containsKey("javax.xml.parsers.SAXParserFactory"))
-// System.setProperty("javax.xml.parsers.SAXParserFactory",
-// "org.apache.xerces.jaxp.SAXParserFactoryImpl");
+ // if (!systemProperties
+ // .containsKey("javax.xml.parsers.DocumentBuilderFactory"))
+ // System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
+ // "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
+ // if
+ // (!systemProperties.containsKey("javax.xml.parsers.SAXParserFactory"))
+ // System.setProperty("javax.xml.parsers.SAXParserFactory",
+ // "org.apache.xerces.jaxp.SAXParserFactoryImpl");
if (!systemProperties
.containsKey("javax.xml.transform.TransformerFactory"))
System.setProperty("javax.xml.transform.TransformerFactory",
}
}
- public void updateAndExecute(RealizedFlow realizedFlow) {
- OsgiBundle osgiBundle = new OsgiBundle(realizedFlow);
+ public void upgrade(NameVersion nameVersion) {
+ OsgiBundle osgiBundle = new OsgiBundle(nameVersion);
bundlesManager.upgradeSynchronous(osgiBundle);
- execute(realizedFlow);
}
protected synchronized ExecutionFlowDescriptorConverter getExecutionFlowDescriptorConverter(
}
}
- 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 ModuleDescriptor getModuleDescriptor(String moduleName,
String version) {
return getExecutionModuleDescriptor(moduleName, version);
executionContexts.put(osgiBundle, executionContext);
if (log.isTraceEnabled())
log.debug("Registered execution context from " + osgiBundle);
+ // Notify
+ for (ExecutionModulesListener listener : getExecutionModulesListeners())
+ listener.executionModuleAdded(osgiBundle, executionContext);
+
} else if (service instanceof ExecutionFlow) {
ExecutionFlow executionFlow = (ExecutionFlow) service;
OsgiBundle osgiBundle = asOsgiBundle(properties);
log
.debug("Registered " + executionFlow + " from "
+ osgiBundle);
+ for (ExecutionModulesListener listener : getExecutionModulesListeners())
+ listener.executionFlowAdded(osgiBundle, executionFlow);
} else if (service instanceof ExecutionFlowDescriptorConverter) {
ExecutionFlowDescriptorConverter executionFlowDescriptorConverter = (ExecutionFlowDescriptorConverter) service;
if (service instanceof ExecutionContext) {
OsgiBundle osgiBundle = asOsgiBundle(properties);
if (executionContexts.containsKey(osgiBundle)) {
- executionContexts.remove(osgiBundle);
+ ExecutionContext executionContext = executionContexts
+ .remove(osgiBundle);
if (log.isTraceEnabled())
log.debug("Removed execution context from " + osgiBundle);
+ // Notify
+ for (ExecutionModulesListener listener : getExecutionModulesListeners())
+ listener.executionModuleRemoved(osgiBundle,
+ executionContext);
}
} else if (service instanceof ExecutionFlow) {
ExecutionFlow executionFlow = (ExecutionFlow) service;
if (log.isTraceEnabled())
log.debug("Removed flows set from " + osgiBundle);
}
+ for (ExecutionModulesListener listener : getExecutionModulesListeners())
+ listener.executionFlowRemoved(osgiBundle, executionFlow);
}
} else if (service instanceof ExecutionFlowDescriptorConverter) {
OsgiBundle osgiBundle = asOsgiBundle(properties);