From d42c1fa4eca1d9d84a808523a3422355142f4c40 Mon Sep 17 00:00:00 2001 From: lburgazzoli Date: Fri, 23 Sep 2016 14:59:56 +0200 Subject: [PATCH] OSFUSE-296: Provide example usage of properties from ConfigMap in Karaf quickstart --- README.md | 17 +++-- pom.xml | 13 +--- .../fabric8/quickstarts/camel/log/MyBean.java | 28 ++++++++ .../OSGI-INF/blueprint/camel-log.xml | 68 +++++++++++-------- 4 files changed, 82 insertions(+), 44 deletions(-) create mode 100644 src/main/java/io/fabric8/quickstarts/camel/log/MyBean.java diff --git a/README.md b/README.md index 9a17e96..731d3a6 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,25 @@ # Karaf Camel Log QuickStart -This quickstart shows a simple Apache Camel application that logs a message to the server log every 5th second. - -This example is implemented using solely the XML DSL (there is no Java code). The source code is provided in the following XML file `src/main/resources/OSGI-INF/blueprint/camel-log.xml`. +This quickstart shows a simple Apache Camel application that logs a message taken from a Kubernetes ConfigMap to the server log every 5th second. It also shows how Karaf assembly files can be overriden using resources from `src/main/resources/assembly/`. The included sample log file `etc/org.ops4j.pax.logging.cfg` sets the log level to DEBUG. +Before running the example you should create a ConfigMap named camel-log in Kubernetes with at least a single key named message. + +* Kubernetes: + ``` + kubectl create configmap camel-log --from-literal=message=Hello + ``` + +* OpenShift: + ``` + oc create configmap camel-log --from-literal=message=Hello + ``` ### Building The example can be built with - mvn clean install + mvn clean install -Ddocker.skip ### Running the example in fabric8 diff --git a/pom.xml b/pom.xml index d4f4fe7..c2efbf7 100644 --- a/pom.xml +++ b/pom.xml @@ -33,9 +33,8 @@ 2.17.3 2.4.4 - 4.0.5 + 4.0.6 2.2.161 - 1.3.72 3.3 2.18.1 @@ -115,13 +114,6 @@ features xml - - io.fabric8.kubernetes - kubernetes-karaf - ${kubernetes-client.version} - features - xml - io.fabric8 fabric8-karaf-features @@ -206,8 +198,6 @@ jaas aries-blueprint camel-blueprint - kubernetes-client - openshift-client fabric8-karaf-blueprint @@ -220,7 +210,6 @@ --> static - Discard mvn:org.apache.karaf.jaas/org.apache.karaf.jaas.boot/${karaf.version};type:=boot;export:=true;delegate:=true diff --git a/src/main/java/io/fabric8/quickstarts/camel/log/MyBean.java b/src/main/java/io/fabric8/quickstarts/camel/log/MyBean.java new file mode 100644 index 0000000..8c6ed47 --- /dev/null +++ b/src/main/java/io/fabric8/quickstarts/camel/log/MyBean.java @@ -0,0 +1,28 @@ +/** + * Copyright 2005-2016 Red Hat, Inc. + * + * Red Hat 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 io.fabric8.quickstarts.camel.log; + +public class MyBean { + private final String message; + + public MyBean(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } +} diff --git a/src/main/resources/OSGI-INF/blueprint/camel-log.xml b/src/main/resources/OSGI-INF/blueprint/camel-log.xml index 3e41e8a..55c60b4 100644 --- a/src/main/resources/OSGI-INF/blueprint/camel-log.xml +++ b/src/main/resources/OSGI-INF/blueprint/camel-log.xml @@ -23,34 +23,46 @@ The root element for any OSGi Blueprint file is 'blueprint' - you also see the namespace definitions for both the Blueprint and the Camel namespaces. --> - - - - - - - - - - Hello from Camel! - - - - + http://www.osgi.org/xmlns/blueprint/v1.0.0 + https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd + http://camel.apache.org/schema/blueprint + http://camel.apache.org/schema/blueprint/camel-blueprint.xsd + http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.3.0 + http://aries.apache.org/schemas/blueprint-ext/blueprint-ext-1.3.xsd"> + + + + + + + + + + + + + + + + + + +