camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [3/8] git commit: beforeStop on Main should do internal stop logic in independet method, as end users most likely wont call super when they override the method to do their custom logic.
Date Fri, 08 Nov 2013 14:18:10 GMT
beforeStop on Main should do internal stop logic in independet method, as end users most likely
wont call super when they override the method to do their custom logic.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/85e00fed
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/85e00fed
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/85e00fed

Branch: refs/heads/master
Commit: 85e00fed904f745495bd8ef2e2da9258d593a049
Parents: 6eec501
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Nov 8 15:18:11 2013 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Nov 8 15:18:11 2013 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/camel/main/MainSupport.java | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/85e00fed/camel-core/src/main/java/org/apache/camel/main/MainSupport.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/main/MainSupport.java b/camel-core/src/main/java/org/apache/camel/main/MainSupport.java
index e040f9f..2a3498f 100644
--- a/camel-core/src/main/java/org/apache/camel/main/MainSupport.java
+++ b/camel-core/src/main/java/org/apache/camel/main/MainSupport.java
@@ -149,6 +149,7 @@ public abstract class MainSupport extends ServiceSupport {
             try {
                 afterStart();
                 waitUntilCompleted();
+                internalBeforeStop();
                 beforeStop();
                 stop();
             } catch (Exception e) {
@@ -178,9 +179,17 @@ public abstract class MainSupport extends ServiceSupport {
      * Callback to run custom logic before CamelContext is being stopped.
      */
     protected void beforeStop() throws Exception {
-        if (camelTemplate != null) {
-            ServiceHelper.stopService(camelTemplate);
-            camelTemplate = null;
+        // noop
+    }
+
+    private void internalBeforeStop() {
+        try {
+            if (camelTemplate != null) {
+                ServiceHelper.stopService(camelTemplate);
+                camelTemplate = null;
+            }
+        } catch (Exception e) {
+            LOG.debug("Error stopping camelTemplate due " + e.getMessage() + ". This exception
is ignored.", e);
         }
     }
 


Mime
View raw message