private void jarAdded(Path jarFile) { Path unpackLocation = processJarFile(jarFile); if (unpackLocation != null) { suspend(); folderAdded(unpackLocation); saveMap(); resume(); } else { logger.warning(String.format("Jar %s has not been unpacked.", jarFile.toString())); } }
private void handleUninstalledModules() { Path[] paths = new Path[jarAliases.size()]; jarAliases.keySet().toArray(paths); for (Path path : paths) { if (!Files.exists(path)) { jarDeleted(path); } } }
private void jarDeleted(Path jarFile) { String alias = jarAliases.get(jarFile); if (alias == null) { String fileName = jarFile.getFileName().toString().replace(".jar", ""); int idx = fileName.lastIndexOf("."); if (idx > 0) { alias = fileName.substring(idx + 1); } else { alias = fileName; } } ToolAdapterOperatorDescriptor operatorDescriptor = ToolAdapterRegistry.INSTANCE.findByAlias(alias); if (operatorDescriptor != null) { suspend(); ToolAdapterIO.removeOperator(operatorDescriptor); jarAliases.remove(jarFile); saveMap(); resume(); } else { logger.warning(String.format("Cannot find adapter for %s", jarFile.toString())); } }
Files.createDirectory(nbUserModulesPath); readMap(); monitorPath(adaptersFolder); monitorPath(nbUserModulesPath); File[] jars = nbUserModulesPath.toFile().listFiles(pathname -> pathname.getName().toLowerCase().endsWith("jar")); if (jars != null) { .forEach(f -> { try { processJarFile(f.toPath()); } catch (Exception ex) { logger.warning(ex.getMessage()); handleUninstalledModules(); if (kind == StandardWatchEventKinds.ENTRY_CREATE) { if (!isJar) { folderAdded(adaptersFolder.resolve(fileName)); } else { jarAdded(nbUserModulesPath.resolve(fileName)); folderDeleted(adaptersFolder.resolve(fileName)); } else { jarDeleted(nbUserModulesPath.resolve(fileName));
ToolAdapterIO.removeOperator(descriptor, false); AdapterWatcher.INSTANCE.unmonitorPath(oldPath); ToolAdapterIO.setAdaptersPath(path); if (!newPath.equals(oldPath.toAbsolutePath().toString())) { AdapterWatcher.INSTANCE.monitorPath(path); } catch (IOException e) { logger.warning(String.format("Could not watch for the new adapter path %s [%s]", path.toString(), e.getMessage()));