camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-12064) Create a camel-example-olingo4-blueprint example
Date Tue, 05 Dec 2017 10:36:00 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-12064?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16278366#comment-16278366
] 

ASF GitHub Bot commented on CAMEL-12064:
----------------------------------------

oscerd closed pull request #2133: [CAMEL-12064] Create camel-example-olingo4-blueprint example
URL: https://github.com/apache/camel/pull/2133
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/examples/camel-example-olingo4-blueprint/README.md b/examples/camel-example-olingo4-blueprint/README.md
new file mode 100644
index 00000000000..196a52c776d
--- /dev/null
+++ b/examples/camel-example-olingo4-blueprint/README.md
@@ -0,0 +1,70 @@
+# Camel Olingo4 OSGI Example using Blueprint
+
+### Introduction
+
+This example shows how to use the camel-olingo4 component in an OSGI environment. We will
use the
+the sample OData 4.0 remote TripPinservice published on http://services.odata.org/TripPinRESTierService
by creating
+two People who's data are loaded from a directory.
+
+#### OSGi / Karaf
+
+This example can be executed within Karaf 4.x. and relies on the ```camel-olingo4``` feature.
+
+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-olingo4
+    ```
+
+3. Then install and start the example:
+
+    ```sh
+    karaf@root()> install -s mvn:org.apache.camel.example/camel-example-olingo4-blueprint/${version}
+    ```
+4. Copy the files found in ```src/main/resources``` to the ```work/odata/input``` in the
karaf install
+   root directory created by the camel route. 
+
+By tailing the log with:
+
+```sh
+karaf@root()> log:tail
+```
+
+The following messages should be displayed:
+
+```
+2017-11-29 15:46:22,524 | INFO  | nt Dispatcher: 1 | BlueprintCamelContext            | 62
- org.apache.camel.camel-core - 2.21.0.SNAPSHOT | Apache Camel 2.21.0-SNAPSHOT (CamelContext:
odata4-example-context) started in 0.102 seconds
+2017-11-29 15:46:23,528 | INFO  | work/odata/input | odata-route                      | 62
- org.apache.camel.camel-core - 2.21.0.SNAPSHOT | Receiving file person2json
+2017-11-29 15:46:23,528 | INFO  | work/odata/input | odata-route                      | 62
- org.apache.camel.camel-core - 2.21.0.SNAPSHOT | Sending file person2json to OData Test Service
+2017-11-29 15:46:24,317 | INFO  | work/odata/input | odata-route                      | 62
- org.apache.camel.camel-core - 2.21.0.SNAPSHOT | Receiving file person1.json
+2017-11-29 15:46:24,317 | INFO  | work/odata/input | odata-route                      | 62
- org.apache.camel.camel-core - 2.21.0.SNAPSHOT | Sending file person1.json to OData Test
Service
+2017-11-29 15:46:24,665 | INFO  | I/O dispatcher 1 | odata-route                      | 62
- org.apache.camel.camel-core - 2.21.0.SNAPSHOT | Done creating person with properties [ClientPropertyImpl{name=UserName,
value=jdoe, annotations=[]}, ClientPropertyImpl{name=FirstName, value=John, annotations=[]},
ClientPropertyImpl{name=LastName, value=Doe, annotations=[]}, ClientPropertyImpl{name=MiddleName,
value=, annotations=[]}, ClientPropertyImpl{name=Gender, value=Male, annotations=[]}, ClientPropertyImpl{name=Age,
value=, annotations=[]}, ClientPropertyImpl{name=Emails, value=ClientCollectionValueImpl [values=[]super[AbstractClientValue
[typeName=null]]], annotations=[]}, ClientPropertyImpl{name=FavoriteFeature, value=Feature1,
annotations=[]}, ClientPropertyImpl{name=Features, value=ClientCollectionValueImpl [values=[]super[AbstractClientValue
[typeName=null]]], annotations=[]}, ClientPropertyImpl{name=AddressInfo, value=ClientCollectionValueImpl
[values=[]super[AbstractClientValue [typeName=null]]], annotations=[]}, ClientPropertyImpl{name=HomeAddress,
value=, annotations=[]}]
+2017-11-29 15:46:24,689 | INFO  | I/O dispatcher 2 | odata-route                      | 62
- org.apache.camel.camel-core - 2.21.0.SNAPSHOT | Done creating person with properties [ClientPropertyImpl{name=UserName,
value=jmorrow, annotations=[]}, ClientPropertyImpl{name=FirstName, value=Jerome, annotations=[]},
ClientPropertyImpl{name=LastName, value=Morrow, annotations=[]}, ClientPropertyImpl{name=MiddleName,
value=, annotations=[]}, ClientPropertyImpl{name=Gender, value=Male, annotations=[]}, ClientPropertyImpl{name=Age,
value=, annotations=[]}, ClientPropertyImpl{name=Emails, value=ClientCollectionValueImpl [values=[]super[AbstractClientValue
[typeName=null]]], annotations=[]}, ClientPropertyImpl{name=FavoriteFeature, value=Feature1,
annotations=[]}, ClientPropertyImpl{name=Features, value=ClientCollectionValueImpl [values=[]super[AbstractClientValue
[typeName=null]]], annotations=[]}, ClientPropertyImpl{name=AddressInfo, value=ClientCollectionValueImpl
[values=[]super[AbstractClientValue [typeName=null]]], annotations=[]}, ClientPropertyImpl{name=HomeAddress,
value=, annotations=[]}]
+
+```
+
+You can uninstall the example with:
+
+```sh
+karaf@root()> uninstall camel-example-olingo4-blueprint
+```
+
+### 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-olingo4-blueprint/pom.xml b/examples/camel-example-olingo4-blueprint/pom.xml
new file mode 100644
index 00000000000..44787a531e7
--- /dev/null
+++ b/examples/camel-example-olingo4-blueprint/pom.xml
@@ -0,0 +1,51 @@
+<?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.21.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-example-olingo4-blueprint</artifactId>
+  <name>Camel :: Example :: Olingo4 :: Blueprint</name>
+  <description>An example which use the Olingo4 component in Blueprint</description>
+  <packaging>jar</packaging>
+
+  <properties>
+    <category>OSGi</category>
+    <title>Olingo4 Blueprint</title>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-blueprint</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-olingo4</artifactId>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/examples/camel-example-olingo4-blueprint/src/main/java/org/apache/camel/example/olingo4/blueprint/Olingo4TestConfiguration.java
b/examples/camel-example-olingo4-blueprint/src/main/java/org/apache/camel/example/olingo4/blueprint/Olingo4TestConfiguration.java
new file mode 100644
index 00000000000..9f6d82aa1e8
--- /dev/null
+++ b/examples/camel-example-olingo4-blueprint/src/main/java/org/apache/camel/example/olingo4/blueprint/Olingo4TestConfiguration.java
@@ -0,0 +1,50 @@
+/**
+ * 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.olingo4.blueprint;
+
+import java.io.IOException;
+import org.apache.camel.component.olingo4.Olingo4Configuration;
+import org.apache.http.HttpHost;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.protocol.BasicHttpContext;
+import org.apache.http.protocol.HttpContext;
+
+public class Olingo4TestConfiguration extends Olingo4Configuration {
+
+    public Olingo4TestConfiguration() {
+        setServiceUri(getTestServiceUri("http://services.odata.org/TripPinRESTierService"));
+        setContentType("application/json;charset=utf-8");
+    }
+
+    protected String getTestServiceUri(String baseUrl) {
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        HttpGet httpGet = new HttpGet(baseUrl);
+        HttpContext httpContext = new BasicHttpContext();
+        try {
+            httpclient.execute(httpGet, httpContext);
+        } catch (IOException e) {
+            throw new RuntimeException("Error getting OData Test service URI using base URL:"
+ baseUrl);
+        }
+        HttpUriRequest currentReq = (HttpUriRequest)httpContext.getAttribute("http.request");
+        HttpHost currentHost = (HttpHost)httpContext.getAttribute("http.target_host");
+        String currentUrl = currentHost.toURI() + currentReq.getURI();
+        return currentUrl;
+    }
+}
diff --git a/examples/camel-example-olingo4-blueprint/src/main/resources/OSGI-INF/blueprint/odata.xml
b/examples/camel-example-olingo4-blueprint/src/main/resources/OSGI-INF/blueprint/odata.xml
new file mode 100644
index 00000000000..80f25a4526c
--- /dev/null
+++ b/examples/camel-example-olingo4-blueprint/src/main/resources/OSGI-INF/blueprint/odata.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--
+
+    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"
+           xsi:schemaLocation="
+             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">
+
+  <bean id="odata4" class="org.apache.camel.component.olingo4.Olingo4Component">
+    <property name="configuration" ref="odata4Configuration"/>
+  </bean>
+
+  <bean id="odata4Configuration" class="org.apache.camel.example.olingo4.blueprint.Olingo4TestConfiguration"/>
+
+  <camelContext xmlns="http://camel.apache.org/schema/blueprint" id="odata4-example-context">
+    <route id="odata-route">
+
+      <from uri="file:work/odata/input" />
+
+      <log message="Receiving file ${file:name}" />
+      <log message="Sending file ${file:name} to OData Test Service" />
+
+      <unmarshal>
+        <string charset="UTF-8"/>
+      </unmarshal>
+
+      <to uri="odata4://create/People"/>
+
+      <log message="Done creating person with properties ${body.properties}" />
+    </route>
+  </camelContext>
+
+</blueprint>
\ No newline at end of file
diff --git a/examples/camel-example-olingo4-blueprint/src/main/resources/data/person1.json
b/examples/camel-example-olingo4-blueprint/src/main/resources/data/person1.json
new file mode 100644
index 00000000000..ee373c667ef
--- /dev/null
+++ b/examples/camel-example-olingo4-blueprint/src/main/resources/data/person1.json
@@ -0,0 +1,5 @@
+{
+  "UserName": "jmorrow",
+  "FirstName": "Jerome",
+  "LastName": "Morrow"
+}
\ No newline at end of file
diff --git a/examples/camel-example-olingo4-blueprint/src/main/resources/data/person2json
b/examples/camel-example-olingo4-blueprint/src/main/resources/data/person2json
new file mode 100644
index 00000000000..283f20749cb
--- /dev/null
+++ b/examples/camel-example-olingo4-blueprint/src/main/resources/data/person2json
@@ -0,0 +1,5 @@
+{
+"UserName": "jdoe",
+"FirstName": "John",
+"LastName": "Doe"
+}
\ No newline at end of file
diff --git a/examples/pom.xml b/examples/pom.xml
index e4558eb5f52..50a1eda5ec2 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -77,6 +77,7 @@
     <module>camel-example-management</module>
     <module>camel-example-mybatis</module>
     <module>camel-example-netty-http</module>
+    <module>camel-example-olingo4-blueprint</module>
     <module>camel-example-opentracing</module>
     <module>camel-example-pojo-messaging</module>
     <module>camel-example-reactive-streams</module>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Create a camel-example-olingo4-blueprint example
> ------------------------------------------------
>
>                 Key: CAMEL-12064
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12064
>             Project: Camel
>          Issue Type: Task
>            Reporter: John Poth
>
> It would be nice have an example for camel-olingo4 in OSGI environment.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message