X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=cms%2Forg.argeo.slc.spring%2Fsrc%2Forg%2Fargeo%2Fslc%2Fcore%2Fexecution%2FAbstractSpringExecutionModule.java;fp=cms%2Forg.argeo.slc.spring%2Fsrc%2Forg%2Fargeo%2Fslc%2Fcore%2Fexecution%2FAbstractSpringExecutionModule.java;h=366b8d4896a6c6ca2db5e0504e180fdf924794eb;hb=ecc22e604e47533c79de9cecdcdeacbc752cbff1;hp=0000000000000000000000000000000000000000;hpb=e07ded4632e53f8b8869763bc1f1f4091361e76e;p=gpl%2Fargeo-slc.git diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java new file mode 100644 index 000000000..366b8d489 --- /dev/null +++ b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java @@ -0,0 +1,117 @@ +package org.argeo.slc.core.execution; + +import org.argeo.slc.execution.ExecutionModule; + +@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()); + + Map executionFlows = listFlows(); + for (String name : executionFlows.keySet()) { + ExecutionFlow executionFlow = executionFlows.get(name); + + Assert.notNull(executionFlow.getName()); + Assert.state(name.equals(executionFlow.getName())); + + ExecutionSpec executionSpec = executionFlow.getExecutionSpec(); + Assert.notNull(executionSpec); + Assert.notNull(executionSpec.getName()); + + Map values = new TreeMap(); + for (String key : executionSpec.getAttributes().keySet()) { + ExecutionSpecAttribute attribute = executionSpec + .getAttributes().get(key); + + if (executionFlow.isSetAsParameter(key)) { + Object value = executionFlow.getParameter(key); + if (attribute instanceof PrimitiveSpecAttribute) { + PrimitiveValue primitiveValue = new PrimitiveValue(); + primitiveValue + .setType(((PrimitiveSpecAttribute) attribute) + .getType()); + primitiveValue.setValue(value); + values.put(key, primitiveValue); + } else if (attribute instanceof RefSpecAttribute) { + RefValue refValue = new RefValue(); + if (value instanceof ScopedObject) { + refValue.setLabel("RUNTIME " + + value.getClass().getName()); + } else { + refValue.setLabel("STATIC " + + 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()); + } + } + + } + + 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); + } + + return md; + } + + protected Map listFlows() { + GenericBeanFactoryAccessor accessor = new GenericBeanFactoryAccessor( + applicationContext); + Map executionFlows = accessor + .getBeansOfType(ExecutionFlow.class); + return executionFlows; + } + + 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; + }*/ + +}