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 2017/04/19 12:31:03 UTC
camel git commit: Clean up example applications
Repository: camel
Updated Branches:
refs/heads/master 28fa5cf61 -> 56f2b24a2
Clean up example applications
This change cleans the example applications provided to show
some simple routes with camel-milo.
Signed-off-by: Jens Reimann <jr...@redhat.com>
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/56f2b24a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/56f2b24a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/56f2b24a
Branch: refs/heads/master
Commit: 56f2b24a2d4dbb408b71610bfe90fbfa2e9f7147
Parents: 28fa5cf
Author: Jens Reimann <jr...@redhat.com>
Authored: Wed Apr 19 14:14:54 2017 +0200
Committer: Jens Reimann <jr...@redhat.com>
Committed: Wed Apr 19 14:19:16 2017 +0200
----------------------------------------------------------------------
.../component/milo/testing/Application.java | 73 ----------------
.../milo/testing/Application2Client.java | 62 -------------
.../milo/testing/Application2Server.java | 72 ----------------
.../component/milo/testing/ExampleClient.java | 62 +++++++++++++
.../component/milo/testing/ExampleServer.java | 91 ++++++++++++++++++++
5 files changed, 153 insertions(+), 207 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/56f2b24a/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/Application.java
----------------------------------------------------------------------
diff --git a/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/Application.java b/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/Application.java
deleted file mode 100644
index a78efbf..0000000
--- a/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/Application.java
+++ /dev/null
@@ -1,73 +0,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.
- */
-package org.apache.camel.component.milo.testing;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.impl.DefaultCamelContext;
-
-public final class Application {
-
- private Application() {
- }
-
- public static void main(final String[] args) throws Exception {
-
- // camel conext
-
- final CamelContext context = new DefaultCamelContext();
-
- // add paho
-
- // no need to register, gets auto detected
- // context.addComponent("paho", new PahoComponent());
-
- // no need to register, gets auto detected
- // context.addComponent("milo-server", new MiloClientComponent());
- // context.addComponent("milo-client", new MiloClientComponent());
-
- // add routes
-
- context.addRoutes(new RouteBuilder() {
-
- @Override
- public void configure() throws Exception {
- from("paho:javaonedemo/eclipse-greenhouse-9home/sensors/temperature?brokerUrl=tcp://iot.eclipse.org:1883").log("Temp update: ${body}").convertBodyTo(String.class)
- .to("milo-server:MyItem");
-
- from("milo-server:MyItem").log("MyItem: ${body}");
-
- from("milo-server:MyItem2").log("MyItem2 : ${body}").to("paho:de/dentrassi/camel/milo/test1?brokerUrl=tcp://iot.eclipse.org:1883");
-
- from("milo-client:tcp://foo:bar@localhost:12685?nodeId=items-MyItem&namespaceUri=urn:camel").log("From OPC UA: ${body}")
- .to("milo-client:tcp://localhost:12685?nodeId=items-MyItem2&namespaceUri=urn:camel");
-
- from("paho:de/dentrassi/camel/milo/test1?brokerUrl=tcp://iot.eclipse.org:1883").log("Back from MQTT: ${body}");
- }
- });
-
- // start
-
- context.start();
-
- // sleep
-
- while (true) {
- Thread.sleep(Long.MAX_VALUE);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/56f2b24a/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/Application2Client.java
----------------------------------------------------------------------
diff --git a/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/Application2Client.java b/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/Application2Client.java
deleted file mode 100644
index d613a18..0000000
--- a/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/Application2Client.java
+++ /dev/null
@@ -1,62 +0,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.
- */
-package org.apache.camel.component.milo.testing;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.impl.DefaultCamelContext;
-
-public final class Application2Client {
-
- private Application2Client() {
- }
-
- public static void main(final String[] args) throws Exception {
-
- // camel conext
-
- final CamelContext context = new DefaultCamelContext();
-
- // add paho
-
- // no need to register, gets auto detected
- // context.addComponent("paho", new PahoComponent());
-
- // add OPC UA
-
- // add routes
-
- context.addRoutes(new RouteBuilder() {
-
- @Override
- public void configure() throws Exception {
- from("milo-client:tcp://foo:bar@localhost:12685?nodeId=items-MyItem&namespaceUri=urn:org:apache:camel").log("From OPC UA: ${body}")
- .to("milo-client:tcp://foo:bar@localhost:12685?nodeId=items-MyItem2&namespaceUri=urn:org:apache:camel");
- }
- });
-
- // start
-
- context.start();
-
- // sleep
-
- while (true) {
- Thread.sleep(Long.MAX_VALUE);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/56f2b24a/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/Application2Server.java
----------------------------------------------------------------------
diff --git a/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/Application2Server.java b/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/Application2Server.java
deleted file mode 100644
index ae85890..0000000
--- a/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/Application2Server.java
+++ /dev/null
@@ -1,72 +0,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.
- */
-package org.apache.camel.component.milo.testing;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.milo.server.MiloServerComponent;
-import org.apache.camel.impl.DefaultCamelContext;
-
-public final class Application2Server {
- private Application2Server() {
- }
-
- public static void main(final String[] args) throws Exception {
-
- // camel conext
-
- final CamelContext context = new DefaultCamelContext();
-
- // add paho
-
- // no need to register, gets auto detected
- // context.addComponent("paho", new PahoComponent());
- ((MiloServerComponent)context.getComponent("milo-server")).setUserAuthenticationCredentials("foo:bar");
-
- // add routes
-
- context.addRoutes(new RouteBuilder() {
-
- @Override
- public void configure() throws Exception {
- /*
- * from(
- * "paho:javaonedemo/eclipse-greenhouse-9home/sensors/temperature?brokerUrl=tcp://iot.eclipse.org:1883")
- * .log("Temp update: ${body}").convertBodyTo(String.class).to(
- * "milo-server:MyItem");
- */
-
- from("paho:my/foo/bar?brokerUrl=tcp://iot.eclipse.org:1883").log("Temp update: ${body}").convertBodyTo(String.class).to("milo-server:MyItem");
-
- from("milo-server:MyItem").log("MyItem: ${body}");
- from("milo-server:MyItem2").log("MyItem2: ${body}").convertBodyTo(String.class).to("paho:de/dentrassi/camel/milo/temperature?brokerUrl=tcp://iot.eclipse.org:1883");
-
- from("paho:de/dentrassi/camel/milo/temperature?brokerUrl=tcp://iot.eclipse.org:1883").log("Back from MQTT: ${body}");
- }
- });
-
- // start
-
- context.start();
-
- // sleep
-
- while (true) {
- Thread.sleep(Long.MAX_VALUE);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/56f2b24a/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/ExampleClient.java
----------------------------------------------------------------------
diff --git a/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/ExampleClient.java b/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/ExampleClient.java
new file mode 100644
index 0000000..38c0a06
--- /dev/null
+++ b/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/ExampleClient.java
@@ -0,0 +1,62 @@
+/**
+ * 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.component.milo.testing;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.milo.NodeIds;
+import org.apache.camel.impl.DefaultCamelContext;
+
+/**
+ * An example application focusing on the OPC UA client endpoint
+ */
+public final class ExampleClient {
+
+ private ExampleClient() {
+ }
+
+ public static void main(final String[] args) throws Exception {
+
+ // camel conext
+
+ final CamelContext context = new DefaultCamelContext();
+
+ // add routes
+
+ context.addRoutes(new RouteBuilder() {
+
+ @Override
+ public void configure() throws Exception {
+ // bridge item1 to item2
+ final String item1 = NodeIds.nodeValue("urn:org:apache:camel", "items-MyItem");
+ final String item2 = NodeIds.nodeValue("urn:org:apache:camel", "items-MyItem2");
+ from("milo-client:tcp://foo:bar@localhost:12685?node=" + item1).log("From OPC UA: ${body}")
+ .to("milo-client:tcp://foo:bar@localhost:12685?node" + item2);
+ }
+ });
+
+ // start
+
+ context.start();
+
+ // sleep
+
+ while (true) {
+ Thread.sleep(Long.MAX_VALUE);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/56f2b24a/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/ExampleServer.java
----------------------------------------------------------------------
diff --git a/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/ExampleServer.java b/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/ExampleServer.java
new file mode 100644
index 0000000..2f39a91
--- /dev/null
+++ b/components/camel-milo/src/test/java/org/apache/camel/component/milo/testing/ExampleServer.java
@@ -0,0 +1,91 @@
+/**
+ * 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.component.milo.testing;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.milo.server.MiloServerComponent;
+import org.apache.camel.impl.DefaultCamelContext;
+
+/**
+ * This is a simple example application which tests a few ways of mapping data
+ * to an OPC UA server instance.
+ */
+public final class ExampleServer {
+ private ExampleServer() {
+ }
+
+ public static void main(final String[] args) throws Exception {
+
+ // camel conext
+
+ final CamelContext context = new DefaultCamelContext();
+
+ // configure milo
+
+ ((MiloServerComponent)context.getComponent("milo-server"))
+ .setUserAuthenticationCredentials("foo:bar");
+
+ // add routes
+
+ context.addRoutes(new RouteBuilder() {
+
+ @Override
+ public void configure() throws Exception {
+ /*
+ * Take an MQTT topic and forward its content to an OPC UA
+ * server item. You can e.g. take some MQTT application and an
+ * OPC UA client, connect with both applications to their
+ * topics/items. When you write on the MQTT item it will pop up
+ * on the OPC UA item.
+ */
+ from("paho:my/foo/bar?brokerUrl=tcp://iot.eclipse.org:1883").log("Temp update: ${body}")
+ .convertBodyTo(String.class).to("milo-server:MyItem");
+
+ /*
+ * Creating a simple item which has not data but logs anything
+ * which gets written to by an OPC UA write call
+ */
+ from("milo-server:MyItem").log("MyItem: ${body}");
+
+ /*
+ * Creating an item which takes write command and forwards them
+ * to an MQTT topic
+ */
+ from("milo-server:MyItem2").log("MyItem2: ${body}").convertBodyTo(String.class)
+ .to("paho:de/dentrassi/camel/milo/temperature?brokerUrl=tcp://iot.eclipse.org:1883");
+
+ /*
+ * Re-read the output from the previous route from MQTT to the
+ * local logging
+ */
+ from("paho:de/dentrassi/camel/milo/temperature?brokerUrl=tcp://iot.eclipse.org:1883")
+ .log("Back from MQTT: ${body}");
+ }
+ });
+
+ // start
+
+ context.start();
+
+ // sleep
+
+ while (true) {
+ Thread.sleep(Long.MAX_VALUE);
+ }
+ }
+}