This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karaf-examples.git


The following commit(s) were added to refs/heads/main by this push:
     new 018dec6  Add kamelet chuck norris example
018dec6 is described below

commit 018dec64e471ece185c18226562a089b5e3578b1
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Jun 1 15:15:44 2021 +0200

    Add kamelet chuck norris example
---
 examples/README.adoc                               |   4 +-
 .../camel-example-kamelet-chucknorris/README.adoc  |  65 +++++++++
 examples/camel-example-kamelet-chucknorris/pom.xml | 146 +++++++++++++++++++++
 .../resources/OSGI-INF/blueprint/camel-context.xml |  33 +++++
 .../src/main/resources/features.xml                |  32 +++++
 .../kamelets/chuck-norris-source.kamelet.yaml      |  42 ++++++
 .../src/main/resources/log4j2.properties           |  23 ++++
 examples/pom.xml                                   |   1 +
 8 files changed, 345 insertions(+), 1 deletion(-)

diff --git a/examples/README.adoc b/examples/README.adoc
index 427816a..31fe610 100644
--- a/examples/README.adoc
+++ b/examples/README.adoc
@@ -11,7 +11,7 @@ View the individual example READMEs for details.
 == Examples
 
 // examples: START
-Number of Examples: 14 (0 deprecated)
+Number of Examples: 15 (0 deprecated)
 
 [width="100%",cols="4,2,4",options="header"]
 |===
@@ -31,6 +31,8 @@ Number of Examples: 14 (0 deprecated)
 
 | link:camel-example-ehcache-blueprint/README.adoc[EHCache OSGi] 
(camel-example-ehcache-blueprint) | OSGi | An example using EHCache with OSGi 
Blueprint
 
+| link:camel-example-kamelet-chucknorris/README.adoc[Kamelet Chuck Norris] 
(camel-example-kamelet-chucknorris) | OSGi | 
+
 | link:camel-example-netty-http/README.adoc[Netty HTTP] 
(camel-example-netty-http) | OSGi | An example showing how to use a shared 
Netty HTTP server with multiple Camel applications in OSGi
         container
     
