You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@edgent.apache.org by dj...@apache.org on 2016/04/04 17:14:31 UTC

[3/6] incubator-quarks git commit: Add utility application registration method

Add utility application registration method


Project: http://git-wip-us.apache.org/repos/asf/incubator-quarks/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quarks/commit/77b5f580
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quarks/tree/77b5f580
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quarks/diff/77b5f580

Branch: refs/heads/master
Commit: 77b5f5804c6377cbf9c3b922a7ce191a66b71426
Parents: c2ecdcc
Author: Dan Debrunner <dj...@debrunners.com>
Authored: Sat Apr 2 09:18:31 2016 -0700
Committer: Dan Debrunner <dj...@debrunners.com>
Committed: Sat Apr 2 09:18:31 2016 -0700

----------------------------------------------------------------------
 .../java/quarks/providers/iot/IotProvider.java  | 25 ++++++++++++++++++++
 1 file changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quarks/blob/77b5f580/providers/iot/src/main/java/quarks/providers/iot/IotProvider.java
----------------------------------------------------------------------
diff --git a/providers/iot/src/main/java/quarks/providers/iot/IotProvider.java b/providers/iot/src/main/java/quarks/providers/iot/IotProvider.java
index 608ab9f..f7e7719 100644
--- a/providers/iot/src/main/java/quarks/providers/iot/IotProvider.java
+++ b/providers/iot/src/main/java/quarks/providers/iot/IotProvider.java
@@ -35,6 +35,7 @@ import quarks.execution.DirectSubmitter;
 import quarks.execution.Job;
 import quarks.execution.services.ControlService;
 import quarks.execution.services.ServiceContainer;
+import quarks.function.BiConsumer;
 import quarks.function.Function;
 import quarks.providers.direct.DirectProvider;
 import quarks.runtime.appservice.AppService;
@@ -283,4 +284,28 @@ public class IotProvider implements TopologyProvider,
     protected IotDevice createMessageHubDevice(Topology topology) {
         return iotDeviceCreator.apply(topology);
     }
+    
+    /**
+     * Register an application that uses an {@code IotDevice}.
+     * <BR>
+     * Wrapper around {@link ApplicationService#registerTopology(String, BiConsumer)}
+     * that passes in an {@link IotDevice} and configuration to the supplied
+     * function {@code builder} that builds the application. The passed
+     * in {@code IotDevice} is created using {@link IotDevicePubSub#addIotDevice(quarks.topology.TopologyElement)}.
+     * <BR>
+     * Note that {@code builder} obtains a reference to its topology using
+     * {@link IotDevice#topology()}.
+     * <P>
+     * When the application is
+     * {@link quarks.topology.mbeans.ApplicationServiceMXBean#submit(String, String) submitted} {@code builder.accept(iotDevice, config)}
+     * is called to build the application's graph.
+     * </P>
+     * 
+     * @param applicationName Application name
+     * @param builder Function that builds the topology.
+     */
+    public void registerTopology(String applicationName, BiConsumer<IotDevice, JsonObject> builder) {
+        getApplicationService().registerTopology(applicationName,
+                (topology,config) -> builder.accept(IotDevicePubSub.addIotDevice(topology), config));
+    }
 }