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 2013/05/21 07:43:52 UTC

[3/8] git commit: Fixed simple language routeId function to return the id of the current route and not the originated route.

Fixed simple language routeId function to return the id of the current route and not the originated route.


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

Branch: refs/heads/master
Commit: 9708a102b968bb9bb5e575bec3031cab3500f9b1
Parents: 9ede133
Author: Claus Ibsen <da...@apache.org>
Authored: Mon May 20 18:24:40 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue May 21 07:43:38 2013 +0200

----------------------------------------------------------------------
 .../apache/camel/builder/ExpressionBuilder.java    |    9 ++++++-
 .../apache/camel/processor/CorrectRouteIdTest.java |   20 +++++++++++++++
 2 files changed, 28 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9708a102/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java b/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
index 0d135bd..c4fbce2 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
@@ -43,6 +43,8 @@ import org.apache.camel.component.properties.PropertiesComponent;
 import org.apache.camel.language.bean.BeanLanguage;
 import org.apache.camel.model.language.MethodCallExpression;
 import org.apache.camel.spi.Language;
+import org.apache.camel.spi.RouteContext;
+import org.apache.camel.spi.UnitOfWork;
 import org.apache.camel.support.ExpressionAdapter;
 import org.apache.camel.support.TokenPairExpressionIterator;
 import org.apache.camel.support.TokenXMLPairExpressionIterator;
@@ -1400,7 +1402,12 @@ public final class ExpressionBuilder {
     public static Expression routeIdExpression() {
         return new ExpressionAdapter() {
             public Object evaluate(Exchange exchange) {
-                return exchange.getFromRouteId();
+                UnitOfWork uow = exchange.getUnitOfWork();
+                RouteContext rc = uow != null ? uow.getRouteContext() : null;
+                if (rc != null) {
+                    return rc.getRoute().getId();
+                }
+                return null;
             }
 
             @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/9708a102/camel-core/src/test/java/org/apache/camel/processor/CorrectRouteIdTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/CorrectRouteIdTest.java b/camel-core/src/test/java/org/apache/camel/processor/CorrectRouteIdTest.java
new file mode 100644
index 0000000..f5a5661
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/CorrectRouteIdTest.java
@@ -0,0 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+public class CorrectRouteIdTest {
+}