You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by js...@apache.org on 2006/08/24 19:52:47 UTC

svn commit: r434446 - in /incubator/servicemix/trunk/servicemix-beanflow/src: main/java/org/apache/servicemix/beanflow/JoinSupport.java main/java/org/apache/servicemix/beanflow/Workflow.java test/java/org/apache/servicemix/beanflow/JoinTest.java

Author: jstrachan
Date: Thu Aug 24 10:52:46 2006
New Revision: 434446

URL: http://svn.apache.org/viewvc?rev=434446&view=rev
Log:
simplified the code a little in an attempt to remove some occasional timing issues we have

Modified:
    incubator/servicemix/trunk/servicemix-beanflow/src/main/java/org/apache/servicemix/beanflow/JoinSupport.java
    incubator/servicemix/trunk/servicemix-beanflow/src/main/java/org/apache/servicemix/beanflow/Workflow.java
    incubator/servicemix/trunk/servicemix-beanflow/src/test/java/org/apache/servicemix/beanflow/JoinTest.java

Modified: incubator/servicemix/trunk/servicemix-beanflow/src/main/java/org/apache/servicemix/beanflow/JoinSupport.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-beanflow/src/main/java/org/apache/servicemix/beanflow/JoinSupport.java?rev=434446&r1=434445&r2=434446&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-beanflow/src/main/java/org/apache/servicemix/beanflow/JoinSupport.java (original)
+++ incubator/servicemix/trunk/servicemix-beanflow/src/main/java/org/apache/servicemix/beanflow/JoinSupport.java Thu Aug 24 10:52:46 2006
@@ -33,16 +33,20 @@
     }
 
     public JoinSupport(List<Activity> activities) {
-        for (Activity activity : activities) {
-            activity.getState().addRunnable(this);
-            children.add(activity);
+        synchronized (children) {
+            for (Activity activity : activities) {
+                activity.getState().addRunnable(this);
+                children.add(activity);
+            }
         }
     }
 
     public JoinSupport(Activity... activities) {
-        for (Activity activity : activities) {
-            activity.getState().addRunnable(this);
-            children.add(activity);
+        synchronized (children) {
+            for (Activity activity : activities) {
+                activity.getState().addRunnable(this);
+                children.add(activity);
+            }
         }
     }
 

Modified: incubator/servicemix/trunk/servicemix-beanflow/src/main/java/org/apache/servicemix/beanflow/Workflow.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-beanflow/src/main/java/org/apache/servicemix/beanflow/Workflow.java?rev=434446&r1=434445&r2=434446&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-beanflow/src/main/java/org/apache/servicemix/beanflow/Workflow.java (original)
+++ incubator/servicemix/trunk/servicemix-beanflow/src/main/java/org/apache/servicemix/beanflow/Workflow.java Thu Aug 24 10:52:46 2006
@@ -91,32 +91,28 @@
 
     public void run() {
         if (!isSuspended() && !isStopped()) {
-            T stepToExecute = null;
-            if (nextStep != null) {
-                stepToExecute = nextStep;
-                nextStep = null;
-                // lets fire any conditions
-                // This very function is a listener of step, so setting the step
-                // will trigger ourself.  We just need to return now.
-                step.set(stepToExecute);
-                return;
-            }
-            else {
-                stepToExecute = step.get();
-            }
-            if (log.isDebugEnabled()) {
-                log.debug("About to execute step: " + stepToExecute);
-            }
-            
+            T stepToExecute = step.get();
             if (stepToExecute != null) {
+                if (log.isDebugEnabled()) {
+                    log.debug("About to execute step: " + stepToExecute);
+                }
+                
                 interpreter.executeStep(stepToExecute, this);
-
                 nextStep();
             }
         }
     }
 
     public void nextStep() {
+        if (nextStep != null) {
+            T stepToExecute = nextStep;
+            nextStep = null;
+            // lets fire any conditions
+            // This very function is a listener of step, so setting the step
+            // will trigger ourself.  We just need to return now.
+            step.set(stepToExecute);
+        }
+
         // if we are not stopped lets add a task to re-evaluate ourself
         if (!isStopped() && !isSuspended()) {
             executor.execute(this);
@@ -195,7 +191,7 @@
 
             public void run() {
                 setNextStep(joinedStep);
-                nextStep();
+                //nextStep();
             }
         };
     }

Modified: incubator/servicemix/trunk/servicemix-beanflow/src/test/java/org/apache/servicemix/beanflow/JoinTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-beanflow/src/test/java/org/apache/servicemix/beanflow/JoinTest.java?rev=434446&r1=434445&r2=434446&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-beanflow/src/test/java/org/apache/servicemix/beanflow/JoinTest.java (original)
+++ incubator/servicemix/trunk/servicemix-beanflow/src/test/java/org/apache/servicemix/beanflow/JoinTest.java Thu Aug 24 10:52:46 2006
@@ -20,8 +20,6 @@
 
 import java.util.concurrent.TimeUnit;
 
-import junit.framework.TestCase;
-
 /**
  * 
  * @version $Revision$