You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/02/01 20:59:09 UTC

[1/2] camel git commit: Add Camel OSGi to Camel CDI feature

Repository: camel
Updated Branches:
  refs/heads/master 3e94cdd3e -> 35becd183


Add Camel OSGi to Camel CDI feature


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d12c884e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d12c884e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d12c884e

Branch: refs/heads/master
Commit: d12c884edaeb773581e704d90a433fd2cee20bfc
Parents: 3e94cdd
Author: Antonin Stefanutti <an...@stefanutti.fr>
Authored: Mon Feb 1 20:42:36 2016 +0100
Committer: Antonin Stefanutti <an...@stefanutti.fr>
Committed: Mon Feb 1 20:42:36 2016 +0100

----------------------------------------------------------------------
 platforms/karaf/features/src/main/resources/features.xml | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d12c884e/platforms/karaf/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml
index 10ddd6e..a43c917 100644
--- a/platforms/karaf/features/src/main/resources/features.xml
+++ b/platforms/karaf/features/src/main/resources/features.xml
@@ -265,6 +265,7 @@
   	<!-- you've got to install pax-cdi-weld or pax-cdi-openwebbeans in order to make it works -->
   	<feature version='${pax-cdi-version}'>pax-cdi</feature>
     <feature version='${project.version}'>camel-core</feature>
+    <bundle>mvn:org.apache.camel/camel-core-osgi/${project.version}</bundle>
     <bundle>mvn:org.apache.camel/camel-cdi/${project.version}</bundle>
   </feature>
   <feature name='camel-chunk' version='${project.version}' resolver='(obr)' start-level='50'>


[2/2] camel git commit: OSGi CDI example

Posted by da...@apache.org.
OSGi CDI example


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/35becd18
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/35becd18
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/35becd18

Branch: refs/heads/master
Commit: 35becd1839f6a1bb6e77851ff7190703420ed430
Parents: d12c884
Author: Antonin Stefanutti <an...@stefanutti.fr>
Authored: Mon Feb 1 20:45:05 2016 +0100
Committer: Antonin Stefanutti <an...@stefanutti.fr>
Committed: Mon Feb 1 20:45:05 2016 +0100

----------------------------------------------------------------------
 examples/camel-example-cdi-osgi/README.md       |  90 ++++++
 examples/camel-example-cdi-osgi/pom.xml         | 303 +++++++++++++++++++
 .../apache/camel/example/cdi/osgi/Config.java   |  35 +++
 .../apache/camel/example/cdi/osgi/Consumer.java |  31 ++
 .../org/apache/camel/example/cdi/osgi/Jms.java  |  41 +++
 .../apache/camel/example/cdi/osgi/Producer.java |  30 ++
 .../src/main/resources/META-INF/LICENSE.txt     | 203 +++++++++++++
 .../src/main/resources/META-INF/NOTICE.txt      |  11 +
 .../src/main/resources/META-INF/beans.xml       |  18 ++
 .../src/main/resources/jms.properties           |   1 +
 .../src/main/resources/log4j.properties         |  27 ++
 .../camel/example/cdi/osgi/CdiOsgiIT.java       | 101 +++++++
 .../camel/example/cdi/osgi/PaxExamOptions.java  | 119 ++++++++
 examples/pom.xml                                |   1 +
 parent/pom.xml                                  |   1 +
 15 files changed, 1012 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/35becd18/examples/camel-example-cdi-osgi/README.md
