1 package org
.argeo
.slc
.executionflow
;
3 import java
.util
.HashMap
;
6 import org
.argeo
.slc
.SlcException
;
7 import org
.springframework
.aop
.framework
.ProxyFactory
;
8 import org
.springframework
.beans
.factory
.BeanNameAware
;
10 public class SimpleExecutionSpec
implements ExecutionSpec
, BeanNameAware
{
11 private final static ThreadLocal
<ExecutionFlow
> initializingFlow
= new ThreadLocal
<ExecutionFlow
>();
13 private Map
<String
, ExecutionSpecAttribute
> attributes
= new HashMap
<String
, ExecutionSpecAttribute
>();
15 private String name
= null;
17 public Map
<String
, ExecutionSpecAttribute
> getAttributes() {
21 public void setAttributes(Map
<String
, ExecutionSpecAttribute
> attributes
) {
22 this.attributes
= attributes
;
25 public Object
createRef(String name
) {
26 ExecutionFlow flow
= initializingFlow
.get();
28 throw new SlcException("No flow is currently initializing."
29 + " Declare flow refs as inner beans or prototypes.");
31 RefSpecAttribute refSpecAttribute
= (RefSpecAttribute
) attributes
33 Class
<?
> targetClass
= refSpecAttribute
.getTargetClass();
34 ExecutionTargetSource targetSource
= new ExecutionTargetSource(flow
,
36 ProxyFactory proxyFactory
= new ProxyFactory();
37 proxyFactory
.setTargetClass(targetClass
);
38 proxyFactory
.setProxyTargetClass(true);
39 proxyFactory
.setTargetSource(targetSource
);
41 return proxyFactory
.getProxy();
44 public void setBeanName(String name
) {
48 public String
getName() {
52 public static void flowInitializationStarted(ExecutionFlow flow
) {
53 initializingFlow
.set(flow
);
56 public static void flowInitializationFinished(ExecutionFlow flow
) {
57 ExecutionFlow registeredFlow
= initializingFlow
.get();
58 if (registeredFlow
== null)
59 throw new SlcException("No flow registered");
60 if (!flow
.getUuid().equals(registeredFlow
.getUuid()))
61 throw new SlcException("Current flow is " + flow
);
62 initializingFlow
.set(null);