]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java
Fix SVN issues
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.simple / src / main / java / org / argeo / slc / core / execution / AbstractSpringExecutionModule.java
index 0d9770a453beff40feac0b2a668d635e42549c50..bca30d0ed2baa1c5715e641ce82c8bffae7aafd5 100644 (file)
@@ -1,17 +1,17 @@
 package org.argeo.slc.core.execution;
 
-import java.util.HashMap;
 import java.util.Map;
 import java.util.TreeMap;
 
 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;
@@ -19,20 +19,22 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.util.Assert;
 
-public abstract class AbstractSpringExecutionModule implements ExecutionModule,
-               ApplicationContextAware {
-       private ApplicationContext applicationContext;
+@Deprecated
+public abstract class AbstractSpringExecutionModule implements ExecutionModule
+                {
+/*
+       protected ApplicationContext applicationContext;
+
+       protected ExecutionContext executionContext;
+
+       protected ExecutionFlowDescriptorConverter descriptorConverter = new DefaultDescriptorConverter();
 
        public ExecutionModuleDescriptor getDescriptor() {
                ExecutionModuleDescriptor md = new ExecutionModuleDescriptor();
                md.setName(getName());
                md.setVersion(getVersion());
 
-               GenericBeanFactoryAccessor accessor = new GenericBeanFactoryAccessor(
-                               applicationContext);
-               Map<String, ExecutionFlow> executionFlows = accessor
-                               .getBeansOfType(ExecutionFlow.class);
-
+               Map<String, ExecutionFlow> executionFlows = listFlows();
                for (String name : executionFlows.keySet()) {
                        ExecutionFlow executionFlow = executionFlows.get(name);
 
@@ -67,6 +69,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());
@@ -77,11 +86,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);
                }
@@ -89,21 +100,35 @@ public abstract class AbstractSpringExecutionModule implements ExecutionModule,
                return md;
        }
 
-       public void execute(SlcExecution slcExecution) {
-               applicationContext.publishEvent(new NewExecutionEvent(this,
-                               slcExecution));
+       protected Map<String, ExecutionFlow> listFlows() {
+               GenericBeanFactoryAccessor accessor = new GenericBeanFactoryAccessor(
+                               applicationContext);
+               Map<String, ExecutionFlow> executionFlows = accessor
+                               .getBeansOfType(ExecutionFlow.class);
+               return executionFlows;
        }
-       
-       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;
+       }*/
+
 }