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 2017/01/03 14:27:31 UTC
camel git commit: Added little kotlin example
Repository: camel
Updated Branches:
refs/heads/master af605fbce -> c4272100b
Added little kotlin example
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c4272100
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c4272100
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c4272100
Branch: refs/heads/master
Commit: c4272100b98d182f8a66c263f7b748d0e7b56916
Parents: af605fb
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jan 3 15:27:21 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jan 3 15:27:21 2017 +0100
----------------------------------------------------------------------
examples/README.md | 1 +
examples/camel-example-kotlin/ReadMe.md | 15 +++
examples/camel-example-kotlin/pom.xml | 126 +++++++++++++++++++
.../kotlin/org/apache/camel/example/MainApp.kt | 35 ++++++
.../org/apache/camel/example/MyRouteBuilder.kt | 28 +++++
.../src/main/resources/log4j2.properties | 7 ++
6 files changed, 212 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/c4272100/examples/README.md
----------------------------------------------------------------------
diff --git a/examples/README.md b/examples/README.md
index 5fe7b10..5ec19f1 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -46,6 +46,7 @@ All examples have been sort by type/category
##### Other Languages
* [camel-example-groovy](camel-example-groovy/ReadMe.md)
+* [camel-example-kotlin](camel-example-kotlin/ReadMe.md)
* [camel-example-scala](camel-example-scala/ReadMe.md)
##### CDI
http://git-wip-us.apache.org/repos/asf/camel/blob/c4272100/examples/camel-example-kotlin/ReadMe.md
----------------------------------------------------------------------
diff --git a/examples/camel-example-kotlin/ReadMe.md b/examples/camel-example-kotlin/ReadMe.md
new file mode 100644
index 0000000..4d30263
--- /dev/null
+++ b/examples/camel-example-kotlin/ReadMe.md
@@ -0,0 +1,15 @@
+Camel Router with Kotlin Project
+================================
+
+To build this project use
+
+ mvn install
+
+To run this project
+
+ mvn exec:java
+
+For more help see the Apache Camel documentation
+
+ http://camel.apache.org/
+
http://git-wip-us.apache.org/repos/asf/camel/blob/c4272100/examples/camel-example-kotlin/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-kotlin/pom.xml b/examples/camel-example-kotlin/pom.xml
new file mode 100644
index 0000000..35fa24e
--- /dev/null
+++ b/examples/camel-example-kotlin/pom.xml
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>examples</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-example-kotlin</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel :: Example :: Kotlin</name>
+ <description>A Camel route using Kotlin</description>
+
+ <properties>
+ <kotlin.version>1.0.4</kotlin.version>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-stdlib</artifactId>
+ <version>${kotlin.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+
+ <!-- used for jetty -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jetty</artifactId>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
+ <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
+
+ <defaultGoal>install</defaultGoal>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>${maven-resources-plugin-version}</version>
+ <configuration>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>kotlin-maven-plugin</artifactId>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <version>${kotlin.version}</version>
+ <executions>
+ <execution>
+ <id>compile</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>test-compile</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>test-compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Allows the example to be run via 'mvn compile exec:java' -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>${exec-maven-plugin-version}</version>
+ <configuration>
+ <mainClass>org.apache.camel.example.MainAppKt</mainClass>
+ <includePluginDependencies>false</includePluginDependencies>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/c4272100/examples/camel-example-kotlin/src/main/kotlin/org/apache/camel/example/MainApp.kt
----------------------------------------------------------------------
diff --git a/examples/camel-example-kotlin/src/main/kotlin/org/apache/camel/example/MainApp.kt b/examples/camel-example-kotlin/src/main/kotlin/org/apache/camel/example/MainApp.kt
new file mode 100644
index 0000000..82bb32f
--- /dev/null
+++ b/examples/camel-example-kotlin/src/main/kotlin/org/apache/camel/example/MainApp.kt
@@ -0,0 +1,35 @@
+/**
+ * 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.example
+
+import org.apache.camel.main.Main
+
+/**
+ * A static main() so we can easily run these routing rules in our IDE
+ */
+fun main(args: Array<String>) {
+ System.out.println("\n\n\n\n");
+ System.out.println("===============================================");
+ System.out.println("Open your web browser on http://localhost:8080");
+ System.out.println("Press ctrl+c to stop this example");
+ System.out.println("===============================================");
+ System.out.println("\n\n\n\n");
+
+ val main = Main()
+ main.addRouteBuilder(MyRouteBuilder())
+ main.run(args)
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/c4272100/examples/camel-example-kotlin/src/main/kotlin/org/apache/camel/example/MyRouteBuilder.kt
----------------------------------------------------------------------
diff --git a/examples/camel-example-kotlin/src/main/kotlin/org/apache/camel/example/MyRouteBuilder.kt b/examples/camel-example-kotlin/src/main/kotlin/org/apache/camel/example/MyRouteBuilder.kt
new file mode 100644
index 0000000..a41f5a1
--- /dev/null
+++ b/examples/camel-example-kotlin/src/main/kotlin/org/apache/camel/example/MyRouteBuilder.kt
@@ -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.example
+
+import org.apache.camel.builder.RouteBuilder
+
+class MyRouteBuilder() : RouteBuilder() {
+
+ override fun configure() {
+ from("jetty:http://0.0.0.0:8080")
+ .transform(constant("Hello from Kotlin"))
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/c4272100/examples/camel-example-kotlin/src/main/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/examples/camel-example-kotlin/src/main/resources/log4j2.properties b/examples/camel-example-kotlin/src/main/resources/log4j2.properties
new file mode 100644
index 0000000..328db35
--- /dev/null
+++ b/examples/camel-example-kotlin/src/main/resources/log4j2.properties
@@ -0,0 +1,7 @@
+
+appender.out.type = Console
+appender.out.name = out
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n
+rootLogger.level = INFO
+rootLogger.appenderRef.out.ref = out