----------------------------------------------------------------------
diff --git a/examples/camel-example-cdi-osgi/README.md b/examples/camel-example-cdi-osgi/README.md
new file mode 100644
index 0000000..0fc4370
--- /dev/null
+++ b/examples/camel-example-cdi-osgi/README.md
@@ -0,0 +1,90 @@
+# OSGi Example - CDI
+
+### Introduction
+
+This example illustrates a CDI application that can be executed inside an OSGi container
+using PAX CDI. This application can run unchanged as well in Java SE inside a standalone
+CDI container.
+
+The example starts an ActiveMQ in-memory broker and publishes a message when the Camel
+context has started.
+
+The example is implemented in Java with CDI dependency injection. It uses JBoss Weld
+as the minimal CDI container to run the application, though you can run the application
+in any CDI compliant container. In OSGi, PAX CDI is used to managed the lifecycle of
+the CDI container.
+
+The `camel-core` and `camel-sjms` components are used in this example.
+
+### Build
+
+You will need to build this example first:
+
+    $ mvn install
+
+### Run
+
+#### Java SE
+
+You can run this example using:
+
+    $ mvn camel:run
+
+When the Camel application starts, you should see the following message being logged to the console, e.g.:
+```
+2016-02-01 20:13:46,922 [cdi.Main.main()] INFO  DefaultCamelContext - Apache Camel 2.17-SNAPSHOT (CamelContext: osgi-example) started in 0.769 seconds
+2016-02-01 20:13:47,008 [ Session Task-1] INFO  consumer-route      - Received message [Sample Message] from [Producer]
+```
+
+The Camel application can be stopped pressing <kbd>ctrl</kbd>+<kbd>c</kbd> in the shell.
+
+#### OSGi / Karaf
+
+This example can be executed within Karaf. From the command line, in `bin` directory,
+start Karaf:
+
+    $ ./karaf
+    
+Then install the following pre-requisites:
+
+    features:addUrl mvn:org.apache.camel.karaf/apache-camel/${version}/xml/features
+    features:addUrl mvn:org.apache.activemq/activemq-karaf/5.12.1/xml/features
+    features:install activemq-broker-noweb
+    features:install pax-cdi-weld
+    features:install camel-cdi
+    features:install camel-sjms
+    
+Finally install and start the example:
+
+    osgi:install -s mvn:org.apache.camel/camel-example-cdi-osgi/${version}
+
+The following messages should be logged:
+
+```
+2016-02-01 20:28:43,446 | INFO  | nsole user karaf | DefaultCamelContext              | 58 - org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Apache Camel 2.17-SNAPSHOT (CamelContext: osgi-example) is starting
+2016-02-01 20:28:43,447 | INFO  | nsole user karaf | ManagedManagementStrategy        | 58 - org.apache.camel.camel-core - 2.17.0.SNAPSHOT | JMX is enabled
+2016-02-01 20:28:43,565 | INFO  | nsole user karaf | DefaultTypeConverter             | 58 - org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Loaded 182 type converters
+2016-02-01 20:28:43,585 | INFO  | nsole user karaf | DefaultRuntimeEndpointRegistry   | 58 - org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Runtime endpoint registry is in extended mode gathering usage statistics of all incoming and outgoing endpoints (cache limit: 1000)
+2016-02-01 20:28:43,675 | INFO  | nsole user karaf | BrokerService                    | 187 - org.apache.activemq.activemq-osgi - 5.12.1 | Using Persistence Adapter: MemoryPersistenceAdapter
+2016-02-01 20:28:43,679 | INFO  | nsole user karaf | BrokerService                    | 187 - org.apache.activemq.activemq-osgi - 5.12.1 | Apache ActiveMQ 5.12.1 (broker, ID:mbp.local-50823-1454354911797-0:2) is starting
+2016-02-01 20:28:43,679 | INFO  | nsole user karaf | BrokerService                    | 187 - org.apache.activemq.activemq-osgi - 5.12.1 | Apache ActiveMQ 5.12.1 (broker, ID:mbp.local-50823-1454354911797-0:2) started
+2016-02-01 20:28:43,679 | INFO  | nsole user karaf | BrokerService                    | 187 - org.apache.activemq.activemq-osgi - 5.12.1 | For help or more information please see: http://activemq.apache.org
+2016-02-01 20:28:43,679 | WARN  | nsole user karaf | BrokerService                    | 187 - org.apache.activemq.activemq-osgi - 5.12.1 | Memory Usage for the Broker (1024 mb) is more than the maximum available for the JVM: 455 mb - resetting to 70% of maximum available: 318 mb
+2016-02-01 20:28:43,681 | INFO  | nsole user karaf | TransportConnector               | 187 - org.apache.activemq.activemq-osgi - 5.12.1 | Connector vm://broker started
+2016-02-01 20:28:43,784 | INFO  | nsole user karaf | DefaultCamelContext              | 58 - org.apache.camel.camel-core - 2.17.0.SNAPSHOT | AllowUseOriginalMessage is enabled. If access to the original message is not needed, then its recommended to turn this option off as it may improve performance.
+2016-02-01 20:28:43,784 | INFO  | nsole user karaf | DefaultCamelContext              | 58 - org.apache.camel.camel-core - 2.17.0.SNAPSHOT | StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
+2016-02-01 20:28:43,845 | INFO  | nsole user karaf | DefaultCamelContext              | 58 - org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Route: consumer-route started and consuming from: Endpoint[sjms://sample.queue]
+2016-02-01 20:28:43,845 | INFO  | nsole user karaf | DefaultCamelContext              | 58 - org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Total 1 routes, of which 1 is started.
+2016-02-01 20:28:43,846 | INFO  | nsole user karaf | DefaultCamelContext              | 58 - org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Apache Camel 2.17-SNAPSHOT (CamelContext: osgi-example) started in 0.400 seconds
+2016-02-01 20:28:43,899 | INFO  | Q Session Task-1 | consumer-route                   | 58 - org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Received message [Sample Message] from [Producer]
+
+```
+
+### Forum, Help, etc
+
+If you hit an problems please let us know on the Camel Forums
+	<http://camel.apache.org/discussion-forums.html>
+
+Please help us make Apache Camel better - we appreciate any feedback you may have. Enjoy!
+
+The Camel riders!