diff --git a/examples/camel-example-kamelet-chucknorris/README.adoc 
b/examples/camel-example-kamelet-chucknorris/README.adoc
new file mode 100644
index 0000000..86c7e51
--- /dev/null
+++ b/examples/camel-example-kamelet-chucknorris/README.adoc
@@ -0,0 +1,65 @@
+== Camel Example Kamelet Chuck Norris
+
+=== Introduction
+
+This example shows how you can build a simple Kamelet and use with your Camel 
applications.
+
+The kamelet is created as a YAML file in the `src/main/resources/kamelets' 
directory.
+We have developed a Chuck Norris Kamelet that periodically gets a joke from 
the Chuck Norris internet database.
+
+A Camel routes is _coded_ in OSGi Blueprint in the 
`src/main/resources/OSGI-INF/blueprint/camel-context.xml` file
+using the XML DSL that uses the Kamelet, and log the result from the Kamelet 
to the console.
+
+=== Build
+
+You will need to compile this example first:
+
+[source,sh]
+----
+$ mvn compile
+----
+
+=== Run
+
+You can run this example using
+
+[source,sh]
+----
+$ mvn camel-karaf:run
+----
+
+=== Run with Karaf
+
+You will need to install this example first to your local maven
+repository with:
+
+....
+mvn install
+....
+
+Then you can install this example from the shell using this example’s
+`+features.xml+` for easy provisioning:
+
+....
+feature:repo-add 
mvn:org.apache.camel.example/camel-example-kamelet-chucknorris/${version}/xml/features
+feature:install camel-example-kamelet-chucknorris
+....
+
+And you can see the application running by tailing the logs:
+
+....
+log:tail
+....
+
+And you can use ctrl+c to stop tailing the log.
+
+
+=== Help and contributions
+
+If you hit any problem using Camel or have some feedback, then please
+https://camel.apache.org/community/support/[let us know].
+
+We also love contributors, so
+https://camel.apache.org/community/contributing/[get involved] :-)
+
+The Camel riders!
diff --git a/examples/camel-example-kamelet-chucknorris/pom.xml 
b/examples/camel-example-kamelet-chucknorris/pom.xml
new file mode 100644
index 0000000..d8b9e4b
--- /dev/null
+++ b/examples/camel-example-kamelet-chucknorris/pom.xml
@@ -0,0 +1,146 @@
+<?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.example</groupId>
+        <artifactId>karaf-examples</artifactId>
+        <version>3.11.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-example-kamelet-chucknorris</artifactId>
+    <packaging>jar</packaging>
+    <name>Camel :: Example :: Kamelet :: Chuck Norris</name>
+    <description></description>
+
+    <properties>
+        <category>OSGi</category>
+        <title>Kamelet Chuck Norris</title>
+    </properties>
+
+    <dependencyManagement>
+        <dependencies>
+            <!-- Add Camel BOM -->
+            <dependency>
+                <groupId>org.apache.camel</groupId>
+                <artifactId>camel-bom</artifactId>
+                <version>${camel.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <!-- Add Camel Karaf BOM -->
+            <dependency>
+                <groupId>org.apache.camel.karaf</groupId>
+                <artifactId>camel-karaf-bom</artifactId>
+                <version>${camel.karaf.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+
+        <!-- Camel -->
+        <dependency>
+            <groupId>org.apache.camel.karaf</groupId>
+            <artifactId>camel-blueprint</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-kamelet</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-timer</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-http</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-jsonpath</artifactId>
+        </dependency>
+
+        <!-- to allow running this example via mvn camel-karaf:run -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-yaml-dsl</artifactId>
+        </dependency>
+
+         <!-- logging -->
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <version>${log4j2-version}</version>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <version>${log4j2-version}</version>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-slf4j-impl</artifactId>
+            <version>${log4j2-version}</version>
+            <scope>runtime</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <!-- Allows the routes to be run via 'mvn camel-karaf:run' -->
+            <plugin>
+                <groupId>org.apache.camel.karaf</groupId>
+                <artifactId>camel-karaf-maven-plugin</artifactId>
+                <version>${camel.version}</version>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-artifacts</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    <file>target/classes/features.xml</file>
+                                    <type>xml</type>
+                                    <classifier>features</classifier>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git 
a/examples/camel-example-kamelet-chucknorris/src/main/resources/OSGI-INF/blueprint/camel-context.xml
 
b/examples/camel-example-kamelet-chucknorris/src/main/resources/OSGI-INF/blueprint/camel-context.xml
new file mode 100644
index 0000000..a292897
--- /dev/null
+++ 
b/examples/camel-example-kamelet-chucknorris/src/main/resources/OSGI-INF/blueprint/camel-context.xml
@@ -0,0 +1,33 @@
+<?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.
+
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+           xmlns:camel="http://camel.apache.org/schema/blueprint";
+           xsi:schemaLocation="
+             http://www.osgi.org/xmlns/blueprint/v1.0.0 
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd";>
+
+    <camelContext xmlns="http://camel.apache.org/schema/blueprint";>
+        <route>
+            <from uri="kamelet:chuck-norris-source"/>
+            <log message="${body}"/>
+        </route>
+    </camelContext>
+
+</blueprint>
diff --git 
a/examples/camel-example-kamelet-chucknorris/src/main/resources/features.xml 
b/examples/camel-example-kamelet-chucknorris/src/main/resources/features.xml
new file mode 100644
index 0000000..12d12d6
--- /dev/null
+++ b/examples/camel-example-kamelet-chucknorris/src/main/resources/features.xml
@@ -0,0 +1,32 @@
+<?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.
+
+-->
+<features>
+    
<repository>mvn:org.apache.camel.karaf/apache-camel/${camel.version}/xml/features</repository>
+
+    <feature name="camel-example-kamelet-chucknorris" 
version="${camel.version}">
+        <feature version="${camel.version}">camel</feature>
+        <feature version="${camel.version}">camel-blueprint</feature>
+        <feature version="${camel.version}">camel-kamelet</feature>
+        <feature version="${camel.version}">camel-http</feature>
+        <feature version="${camel.version}">camel-jsonpath</feature>
+        
<bundle>mvn:org.apache.camel.example/camel-example-kamelet-chucknorris/${project.version}</bundle>
+    </feature>
+
+</features>
diff --git 
a/examples/camel-example-kamelet-chucknorris/src/main/resources/kamelets/chuck-norris-source.kamelet.yaml
 
b/examples/camel-example-kamelet-chucknorris/src/main/resources/kamelets/chuck-norris-source.kamelet.yaml
new file mode 100644
index 0000000..42c2644
--- /dev/null
+++ 
b/examples/camel-example-kamelet-chucknorris/src/main/resources/kamelets/chuck-norris-source.kamelet.yaml
@@ -0,0 +1,42 @@
+apiVersion: camel.apache.org/v1alpha1
+kind: Kamelet
+metadata:
+  name: chuck-norris-source
+  annotations:
+    camel.apache.org/kamelet.support.level: "Preview"
+    camel.apache.org/catalog.version: "main-SNAPSHOT"
+    camel.apache.org/kamelet.icon: 
data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pg0KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJDYXBhXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgNTEyIDUxMiIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDA
 [...]
+    camel.apache.org/provider: "Apache Software Foundation"
+    camel.apache.org/kamelet.group: "Chuck Norris"
+  labels:
+    camel.apache.org/kamelet.type: "source"
+spec:
+  definition:
+    title: "Chuck Norris Source"
+    description: |-
+      Gets peridically Chuck Norris jokes from http://www.icndb.com/
+    type: object
+    properties:
+      period:
+        title: Period
+        description: The interval (msec) to wait before getting the next joke
+        type: integer
+        default: 5000
+  types:
+    out:
+      mediaType: text/plain
+  dependencies:
+    - "camel:kamelet"
+    - "camel:timer"
+    - "camel:http"
+    - "camel:jsonpath"
+  flow:
+    from:
+      uri: "timer:chuck"
+      parameters:
+        period: "{{period}}"
+      steps:
+        - to: "http://api.icndb.com/jokes/random";
+        - set-body:
+            jsonpath: "$.value.joke"
+        - to: "kamelet:sink"
\ No newline at end of file
diff --git 
a/examples/camel-example-kamelet-chucknorris/src/main/resources/log4j2.properties
 
b/examples/camel-example-kamelet-chucknorris/src/main/resources/log4j2.properties
new file mode 100644
index 0000000..d9f0508
--- /dev/null
+++ 
b/examples/camel-example-kamelet-chucknorris/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 = [%30.30t] %-30.30c{1} %-5p %m%n
+rootLogger.level = INFO
+rootLogger.appenderRef.out.ref = out
diff --git a/examples/pom.xml b/examples/pom.xml
index 07f4768..4502755 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -85,6 +85,7 @@
         <module>camel-example-fhir-osgi</module>
         <module>camel-example-cxf-blueprint</module>
         <module>camel-example-ehcache-blueprint</module>
+        <module>camel-example-kamelet-chucknorris</module>
         <module>camel-example-mybatis</module>
         <module>camel-example-netty-http</module>
         <module>camel-example-olingo4-blueprint</module>

Reply via email to