You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gg...@apache.org on 2023/06/30 09:46:39 UTC

[camel-kamelets-examples] branch main updated (fc4f115 -> 8feb172)

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

ggrzybek pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets-examples.git


    from fc4f115  Update README.adoc
     new d4f46e1  Add example that includes more <route> elements under top-level <camel> element
     new 8feb172  Add example that registers bean instances from provided *.java file using XML and YAML DSLs

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 jbang/{hello-java => app-routes-beans}/README.adoc | 15 ++++++-----
 jbang/app-routes-beans/StandaloneGreeter.java      | 21 ++++++++++++++++
 jbang/app-routes-beans/app.xml                     | 29 ++++++++++++++++++++++
 jbang/app-routes-beans/beans.yaml                  |  5 ++++
 jbang/{hello-java => app-routes}/README.adoc       | 15 ++++++-----
 jbang/app-routes/app.xml                           | 21 ++++++++++++++++
 6 files changed, 94 insertions(+), 12 deletions(-)
 copy jbang/{hello-java => app-routes-beans}/README.adoc (73%)
 create mode 100644 jbang/app-routes-beans/StandaloneGreeter.java
 create mode 100644 jbang/app-routes-beans/app.xml
 create mode 100644 jbang/app-routes-beans/beans.yaml
 copy jbang/{hello-java => app-routes}/README.adoc (78%)
 create mode 100644 jbang/app-routes/app.xml


[camel-kamelets-examples] 02/02: Add example that registers bean instances from provided *.java file using XML and YAML DSLs

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8feb172a94a7868901c448e4ec86d6b20609fb10
Author: Grzegorz Grzybek <gr...@gmail.com>
AuthorDate: Fri Jun 30 11:46:27 2023 +0200

    Add example that registers bean instances from provided *.java file using XML and YAML DSLs
---
 jbang/app-routes-beans/README.adoc            | 85 +++++++++++++++++++++++++++
 jbang/app-routes-beans/StandaloneGreeter.java | 21 +++++++
 jbang/app-routes-beans/app.xml                | 29 +++++++++
 jbang/app-routes-beans/beans.yaml             |  5 ++
 4 files changed, 140 insertions(+)

diff --git a/jbang/app-routes-beans/README.adoc b/jbang/app-routes-beans/README.adoc
new file mode 100644
index 0000000..6004eb9
--- /dev/null
+++ b/jbang/app-routes-beans/README.adoc
@@ -0,0 +1,85 @@
+== Hello Java
+
+This example shows how beans defined directly in Java source code can be added to Camel registry using XML and YAML DSLs.
+
+Camel 4 is required.
+
+=== Install JBang
+
+First install JBang according to https://www.jbang.dev
+
+When JBang is installed then you should be able to run from a shell:
+
+[source,sh]
+----
+$ jbang --version
+----
+
+This will output the version of JBang.
+
+To run this example you can either install Camel on JBang via:
+
+[source,sh]
+----
+$ jbang app install camel@apache/camel
+----
+
+Which allows to run CamelJBang with `camel` as shown below.
+
+=== How to run
+
+Then you can run this example using:
+
+[source,sh]
+----
+$ camel run StandaloneGreeter.java beans.yaml app.xml
+----
+
+Or run with JBang using the longer command line (without installing camel as app in JBang):
+
+[source,sh]
+----
+$ jbang camel@apache/camel run StandaloneGreeter.java beans.yaml app.xml
+----
+
+=== Live reload
+
+You can run the example in dev mode which allows you to edit the example,
+and hot-reload when the file is saved.
+
+[source,sh]
+----
+$ camel run StandaloneGreeter.java beans.yaml app.xml --dev
+----
+
+=== Run directly from github
+
+The example can also be run directly by referring to the github URL as shown:
+
+[source,sh]
+----
+$ jbang camel@apache/camel run https://github.com/apache/camel-kamelets-examples/tree/main/jbang/app-routes-beans
+----
+
+=== Developer Web Console
+
+You can enable the developer console via `--console` flag as show:
+
+[source,sh]
+----
+$ camel run StandaloneGreeter.java beans.yaml app.xml --console
+----
+
+Then you can browse: http://localhost:8080/q/dev to introspect the running Camel applicaton.
+Under "beans" Camel should display `greeter1` and `greeter2` beans.
+
+
+=== 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/jbang/app-routes-beans/StandaloneGreeter.java b/jbang/app-routes-beans/StandaloneGreeter.java
new file mode 100644
index 0000000..2a43270
--- /dev/null
+++ b/jbang/app-routes-beans/StandaloneGreeter.java
@@ -0,0 +1,21 @@
+package camel.example;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.util.StringHelper;
+
+public class StandaloneGreeter implements Processor {
+
+    private String message;
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        String msg = exchange.getIn().getBody(String.class);
+        exchange.getIn().setBody(message + " " + StringHelper.after(msg, "I'm "));
+    }
+
+}
diff --git a/jbang/app-routes-beans/app.xml b/jbang/app-routes-beans/app.xml
new file mode 100644
index 0000000..ff245ca
--- /dev/null
+++ b/jbang/app-routes-beans/app.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<camel>
+
+    <bean name="greeter2" type="camel.example.StandaloneGreeter">
+        <properties>
+            <property key="message" value="Hello"/>
+        </properties>
+    </bean>
+
+    <route id="r1">
+        <from uri="timer:xml?period={{time:1100}}"/>
+        <setBody>
+            <simple>I'm Route ${routeId}</simple>
+        </setBody>
+        <bean ref="greeter1" />
+        <log message="${body}"/>
+    </route>
+
+    <route id="r2">
+        <from uri="timer:xml?period={{time:1200}}"/>
+        <setBody>
+            <simple>I'm Route ${routeId}</simple>
+        </setBody>
+        <bean ref="greeter2" />
+        <log message="${body}"/>
+    </route>
+
+</camel>
diff --git a/jbang/app-routes-beans/beans.yaml b/jbang/app-routes-beans/beans.yaml
new file mode 100644
index 0000000..150c587
--- /dev/null
+++ b/jbang/app-routes-beans/beans.yaml
@@ -0,0 +1,5 @@
+- beans:
+  - name: greeter1
+    type: camel.example.StandaloneGreeter
+    properties:
+      message: 'Howdy'


