camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r582309 - in /activemq/camel/trunk/camel-core/src/main/java/org/apache/camel: component/seda/ impl/ processor/
Date Fri, 05 Oct 2007 15:16:03 GMT
Author: chirino
Date: Fri Oct  5 08:16:00 2007
New Revision: 582309

URL: http://svn.apache.org/viewvc?rev=582309&view=rev
Log:
Added a isRunAllowed() method to ServiceSupport to make it eaiser for derived 
classes to know when it should continue to process messages.

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/impl/EventDrivenPollingConsumer.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DelayProcessorSupport.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=582309&r1=582308&r2=582309&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 08:16:00 2007
@@ -50,14 +50,14 @@
     }
 
     public void run() {
-        while (!isStopping() && !isStopped()) {
+        while (isRunAllowed()) {
             final Exchange exchange;
             try {
                 exchange = endpoint.getQueue().poll(1000, TimeUnit.MILLISECONDS);
             } catch (InterruptedException e) {
                 break;
             }
-            if (exchange != null && !isStopping()) {
+            if (exchange != null && isRunAllowed()) {
                 processor.process(exchange, new AsyncCallback() {
                     public void done(boolean sync) {
                     }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/EventDrivenPollingConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/EventDrivenPollingConsumer.java?rev=582309&r1=582308&r2=582309&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/EventDrivenPollingConsumer.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/EventDrivenPollingConsumer.java
Fri Oct  5 08:16:00 2007
@@ -58,7 +58,7 @@
     }
 
     public E receive() {
-        while (!isStopping() && !isStopped()) {
+        while (isRunAllowed()) {
             try {
                 return queue.take();
             } catch (InterruptedException e) {

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java?rev=582309&r1=582308&r2=582309&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java
Fri Oct  5 08:16:00 2007
@@ -94,6 +94,16 @@
     }
 
     /**
+     * Helper methods so the service knows if it should keep running.  Returns
+     * false if the service is being stopped or is stopped.
+     *  
+     * @return true if the service should continue to run.
+     */
+    protected boolean isRunAllowed() {
+        return !(stopping.get() || stopped.get());
+    }
+
+    /**
      * @return true if this service is closed
      */
     public boolean isStopped() {

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java?rev=582309&r1=582308&r2=582309&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
Fri Oct  5 08:16:00 2007
@@ -62,7 +62,7 @@
 
     public void run() {
         LOG.debug("Starting thread for " + this);
-        while (!isStopped() && !isStopping()) {
+        while (isRunAllowed()) {
             try {
                 processBatch();
             } catch (Exception e) {

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java?rev=582309&r1=582308&r2=582309&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
Fri Oct  5 08:16:00 2007
@@ -91,7 +91,7 @@
         while (true) {
             
             // We can't keep retrying if the route is being shutdown.
-            if (isStopping() || isStopped()) {
+            if (!isRunAllowed()) {
                 if (exchange.getException() == null) {
                     exchange.setException(new RejectedExecutionException());
                 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DelayProcessorSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DelayProcessorSupport.java?rev=582309&r1=582308&r2=582309&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DelayProcessorSupport.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DelayProcessorSupport.java
Fri Oct  5 08:16:00 2007
@@ -78,7 +78,7 @@
             if (delay < 0) {
                 return;
             } else {
-                if (isFastStop() && (isStopped() || isStopping())) {
+                if (isFastStop() && !isRunAllowed()) {
                     throw new AlreadyStoppedException();
                 }
                 try {



Mime
View raw message