Glad to help!

As you’ve seen, the JsonControlService impl has support for mapping a JSON 
object to a method invocation on a registered control bean.  IotProvider then 
adds a builtin topology/job that maps an external “device command” to use that 
JsonControlService feature.   The net is when you use IotProvider you don’t 
have to write any Edgent app machinery to support method invocation on a 
registered control bean.  That includes invoking registerJar().

Edgent applications can define and register their own control beans too.

IotProvider also allows you to say “please build and submit this topology when 
the provider is started” (in addition to supporting submit via a remote submit 
device cmd).

There’s a sample code fragment for creating/initializing an IotProvider in its 
javadoc (at least the latest version, not sure about 1.1.0).  Be sure to look 
at its package javadoc too for sample device commands.

One sample use of IotProvider (and IotDevice) is the IotpFullScenario sample[1]

The EdgeVideoAnalytics demo system uses it and also includes IoT hub clients 
that “send commands to"  (publish device commands for) the Edgent app)[2]

That said, neither of those utilize the registerJar capability… though both 
inherently support it.

A third, preferred?, option for locally invoking registerJar and submit is to 
just lookup and use the registered ApplicationServiceMXBean created by 
AppService.createAndRegister().  e.g.
        ApplicationServiceMXBean appControl = controlService.getControl(
            ApplicationServiceMXBean.TYPE,
            ApplicationService.ALIAS,
            ApplicationServiceMXBean.class);
        appControl.registerJar(…)
        appControl.submit(…)

I say preferred because I think of the JSON / controlRequest() mechanism as 
existing mostly to support external/remote method invocation spec use case. 
(Which IotProvider does for you)

By “sample” I just mean some runnable code (and run script) that’s part of the 
Edgent distribution that demonstrates a feature.  Just something under 
“samples” like IotFullScenario as opposed to a recipe on the website.

— Dale

[1] 
https://github.com/apache/incubator-edgent/blob/master/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/IotpFullScenario.java
 
<https://github.com/apache/incubator-edgent/blob/master/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/IotpFullScenario.java>
[2] https://github.com/IBMStreams/streamsx.edgevideoanalytics.starterkit 
<https://github.com/IBMStreams/streamsx.edgevideoanalytics.starterkit>

Reply via email to