camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: CAMEL-9160: Dynamic to - Should use language: as prefix when using other languages
Date Thu, 24 Sep 2015 12:53:04 GMT
Repository: camel
Updated Branches:
  refs/heads/master 7228c13b3 -> 6ca72e1d8


CAMEL-9160: Dynamic to - Should use language: as prefix when using other languages


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

Branch: refs/heads/master
Commit: 6ca72e1d854300a0b909389727a654d8a4357554
Parents: 7228c13
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Sep 24 14:14:07 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Sep 24 14:54:35 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/model/ToDynamicDefinition.java | 30 +++++++++++---------
 .../ManagedSendDynamicProcessorTest.java        |  2 +-
 ...amicLanguageSimpleAndXPathAndHeaderTest.java |  2 +-
 .../ToDynamicLanguageSimpleAndXPathTest.java    |  2 +-
 .../processor/ToDynamicLanguageXPathTest.java   |  2 +-
 ...namicLanguageSimpleAndXPathAndHeaderTest.xml |  2 +-
 ...pringToDynamicLanguageSimpleAndXPathTest.xml |  2 +-
 .../SpringToDynamicLanguageXPathTest.xml        |  2 +-
 8 files changed, 24 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6ca72e1d/camel-core/src/main/java/org/apache/camel/model/ToDynamicDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/ToDynamicDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ToDynamicDefinition.java
