You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ha...@apache.org on 2008/04/25 04:16:45 UTC
svn commit: r651477 - in /activemq/camel/trunk/components/camel-scala: ./
src/main/scala/org/apache/camel/scala/
src/main/scala/org/apache/camel/scala/builder/
src/main/scala/org/apache/camel/scala/dsl/
src/main/scala/org/apache/camel/scala/dsl/languag...
Author: hadrian
Date: Thu Apr 24 19:16:40 2008
New Revision: 651477
URL: http://svn.apache.org/viewvc?rev=651477&view=rev
Log:
CAMEL-462 take 2. Patch applied with many thanks!
Added:
activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/builder/
activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/builder/RouteBuilder.scala
- copied, changed from r651474, activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilder.scala
activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/builder/RouteBuilderSupport.scala
- copied, changed from r651474, activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilderSupport.scala
activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SChoiceType.scala
activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SProcessorType.scala
activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SRouteType.scala
activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SSplitterType.scala
activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/ScalaDsl.scala
activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/Wrapper.scala
activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/languages/JXPath.scala
activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/builder/
activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/builder/RouteBuilderUnwrapTest.scala
activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/RecipientListRouteTest.scala
activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/test/
activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/test/Envelope.scala
activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/test/Person.scala
Removed:
activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilder.scala
activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilderSupport.scala
Modified:
activemq/camel/trunk/components/camel-scala/pom.xml
activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/RichExchange.scala
activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichChoice.scala
activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichProcessor.scala
activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichUriString.scala
activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/languages/XPath.scala
activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/ScalaTestSupport.scala
activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/BasicRouteBuilderTest.scala
activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ContentBasedRouterTest.scala
activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/FilterRouteBuilderTest.scala
activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineAndMulticastTest.scala
activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineRouteBuilderTest.scala
activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/SplitterRouteBuilderTest.scala
Modified: activemq/camel/trunk/components/camel-scala/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/pom.xml?rev=651477&r1=651476&r2=651477&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-scala/pom.xml (original)
+++ activemq/camel/trunk/components/camel-scala/pom.xml Thu Apr 24 19:16:40 2008
@@ -87,6 +87,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jxpath</artifactId>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
Modified: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/RichExchange.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/RichExchange.scala?rev=651477&r1=651476&r2=651477&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/RichExchange.scala (original)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/RichExchange.scala Thu Apr 24 19:16:40 2008
@@ -21,14 +21,13 @@
/**
* Rich wrapper for Camel's Exchange implementations
*/
-
class RichExchange(val exchange : Exchange) {
def in : Any = exchange.getIn().getBody()
def in(header:String) : Any = exchange.getIn().getHeader(header)
- def in(target:Class[Any]) : Any = exchange.getIn().getBody(target)
+ def in[T](target:Class[T]) : T = exchange.getIn().getBody(target)
def out : Any = exchange.getOut().getBody()
Copied: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/builder/RouteBuilder.scala (from r651474, activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilder.scala)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/builder/RouteBuilder.scala?p2=activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/builder/RouteBuilder.scala&p1=activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilder.scala&r1=651474&r2=651477&rev=651477&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilder.scala (original)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/builder/RouteBuilder.scala Thu Apr 24 19:16:40 2008
@@ -14,13 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.scala.dsl;
+package org.apache.camel.scala.builder;
import org.apache.camel.model.ProcessorType
import org.apache.camel.model.ChoiceType
import collection.mutable.Stack
+import org.apache.camel.scala.dsl._
+
/**
Scala RouteBuilder implementation
*/
@@ -30,64 +32,31 @@
override def configure() = {}
}
- val stack = new Stack[ProcessorType[T] forSome {type T}];
+ val stack = new Stack[ScalaDsl];
- implicit def stringToUri(uri:String) : RichUriString = new RichUriString(uri, this)
- implicit def choiceWrapper(choice: ChoiceType) = new RichChoiceType(choice, this);
- implicit def processorWrapper(processor: ProcessorType[T] forSome {type T}) = new RichProcessor(processor, this)
+ implicit def stringToRoute(target: String) : SRouteType = new SRouteType(builder.from(target), this)
+ implicit def unwrap[W](wrapper: Wrapper[W]) = wrapper.unwrap
def print() = {
println(builder)
this
}
- def build(context: ProcessorType[T] forSome {type T}, block: => Unit) {
+ def build(context: ScalaDsl, block: => Unit) {
stack.push(context)
block
stack.pop()
}
- def from(uri: String) = builder.from(uri)
-
- def -->(uris: String*) = to(uris:_*)
- def to(uris: String*) = {
- uris.length match {
- case 1 => stack.top.to(uris(0))
- case _ => {
- val multicast = stack.top.multicast
- for (uri <- uris) multicast.to(uri)
- stack.top
- }
- }
- }
-
- var when = (filter: Exchange => Boolean) => {
- val choice = stack.top match {
- case c: ChoiceType => c
- case _ => stack.top.choice()
- }
- new RichChoiceType(choice.when(new WhenPredicate(filter)), this) : RichChoiceType
- }
+ def from(uri: String) = new SRouteType(builder.from(uri), this)
- def choice(block: => Unit) = {
- build(stack.top.choice(), block)
- }
+ def choice = stack.top.choice
+ def -->(uris: String*) = stack.top.to(uris: _*)
+ def to(uris: String*) = stack.top.to(uris: _*)
+ def when(filter: Exchange => Boolean) = stack.top.when(filter)
+ def as[Target](toType: Class[Target]) = stack.top.as(toType)
+ def recipients(expression: Exchange => Any) = stack.top.recipients(expression)
+ def splitter(expression: Exchange => Any) = stack.top.splitter(expression)
+ def otherwise = stack.top.otherwise
- def otherwise : ChoiceType = {
- stack.top match {
- case choice: ChoiceType => choice.otherwise
- case _ => throw new Exception("otherwise is only supported in a choice block or after a when statement")
- }
- }
-
- def splitter(expression: Exchange => Any) = stack.top.splitter(new ScalaExpression(expression))
-
- def as[T](toType: Class[T]) = stack.top.convertBodyTo(toType)
-}
-
-object RouteBuilder {
-
- def routes(definitions: => Unit) = new RouteBuilder {
- definitions
- }
-}
+}
\ No newline at end of file
Copied: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/builder/RouteBuilderSupport.scala (from r651474, activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilderSupport.scala)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/builder/RouteBuilderSupport.scala?p2=activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/builder/RouteBuilderSupport.scala&p1=activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilderSupport.scala&r1=651474&r2=651477&rev=651477&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilderSupport.scala (original)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/builder/RouteBuilderSupport.scala Thu Apr 24 19:16:40 2008
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.scala.dsl;
+package org.apache.camel.scala.builder;
trait RouteBuilderSupport {
- implicit def scalaToJavaBuilder(scalaBuilder: org.apache.camel.scala.dsl.RouteBuilder) = scalaBuilder.builder
+ implicit def scalaToJavaBuilder(scalaBuilder: org.apache.camel.scala.builder.RouteBuilder) = scalaBuilder.builder
}
Modified: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichChoice.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichChoice.scala?rev=651477&r1=651476&r2=651477&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichChoice.scala (original)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichChoice.scala Thu Apr 24 19:16:40 2008
@@ -1,40 +0,0 @@
-/**
- * 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.ChoiceType
-
-class RichChoiceType(val choice: ChoiceType, val builder:RouteBuilder) {
-
- def when(test: Exchange => Boolean)(block: => Unit) : ChoiceType = {
- choice
- }
-
- def apply(block: => Unit) : RichChoiceType = {
- builder.build(choice, block)
- this
- }
-
- def to(uri: String) = {
- choice.to(uri)
- }
-
- def otherwise(block: => Unit) = {
- choice.otherwise
- builder.build(choice, block)
- }
-}
Modified: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichProcessor.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichProcessor.scala?rev=651477&r1=651476&r2=651477&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichProcessor.scala (original)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichProcessor.scala Thu Apr 24 19:16:40 2008
@@ -1,31 +0,0 @@
-/**
- * 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.ProcessorType
-
-class RichProcessor(processor : ProcessorType[T] forSome {type T}, builder: RouteBuilder) {
-
- def -->(uri: String) = processor.to(uri)
-
- def splitter(expression: Exchange => Any) = processor.splitter(new ScalaExpression(expression))
-
- def as(target: Class[T] forSome {type T}) = processor.convertBodyTo(target).asInstanceOf[ProcessorType[T] forSome {type T}]
-
- def apply(block: => Unit) = builder.build(processor, block)
-
-}
Modified: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichUriString.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichUriString.scala?rev=651477&r1=651476&r2=651477&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichUriString.scala (original)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichUriString.scala Thu Apr 24 19:16:40 2008
@@ -1,52 +0,0 @@
-/**
- * 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.FilterType
-import org.apache.camel.model.SplitterType
-import org.apache.camel.model.ProcessorType
-
-class RichUriString(uri:String, builder:RouteBuilder) {
-
- def to(targets: String*) : ProcessorType[T] forSome {type T} = {
- val from = builder.from(uri)
- targets.length match {
- case 1 => from.to(targets(0))
- case _ => {
- val multicast = from.multicast
- for (target <- targets) multicast.to(target)
- from
- }
- }
- }
- def -->(targets: String*) : ProcessorType[T] forSome {type T} = to(targets:_*)
-
- def ==>(block: => Unit) = {
- builder.build(builder.from(uri), block)
- }
-
- def when(filter: Exchange => Boolean) : FilterType =
- builder.from(uri).filter(new WhenPredicate(filter))
-
- def splitter(expression: Exchange => Any) : SplitterType = {
- println("configuring splitter with " + expression)
- builder.from(uri).splitter(new ScalaExpression(expression))
- }
-
- def as(target: Class[T] forSome {type T}) = builder.from(uri).convertBodyTo(target)
-
-}
Added: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SChoiceType.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SChoiceType.scala?rev=651477&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SChoiceType.scala (added)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SChoiceType.scala Thu Apr 24 19:16:40 2008
@@ -0,0 +1,36 @@
+/**
+ * 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.ChoiceType
+import org.apache.camel.scala.builder.RouteBuilder
+
+class SChoiceType(val target: ChoiceType)(implicit val builder: RouteBuilder) extends ScalaDsl with Wrapper[ChoiceType] {
+
+ val unwrap = target
+
+ override def otherwise = {
+ target.otherwise
+ this
+ }
+
+ override def when(filter: Exchange => Boolean) = {
+ target.when(new WhenPredicate(filter))
+ this
+ }
+
+}
Added: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SProcessorType.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SProcessorType.scala?rev=651477&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SProcessorType.scala (added)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SProcessorType.scala Thu Apr 24 19:16:40 2008
@@ -0,0 +1,26 @@
+/**
+ * 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.ProcessorType
+import org.apache.camel.scala.builder.RouteBuilder
+
+class SProcessorType(val target: ProcessorType[P] forSome {type P})(implicit val builder: RouteBuilder) extends ScalaDsl with Wrapper[ProcessorType[P] forSome {type P}] {
+
+ val unwrap = target
+
+}
Added: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SRouteType.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SRouteType.scala?rev=651477&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SRouteType.scala (added)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SRouteType.scala Thu Apr 24 19:16:40 2008
@@ -0,0 +1,28 @@
+/**
+ * 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.RouteType
+import org.apache.camel.scala.builder.RouteBuilder
+
+class SRouteType(val target: RouteType, val builder: RouteBuilder) extends ScalaDsl with Wrapper[RouteType] {
+
+ val unwrap = target
+
+ def ==>(block: => Unit) = apply(this, block)
+
+}
Added: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SSplitterType.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SSplitterType.scala?rev=651477&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SSplitterType.scala (added)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SSplitterType.scala Thu Apr 24 19:16:40 2008
@@ -0,0 +1,26 @@
+/**
+ * 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.SplitterType
+import org.apache.camel.scala.builder.RouteBuilder
+
+class SSplitterType(val target: SplitterType)(implicit val builder: RouteBuilder) extends ScalaDsl with Wrapper[SplitterType] {
+
+ val unwrap = target
+
+}
Added: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/ScalaDsl.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/ScalaDsl.scala?rev=651477&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/ScalaDsl.scala (added)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/ScalaDsl.scala Thu Apr 24 19:16:40 2008
@@ -0,0 +1,67 @@
+/**
+ * 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.ProcessorType
+import org.apache.camel.model.FilterType
+import org.apache.camel.model.ChoiceType
+
+import org.apache.camel.scala.builder.RouteBuilder
+
+trait ScalaDsl {
+
+ val target : ProcessorType[T] forSome {type T}
+ implicit val builder: RouteBuilder
+
+ def -->(uris: String*) = to(uris:_*)
+ def to(uris: String*) = {
+ uris.length match {
+ case 1 => target.to(uris(0))
+ case _ => {
+ val multicast = target.multicast
+ uris.foreach(multicast.to(_))
+ }
+ }
+ this
+ }
+
+ def when(filter: Exchange => Boolean) : SChoiceType =
+ new SChoiceType(target.choice).when(filter)
+
+ def as[Target](toType: Class[Target]) = {
+ target.convertBodyTo(toType)
+ new SProcessorType(target.asInstanceOf[ProcessorType[P] forSome {type P}])
+ }
+
+ def splitter(expression: Exchange => Any) =
+ new SSplitterType(target.splitter(new ScalaExpression(expression)))
+
+ def recipients(expression: Exchange => Any) =
+ target.recipientList(new ScalaExpression(expression))
+
+ def apply(block: => Unit) = {
+ builder.build(this, block)
+ this
+ }
+
+ def choice = new SChoiceType(target.choice)
+
+ def otherwise : SChoiceType =
+ throw new Exception("otherwise is only supported in a choice block or after a when statement")
+
+
+}
Added: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/Wrapper.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/Wrapper.scala?rev=651477&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/Wrapper.scala (added)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/Wrapper.scala Thu Apr 24 19:16:40 2008
@@ -0,0 +1,26 @@
+/**
+ * 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;
+
+/**
+ * Wraps a given type T and supports unwrapping it on demand
+ */
+trait Wrapper[T] {
+
+ val unwrap : T
+
+}
Added: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/languages/JXPath.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/languages/JXPath.scala?rev=651477&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/languages/JXPath.scala (added)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/languages/JXPath.scala Thu Apr 24 19:16:40 2008
@@ -0,0 +1,37 @@
+/**
+ * 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.languages;
+
+import org.apache.camel.builder.xml.XPathBuilder
+
+/**
+ * Trait to improve JXPath support for Scala DSL
+ */
+trait JXPath {
+
+ implicit def exchangeToJXpath(exchange: Exchange) = new RichJXPathExchange(exchange)
+
+ class RichJXPathExchange(val exchange: Exchange) {
+
+ val language = exchange.getContext().resolveLanguage("jxpath")
+
+ def jxpath(jxpath: String) : Any =
+ language.createExpression(jxpath).evaluate(exchange)
+
+ }
+
+}
Modified: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/languages/XPath.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/languages/XPath.scala?rev=651477&r1=651476&r2=651477&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/languages/XPath.scala (original)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/languages/XPath.scala Thu Apr 24 19:16:40 2008
@@ -23,11 +23,9 @@
*/
trait XPath {
- def xpath(path: String) = XPathBuilder.xpath(path)
-
implicit def exchangeToXpath(exchange: Exchange) = new RichXPathExchange(exchange)
- class RichXPathExchange(exchange: Exchange) {
+ class RichXPathExchange(val exchange: Exchange) {
def xpath(xpath: String) : Any = {
val builder = new XPathBuilder[Exchange](xpath)
Modified: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/ScalaTestSupport.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/ScalaTestSupport.scala?rev=651477&r1=651476&r2=651477&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/ScalaTestSupport.scala (original)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/ScalaTestSupport.scala Thu Apr 24 19:16:40 2008
@@ -18,6 +18,7 @@
import org.apache.camel.ContextTestSupport
import org.apache.camel.component.mock.MockEndpoint
+import builder.RouteBuilderSupport
import org.apache.camel.scala.dsl._
abstract class ScalaTestSupport extends ContextTestSupport with RouteBuilderSupport with Preamble {
Added: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/builder/RouteBuilderUnwrapTest.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/builder/RouteBuilderUnwrapTest.scala?rev=651477&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/builder/RouteBuilderUnwrapTest.scala (added)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/builder/RouteBuilderUnwrapTest.scala Thu Apr 24 19:16:40 2008
@@ -0,0 +1,52 @@
+/**
+ * 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.builder;
+
+import org.apache.camel.scala.dsl.Wrapper
+import org.apache.camel.scala.test.{Person,Adult}
+import junit.framework.TestCase
+import junit.framework.Assert._
+
+class RouteBuilderUnwrapTest extends TestCase {
+
+ def builder = new RouteBuilder {
+
+ val person = new PersonWrapper
+
+ def testUnwrap = {
+ //access the wrapper
+ assertEquals("Apache Camel", person.vote)
+
+ //unwrap when necessary
+ assertTrue(person.canVote)
+ }
+
+ }
+
+
+ def testUnwrapWhenNecessary() = builder.testUnwrap
+
+ class PersonWrapper extends Wrapper[Person] {
+
+ val person = new Adult("Gert")
+ val unwrap = person
+
+ def vote = "Apache Camel"
+
+ }
+
+}
Modified: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/BasicRouteBuilderTest.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/BasicRouteBuilderTest.scala?rev=651477&r1=651476&r2=651477&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/BasicRouteBuilderTest.scala (original)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/BasicRouteBuilderTest.scala Thu Apr 24 19:16:40 2008
@@ -17,6 +17,7 @@
package org.apache.camel.scala.dsl;
import org.apache.camel.scala.ScalaTestSupport
+import scala.builder.RouteBuilder
class BasicRouteBuilderTest extends ScalaTestSupport {
Modified: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ContentBasedRouterTest.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ContentBasedRouterTest.scala?rev=651477&r1=651476&r2=651477&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ContentBasedRouterTest.scala (original)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ContentBasedRouterTest.scala Thu Apr 24 19:16:40 2008
@@ -15,6 +15,8 @@
* limitations under the License.
*/
package org.apache.camel.scala.dsl;
+
+import scala.builder.RouteBuilder
class ContentBasedRouterTest extends ScalaTestSupport {
Modified: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/FilterRouteBuilderTest.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/FilterRouteBuilderTest.scala?rev=651477&r1=651476&r2=651477&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/FilterRouteBuilderTest.scala (original)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/FilterRouteBuilderTest.scala Thu Apr 24 19:16:40 2008
@@ -16,7 +16,7 @@
*/
package org.apache.camel.scala.dsl;
-import org.apache.camel.scala.dsl.RouteBuilder.routes;
+import scala.builder.RouteBuilder
class FilterRouteBuilderTest extends ScalaTestSupport {
@@ -41,7 +41,7 @@
override protected def createRouteBuilder() =
new RouteBuilder {
//START SNIPPET: simple
- "direct:a" when(_.in == "<hello/>") to "mock:a"
+ "direct:a" when(_.in == "<hello/>") to("mock:a")
//END SNIPPET: simple
//START SNIPPET: alternatives
Modified: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineAndMulticastTest.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineAndMulticastTest.scala?rev=651477&r1=651476&r2=651477&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineAndMulticastTest.scala (original)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineAndMulticastTest.scala Thu Apr 24 19:16:40 2008
@@ -15,6 +15,8 @@
* limitations under the License.
*/
package org.apache.camel.scala.dsl;
+
+import scala.builder.RouteBuilder
class PipelineAndMulticastTest extends ScalaTestSupport {
Modified: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineRouteBuilderTest.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineRouteBuilderTest.scala?rev=651477&r1=651476&r2=651477&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineRouteBuilderTest.scala (original)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineRouteBuilderTest.scala Thu Apr 24 19:16:40 2008
@@ -16,6 +16,8 @@
*/
package org.apache.camel.scala.dsl;
+import scala.builder.RouteBuilder
+
class PipelineRouteBuilderTest extends ScalaTestSupport {
def testPipelineWithArrows() = testPipeline("direct:a", "mock:a", "mock:b")
Added: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/RecipientListRouteTest.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/RecipientListRouteTest.scala?rev=651477&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/RecipientListRouteTest.scala (added)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/RecipientListRouteTest.scala Thu Apr 24 19:16:40 2008
@@ -0,0 +1,66 @@
+/**
+ * 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 scala.builder.RouteBuilder
+import scala.test.{Adult, Toddler, Envelope}
+
+class RecipientListRouteTest extends ScalaTestSupport {
+
+ def testRecipientList = {
+ "mock:a" expect {_.count = 1}
+ "direct:a" ! ("send this message to mock:a", "send this message to mock:z")
+ "mock:a" assert()
+ }
+
+ def testRecipientListWithPatternMatching = {
+ "mock:playgarden" expect {_.count = 1}
+ "direct:b" ! (new Adult("Gert"), new Toddler("Ewan"))
+ "mock:playgarden" assert()
+ }
+
+ def testRecipientListWithJXPath = {
+ "mock:c" expect {_.count = 2}
+ "mock:d" expect {_.count = 1}
+ "direct:c" ! (new Envelope("mock:d"), new Envelope("mock:y"))
+ "mock:c" assert()
+ "mock:d" assert()
+ }
+
+ override protected def createRouteBuilder() =
+ new RouteBuilder with languages.JXPath {
+ //START SNIPPET: simple
+ "direct:a" recipients(_.in(classOf[String]).substring(21))
+ //END SNIPPET: simple
+
+ //START SNIPPET: pattern
+ "direct:b" recipients(_.in match {
+ case Toddler(_) => "mock:playgarden"
+ case _ => "mock:work"
+ })
+ //END SNIPPET: pattern
+
+ //START SNIPPET: block
+ "direct:c" ==> {
+ to("mock:c")
+ recipients(_.jxpath("./in/body/destination"))
+ }
+ //END SNIPPET: block
+ }.print
+
+
+}
Modified: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/SplitterRouteBuilderTest.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/SplitterRouteBuilderTest.scala?rev=651477&r1=651476&r2=651477&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/SplitterRouteBuilderTest.scala (original)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/SplitterRouteBuilderTest.scala Thu Apr 24 19:16:40 2008
@@ -18,6 +18,7 @@
import org.w3c.dom.Document
import languages.XPath
+import scala.builder.RouteBuilder
/**
* Test case for Splitter
@@ -43,7 +44,7 @@
new RouteBuilder with XPath {
//END SNIPPET: xpath
//START SNIPPET: simple
- "direct:a" as(classOf[Document]) splitter(xpath("/persons/person")) to "mock:a"
+ "direct:a" as(classOf[Document]) splitter(_.xpath("/persons/person")) to "mock:a"
//END SNIPPET: simple
//START SNIPPET: block
Added: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/test/Envelope.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/test/Envelope.scala?rev=651477&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/test/Envelope.scala (added)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/test/Envelope.scala Thu Apr 24 19:16:40 2008
@@ -0,0 +1,26 @@
+/**
+ * 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.test;
+
+/**
+ * Just a simple envelope test class
+ */
+class Envelope(destination: String) {
+
+ def getDestination = destination
+
+}
Added: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/test/Person.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/test/Person.scala?rev=651477&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/test/Person.scala (added)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/test/Person.scala Thu Apr 24 19:16:40 2008
@@ -0,0 +1,30 @@
+/**
+ * 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.test;
+
+/**
+ * Just a simple Person test class
+ */
+abstract class Person {
+ def canVote : Boolean
+}
+case class Adult(name: String) extends Person {
+ def canVote = true
+}
+case class Toddler(name: String) extends Person {
+ def canVote = false
+}