1 package org
.argeo
.slc
.core
.execution
;
6 import org
.apache
.commons
.logging
.Log
;
7 import org
.apache
.commons
.logging
.LogFactory
;
8 import org
.argeo
.slc
.SlcException
;
9 import org
.springframework
.beans
.BeansException
;
10 import org
.springframework
.beans
.MutablePropertyValues
;
11 import org
.springframework
.beans
.factory
.config
.BeanDefinition
;
12 import org
.springframework
.beans
.factory
.config
.BeanFactoryPostProcessor
;
13 import org
.springframework
.beans
.factory
.config
.ConfigurableListableBeanFactory
;
14 import org
.springframework
.beans
.factory
.support
.BeanDefinitionRegistry
;
15 import org
.springframework
.beans
.factory
.support
.GenericBeanDefinition
;
16 import org
.springframework
.core
.Ordered
;
17 import org
.springframework
.core
.PriorityOrdered
;
19 public abstract class AbstractExecutionFlowGenerator
implements
20 BeanFactoryPostProcessor
, PriorityOrdered
{
21 private final Log log
= LogFactory
.getLog(getClass());
23 protected abstract Map
<String
, BeanDefinition
> createExecutionFlowDefinitions(
24 ConfigurableListableBeanFactory beanFactory
);
26 public void postProcessBeanFactory(
27 ConfigurableListableBeanFactory beanFactory
) throws BeansException
{
28 if (!(beanFactory
instanceof BeanDefinitionRegistry
)) {
29 throw new SlcException("Can only work on "
30 + BeanDefinitionRegistry
.class);
33 Map
<String
, BeanDefinition
> definitions
= createExecutionFlowDefinitions(beanFactory
);
35 for (String beanName
: definitions
.keySet()) {
36 if (log
.isTraceEnabled())
37 log
.debug("Registering execution flow " + beanName
);
38 ((BeanDefinitionRegistry
) beanFactory
).registerBeanDefinition(
39 beanName
, definitions
.get(beanName
));
43 protected GenericBeanDefinition
createDefaultFlowDefinition(
44 List
<Runnable
> executables
) {
45 GenericBeanDefinition bd
= new GenericBeanDefinition();
46 bd
.setBeanClass(DefaultExecutionFlow
.class);
48 MutablePropertyValues mpv
= new MutablePropertyValues();
49 mpv
.addPropertyValue("executables", executables
);
51 bd
.setPropertyValues(mpv
);
55 public int getOrder() {
56 return Ordered
.HIGHEST_PRECEDENCE
;