You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2016/09/08 15:42:04 UTC
[4/4] camel git commit: CAMEL-7831: create a java8 only demo showing
how to use lambda expressions for Predicate / Expression inside the Java DSL
(using Message as a typesafe parameter)
CAMEL-7831: create a java8 only demo showing how to use lambda expressions for Predicate / Expression inside the Java DSL (using Message as a typesafe parameter)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/624b8a73
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/624b8a73
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/624b8a73
Branch: refs/heads/master
Commit: 624b8a7358eaf5597e47ffe30209d2d22ab50911
Parents: 45f3147
Author: lburgazzoli <lb...@gmail.com>
Authored: Thu Sep 8 17:10:16 2016 +0200
Committer: lburgazzoli <lb...@gmail.com>
Committed: Thu Sep 8 17:10:16 2016 +0200
----------------------------------------------------------------------
examples/camel-example-dsl-java8/pom.xml | 79 -------------------
.../camel/example/dsl/java8/MyApplication.java | 80 --------------------
.../src/main/resources/log4j2.properties | 23 ------
examples/camel-example-java8/pom.xml | 79 +++++++++++++++++++
.../camel/example/java8/MyApplication.java | 80 ++++++++++++++++++++
.../src/main/resources/log4j2.properties | 23 ++++++
examples/pom.xml | 2 +-
7 files changed, 183 insertions(+), 183 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/624b8a73/examples/camel-example-dsl-java8/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-dsl-java8/pom.xml b/examples/camel-example-dsl-java8/pom.xml
deleted file mode 100644
index 436169f..0000000
--- a/examples/camel-example-dsl-java8/pom.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-<?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.18.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>camel-example-dsl-java8</artifactId>
- <packaging>jar</packaging>
- <name>Camel :: Example :: DSL :: Java8 :: Spring JavaConfig</name>
- <description>An example for showing Camel Spring JavaConfig DSL for Java 8</description>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- </dependency>
-
- <!-- logging -->
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-jul</artifactId>
- <scope>runtime</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <!-- Allows the example to be run via 'mvn compile exec:java' -->
- <plugin>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-maven-plugin</artifactId>
- <version>${project.version}</version>
- <configuration>
- <mainClass>org.apache.camel.example.dsl.java8.MyApplication</mainClass>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/624b8a73/examples/camel-example-dsl-java8/src/main/java/org/apache/camel/example/dsl/java8/MyApplication.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-dsl-java8/src/main/java/org/apache/camel/example/dsl/java8/MyApplication.java b/examples/camel-example-dsl-java8/src/main/java/org/apache/camel/example/dsl/java8/MyApplication.java
deleted file mode 100644
index abaf561..0000000
--- a/examples/camel-example-dsl-java8/src/main/java/org/apache/camel/example/dsl/java8/MyApplication.java
+++ /dev/null
@@ -1,80 +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.example.dsl.java8;
-
-import java.util.Date;
-import java.util.Objects;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.main.Main;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class MyApplication {
- private static final Logger LOGGER = LoggerFactory.getLogger(MyApplication.class);
-
- private MyApplication() {
- }
-
- public static void main(String[] args) throws Exception {
- Main main = new Main();
- main.addRouteBuilder(new MyRouteBuilder());
- main.run(args);
- }
-
- private static class MyRouteBuilder extends RouteBuilder {
- @Override
- public void configure() throws Exception {
- from("timer:simple?period=503")
- .id("simple-route")
- .transform()
- .exchange(this::dateToTime)
- .process()
- .message(this::log)
- .process()
- .body(this::log)
- .choice()
- .when()
- .body(Integer.class, b -> (b & 1) == 0)
- .log("Received even number")
- .when()
- .body(Integer.class, (b, h) -> h.containsKey("skip") ? false : (b & 1) == 0)
- .log("Received odd number")
- .when()
- .body(Objects::isNull)
- .log("Received null body")
- .when()
- .body(Integer.class, b -> (b & 1) != 0)
- .log("Received odd number")
- .endChoice();
- }
-
- private Long dateToTime(Exchange e) {
- return e.getProperty(Exchange.TIMER_FIRED_TIME, Date.class).getTime();
- }
-
- private void log(Object b) {
- LOGGER.info("body is: {}", b);
- }
-
- private void log(Message m) {
- LOGGER.info("message is: {}", m);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/624b8a73/examples/camel-example-dsl-java8/src/main/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/examples/camel-example-dsl-java8/src/main/resources/log4j2.properties b/examples/camel-example-dsl-java8/src/main/resources/log4j2.properties
deleted file mode 100644
index 2f2e68b..0000000
--- a/examples/camel-example-dsl-java8/src/main/resources/log4j2.properties
+++ /dev/null
@@ -1,23 +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.
-## ---------------------------------------------------------------------------
-
-appender.out.type = Console
-appender.out.name = out
-appender.out.layout.type = PatternLayout
-appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
-rootLogger.level = INFO
-rootLogger.appenderRef.out.ref = out
http://git-wip-us.apache.org/repos/asf/camel/blob/624b8a73/examples/camel-example-java8/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-java8/pom.xml b/examples/camel-example-java8/pom.xml
new file mode 100644
index 0000000..c6818ad
--- /dev/null
+++ b/examples/camel-example-java8/pom.xml
@@ -0,0 +1,79 @@
+<?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.18.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-example-dsl-java8</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel :: Example :: DSL :: Java8 :: Spring JavaConfig</name>
+ <description>An example for showing Camel Spring JavaConfig DSL for Java 8</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-jul</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- Allows the example to be run via 'mvn compile exec:java' -->
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <configuration>
+ <mainClass>org.apache.camel.example.java8.MyApplication</mainClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/624b8a73/examples/camel-example-java8/src/main/java/org/apache/camel/example/java8/MyApplication.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-java8/src/main/java/org/apache/camel/example/java8/MyApplication.java b/examples/camel-example-java8/src/main/java/org/apache/camel/example/java8/MyApplication.java
new file mode 100644
index 0000000..220058c
--- /dev/null
+++ b/examples/camel-example-java8/src/main/java/org/apache/camel/example/java8/MyApplication.java
@@ -0,0 +1,80 @@
+/**
+ * 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.java8;
+
+import java.util.Date;
+import java.util.Objects;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.main.Main;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class MyApplication {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MyApplication.class);
+
+ private MyApplication() {
+ }
+
+ public static void main(String[] args) throws Exception {
+ Main main = new Main();
+ main.addRouteBuilder(new MyRouteBuilder());
+ main.run(args);
+ }
+
+ private static class MyRouteBuilder extends RouteBuilder {
+ @Override
+ public void configure() throws Exception {
+ from("timer:simple?period=503")
+ .id("simple-route")
+ .transform()
+ .exchange(this::dateToTime)
+ .process()
+ .message(this::log)
+ .process()
+ .body(this::log)
+ .choice()
+ .when()
+ .body(Integer.class, b -> (b & 1) == 0)
+ .log("Received even number")
+ .when()
+ .body(Integer.class, (b, h) -> h.containsKey("skip") ? false : (b & 1) == 0)
+ .log("Received odd number")
+ .when()
+ .body(Objects::isNull)
+ .log("Received null body")
+ .when()
+ .body(Integer.class, b -> (b & 1) != 0)
+ .log("Received odd number")
+ .endChoice();
+ }
+
+ private Long dateToTime(Exchange e) {
+ return e.getProperty(Exchange.TIMER_FIRED_TIME, Date.class).getTime();
+ }
+
+ private void log(Object b) {
+ LOGGER.info("body is: {}", b);
+ }
+
+ private void log(Message m) {
+ LOGGER.info("message is: {}", m);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/624b8a73/examples/camel-example-java8/src/main/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/examples/camel-example-java8/src/main/resources/log4j2.properties b/examples/camel-example-java8/src/main/resources/log4j2.properties
new file mode 100644
index 0000000..2f2e68b
--- /dev/null
+++ b/examples/camel-example-java8/src/main/resources/log4j2.properties
@@ -0,0 +1,23 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+appender.out.type = Console
+appender.out.name = out
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+rootLogger.level = INFO
+rootLogger.appenderRef.out.ref = out
http://git-wip-us.apache.org/repos/asf/camel/blob/624b8a73/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index ec1c38c..2682825 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -53,11 +53,11 @@
<module>camel-example-cxf-proxy</module>
<module>camel-example-cxf-tomcat</module>
<module>camel-example-console</module>
- <module>camel-example-dsl-java8</module>
<module>camel-example-etl</module>
<module>camel-example-ftp</module>
<module>camel-example-guice-jms</module>
<module>camel-example-hystrix</module>
+ <module>camel-example-java8</module>
<module>camel-example-jdbc</module>
<module>camel-example-jmx</module>
<module>camel-example-jms-file</module>