]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/InstantiationManager.java
Minimal Hello World execution module
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / execution / InstantiationManager.java
index eb6ce53473407a258fb5f1a6af52401be5201eb8..af2763d66ace105a944a7d76119a485750ad20a8 100644 (file)
@@ -1,3 +1,19 @@
+/*\r
+ * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *         http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
 package org.argeo.slc.core.execution;\r
 \r
 import java.util.Stack;\r
@@ -26,14 +42,14 @@ public class InstantiationManager {
        }\r
 \r
        public void flowInitializationStarted(ExecutionFlow flow, String flowName) {\r
-               if (log.isTraceEnabled())\r
-                       log.trace("Start initialization of " + flow.hashCode() + " ("\r
-                                       + flow + " - " + flow.getClass() + ")");\r
-\r
                // set the flow name if it is DefaultExecutionFlow\r
                if (flow instanceof DefaultExecutionFlow) {\r
                        ((DefaultExecutionFlow) flow).setBeanName(flowName);\r
                }\r
+               \r
+               if (log.isTraceEnabled())\r
+                       log.trace("Start initialization of " + flow.hashCode() + " ("\r
+                                       + flow + " - " + flow.getClass() + ")");\r
 \r
                // log.info("# flowInitializationStarted " + flowName);\r
                // create a stack for this thread if there is none\r
@@ -47,12 +63,19 @@ public class InstantiationManager {
                if (log.isTraceEnabled())\r
                        log.trace("Finish initialization of " + flow.hashCode() + " ("\r
                                        + flow + " - " + flow.getClass() + ")");\r
-               ExecutionFlow registeredFlow = flowStack.get().pop();\r
-               if (registeredFlow != null) {\r
-                       if (!flow.getName().equals(registeredFlow.getName()))\r
-                               throw new SlcException("Current flow is " + flow);\r
-                       // log.info("# flowInitializationFinished " + flowName);\r
-                       // initializingFlow.set(null);\r
+               \r
+               if(flowStack.get() != null) {\r
+                       ExecutionFlow registeredFlow = flowStack.get().pop();\r
+                       if (registeredFlow != null) {\r
+                               if (!flow.getName().equals(registeredFlow.getName()))\r
+                                       throw new SlcException("Current flow is " + flow);\r
+                               // log.info("# flowInitializationFinished " + flowName);\r
+                               // initializingFlow.set(null);\r
+                       }\r
+               }\r
+               else {\r
+                       // happens for flows imported as services\r
+                       log.warn("flowInitializationFinished - Flow Stack is null");\r
                }\r
        }\r
 \r