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 static Log log
= LogFactory
22 .getLog(AbstractExecutionFlowGenerator
.class);
24 protected abstract Map
<String
, BeanDefinition
> createExecutionFlowDefinitions(
25 ConfigurableListableBeanFactory beanFactory
);
27 public void postProcessBeanFactory(
28 ConfigurableListableBeanFactory beanFactory
) throws BeansException
{
29 if (!(beanFactory
instanceof BeanDefinitionRegistry
)) {
30 throw new SlcException("Can only work on "
31 + BeanDefinitionRegistry
.class);
34 Map
<String
, BeanDefinition
> definitions
= createExecutionFlowDefinitions(beanFactory
);
36 for (String beanName
: definitions
.keySet()) {
37 if (log
.isDebugEnabled())
38 log
.debug("Registering execution flow " + beanName
);
39 ((BeanDefinitionRegistry
) beanFactory
).registerBeanDefinition(
40 beanName
, definitions
.get(beanName
));
44 protected GenericBeanDefinition
createDefaultFlowDefinition(
45 List
<Runnable
> executables
) {
46 GenericBeanDefinition bd
= new GenericBeanDefinition();
47 bd
.setBeanClass(DefaultExecutionFlow
.class);
49 MutablePropertyValues mpv
= new MutablePropertyValues();
50 mpv
.addPropertyValue("executables", executables
);
52 bd
.setPropertyValues(mpv
);
56 public int getOrder() {
57 return Ordered
.HIGHEST_PRECEDENCE
;