http://git-wip-us.apache.org/repos/asf/camel/blob/35becd18/examples/camel-example-cdi-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-cdi-osgi/pom.xml b/examples/camel-example-cdi-osgi/pom.xml
new file mode 100755
index 0000000..890ae7e
--- /dev/null
+++ b/examples/camel-example-cdi-osgi/pom.xml
@@ -0,0 +1,303 @@
+<?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</groupId>
+    <artifactId>examples</artifactId>
+    <version>2.17-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-example-cdi-osgi</artifactId>
+  <name>Camel :: Example :: CDI :: OSGi</name>
+  <description>PAX CDI example</description>
+  <packaging>bundle</packaging>
+
+  <dependencies>
+
+    <!-- Camel -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-cdi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-sjms</artifactId>
+    </dependency>
+
+    <!-- ActiveMQ -->
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>activemq-client</artifactId>
+    </dependency>
+
+    <!-- CDI API -->
+    <dependency>
+      <groupId>javax.enterprise</groupId>
+      <artifactId>cdi-api</artifactId>
+      <version>${cdi-api-1.2-version}</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <!-- OSGi API -->
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+      <scope>provided</scope>
+    </dependency>
+
+    <!-- logging -->
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+    </dependency>
+
+    <!-- test -->
+
+    <!-- PAX Exam -->
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-spi</artifactId>
+      <version>${pax-exam-version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-junit4</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-container-karaf</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.url</groupId>
+      <artifactId>pax-url-aether</artifactId>
+      <version>2.4.5</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.tinybundles</groupId>
+      <artifactId>tinybundles</artifactId>
+      <version>2.1.1</version>
+    </dependency>
+
+    <!-- Karaf & Command Shell -->
+    <dependency>
+      <groupId>org.apache.karaf</groupId>
+      <artifactId>apache-karaf</artifactId>
+      <version>${karaf4-version}</version>
+      <type>zip</type>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.karaf.features</groupId>
+          <artifactId>framework</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.karaf.shell</groupId>
+      <artifactId>org.apache.karaf.shell.core</artifactId>
+      <version>${karaf4-version}</version>
+    </dependency>
+
+    <!-- Karaf Camel commands -->
+    <dependency>
+      <groupId>org.apache.camel.karaf</groupId>
+      <artifactId>camel-karaf-commands</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>*</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-commands-core</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-catalog</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- Karaf Features -->
+    <dependency>
+      <groupId>org.ops4j.pax.cdi</groupId>
+      <artifactId>pax-cdi-features</artifactId>
+      <version>${pax-cdi-version}</version>
+      <classifier>features</classifier>
+      <type>xml</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel.karaf</groupId>
+      <artifactId>apache-camel</artifactId>
+      <version>${project.version}</version>
+      <classifier>features</classifier>
+      <type>xml</type>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>*</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>activemq-karaf</artifactId>
+      <version>${activemq-version}</version>
+      <classifier>features</classifier>
+      <type>xml</type>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>*</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+
+    <!-- for camel:run -->
+    <dependency>
+      <groupId>org.apache.deltaspike.cdictrl</groupId>
+      <artifactId>deltaspike-cdictrl-weld</artifactId>
+      <version>${deltaspike-version}</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.weld.se</groupId>
+      <artifactId>weld-se</artifactId>
+      <version>${weld2-version}</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>activemq-broker</artifactId>
+      <version>${activemq-version}</version>
+      <scope>runtime</scope>
+    </dependency>
+
+  </dependencies>
+
+  <build>
+    <!-- Easier to get the local artifact from the integration tests -->
+    <finalName>${artifactId}</finalName>
+
+    <plugins>
+
+      <!-- Camel plugin to run the example in Java SE -->
+      <plugin>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-maven-plugin</artifactId>
+        <version>${project.version}</version>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.servicemix.tooling</groupId>
+        <artifactId>depends-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>generate-depends-file</id>
+            <goals>
+              <goal>generate-depends-file</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
+            <Export-Package>org.apache.camel.example.cdi.osgi*</Export-Package>
+            <Import-Package>*</Import-Package>
+            <Require-Capability>
+              osgi.extender; filter:="(osgi.extender=pax.cdi)",
+              org.ops4j.pax.cdi.extension; filter:="(extension=camel-cdi-extension)"
+            </Require-Capability>
+          </instructions>
+        </configuration>
+      </plugin>
+
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>integration</id>
+      <build>
+        <plugins>
+          <!-- Execute in the integration-test phase so that the packaged JAR can be used -->
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <executions>
+              <execution>
+                <phase>integration-test</phase>
+                <goals>
+                  <goal>test</goal>
+                </goals>
+                <configuration>
+                  <includes>
+                    <include>**/*IT.java</include>
+                  </includes>
+                  <forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/35becd18/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Config.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Config.java b/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Config.java
new file mode 100644
index 0000000..d480326
--- /dev/null
+++ b/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Config.java
@@ -0,0 +1,35 @@
+/**
+ * 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.
+ */
+package org.apache.camel.example.cdi.osgi;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+import org.apache.camel.component.properties.PropertiesComponent;
+
+class Config {
+
+    @Produces
+    @ApplicationScoped
+    @Named("properties")
+    PropertiesComponent properties() {
+        PropertiesComponent component = new PropertiesComponent();
+        component.setLocation("classpath:jms.properties");
+        return component;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/35becd18/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Consumer.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Consumer.java b/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Consumer.java
new file mode 100644
index 0000000..e3afae8
--- /dev/null
+++ b/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Consumer.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.
+ */
+package org.apache.camel.example.cdi.osgi;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.ContextName;
+
+@ContextName("osgi-example")
+class Consumer extends RouteBuilder {
+
+    @Override
+    public void configure() {
+        from("sjms:sample.queue")
+            .routeId("consumer-route")
+            .log("Received message [${body}] from [${header.Sender}]");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/35becd18/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Jms.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Jms.java b/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Jms.java
new file mode 100644
index 0000000..ef7e28a
--- /dev/null
+++ b/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Jms.java
@@ -0,0 +1,41 @@
+/**
+ * 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.
+ */
+package org.apache.camel.example.cdi.osgi;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.PropertyInject;
+import org.apache.camel.component.sjms.SjmsComponent;
+
+class Jms {
+
+    @PropertyInject("jms.maxConnections")
+    int maxConnections;
+
+    @Produces
+    @Named("sjms")
+    @ApplicationScoped
+    SjmsComponent sjms() {
+        SjmsComponent component = new SjmsComponent();
+        component.setConnectionFactory(new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useShutdownHook=false&broker.useJmx=false"));
+        component.setConnectionCount(maxConnections);
+        return component;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/35becd18/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Producer.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Producer.java b/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Producer.java
new file mode 100644
index 0000000..89accc9
--- /dev/null
+++ b/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Producer.java
@@ -0,0 +1,30 @@
+/**
+ * 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.
+ */
+package org.apache.camel.example.cdi.osgi;
+
+import javax.enterprise.event.Observes;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.management.event.CamelContextStartedEvent;
+
+class Producer {
+
+    void sendMessage(@Observes CamelContextStartedEvent event, @Uri("sjms:sample.queue") ProducerTemplate producer) {
+        producer.sendBodyAndHeader("Sample Message", "Sender", getClass().getSimpleName());
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/35becd18/examples/camel-example-cdi-osgi/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/examples/camel-example-cdi-osgi/src/main/resources/META-INF/LICENSE.txt b/examples/camel-example-cdi-osgi/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/examples/camel-example-cdi-osgi/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+

http://git-wip-us.apache.org/repos/asf/camel/blob/35becd18/examples/camel-example-cdi-osgi/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/examples/camel-example-cdi-osgi/src/main/resources/META-INF/NOTICE.txt b/examples/camel-example-cdi-osgi/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/examples/camel-example-cdi-osgi/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.

http://git-wip-us.apache.org/repos/asf/camel/blob/35becd18/examples/camel-example-cdi-osgi/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-cdi-osgi/src/main/resources/META-INF/beans.xml b/examples/camel-example-cdi-osgi/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..112d56d
--- /dev/null
+++ b/examples/camel-example-cdi-osgi/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,18 @@
+<?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.
+-->
+<beans/>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/35becd18/examples/camel-example-cdi-osgi/src/main/resources/jms.properties
----------------------------------------------------------------------
diff --git a/examples/camel-example-cdi-osgi/src/main/resources/jms.properties b/examples/camel-example-cdi-osgi/src/main/resources/jms.properties
new file mode 100644
index 0000000..5befb53
--- /dev/null
+++ b/examples/camel-example-cdi-osgi/src/main/resources/jms.properties
@@ -0,0 +1 @@
+jms.maxConnections=4
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/35becd18/examples/camel-example-cdi-osgi/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/examples/camel-example-cdi-osgi/src/main/resources/log4j.properties b/examples/camel-example-cdi-osgi/src/main/resources/log4j.properties
new file mode 100644
index 0000000..332fc9b
--- /dev/null
+++ b/examples/camel-example-cdi-osgi/src/main/resources/log4j.properties
@@ -0,0 +1,27 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+
+# default properties to initialise log4j
+log4j.rootLogger=INFO, console
+
+# settings for specific packages
+#log4j.logger.org.apache.camel.cdi=DEBUG
+
+# Console appender
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/35becd18/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/CdiOsgiIT.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/CdiOsgiIT.java b/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/CdiOsgiIT.java
new file mode 100644
index 0000000..a05b3fd
--- /dev/null
+++ b/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/CdiOsgiIT.java
@@ -0,0 +1,101 @@
+/**
+ * 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.
+ */
+package org.apache.camel.example.cdi.osgi;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import javax.inject.Inject;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.api.management.mbean.ManagedRouteMBean;
+import org.apache.karaf.shell.api.console.Session;
+import org.apache.karaf.shell.api.console.SessionFactory;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+
+import static org.apache.camel.example.cdi.osgi.PaxExamOptions.ACTIVEMQ;
+import static org.apache.camel.example.cdi.osgi.PaxExamOptions.CAMEL_CDI;
+import static org.apache.camel.example.cdi.osgi.PaxExamOptions.CAMEL_COMMANDS;
+import static org.apache.camel.example.cdi.osgi.PaxExamOptions.CAMEL_SJMS;
+import static org.apache.camel.example.cdi.osgi.PaxExamOptions.KARAF;
+import static org.apache.camel.example.cdi.osgi.PaxExamOptions.PAX_CDI_IMPL;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.streamBundle;
+import static org.ops4j.pax.exam.CoreOptions.when;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.debugConfiguration;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class CdiOsgiIT {
+
+    @Inject
+    private CamelContext context;
+
+    @Inject
+    private SessionFactory sessionFactory;
+
+    @Configuration
+    public Option[] config() throws IOException {
+        return options(
+            KARAF.option(),
+            CAMEL_COMMANDS.option(),
+            PAX_CDI_IMPL.option(),
+            CAMEL_CDI.option(),
+            CAMEL_SJMS.option(),
+            ACTIVEMQ.option(),
+            streamBundle(
+                TinyBundles.bundle()
+                    .read(
+                        Files.newInputStream(
+                            Paths.get("target")
+                                .resolve("camel-example-cdi-osgi.jar")))
+                    .build()),
+            when(false)
+                .useOptions(
+                    debugConfiguration("5005", true))
+        );
+    }
+
+    @Test
+    public void testRouteStatus() {
+        assertThat("Route status is incorrect!", context.getRouteStatus("consumer-route"), equalTo(ServiceStatus.Started));
+    }
+
+    @Test
+    public void testExchangesCompleted() throws Exception {
+        ManagedRouteMBean route = context.getManagedRoute(context.getRoute("consumer-route").getId(), ManagedRouteMBean.class);
+        assertThat("Number of exchanges completed is incorrect!", route.getExchangesCompleted(), equalTo(1L));
+    }
+
+    @Test
+    public void testExecuteCommands() throws Exception {
+        Session session = sessionFactory.create(System.in, System.out, System.err);
+        session.execute("camel:context-list");
+        session.execute("camel:route-list");
+        session.execute("camel:route-info consumer-route");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/35becd18/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/PaxExamOptions.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/PaxExamOptions.java b/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/PaxExamOptions.java
new file mode 100644
index 0000000..452812a
--- /dev/null
+++ b/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/PaxExamOptions.java
@@ -0,0 +1,119 @@
+/**
+ * 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.
+ */
+package org.apache.camel.example.cdi.osgi;
+
+import java.io.File;
+
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.karaf.options.LogLevelOption;
+import org.ops4j.pax.exam.options.DefaultCompositeOption;
+
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
+
+public enum PaxExamOptions {
+
+    KARAF(
+        karafDistributionConfiguration()
+            .frameworkUrl(
+                maven()
+                    .groupId("org.apache.karaf")
+                    .artifactId("apache-karaf")
+                    .versionAsInProject()
+                    .type("zip"))
+            .name("Apache Karaf")
+            .useDeployFolder(false)
+            .unpackDirectory(new File("target/paxexam/unpack/")),
+        keepRuntimeFolder(),
+        // Don't bother with local console output as it just ends up cluttering the logs
+        configureConsole().ignoreLocalConsole(),
+        // Force the log level to INFO so we have more details during the test. It defaults to WARN.
+        logLevel(LogLevelOption.LogLevel.INFO),
+        // JUnit and Hamcrest
+        junitBundles()
+    ),
+    CAMEL_COMMANDS(
+        mavenBundle()
+            .groupId("org.apache.camel.karaf")
+            .artifactId("camel-karaf-commands")
+            .versionAsInProject(),
+        mavenBundle()
+            .groupId("org.apache.camel")
+            .artifactId("camel-commands-core")
+            .versionAsInProject(),
+        mavenBundle()
+            .groupId("org.apache.camel")
+            .artifactId("camel-catalog")
+            .versionAsInProject()
+    ),
+    PAX_CDI_IMPL(
+        features(
+            maven()
+                .groupId("org.ops4j.pax.cdi")
+                .artifactId("pax-cdi-features")
+                .type("xml")
+                .classifier("features")
+                .versionAsInProject(),
+            "pax-cdi-weld")
+    ),
+    CAMEL_CDI(
+        features(
+            maven()
+                .groupId("org.apache.camel.karaf")
+                .artifactId("apache-camel")
+                .type("xml")
+                .classifier("features")
+                .versionAsInProject(),
+            "camel-cdi")
+    ),
+    CAMEL_SJMS(
+        mavenBundle()
+            .groupId("org.apache.camel")
+            .artifactId("camel-sjms")
+            .versionAsInProject(),
+        mavenBundle()
+            .groupId("commons-pool")
+            .artifactId("commons-pool")
+            .versionAsInProject()
+    ),
+    ACTIVEMQ(
+        features(
+            maven()
+                .groupId("org.apache.activemq")
+                .artifactId("activemq-karaf")
+                .type("xml")
+                .classifier("features")
+                .versionAsInProject(),
+            "activemq-broker-noweb")
+    );
+
+    private final Option[] options;
+
+    PaxExamOptions(Option... options) {
+        this.options = options;
+    }
+
+    public Option option() {
+        return new DefaultCompositeOption(options);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/35becd18/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index 78fc546..16df3fc 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -38,6 +38,7 @@
     <module>camel-example-cafe</module>
     <module>camel-example-cdi</module>
     <module>camel-example-cdi-metrics</module>
+    <module>camel-example-cdi-osgi</module>
     <module>camel-example-cdi-properties</module>
     <module>camel-example-cdi-rest-servlet</module>
     <module>camel-example-cxf</module>

http://git-wip-us.apache.org/repos/asf/camel/blob/35becd18/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 8fbf980..cac96b9 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -346,6 +346,7 @@
     <kafka-clients-bundle-version>0.9.0.0_1</kafka-clients-bundle-version>
     <karaf-version>2.4.4</karaf-version>
     <karaf3-version>3.0.5</karaf3-version>
+    <karaf4-version>4.0.4</karaf4-version>
     <kie-version>6.3.0.Final</kie-version>
     <krati-version>0.4.9</krati-version>
     <kubernetes-client-version>1.3.67</kubernetes-client-version>