index eb78088..956a73f 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ToDynamicDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ToDynamicDefinition.java
@@ -35,9 +35,9 @@ import org.apache.camel.spi.RouteContext;
 import org.apache.camel.util.ObjectHelper;
 
 /**
- * Sends the message to a dynamic endpoint (uri supports languages)
+ * Sends the message to a dynamic endpoint
  * <p/>
- * You can specify multiple languages in the uri separated by the plus sign, such as <tt>mock:+xpath:/order/@uri</tt>
+ * You can specify multiple languages in the uri separated by the plus sign, such as <tt>mock:+language:xpath:/order/@uri</tt>
  * where <tt>mock:</tt> would be a prefix to a xpath expression.
  * <p/>
  * For more dynamic behavior use <a href="http://camel.apache.org/recipient-list.html">Recipient
List</a> or
@@ -86,18 +86,22 @@ public class ToDynamicDefinition extends NoOutputDefinition<ToDynamicDefinition>
         String[] parts = uri.split("\\+");
         for (String part : parts) {
             // the part may have optional language to use, so you can mix languages
-            String before = ObjectHelper.before(part, ":");
-            String after = ObjectHelper.after(part, ":");
-            if (before != null && after != null) {
-                // maybe its a language
-                try {
-                    Language partLanguage = routeContext.getCamelContext().resolveLanguage(before);
-                    if (partLanguage != null) {
-                        Expression exp = partLanguage.createExpression(after);
-                        list.add(exp);
+            String value = ObjectHelper.after(part, "language:");
+            if (value != null) {
+                String before = ObjectHelper.before(value, ":");
+                String after = ObjectHelper.after(value, ":");
+                if (before != null && after != null) {
+                    // maybe its a language, must have language: as prefix
+                    try {
+                        Language partLanguage = routeContext.getCamelContext().resolveLanguage(before);
+                        if (partLanguage != null) {
+                            Expression exp = partLanguage.createExpression(after);
+                            list.add(exp);
+                            continue;
+                        }
+                    } catch (NoSuchLanguageException e) {
+                        // ignore
                     }
-                } catch (NoSuchLanguageException e) {
-                    // ignore
                 }
             }
             // fallback and use simple language

http://git-wip-us.apache.org/repos/asf/camel/blob/6ca72e1d/camel-core/src/test/java/org/apache/camel/management/ManagedSendDynamicProcessorTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/management/ManagedSendDynamicProcessorTest.java
b/camel-core/src/test/java/org/apache/camel/management/ManagedSendDynamicProcessorTest.java
index 2963ff4..1512b4b 100644
--- a/camel-core/src/test/java/org/apache/camel/management/ManagedSendDynamicProcessorTest.java
+++ b/camel-core/src/test/java/org/apache/camel/management/ManagedSendDynamicProcessorTest.java
@@ -92,7 +92,7 @@ public class ManagedSendDynamicProcessorTest extends ManagementTestSupport
{
 
         String json = (String) mbeanServer.invoke(on, "informationJson", null, null);
         assertNotNull(json);
-        assertTrue(json.contains("\"description\": \"Sends the message to a dynamic endpoint
(uri supports languages)"));
+        assertTrue(json.contains("\"description\": \"Sends the message to a dynamic endpoint"));
         assertTrue(json.contains(" \"uri\": { \"kind\": \"attribute\", \"required\": \"true\",
\"type\": \"string\", \"javaType\": \"java.lang.String\","
                 + " \"deprecated\": \"false\", \"value\": \"direct:${header.whereto}\""));
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/6ca72e1d/camel-core/src/test/java/org/apache/camel/processor/ToDynamicLanguageSimpleAndXPathAndHeaderTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/ToDynamicLanguageSimpleAndXPathAndHeaderTest.java
b/camel-core/src/test/java/org/apache/camel/processor/ToDynamicLanguageSimpleAndXPathAndHeaderTest.java
index 0c48286..f6bf956 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/ToDynamicLanguageSimpleAndXPathAndHeaderTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/ToDynamicLanguageSimpleAndXPathAndHeaderTest.java
@@ -37,7 +37,7 @@ public class ToDynamicLanguageSimpleAndXPathAndHeaderTest extends ContextTestSup
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                    .toD("mock:+xpath:/order/@uri+header:sub");
+                    .toD("mock:+language:xpath:/order/@uri+language:header:sub");
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/6ca72e1d/camel-core/src/test/java/org/apache/camel/processor/ToDynamicLanguageSimpleAndXPathTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/ToDynamicLanguageSimpleAndXPathTest.java
b/camel-core/src/test/java/org/apache/camel/processor/ToDynamicLanguageSimpleAndXPathTest.java
index 4827f18..51dd450 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/ToDynamicLanguageSimpleAndXPathTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/ToDynamicLanguageSimpleAndXPathTest.java
@@ -37,7 +37,7 @@ public class ToDynamicLanguageSimpleAndXPathTest extends ContextTestSupport
{
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                    .toD("mock:+xpath:/order/@uri");
+                    .toD("mock:+language:xpath:/order/@uri");
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/6ca72e1d/camel-core/src/test/java/org/apache/camel/processor/ToDynamicLanguageXPathTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/ToDynamicLanguageXPathTest.java
b/camel-core/src/test/java/org/apache/camel/processor/ToDynamicLanguageXPathTest.java
index b0ea183..2e2319d 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/ToDynamicLanguageXPathTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/ToDynamicLanguageXPathTest.java
@@ -37,7 +37,7 @@ public class ToDynamicLanguageXPathTest extends ContextTestSupport {
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                    .toD("xpath:/order/@uri");
+                    .toD("language:xpath:/order/@uri");
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/6ca72e1d/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringToDynamicLanguageSimpleAndXPathAndHeaderTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringToDynamicLanguageSimpleAndXPathAndHeaderTest.xml
b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringToDynamicLanguageSimpleAndXPathAndHeaderTest.xml
index 64ba8f5..3e3b15f 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringToDynamicLanguageSimpleAndXPathAndHeaderTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringToDynamicLanguageSimpleAndXPathAndHeaderTest.xml
@@ -26,7 +26,7 @@
   <camelContext xmlns="http://camel.apache.org/schema/spring">
     <route>
       <from uri="direct:start"/>
-      <toD uri="mock:+xpath:/order/@uri+header:sub"/>
+      <toD uri="mock:+language:xpath:/order/@uri+header:sub"/>
     </route>
   </camelContext>
   <!-- END SNIPPET: e1 -->

http://git-wip-us.apache.org/repos/asf/camel/blob/6ca72e1d/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringToDynamicLanguageSimpleAndXPathTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringToDynamicLanguageSimpleAndXPathTest.xml
b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringToDynamicLanguageSimpleAndXPathTest.xml
index c498672..ef94032 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringToDynamicLanguageSimpleAndXPathTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringToDynamicLanguageSimpleAndXPathTest.xml
@@ -26,7 +26,7 @@
   <camelContext xmlns="http://camel.apache.org/schema/spring">
     <route>
       <from uri="direct:start"/>
-      <toD uri="mock:+xpath:/order/@uri"/>
+      <toD uri="mock:+language:xpath:/order/@uri"/>
     </route>
   </camelContext>
   <!-- END SNIPPET: e1 -->

http://git-wip-us.apache.org/repos/asf/camel/blob/6ca72e1d/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringToDynamicLanguageXPathTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringToDynamicLanguageXPathTest.xml
b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringToDynamicLanguageXPathTest.xml
index ca17736..fd8d881 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringToDynamicLanguageXPathTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringToDynamicLanguageXPathTest.xml
@@ -26,7 +26,7 @@
   <camelContext xmlns="http://camel.apache.org/schema/spring">
     <route>
       <from uri="direct:start"/>
-      <toD uri="xpath:/order/@uri"/>
+      <toD uri="language:xpath:/order/@uri"/>
     </route>
   </camelContext>
   <!-- END SNIPPET: e1 -->


Mime
View raw message