1 package org
.argeo
.slc
.core
.execution
;
3 import java
.util
.HashMap
;
6 import org
.argeo
.slc
.execution
.ExecutionFlow
;
7 import org
.argeo
.slc
.execution
.ExecutionFlowDescriptor
;
8 import org
.argeo
.slc
.execution
.ExecutionModule
;
9 import org
.argeo
.slc
.execution
.ExecutionModuleDescriptor
;
10 import org
.argeo
.slc
.execution
.ExecutionSpec
;
11 import org
.argeo
.slc
.execution
.ExecutionSpecAttribute
;
12 import org
.argeo
.slc
.process
.SlcExecution
;
13 import org
.springframework
.beans
.BeansException
;
14 import org
.springframework
.beans
.factory
.generic
.GenericBeanFactoryAccessor
;
15 import org
.springframework
.context
.ApplicationContext
;
16 import org
.springframework
.context
.ApplicationContextAware
;
17 import org
.springframework
.util
.Assert
;
19 public abstract class AbstractSpringExecutionModule
implements ExecutionModule
,
20 ApplicationContextAware
{
21 private ApplicationContext applicationContext
;
23 public ExecutionModuleDescriptor
getDescriptor() {
24 ExecutionModuleDescriptor md
= new ExecutionModuleDescriptor();
25 md
.setName(getName());
26 md
.setVersion(getVersion());
28 GenericBeanFactoryAccessor accessor
= new GenericBeanFactoryAccessor(
30 Map
<String
, ExecutionFlow
> executionFlows
= accessor
31 .getBeansOfType(ExecutionFlow
.class);
33 for (String name
: executionFlows
.keySet()) {
34 ExecutionFlow executionFlow
= executionFlows
.get(name
);
36 Assert
.notNull(executionFlow
.getName());
37 Assert
.state(name
.equals(executionFlow
.getName()));
39 ExecutionSpec executionSpec
= executionFlow
.getExecutionSpec();
40 Assert
.notNull(executionSpec
);
41 Assert
.notNull(executionSpec
.getName());
43 Map
<String
, Object
> values
= new HashMap
<String
, Object
>();
44 for (String key
: executionSpec
.getAttributes().keySet()) {
45 ExecutionSpecAttribute attribute
= executionSpec
46 .getAttributes().get(key
);
47 if (attribute
instanceof SimpleExecutionSpec
48 && attribute
.getIsParameter()) {
49 values
.put(key
, executionFlow
.getParameter(key
));
53 ExecutionFlowDescriptor efd
= new ExecutionFlowDescriptor(name
,
54 values
, executionSpec
);
56 if (!md
.getExecutionSpecs().contains(executionSpec
))
57 md
.getExecutionSpecs().add(executionSpec
);
58 md
.getExecutionFlows().add(efd
);
64 public void execute(SlcExecution slcExecution
) {
65 applicationContext
.publishEvent(new NewExecutionEvent(this,
69 public void setApplicationContext(ApplicationContext applicationContext
)
70 throws BeansException
{
71 this.applicationContext
= applicationContext
;