Exemplo n.º 1
0
  @Update
  public void update() {
    if (nativeManager != null) {
      nativeManager.setDico("video", getDictionary().get("video").toString());

      nativeManager.update();
    }
  }
Exemplo n.º 2
0
  @Start
  public void start() {
    try {
      // todo check if not used
      ipc_key = gerRandom();
      ArrayList<String> repos = new ArrayList<String>();
      for (Repository repo : getModelService().getLastModel().getRepositoriesForJ()) {
        repos.add(repo.getUrl());
      }
      // loading model from jar
      ContainerRoot model =
          KevoreeXmiHelper.loadStream(getClass().getResourceAsStream("/KEV-INF/lib.kev"));
      File binary =
          getBootStrapperService()
              .resolveArtifact(
                  "org.kevoree.library.nativeN.faceDetection-wrapper" + getOs(),
                  "org.kevoree.library.nativeN",
                  "1.8.9-SNAPSHOT",
                  "uexe",
                  repos);
      if (binary != null) {
        if (!binary.canExecute()) {
          binary.setExecutable(true);
        }

        JarFile jarFile =
            new JarFile(
                getBootStrapperService()
                    .resolveArtifact(
                        "org.kevoree.library.nativeN.faceDetection-wrapper",
                        "org.kevoree.library.nativeN",
                        "1.8.9-SNAPSHOT",
                        "jar",
                        repos));

        final Enumeration<JarEntry> entries = jarFile.entries();
        while (entries.hasMoreElements()) {
          final JarEntry entry = entries.nextElement();
          if (entry.getName().contains(".")
              && !entry.getName().endsWith(".class")
              && !entry.getName().contains("META-INF")) {
            System.out.println("File : " + entry.getName());
            JarEntry fileEntry = jarFile.getJarEntry(entry.getName());
            InputStream input = jarFile.getInputStream(fileEntry);

            String file = System.getProperty("java.io.tmpdir") + entry.getName();
            File d = new File(file);
            d.mkdirs();
            FileManager.copyFileFromStream(
                input,
                System.getProperty("java.io.tmpdir") + "/FaceDetection/",
                entry.getName(),
                true);
          }
        }

        nativeManager = new NativeManager(ipc_key, binary.getPath(), model);

        nativeManager.addEventListener(
            new NativeListenerPorts() {
              @Override
              public void disptach(NativeEventPort event, String port_name, String msg) {
                MessagePort port = (MessagePort) getPortByName(port_name);
                port.process(msg);
              }
            });

        started = nativeManager.start();

        nativeManager.setDico("video", getDictionary().get("video").toString());

      } else {
        System.err.println(
            "The binary org.kevoree.library.nativeN.faceDetection-wrapper for the architecture "
                + getOs()
                + " is not found");
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }