]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/SimpleExecutionSpec.java
ActiveMQ and Castor integration
[gpl/argeo-slc.git] / runtime / org.argeo.slc.execution / src / main / java / org / argeo / slc / execution / SimpleExecutionSpec.java
index 8d460ff2c22c6c301bf11fc4a571a8fec2790242..d6d0518802182221301f1ee52f845170849b3504 100644 (file)
@@ -3,11 +3,14 @@ package org.argeo.slc.execution;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.argeo.slc.SlcException;
-import org.springframework.aop.framework.ProxyFactory;
 import org.springframework.beans.factory.BeanNameAware;
 
 public class SimpleExecutionSpec implements ExecutionSpec, BeanNameAware {
+       private final static Log log = LogFactory.getLog(SimpleExecutionSpec.class);
+
        private final static ThreadLocal<ExecutionFlow> initializingFlow = new ThreadLocal<ExecutionFlow>();
 
        private Map<String, ExecutionSpecAttribute> attributes = new HashMap<String, ExecutionSpecAttribute>();
@@ -27,18 +30,18 @@ public class SimpleExecutionSpec implements ExecutionSpec, BeanNameAware {
                if (flow == null)
                        throw new SlcException("No flow is currently initializing."
                                        + " Declare flow refs as inner beans or prototypes.");
-
-               RefSpecAttribute refSpecAttribute = (RefSpecAttribute) attributes
-                               .get(name);
-               Class<?> targetClass = refSpecAttribute.getTargetClass();
-               ExecutionTargetSource targetSource = new ExecutionTargetSource(flow,
-                               targetClass, name);
-               ProxyFactory proxyFactory = new ProxyFactory();
-               proxyFactory.setTargetClass(targetClass);
-               proxyFactory.setProxyTargetClass(true);
-               proxyFactory.setTargetSource(targetSource);
-
-               return proxyFactory.getProxy();
+               /*
+                * RefSpecAttribute refSpecAttribute = (RefSpecAttribute) attributes
+                * .get(name); Class<?> targetClass = refSpecAttribute.getTargetClass();
+                * ExecutionTargetSource targetSource = new ExecutionTargetSource(flow,
+                * targetClass, name); ProxyFactory proxyFactory = new ProxyFactory();
+                * proxyFactory.setTargetClass(targetClass);
+                * proxyFactory.setProxyTargetClass(true);
+                * proxyFactory.setTargetSource(targetSource);
+                * 
+                * return proxyFactory.getProxy();
+                */
+               return flow.getParameter(name);
        }
 
        public void setBeanName(String name) {
@@ -49,17 +52,25 @@ public class SimpleExecutionSpec implements ExecutionSpec, BeanNameAware {
                return name;
        }
 
+       // FLOWS INITIALIZATION SUPPORT
+
        public static void flowInitializationStarted(ExecutionFlow flow) {
+               if (log.isTraceEnabled())
+                       log.trace("Start initialization of " + flow.hashCode() + " ("
+                                       + flow + " - " + flow.getClass() + ")");
                initializingFlow.set(flow);
        }
 
        public static void flowInitializationFinished(ExecutionFlow flow) {
+               if (log.isTraceEnabled())
+                       log.trace("Finish initialization of " + flow.hashCode() + " ("
+                                       + flow + " - " + flow.getClass() + ")");
                ExecutionFlow registeredFlow = initializingFlow.get();
-               if (registeredFlow == null)
-                       throw new SlcException("No flow registered");
-               if (!flow.getUuid().equals(registeredFlow.getUuid()))
-                       throw new SlcException("Current flow is " + flow);
-               initializingFlow.set(null);
+               if (registeredFlow != null) {
+                       if (!flow.getName().equals(registeredFlow.getName()))
+                               throw new SlcException("Current flow is " + flow);
+                       initializingFlow.set(null);
+               }
        }
 
        public static Object getInitializingFlowParameter(String key) {
@@ -71,4 +82,9 @@ public class SimpleExecutionSpec implements ExecutionSpec, BeanNameAware {
        public static Boolean isInFlowInitialization() {
                return initializingFlow.get() != null;
        }
+
+       public boolean equals(Object obj) {
+               return ((ExecutionSpec) obj).getName().equals(name);
+       }
+
 }