camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [8/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:15 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/31fddb73
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/31fddb73
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/31fddb73

Branch: refs/heads/camel-2.11.x
Commit: 31fddb73c2c8045d64a7ff81f905d8a181a0eebc
Parents: c7117b7
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:19:13 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/31fddb73/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