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