camel-commits mailing list archives

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

Branch: refs/heads/camel-2.12.x
Commit: e771d52c51a8cf0ebd8226c0251fccddf58d6e6f
Parents: 0717340
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:50 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/e771d52c/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