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
);
28 public void postProcessBeanFactory(
29 ConfigurableListableBeanFactory beanFactory
) throws BeansException
{
30 if (!(beanFactory
instanceof BeanDefinitionRegistry
)) {
31 throw new SlcException("Can only work on "
32 + BeanDefinitionRegistry
.class);
35 Map
<String
, BeanDefinition
> definitions
= createExecutionFlowDefinitions(beanFactory
);
37 for (String beanName
: definitions
.keySet()) {
38 if (log
.isDebugEnabled())
39 log
.debug("Registering execution flow " + beanName
);
40 ((BeanDefinitionRegistry
) beanFactory
).registerBeanDefinition(
41 beanName
, definitions
.get(beanName
));
45 protected GenericBeanDefinition
createDefaultFlowDefinition(
46 List
<Runnable
> executables
) {
47 GenericBeanDefinition bd
= new GenericBeanDefinition();
48 bd
.setBeanClass(DefaultExecutionFlow
.class);
50 MutablePropertyValues mpv
= new MutablePropertyValues();
51 mpv
.addPropertyValue("executables", executables
);
53 bd
.setPropertyValues(mpv
);
58 public int getOrder() {
59 return Ordered
.HIGHEST_PRECEDENCE
;