You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by jp...@apache.org on 2018/07/18 09:59:33 UTC
[camel] 02/02: Add camel-fhir OSGi example
This is an automated email from the ASF dual-hosted git repository.
jpoth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 8bde80ed2355cbcec436610ea3aebfba7a8f11bb
Author: jpoth <po...@gmail.com>
AuthorDate: Wed Jul 18 11:58:18 2018 +0200
Add camel-fhir OSGi example
---
examples/camel-example-fhir-osgi/README.md | 142 +++++++++++++
...pache.camel.example.fhir.osgi.configuration.cfg | 19 ++
examples/camel-example-fhir-osgi/pom.xml | 233 +++++++++++++++++++++
.../src/main/data/hl7v2.patient | 1 +
.../apache/camel/example/fhir/osgi/FhirRoute.java | 64 ++++++
.../resources/OSGI-INF/blueprint/camel-context.xml | 35 ++++
.../src/main/resources/log4j2.properties | 23 ++
.../apache/camel/example/fhir/osgi/FhirOsgiIT.java | 77 +++++++
.../camel/example/fhir/osgi/PaxExamOptions.java | 72 +++++++
examples/pom.xml | 1 +
10 files changed, 667 insertions(+)
diff --git a/examples/camel-example-fhir-osgi/README.md b/examples/camel-example-fhir-osgi/README.md
new file mode 100644
index 0000000..c96296c
--- /dev/null
+++ b/examples/camel-example-fhir-osgi/README.md
@@ -0,0 +1,142 @@
+# FHIR Example - OSGi
+
+### Introduction
+
+This is an example application of the `camel-fhir` component that can be executed inside an OSGi container. We will be
+using Apache Karaf.
+
+### Build
+
+You will need to build this example first:
+
+```sh
+$ mvn install
+```
+
+### Run OSGi / Karaf
+
+This example can be executed within Karaf 4.x
+
+To run the example, from the command line:
+
+1. In the Karaf install root directory, start Karaf:
+
+ ```sh
+ $ bin/karaf
+ ```
+
+2. Install the pre-requisites:
+
+ ```sh
+ karaf@root()> repo-add camel ${version}
+ karaf@root()> feature:install camel-blueprint camel-hl7 camel-fhir
+ ```
+
+3. Copy the configuration file org.apache.camel.example.fhir.osgi.configuration.cfg to the etc/ directory of your Karaf installation:
+ ```
+ InstallDir/etc/org.apache.camel.example.fhir.osgi.configuration.cfg
+ ```
+4. Then install and start the example:
+
+ ```sh
+ karaf@root()> install -s mvn:org.apache.camel.example/camel-example-fhir-osgi/${version}
+ ```
+
+When the Camel application runs, you should see a folder created under `work/fhir/input`. Copy the file `hl7v2.patient`
+located in the `data` folder into it.
+
+By tailing the log with:
+
+ ```sh
+ karaf@root()> log:tail
+ ```
+
+The following messages should be displayed:
+
+ ```
+ 2018-07-17 17:02:35,590 | INFO | nt Dispatcher: 1 | FhirContext | 52 - ca.uhn.hapi.fhir.hapi-fhir-base - 3.3.0 | Creating new FHIR context for FHIR version [DSTU3]
+ 2018-07-17 17:02:35,631 | INFO | nt Dispatcher: 1 | BlueprintCamelContext | 59 - org.apache.camel.camel-blueprint - 2.23.0.SNAPSHOT | Route: fhir-example-osgi started and consuming from: file://work/fhir/input
+ 2018-07-17 17:02:35,631 | INFO | nt Dispatcher: 1 | BlueprintCamelContext | 59 - org.apache.camel.camel-blueprint - 2.23.0.SNAPSHOT | Total 1 routes, of which 1 are started
+ 2018-07-17 17:02:35,632 | INFO | nt Dispatcher: 1 | BlueprintCamelContext | 59 - org.apache.camel.camel-blueprint - 2.23.0.SNAPSHOT | Apache Camel 2.23.0-SNAPSHOT (CamelContext: camel-fhir) started in 0.853 seconds
+ 2018-07-17 17:03:06,157 | INFO | /work/fhir/input | fhir-example-osgi | 61 - org.apache.camel.camel-core - 2.23.0.SNAPSHOT | Converting hl7v2.patient
+ 2018-07-17 17:03:06,577 | INFO | /work/fhir/input | fhir-example-osgi | 61 - org.apache.camel.camel-core - 2.23.0.SNAPSHOT | Inserting Patient: {"resourceType":"Patient","id":"100005056","name":[{"family":"Freeman","given":["Vincent"]}]}
+ 2018-07-17 17:03:08,829 | INFO | d #2 - CamelFhir | fhir-example-osgi | 61 - org.apache.camel.camel-core - 2.23.0.SNAPSHOT | Patient created successfully: true
+ ```
+
+Hit <kbd>ctrl</kbd>+<kbd>c</kbd> to exit the log command.
+
+Camel commands can be used to gain some insights on the Camel context, e.g.:
+
+- The `camel:context-list` displays the Camel context:
+
+ ```
+ karaf@root()> camel:context-list
+ Context Status Total # Failed # Inflight # Uptime
+ ------- ------ ------- -------- ---------- ------
+ camel-fhir Started 1 0 0 3 minute
+ ```
+
+- The `camel:route-list` command displays the Camel routes:
+
+ ```
+ karaf@root()> camel:route-list
+ Context Route Status Total # Failed # Inflight # Uptime
+ ------- ----- ------ ------- -------- ---------- ------
+ camel-fhir fhir-example-osgi Started 1 0 0 4 minutes
+ ```
+
+- And the `camel:route-info` command displays route information:
+
+ ```
+ karaf@root()> camel:route-info camel-fhir fhir-example-osgi
+ Camel Route fhir-example-osgi
+ Camel Context: camel-fhir
+ State: Started
+ State: Started
+
+
+ Statistics
+ Exchanges Total: 1
+ Exchanges Completed: 1
+ Exchanges Failed: 0
+ Exchanges Inflight: 0
+ Min Processing Time: 2674 ms
+ Max Processing Time: 2674 ms
+ Mean Processing Time: 2674 ms
+ Total Processing Time: 2674 ms
+ Last Processing Time: 2674 ms
+ Delta Processing Time: 2674 ms
+ Start Statistics Date: 2018-07-17 17:02:35
+ Reset Statistics Date: 2018-07-17 17:02:35
+ First Exchange Date: 2018-07-17 17:03:08
+ Last Exchange Date: 2018-07-17 17:03:08
+ ```
+
+Finally, you can stop the example with:
+
+ ```sh
+ karaf@root()> uninstall camel-example-fhir-osgi
+ ```
+
+And check in the log that the Camel context has been gracefully
+shutdown:
+
+ ```
+ 2018-07-17 17:09:32,418 | INFO | xample-fhir-osgi | BlueprintExtender | 12 - org.apache.aries.blueprint.core - 1.8.3 | Destroying BlueprintContainer for bundle org.apache.camel.example.camel-example-fhir-osgi/2.23.0.SNAPSHOT
+ 2018-07-17 17:09:32,420 | INFO | nt Dispatcher: 1 | BlueprintCamelContext | 59 - org.apache.camel.camel-blueprint - 2.23.0.SNAPSHOT | Stopping CamelContext: camel-fhir
+ 2018-07-17 17:09:32,421 | INFO | nt Dispatcher: 1 | BlueprintCamelContext | 59 - org.apache.camel.camel-blueprint - 2.23.0.SNAPSHOT | Apache Camel 2.23.0-SNAPSHOT (CamelContext: camel-fhir) is shutting down
+ 2018-07-17 17:09:32,423 | INFO | nt Dispatcher: 1 | DefaultShutdownStrategy | 61 - org.apache.camel.camel-core - 2.23.0.SNAPSHOT | Starting to graceful shutdown 1 routes (timeout 300 seconds)
+ 2018-07-17 17:09:32,427 | INFO | 3 - ShutdownTask | DefaultShutdownStrategy | 61 - org.apache.camel.camel-core - 2.23.0.SNAPSHOT | Route: fhir-example-osgi shutdown complete, was consuming from: file://work/fhir/input
+ 2018-07-17 17:09:32,428 | INFO | nt Dispatcher: 1 | DefaultShutdownStrategy | 61 - org.apache.camel.camel-core - 2.23.0.SNAPSHOT | Graceful shutdown of 1 routes completed in 0 seconds
+ 2018-07-17 17:09:32,438 | INFO | nt Dispatcher: 1 | BlueprintCamelContext | 59 - org.apache.camel.camel-blueprint - 2.23.0.SNAPSHOT | Apache Camel 2.23.0-SNAPSHOT (CamelContext: camel-fhir) uptime 6 minutes
+ 2018-07-17 17:09:32,438 | INFO | nt Dispatcher: 1 | BlueprintCamelContext | 59 - org.apache.camel.camel-blueprint - 2.23.0.SNAPSHOT | Apache Camel 2.23.0-SNAPSHOT (CamelContext: camel-fhir) is shutdown in 0.017 seconds
+ ```
+
+### 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!
diff --git a/examples/camel-example-fhir-osgi/org.apache.camel.example.fhir.osgi.configuration.cfg b/examples/camel-example-fhir-osgi/org.apache.camel.example.fhir.osgi.configuration.cfg
new file mode 100644
index 0000000..7c159c3
--- /dev/null
+++ b/examples/camel-example-fhir-osgi/org.apache.camel.example.fhir.osgi.configuration.cfg
@@ -0,0 +1,19 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+serverUrl=http://localhost:8080/hapi-fhir-jpaserver-example/baseDstu3
+fhirVersion=DSTU3
+input=work/fhir/input
\ No newline at end of file
diff --git a/examples/camel-example-fhir-osgi/pom.xml b/examples/camel-example-fhir-osgi/pom.xml
new file mode 100644
index 0000000..8c0b3b7
--- /dev/null
+++ b/examples/camel-example-fhir-osgi/pom.xml
@@ -0,0 +1,233 @@
+<?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>examples</artifactId>
+ <version>2.23.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-example-fhir-osgi</artifactId>
+ <name>Camel :: Example :: FHIR :: OSGi</name>
+ <description>An example running Camel FHIR in Apache Karaf</description>
+ <packaging>jar</packaging>
+
+ <properties>
+ <category>OSGi</category>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-fhir</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-hl7</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-blueprint</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ca.uhn.hapi</groupId>
+ <artifactId>hapi-structures-v24</artifactId>
+ <version>${hapi-version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </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>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <scope>runtime</scope>
+ </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>
+ <scope>test</scope>
+ </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>
+
+ <!-- Karaf Features -->
+ <dependency>
+ <groupId>org.apache.camel.karaf</groupId>
+ <artifactId>apache-camel</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <!-- Easier to get the local artifact from the integration tests -->
+ <finalName>${project.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.fhir.osgi*</Export-Package>
+ <Import-Package>*</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>it-fhir</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>
diff --git a/examples/camel-example-fhir-osgi/src/main/data/hl7v2.patient b/examples/camel-example-fhir-osgi/src/main/data/hl7v2.patient
new file mode 100644
index 0000000..b5ecbe7
--- /dev/null
+++ b/examples/camel-example-fhir-osgi/src/main/data/hl7v2.patient
@@ -0,0 +1 @@
+MSH|^~\&|Amalga HIS|BUM|New Tester|MS|20111121103141||ORU^R01|2847970-201111211031|P|2.4|||AL|NE|764|ASCII|||
PID||100005056|100005056||Freeman^Vincent^""^^""|""|19810813000000|F||CA|Street 1^""^""^""^34000^SGP^^""~""^""^""^""^Danling Street 5th^THA^^""||326-2275^PRN^PH^^66^675~476-5059^ORN^CP^^66^359~(123)456-7890^ORN^FX^^66^222~^NET^X.400^a@a.a~^NET^X.400^dummy@hotmail.com|(123)456-7890^WPN^PH^^66|UNK|S|BUD||BP000111899|D99999^""||CA|Bangkok|||THA||THA|""|N
PV1||OPD ||||""^""^""||||CNSLT|||||C|VIP|||6262618|PB1||||||||||||||||||||||||20101208134638
PV2|||^Unknown|""^""||||""|""|0||""|||||||||||||||||||||||||||||HP1
ORC|NW|""|BMC1102771601|""|CM||^^^^^""|||||||||""^""^^^""
OBR|1|""|BMC1102771601|""^Brain (CT)||20111028124215||||||||||||||||||CTSCAN|F||^^^^^ROUTINE|||""||||||""|||||||||||^""
OBX|1|FT|""^Brain (CT)||++++ text of report goes here +++|||REQAT|||FINAL|||20111121103040||75929^Gosselin^Angelina
\ No newline at end of file
diff --git a/examples/camel-example-fhir-osgi/src/main/java/org/apache/camel/example/fhir/osgi/FhirRoute.java b/examples/camel-example-fhir-osgi/src/main/java/org/apache/camel/example/fhir/osgi/FhirRoute.java
new file mode 100644
index 0000000..eef2a9f
--- /dev/null
+++ b/examples/camel-example-fhir-osgi/src/main/java/org/apache/camel/example/fhir/osgi/FhirRoute.java
@@ -0,0 +1,64 @@
+/**
+ * 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.fhir.osgi;
+
+import ca.uhn.hl7v2.HL7Exception;
+import ca.uhn.hl7v2.model.v24.message.ORU_R01;
+import ca.uhn.hl7v2.model.v24.segment.PID;
+import org.apache.camel.LoggingLevel;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.http.ProtocolException;
+import org.hl7.fhir.dstu3.model.Patient;
+
+public class FhirRoute extends RouteBuilder {
+
+ @Override
+ public void configure() {
+ from("file:{{input}}").routeId("fhir-example-osgi")
+ .onException(ProtocolException.class)
+ .handled(true)
+ .log(LoggingLevel.ERROR, "Error connecting to FHIR server with URL:{{serverUrl}}, please check the org.apache.camel.example.fhir.osgi.configuration.cfg configuration file ${exception.message}")
+ .end()
+ .onException(HL7Exception.class)
+ .handled(true)
+ .log(LoggingLevel.ERROR, "Error unmarshalling ${file:name} ${exception.message}")
+ .end()
+ .log("Converting ${file:name}")
+ // unmarshall file to hl7 message
+ .unmarshal().hl7()
+ // very simple mapping from a HLV2 patient to dstu3 patient
+ .process(exchange -> {
+ ORU_R01 msg = exchange.getIn().getBody(ORU_R01.class);
+ final PID pid = msg.getPATIENT_RESULT().getPATIENT().getPID();
+ String surname = pid.getPatientName()[0].getFamilyName().getFn1_Surname().getValue();
+ String name = pid.getPatientName()[0].getGivenName().getValue();
+ String patientId = msg.getPATIENT_RESULT().getPATIENT().getPID().getPatientID().getCx1_ID().getValue();
+ Patient patient = new Patient();
+ patient.addName().addGiven(name);
+ patient.getNameFirstRep().setFamily(surname);
+ patient.setId(patientId);
+ exchange.getIn().setBody(patient);
+ })
+ // marshall to JSON for logging
+ .marshal().fhirJson("{{fhirVersion}}")
+ .log("Inserting Patient: ${body}")
+ // create Patient in our FHIR server
+ .to("fhir://create/resource?inBody=resourceAsString&serverUrl={{serverUrl}}&fhirVersion={{fhirVersion}}")
+ // log the outcome
+ .log("Patient created successfully: ${body.getCreated}");
+ }
+}
diff --git a/examples/camel-example-fhir-osgi/src/main/resources/OSGI-INF/blueprint/camel-context.xml b/examples/camel-example-fhir-osgi/src/main/resources/OSGI-INF/blueprint/camel-context.xml
new file mode 100644
index 0000000..650f76a
--- /dev/null
+++ b/examples/camel-example-fhir-osgi/src/main/resources/OSGI-INF/blueprint/camel-context.xml
@@ -0,0 +1,35 @@
+<?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:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
+ xsi:schemaLocation="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
+ http://www.osgi.org/xmlns/blueprint/v1.0.0 http://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">
+
+ <cm:property-placeholder id="placeholder" persistent-id="org.apache.camel.example.fhir.osgi.configuration" />
+
+ <bean id="fhirRoute" class="org.apache.camel.example.fhir.osgi.FhirRoute"/>
+
+ <camelContext id="camel-fhir" xmlns="http://camel.apache.org/schema/blueprint">
+ <routeBuilder ref="fhirRoute"/>
+ </camelContext>
+
+</blueprint>
diff --git a/examples/camel-example-fhir-osgi/src/main/resources/log4j2.properties b/examples/camel-example-fhir-osgi/src/main/resources/log4j2.properties
new file mode 100644
index 0000000..9deb51c
--- /dev/null
+++ b/examples/camel-example-fhir-osgi/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.console.type = Console
+appender.console.name = console
+appender.console.layout.type = PatternLayout
+appender.console.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+rootLogger.level = INFO
+rootLogger.appenderRef.console.ref = console
diff --git a/examples/camel-example-fhir-osgi/src/test/java/org/apache/camel/example/fhir/osgi/FhirOsgiIT.java b/examples/camel-example-fhir-osgi/src/test/java/org/apache/camel/example/fhir/osgi/FhirOsgiIT.java
new file mode 100644
index 0000000..2742a44
--- /dev/null
+++ b/examples/camel-example-fhir-osgi/src/test/java/org/apache/camel/example/fhir/osgi/FhirOsgiIT.java
@@ -0,0 +1,77 @@
+/**
+ * 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.fhir.osgi;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import org.apache.camel.CamelContext;
+import org.apache.camel.ServiceStatus;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.CoreOptions;
+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.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+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;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class FhirOsgiIT {
+
+ @Inject
+ private CamelContext context;
+
+ @Configuration
+ public Option[] config() throws IOException {
+ return options(
+ PaxExamOptions.KARAF.option(),
+ PaxExamOptions.CAMEL_FHIR.option(),
+ streamBundle(
+ TinyBundles.bundle()
+ .read(
+ Files.newInputStream(
+ Paths.get("target")
+ .resolve("camel-example-fhir-osgi.jar")))
+ .build()),
+ when(false)
+ .useOptions(
+ debugConfiguration("5005", true)),
+ CoreOptions.composite(editConfigurationFilePut(
+ "etc/org.apache.camel.example.fhir.osgi.configuration.cfg",
+ new File("org.apache.camel.example.fhir.osgi.configuration.cfg")))
+ );
+ }
+
+ @Test
+ public void testRouteStatus() {
+ assertNotNull(context);
+ assertEquals("Route status is incorrect!", ServiceStatus.Started, context.getRouteStatus("fhir-example-osgi"));
+ }
+}
diff --git a/examples/camel-example-fhir-osgi/src/test/java/org/apache/camel/example/fhir/osgi/PaxExamOptions.java b/examples/camel-example-fhir-osgi/src/test/java/org/apache/camel/example/fhir/osgi/PaxExamOptions.java
new file mode 100644
index 0000000..daae9cb
--- /dev/null
+++ b/examples/camel-example-fhir-osgi/src/test/java/org/apache/camel/example/fhir/osgi/PaxExamOptions.java
@@ -0,0 +1,72 @@
+/**
+ * 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.fhir.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.maven;
+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)
+ ),
+ CAMEL_FHIR(
+ features(
+ maven()
+ .groupId("org.apache.camel.karaf")
+ .artifactId("apache-camel")
+ .type("xml")
+ .classifier("features")
+ .versionAsInProject(),
+ "camel-blueprint","camel-fhir", "camel-hl7")
+ ),
+ ;
+
+ private final Option[] options;
+
+ PaxExamOptions(Option... options) {
+ this.options = options;
+ }
+
+ public Option option() {
+ return new DefaultCompositeOption(options);
+ }
+}
diff --git a/examples/pom.xml b/examples/pom.xml
index 1ab7918..bc2ae0f 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -46,6 +46,7 @@
<module>camel-example-cdi-aws-s3</module>
<module>camel-example-cdi-cassandraql</module>
<module>camel-example-fhir</module>
+ <module>camel-example-fhir-osgi</module>
<module>camel-example-cdi-kubernetes</module>
<module>camel-example-cdi-metrics</module>
<module>camel-example-cdi-osgi</module>