camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1156271 - in /camel/branches/camel-2.8.x: ./ camel-core/src/main/java/org/apache/camel/model/ tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/ tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi...
Date Wed, 10 Aug 2011 17:31:01 GMT
Author: davsclaus
Date: Wed Aug 10 17:31:01 2011
New Revision: 1156271

URL: http://svn.apache.org/viewvc?rev=1156271&view=rev
Log:
Merged revisions 1156260 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk


Added:
    camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint5Test.java
      - copied unchanged from r1156260, camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint5Test.java
    camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/MyException.java
      - copied unchanged from r1156260, camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/MyException.java
    camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-23.xml
      - copied unchanged from r1156260, camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-23.xml
Modified:
    camel/branches/camel-2.8.x/   (props changed)
    camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/model/CatchDefinition.java

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Aug 10 17:31:01 2011
@@ -1 +1 @@
-/camel/trunk:1155230,1156108
+/camel/trunk:1155230,1156108,1156260

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Aug 10 17:31:01 2011
@@ -1 +1 @@
-/camel/trunk:1-1148091,1149488,1153146,1153323,1155229-1155231,1155233-1155276,1155278-1155291,1155293-1155318,1155320-1155327,1156108
+/camel/trunk:1-1148091,1149488,1153146,1153323,1155229-1155231,1155233-1155276,1155278-1155291,1155293-1155318,1155320-1155327,1156108,1156260

Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/model/CatchDefinition.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/model/CatchDefinition.java?rev=1156271&r1=1156270&r2=1156271&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/model/CatchDefinition.java
(original)
+++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/model/CatchDefinition.java
Wed Aug 10 17:31:01 2011
@@ -26,6 +26,7 @@ import javax.xml.bind.annotation.XmlElem
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Expression;
 import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
@@ -33,7 +34,6 @@ import org.apache.camel.builder.Expressi
 import org.apache.camel.processor.CatchProcessor;
 import org.apache.camel.spi.RouteContext;
 import org.apache.camel.util.CastUtils;
-import org.apache.camel.util.ObjectHelper;
 import static org.apache.camel.builder.PredicateBuilder.toPredicate;
 
 /**
@@ -86,8 +86,13 @@ public class CatchDefinition extends Pro
 
     @Override
     public CatchProcessor createProcessor(RouteContext routeContext) throws Exception {
+        // create and load exceptions if not done
+        if (exceptionClasses == null) {
+            exceptionClasses = createExceptionClasses(routeContext.getCamelContext());
+        }
+
         // must have at least one exception
-        if (getExceptionClasses().isEmpty()) {
+        if (exceptionClasses.isEmpty()) {
             throw new IllegalArgumentException("At least one Exception must be configured
to catch");
         }
 
@@ -104,7 +109,7 @@ public class CatchDefinition extends Pro
             handle = handled.createPredicate(routeContext);
         }
 
-        return new CatchProcessor(getExceptionClasses(), childProcessor, when, handle);
+        return new CatchProcessor(exceptionClasses, childProcessor, when, handle);
     }
 
     public List<ProcessorDefinition> getOutputs() {
@@ -120,9 +125,6 @@ public class CatchDefinition extends Pro
     }
 
     public List<Class> getExceptionClasses() {
-        if (exceptionClasses == null) {
-            exceptionClasses = createExceptionClasses();
-        }
         return exceptionClasses;
     }
 
@@ -243,11 +245,13 @@ public class CatchDefinition extends Pro
         this.handled = handled;
     }
 
-    protected List<Class> createExceptionClasses() {
+    protected List<Class> createExceptionClasses(CamelContext context) throws ClassNotFoundException
{
+        // must use the class resolver from CamelContext to load classes to ensure it can
+        // be loaded in all kind of environments such as JEE servers and OSGi etc.
         List<String> list = getExceptions();
         List<Class> answer = new ArrayList<Class>(list.size());
         for (String name : list) {
-            Class<Exception> type = CastUtils.cast(ObjectHelper.loadClass(name, getClass().getClassLoader()));
+            Class<Exception> type = CastUtils.cast(context.getClassResolver().resolveMandatoryClass(name));
             answer.add(type);
         }
         return answer;



Mime
View raw message