camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r773078 - in /camel/trunk/components/camel-scala/src: main/scala/org/apache/camel/scala/dsl/ main/scala/org/apache/camel/scala/dsl/builder/ test/scala/org/apache/camel/scala/dsl/
Date Fri, 08 May 2009 20:18:37 GMT
Author: gertv
Date: Fri May  8 20:18:37 2009
New Revision: 773078

URL: http://svn.apache.org/viewvc?rev=773078&view=rev
Log:
Merge branch 'scala'

Added:
    camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SEnrichDefinition.scala
    camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/EnricherTest.scala
Modified:
    camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/DSL.scala
    camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala
    camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala

Modified: camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/DSL.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/DSL.scala?rev=773078&r1=773077&r2=773078&view=diff
==============================================================================
--- camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/DSL.scala
(original)
+++ camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/DSL.scala
Fri May  8 20:18:37 2009
@@ -17,6 +17,7 @@
 package org.apache.camel.scala.dsl 
 
 import org.apache.camel.model.dataformat.DataFormatDefinition
+import org.apache.camel.processor.aggregate.AggregationStrategy
 
 /**
  * Defines the 'keywords' in our Scala DSL
@@ -29,6 +30,7 @@
   def bean(bean: Any) : DSL
   def choice : SChoiceDefinition
   def delay(delay: Period) : SDelayDefinition
+  def enrich(uri:String, strategy: AggregationStrategy) : DSL
   def idempotentconsumer(expression: Exchange => Any): SIdempotentConsumerDefinition
   def inOnly(): SProcessorDefinition
   def inOut(): SProcessorDefinition

Modified: camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala?rev=773078&r1=773077&r2=773078&view=diff
==============================================================================
--- camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala
(original)
+++ camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala
Fri May  8 20:18:37 2009
@@ -18,11 +18,13 @@
 
 import org.apache.camel.model.ProcessorDefinition
 import org.apache.camel.model.FilterDefinition
-import org.apache.camel.model.ChoiceDefinition
+import org.apache.camel.model.{ChoiceDefinition, EnrichDefinition}
 import org.apache.camel.model.IdempotentConsumerDefinition
 
 import org.apache.camel.model.dataformat.DataFormatDefinition
 
+import org.apache.camel.processor.aggregate.AggregationStrategy
+
 import org.apache.camel.scala.dsl.builder.RouteBuilder
 
 abstract class SAbstractDefinition extends DSL {
@@ -73,6 +75,11 @@
   }
   
   def choice = new SChoiceDefinition(target.choice)
+  
+  def enrich(uri: String, strategy: AggregationStrategy) = {
+    target.enrich(uri, strategy)
+    this
+  }
     
   def otherwise : SChoiceDefinition = 
     throw new Exception("otherwise is only supported in a choice block or after a when statement")

Added: camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SEnrichDefinition.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SEnrichDefinition.scala?rev=773078&view=auto
==============================================================================
--- camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SEnrichDefinition.scala
(added)
+++ camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SEnrichDefinition.scala
Fri May  8 20:18:37 2009
@@ -0,0 +1,29 @@
+/**
+ * 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;
+
+import org.apache.camel.model.EnrichDefinition
+import org.apache.camel.scala.dsl.builder.RouteBuilder
+
+/**
+ * Scala enrichment for Camel's DelayDefinition
+ */
+class SEnrichDefinition(val target: EnrichDefinition)(implicit val builder: RouteBuilder)
extends SAbstractDefinition with Wrapper[EnrichDefinition] {
+ 
+  val unwrap = target
+
+}

Modified: camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala?rev=773078&r1=773077&r2=773078&view=diff
==============================================================================
--- camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala
(original)
+++ camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala
Fri May  8 20:18:37 2009
@@ -18,6 +18,7 @@
 
 import org.apache.camel.model.{ChoiceDefinition, ProcessorDefinition}
 import org.apache.camel.model.dataformat.DataFormatDefinition
+import org.apache.camel.processor.aggregate.AggregationStrategy
 import org.apache.camel.Routes
 
 import collection.mutable.Stack
@@ -84,6 +85,7 @@
   def throttle(frequency: Frequency) = stack.top.throttle(frequency)
   def loadbalance = stack.top.loadbalance
   def delay(delay: Period) = stack.top.delay(delay)
+  def enrich(uri: String, strategy: AggregationStrategy) = stack.top.enrich(uri, strategy)
   def resequence(expression: Exchange => Any) = stack.top.resequence(expression)
   def rollback = stack.top.rollback
   def setbody(expression : Exchange => Any) = stack.top.setbody(expression)

Added: camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/EnricherTest.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/EnricherTest.scala?rev=773078&view=auto
==============================================================================
--- camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/EnricherTest.scala
(added)
+++ camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/EnricherTest.scala
Fri May  8 20:18:37 2009
@@ -0,0 +1,58 @@
+/**
+ * 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;
+ 
+import org.w3c.dom.Document
+import scala.dsl.builder.RouteBuilder
+
+/**
+ * Test case for message enricher
+ */
+class EnricherTest extends ScalaTestSupport {
+  
+  def testSimpleEnricher = testEnricher("direct:a", "mock:a")
+  def testBlockEnricher = testEnricher("direct:b", "mock:b")
+  
+  def testEnricher(direct: String, mock: String) = {
+    mock expect { _.received ("France:Paris", "UK:London") }      
+    direct ! ("France", "UK")   
+    mock assert()
+  }
+  
+  val builder =
+    new RouteBuilder {
+       val strategy = new org.apache.camel.processor.enricher.SampleAggregator()
+
+       //START SNIPPET: simple
+       "direct:a" enrich("direct:enrich", strategy) to ("mock:a")
+       //END SNIPPET: simple
+       
+       //START SNIPPET: block
+       "direct:b" ==> {
+         enrich("direct:enrich", strategy)
+         to("mock:b")
+       }
+       //END SNIPPET: block
+       
+       "direct:enrich" process((exchange:Exchange) => {
+         exchange.out = exchange.in match {
+           case "UK" => "London"
+           case "France" => "Paris"
+         }
+       })
+  }
+}



Mime
View raw message