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-kamelets-examples.git
The following commit(s) were added to refs/heads/main by this push: new 0f56bea Add local JAR example 0f56bea is described below commit 0f56bea1eeb6aa1361b6f89652fbed879e0210b9 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Wed Apr 19 08:55:11 2023 +0200 Add local JAR example --- jbang/local-jar/README.adoc | 81 +++++++++++++++++++++++++++++++ jbang/local-jar/commons-lang3-3.12.0.jar | Bin 0 -> 587402 bytes jbang/local-jar/foo.java | 27 +++++++++++ 3 files changed, 108 insertions(+) diff --git a/jbang/local-jar/README.adoc b/jbang/local-jar/README.adoc new file mode 100644 index 0000000..106a4ab --- /dev/null +++ b/jbang/local-jar/README.adoc @@ -0,0 +1,81 @@ +== Local JAR + +This example shows how you can copy JAR files to this folder, +and use them in your Camel routes. + +=== 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 foo.java commons-lang3-3.12.0.jar +---- + +Or run with wildcard: + +[source,sh] +---- +$ camel run * +---- + + +Or run with JBang using the longer command line (without installing camel as app in JBang): + +[source,sh] +---- +$ jbang camel@apache/camel run foo.java commons-lang3-3.12.0.jar +---- + +=== Exporting to Spring Boot or Quarkus + +You can export the example to a vanilla Camel Spring Boot / Camel Quarkus project, and the local JARs +will be included as well. + +[source,sh] +---- +$ camel export --gav=com.foo:acme:1.0 --runtime=spring-boot --directory=code +---- + +Which will export to a Maven based Spring Boot project in the `code` folder. +You can then run the example with Spring Boot: + +[source,sh] +---- +$ cd code +$ ./mvnw spring-boot:run +-- + + + +=== 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/local-jar/commons-lang3-3.12.0.jar b/jbang/local-jar/commons-lang3-3.12.0.jar new file mode 100644 index 0000000..4d434a2 Binary files /dev/null and b/jbang/local-jar/commons-lang3-3.12.0.jar differ diff --git a/jbang/local-jar/foo.java b/jbang/local-jar/foo.java new file mode 100644 index 0000000..3add8e1 --- /dev/null +++ b/jbang/local-jar/foo.java @@ -0,0 +1,27 @@ +// camel-k: language=java + +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.builder.RouteBuilder; + +import org.apache.commons.lang3.SystemUtils; + +public class foo extends RouteBuilder { + + @Override + public void configure() throws Exception { + + // Write your routes here, for example: + from("timer:java?period={{time:1000}}").routeId("java") + .process(new Processor() { + + @Override + public void process(Exchange exchange) throws Exception { + // use code from local-jar (commons-lang) + String result = SystemUtils.getUserHome().toString(); + exchange.getMessage().setBody(result); + } + }) + .log("${body}"); + } +}