HI, I’ve gotten a step further, but I am still having problems.
My jar file that I start up first, called registerJarExample.jar now contains the correct service entries in the jar file. This application looks like this: package pi; ... public class RegisterJarExample { private static final Logger logger = LoggerFactory.getLogger(RegisterJarExample.class); public static void main(String args[]) throws Exception { File configFile = new File("./device_config.txt"); IotProvider provider = new IotProvider(topology -> new IotpDevice(topology, configFile)); /* * Not sure if I need the next few lines or not ... */ JsonControlService control = new JsonControlService(); provider.getServices().addService(ControlService.class, control); ApplicationService appService = AppService.createAndRegister(provider, provider); provider.start(); logger.info("Here is some info"); } } Then, the jar file that contains the application that I want to run when I issue the registerJar command looks like this: package pi.sensors; ... public class SpeedSensorTopologyBuilder { private static abstract class Sensor implements TopologyBuilder { @Override public BiConsumer<Topology, JsonObject> getBuilder() { return (t,c) -> t.strings(getName()).print(); } } public static class SpeedSensor extends Sensor { @Override public String getName() { return "SpeedJarApp"; } public void accept(IotDevice device, JsonObject config) { TStream<Date> readingTime = device.topology().poll(() -> new Date(), 3, TimeUnit.SECONDS); TStream<JsonObject> speedReading = readingTime.map(rt -> { JsonObject speedInfo = new JsonObject(); long curTime = System.currentTimeMillis(); SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm:ss"); Date dateObj = new Date(curTime); speedInfo.addProperty("time:", sdf.format(dateObj)); try { double speed = SystemInfo.getMemoryUsed() * 0.0000000752; Random randomGenerator = new Random(); int randomInt = randomGenerator.nextInt(20); double randSpeed = speed + randomInt; DecimalFormat df = new DecimalFormat("#.##"); speedInfo.addProperty("Speed", df.format(randSpeed)); } catch(Exception e) { throw new RuntimeException(e); } return speedInfo; }); speedReading.print(); device.events(speedReading, "speedReading", QoS.FIRE_AND_FORGET); } } } I can tell that the application “SpeedJarApp” is being loaded because I put a logger statement in AppService.java here: @Override public void registerTopology(String applicationName, BiConsumer<Topology, JsonObject> builder) { logger.info("Register application name: {}", applicationName); applications.put(applicationName, builder); } and I can see the line “Register application name SpeedJarApp”. However, when I try to “submit’ the SpeedJarApp using this command: edgentControl: {"args":["SpeedJarApp",{}],"op":"submit","alias":"edgent","type":"appService”} Nothing happens. Looking at my code above I know something is wrong because in the ‘accept’ method, which I had used before and worked when I registered the topology through the api instead of via the registerJar command, I’m not passing the IotDevice and I’m not sure how to… Does anyone know how I need to code the method (and if there is a particular method I need to override) to allow me to submit a command that will allow me to start sending events? To clarify, this is the code that is in the jar file that is loaded via the registerJar command. Thanks, Susan > On Sep 15, 2016, at 10:11 AM, Dan Debrunner <d...@debrunners.com> wrote: > > On 9/14/2016 10:48 AM, Susan Cline wrote: > >> Are you saying there is an entry in the jar file that I need to make? >> I.e, put something in the META-INF directory of the jar file? > > Yes, it's documented (with the assumption that the reader knows Jar files) in > the TopologyBuilder class and ApplicationServiceMXBean.registerJar method. > Basically each application is registered as a TopologyBuilder service > provider. > > You can see the ant mechanism to build the jar file here: > > https://github.com/apache/incubator-edgent/blob/b86179228c51bb81b85f5e0d0b588f211595d8d2/api/topology/build.xml#L45 > > > Dan. >