You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/02/08 09:05:30 UTC

[2/2] git commit: CAMEL-7182: Do not throw checked exception in camel-guice as not allowed for pre/post constructs.

CAMEL-7182: Do not throw checked exception in camel-guice as not allowed for pre/post constructs.


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

Branch: refs/heads/master
Commit: cbed0690f906f912d6fa96fb4b70a25c4fd6e417
Parents: 9e47c92
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Feb 8 09:05:45 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Feb 8 09:05:45 2014 +0100

----------------------------------------------------------------------
 .../apache/camel/guice/GuiceCamelContext.java   | 28 ++++++++++++++------
 1 file changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/cbed0690/components/camel-guice/src/main/java/org/apache/camel/guice/GuiceCamelContext.java
----------------------------------------------------------------------
diff --git a/components/camel-guice/src/main/java/org/apache/camel/guice/GuiceCamelContext.java b/components/camel-guice/src/main/java/org/apache/camel/guice/GuiceCamelContext.java
index bb2bf59..7059f0f 100644
--- a/components/camel-guice/src/main/java/org/apache/camel/guice/GuiceCamelContext.java
+++ b/components/camel-guice/src/main/java/org/apache/camel/guice/GuiceCamelContext.java
@@ -29,7 +29,6 @@ import com.google.inject.Inject;
 
 import org.apache.camel.ErrorHandlerFactory;
 import org.apache.camel.RoutesBuilder;
-import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.TypeConverter;
 import org.apache.camel.guice.impl.GuiceInjector;
 import org.apache.camel.guice.inject.Injectors;
@@ -41,6 +40,7 @@ import org.apache.camel.spi.InterceptStrategy;
 import org.apache.camel.spi.LanguageResolver;
 import org.apache.camel.spi.LifecycleStrategy;
 import org.apache.camel.spi.Registry;
+import org.apache.camel.util.ObjectHelper;
 
 /**
  * The default CamelContext implementation for working with Guice.
@@ -60,20 +60,32 @@ public class GuiceCamelContext extends DefaultCamelContext {
 
     @PostConstruct
     @Override
-    public void start() throws Exception {
-        super.start();
+    public void start() {
+        try {
+            super.start();
+        } catch (Exception e) {
+            throw ObjectHelper.wrapRuntimeCamelException(e);
+        }
     }
 
     @PreDestroy
     @Override
-    public void stop() throws Exception {
-        super.stop();
+    public void stop() {
+        try {
+            super.stop();
+        } catch (Exception e) {
+            throw ObjectHelper.wrapRuntimeCamelException(e);
+        }
     }
 
     @Inject
-    public void setRouteBuilders(Set<RoutesBuilder> routeBuilders) throws Exception {
+    public void setRouteBuilders(Set<RoutesBuilder> routeBuilders) {
         for (RoutesBuilder builder : routeBuilders) {
-            addRoutes(builder);
+            try {
+                addRoutes(builder);
+            } catch (Exception e) {
+                throw ObjectHelper.wrapRuntimeCamelException(e);
+            }
         }
     }
 
@@ -157,7 +169,7 @@ public class GuiceCamelContext extends DefaultCamelContext {
                 return injector.getInstance(Context.class);
             }
         } catch (Exception e) {
-            throw new RuntimeCamelException(e);
+            throw ObjectHelper.wrapRuntimeCamelException(e);
         }
     }