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 2019/11/22 20:09:45 UTC
[camel-k] 01/02: Add example that show how to split integration
among multiple files
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 0e3babc7d62dff883188227dc86c44394c255d0d
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Fri Nov 22 17:02:06 2019 +0100
Add example that show how to split integration among multiple files
---
examples/polyglot/JavaRoute.java | 31 +++++++++++++++++++++++++++++++
examples/polyglot/README.adoc | 8 ++++++++
examples/polyglot/beans.groovy | 23 +++++++++++++++++++++++
examples/polyglot/routes.xml | 29 +++++++++++++++++++++++++++++
4 files changed, 91 insertions(+)
diff --git a/examples/polyglot/JavaRoute.java b/examples/polyglot/JavaRoute.java
new file mode 100644
index 0000000..2522b34
--- /dev/null
+++ b/examples/polyglot/JavaRoute.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.Processor;
+
+public class JavaRoute extends RouteBuilder {
+ @Override
+ public void configure() throws Exception {
+ }
+
+ @BindToRegistry
+ public static Processor javaProcessor() {
+ return e -> e.getMessage().setHeader("MyHeader", "HelloFromJava");
+ }
+}
\ No newline at end of file
diff --git a/examples/polyglot/README.adoc b/examples/polyglot/README.adoc
new file mode 100644
index 0000000..76f29bc
--- /dev/null
+++ b/examples/polyglot/README.adoc
@@ -0,0 +1,8 @@
+= Example of route built using multiple DSl
+
+To run it:
+
+[source,shell]
+----
+$ kamel run --name polyglot routes.xml beans.groovy JavaRoute.java
+----
\ No newline at end of file
diff --git a/examples/polyglot/beans.groovy b/examples/polyglot/beans.groovy
new file mode 100644
index 0000000..cdfaf01
--- /dev/null
+++ b/examples/polyglot/beans.groovy
@@ -0,0 +1,23 @@
+// camel-k: language=groovy
+/*
+ * 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.
+ */
+
+beans {
+ groovyProcessor = {
+ it.in.body = 'Hello from Groovy'
+ } as org.apache.camel.Processor
+}
\ No newline at end of file
diff --git a/examples/polyglot/routes.xml b/examples/polyglot/routes.xml
new file mode 100644
index 0000000..e7d2bc7
--- /dev/null
+++ b/examples/polyglot/routes.xml
@@ -0,0 +1,29 @@
+<?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.
+-->
+<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://camel.apache.org/schema/spring"
+ xsi:schemaLocation="
+ http://camel.apache.org/schema/spring
+ http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+ <route id="polyglot">
+ <from uri="timer:hello?period=3s"/>
+ <process ref="javaProcessor"/>
+ <process ref="groovyProcessor"/>
+ <to uri="log:info?showAll=true&multiline=true"/>
+ </route>
+
+</routes>