1 package org
.argeo
.slc
.core
.execution
.generator
;
5 import org
.argeo
.slc
.SlcException
;
6 import org
.springframework
.beans
.factory
.support
.BeanDefinitionRegistry
;
9 * Composite <code>RunnableFactory</code>, redirecting the Runnable
10 * creation to on of the configured <code>RunnableFactory</code> depending
11 * on an entry of the data of the <code>RunnableDataNode</code>.
13 public class CompositeRunnableFactory
implements RunnableFactory
{
16 * Key used to access factory ID in the data of the <code>RunnableDataNode</code>
18 private String factoryKey
;
21 * Maps a factory ID to an ExecutionFlowFactory
23 private Map
<String
, RunnableFactory
> factories
;
25 public void createAndRegisterRunnable(RunnableDataNode node
,
26 BeanDefinitionRegistry beanDefinitionRegistry
) {
27 findFactory(node
).createAndRegisterRunnable(node
, beanDefinitionRegistry
);
31 * Finds the <code>RunnableFactory</code> to use for a <code>RunnableDataNode</code>
33 * @return the <code>RunnableFactory</code> to use for the <code>RunnableDataNode</code>
35 private RunnableFactory
findFactory(RunnableDataNode node
) {
36 // get the factory ID from the data of the RunnableDescriptor
37 Map
<String
, Object
> data
= node
.getData();
38 if (!data
.containsKey(factoryKey
)) {
39 throw new SlcException("No data value for key '" + factoryKey
+ "'");
41 String factoryId
= data
.get(factoryKey
).toString();
43 // see if we have a factory for the factory ID
44 if ((factories
!= null) && factories
.containsKey(factoryId
)) {
45 return factories
.get(factoryId
);
47 // if not, look for a bean of name equals to the factory ID
49 throw new SlcException("Not implemented");
53 public void setFactoryKey(String factoryKey
) {
54 this.factoryKey
= factoryKey
;
57 public void setFactories(Map
<String
, RunnableFactory
> factories
) {
58 this.factories
= factories
;