camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r582282 - in /activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component: seda/SedaConsumer.java vm/VmComponent.java
Date Fri, 05 Oct 2007 14:12:54 GMT
Author: chirino
Date: Fri Oct  5 07:12:53 2007
New Revision: 582282

URL: http://svn.apache.org/viewvc?rev=582282&view=rev
Log:
Some small enhancements suggested by William Tam

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/vm/VmComponent.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java?rev=582282&r1=582281&r2=582282&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
Fri Oct  5 07:12:53 2007
@@ -50,7 +50,7 @@
     }
 
     public void run() {
-        while (!isStopping()) {
+        while (!isStopping() && !isStopped()) {
             final Exchange exchange;
             try {
                 exchange = endpoint.getQueue().poll(1000, TimeUnit.MILLISECONDS);

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/vm/VmComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/vm/VmComponent.java?rev=582282&r1=582281&r2=582282&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/vm/VmComponent.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/vm/VmComponent.java
Fri Oct  5 07:12:53 2007
@@ -19,6 +19,7 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
@@ -34,6 +35,8 @@
  * @version $Revision: 1.1 $
  */
 public class VmComponent extends SedaComponent {
+    
+    private static final AtomicInteger START_COUNTER = new AtomicInteger();
     protected static Map<String, BlockingQueue> queues = new HashMap<String, BlockingQueue>();
 
     @Override
@@ -52,4 +55,24 @@
             return answer;
         }
     }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        START_COUNTER.incrementAndGet();
+    }
+    
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        if (START_COUNTER.decrementAndGet() == 0) {
+            synchronized (queues) {
+                for (BlockingQueue q : queues.values()) {
+                    q.clear();
+                }
+                queues.clear();
+            }
+        }
+    }
+
 }



Mime
View raw message