X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.support.simple%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Fexecution%2FAbstractSpringExecutionModule.java;h=1bbf16821539b2a8ec06bcfc234274ebded757e1;hb=53146ebdda3a7c0c217c44d395d270a7e9d045be;hp=d51f63acb975eeb7e98201fdaab6be7e2027e757;hpb=ae98a7536a842021e433a43427db79a18abf3a6c;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java index d51f63acb..1bbf16821 100644 --- a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java +++ b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java @@ -1,6 +1,5 @@ package org.argeo.slc.core.execution; -import java.util.HashMap; import java.util.Map; import java.util.TreeMap; @@ -8,11 +7,11 @@ import org.argeo.slc.SlcException; import org.argeo.slc.execution.ExecutionContext; import org.argeo.slc.execution.ExecutionFlow; import org.argeo.slc.execution.ExecutionFlowDescriptor; +import org.argeo.slc.execution.ExecutionFlowDescriptorConverter; import org.argeo.slc.execution.ExecutionModule; import org.argeo.slc.execution.ExecutionModuleDescriptor; import org.argeo.slc.execution.ExecutionSpec; import org.argeo.slc.execution.ExecutionSpecAttribute; -import org.argeo.slc.process.SlcExecution; import org.springframework.aop.scope.ScopedObject; import org.springframework.beans.BeansException; import org.springframework.beans.factory.generic.GenericBeanFactoryAccessor; @@ -22,18 +21,12 @@ import org.springframework.util.Assert; public abstract class AbstractSpringExecutionModule implements ExecutionModule, ApplicationContextAware { - + private ApplicationContext applicationContext; private ExecutionContext executionContext; - - public ExecutionContext getExecutionContext() { - return executionContext; - } - public void setExecutionContext(ExecutionContext executionContext) { - this.executionContext = executionContext; - } + private ExecutionFlowDescriptorConverter descriptorConverter = new DefaultDescriptorConverter(); public ExecutionModuleDescriptor getDescriptor() { ExecutionModuleDescriptor md = new ExecutionModuleDescriptor(); @@ -79,6 +72,13 @@ public abstract class AbstractSpringExecutionModule implements ExecutionModule, + value.getClass().getName()); } values.put(key, refValue); + } else if (attribute instanceof ResourceSpecAttribute) { + PrimitiveValue primitiveValue = new PrimitiveValue(); + primitiveValue + .setType(((ResourceSpecAttribute) attribute) + .getType()); + primitiveValue.setValue(value); + values.put(key, primitiveValue); } else { throw new SlcException("Unkown spec attribute type " + attribute.getClass()); @@ -89,11 +89,13 @@ public abstract class AbstractSpringExecutionModule implements ExecutionModule, ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor(name, values, executionSpec); + if (executionFlow.getPath() != null) + efd.setPath(executionFlow.getPath()); // Add execution spec if necessary if (!md.getExecutionSpecs().contains(executionSpec)) md.getExecutionSpecs().add(executionSpec); - + // Add execution flow md.getExecutionFlows().add(efd); } @@ -101,21 +103,27 @@ public abstract class AbstractSpringExecutionModule implements ExecutionModule, return md; } - public void execute(SlcExecution slcExecution) { - applicationContext.publishEvent(new NewExecutionEvent(this, - slcExecution)); - } - - public void execute(ExecutionFlowDescriptor descriptor) { - ExecutionFlow flow = (ExecutionFlow) applicationContext.getBean(descriptor.getName(), - ExecutionFlow.class); - flow.execute(); + public void execute(ExecutionFlowDescriptor executionFlowDescriptor) { + if (descriptorConverter != null) + executionContext.addVariables(descriptorConverter + .convertValues(executionFlowDescriptor)); + ExecutionFlow flow = (ExecutionFlow) applicationContext.getBean( + executionFlowDescriptor.getName(), ExecutionFlow.class); + flow.run(); } - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } + public void setExecutionContext(ExecutionContext executionContext) { + this.executionContext = executionContext; + } + + public void setDescriptorConverter( + ExecutionFlowDescriptorConverter descriptorConverter) { + this.descriptorConverter = descriptorConverter; + } + }