[camel-kamelets-examples] 01/02: Add example that includes more elements under top-level element

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d4f46e1f4965f00cb2c2509893d43d9b5a3838ec
Author: Grzegorz Grzybek <gr...@gmail.com>
AuthorDate: Fri Jun 30 09:54:42 2023 +0200

    Add example that includes more <route> elements under top-level <camel> element
---
 jbang/app-routes/README.adoc | 85 ++++++++++++++++++++++++++++++++++++++++++++
 jbang/app-routes/app.xml     | 21 +++++++++++
 2 files changed, 106 insertions(+)

diff --git a/jbang/app-routes/README.adoc b/jbang/app-routes/README.adoc
new file mode 100644
index 0000000..633b755
--- /dev/null
+++ b/jbang/app-routes/README.adoc
@@ -0,0 +1,85 @@
+== Hello Java
+
+This example shows convenient way to include more routes in one XML file under special `<camel>` root element.
+This allows to declare more routes, rests, route configurations and templates in single XML file.
+
+Camel 4 is required.
+
+=== Install JBang
+
+First install JBang according to https://www.jbang.dev
+
+When JBang is installed then you should be able to run from a shell:
+
+[source,sh]
+----
+$ jbang --version
+----
+
+This will output the version of JBang.
+
+To run this example you can either install Camel on JBang via:
+
+[source,sh]
+----
+$ jbang app install camel@apache/camel
+----
+
+Which allows to run CamelJBang with `camel` as shown below.
+
+=== How to run
+
+Then you can run this example using:
+
+[source,sh]
+----
+$ camel run app.xml
+----
+
+Or run with JBang using the longer command line (without installing camel as app in JBang):
+
+[source,sh]
+----
+$ jbang camel@apache/camel run app.xml
+----
+
+=== Live reload
+
+You can run the example in dev mode which allows you to edit the example,
+and hot-reload when the file is saved.
+
+[source,sh]
+----
+$ camel run app.xml --dev
+----
+
+=== Run directly from github
+
+The example can also be run directly by referring to the github URL as shown:
+
+[source,sh]
+----
+$ jbang camel@apache/camel run https://github.com/apache/camel-kamelets-examples/tree/main/jbang/app-routes
+----
+
+=== Developer Web Console
+
+You can enable the developer console via `--console` flag as show:
+
+[source,sh]
+----
+$ camel run app.xml --console
+----
+
+Then you can browse: http://localhost:8080/q/dev to introspect the running Camel applicaton.
+
+
+=== 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/jbang/app-routes/app.xml b/jbang/app-routes/app.xml
new file mode 100644
index 0000000..79f18e4
--- /dev/null
+++ b/jbang/app-routes/app.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<camel>
+
+    <route id="r1">
+        <from uri="timer:xml?period={{time:1200}}"/>
+        <setBody>
+            <simple>Hello Camel from ${routeId}</simple>
+        </setBody>
+        <log message="${body}"/>
+    </route>
+
+    <route id="r2">
+        <from uri="timer:xml?period={{time:1300}}"/>
+        <setBody>
+            <simple>Hello Camel from ${routeId}</simple>
+        </setBody>
+        <log message="${body}"/>
+    </route>
+
+</camel>