camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: CAMEL-7644: camel-scala, must use ScalaRouteBuilder to ensure a CamelContext is provided when creating routes. The old class is deprecated.
Date Tue, 03 Mar 2015 09:11:38 GMT
Repository: camel
Updated Branches:
  refs/heads/master ae08cd979 -> 01f08a626


CAMEL-7644: camel-scala, must use ScalaRouteBuilder to ensure a CamelContext is provided when
creating routes. The old class is deprecated.


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

Branch: refs/heads/master
Commit: c469ad776a86086c5edbed2cac998dd0596aa7d8
Parents: ae08cd9
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Mar 3 09:19:25 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Mar 3 09:19:25 2015 +0100

----------------------------------------------------------------------
 .../apache/camel/builder/BuilderSupport.java    |  5 ++--
 .../camel/scala/dsl/builder/RouteBuilder.scala  |  3 +++
 .../scala/dsl/builder/ScalaRouteBuilder.scala   | 25 ++++++++++++++++++++
 .../apache/camel/scala/dsl/CamelCBRTest.scala   |  8 ++++---
 4 files changed, 36 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c469ad77/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java b/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java
index e8713c5..85d51eb 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java
@@ -494,12 +494,13 @@ public abstract class BuilderSupport {
         return context;
     }
     
-    @Deprecated
     public void setContext(CamelContext context) {
-        this.context = (ModelCamelContext)context;
+        ObjectHelper.notNull(context, "CamelContext", this);
+        this.context = context.adapt(ModelCamelContext.class);
     }
 
     public void setContext(ModelCamelContext context) {
+        ObjectHelper.notNull(context, "CamelContext", this);
         this.context = context;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/c469ad77/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala
----------------------------------------------------------------------
diff --git a/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala
b/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala
index 5d68b63..1c58e78 100644
--- a/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala
+++ b/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala
@@ -36,7 +36,10 @@ import org.slf4j.{Logger, LoggerFactory}
 
 /**
  * Scala RouteBuilder implementation
+ *
+ * @deprecated use ScalaRouteBuilder
  */
+@Deprecated
 class RouteBuilder extends Preamble with DSL with RoutesBuilder with Languages with Functions
{
 
   val builder = new org.apache.camel.builder.RouteBuilder {

http://git-wip-us.apache.org/repos/asf/camel/blob/c469ad77/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/ScalaRouteBuilder.scala
----------------------------------------------------------------------
diff --git a/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/ScalaRouteBuilder.scala
b/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/ScalaRouteBuilder.scala
new file mode 100644
index 0000000..e0b88cf
--- /dev/null
+++ b/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/ScalaRouteBuilder.scala
@@ -0,0 +1,25 @@
+/**
+ * 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.scala.dsl.builder
+
+import org.apache.camel.CamelContext
+
+class ScalaRouteBuilder(val context:CamelContext) extends RouteBuilder {
+
+  builder.setContext(context)
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/c469ad77/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/CamelCBRTest.scala
----------------------------------------------------------------------
diff --git a/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/CamelCBRTest.scala
b/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/CamelCBRTest.scala
index aa21856..8cb8746 100644
--- a/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/CamelCBRTest.scala
+++ b/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/CamelCBRTest.scala
@@ -17,12 +17,14 @@
 package org.apache.camel.scala.dsl
 
 import org.apache.camel.test.junit4.CamelTestSupport
-import org.apache.camel.scala.dsl.builder.{RouteBuilder, RouteBuilderSupport}
+import org.apache.camel.scala.dsl.builder.{ScalaRouteBuilder, RouteBuilder, RouteBuilderSupport}
 import org.junit.Test
 
 class CamelCBRTest extends CamelTestSupport with RouteBuilderSupport {
 
-  override protected def createRouteBuilder = builder
+  override protected def createRouteBuilder = {
+    builder
+  }
 
   @Test
   def testFoo() {
@@ -45,7 +47,7 @@ class CamelCBRTest extends CamelTestSupport with RouteBuilderSupport {
     assertMockEndpointsSatisfied()
   }
 
-  val builder = new RouteBuilder {
+  lazy val builder = new ScalaRouteBuilder(context()) {
     "direct:start" ==> {
       choice {
         when(simple("${body} == 'foo'")) to "mock:foo"


Mime
View raw message