public static DaemonConfigTO createAndWriteExampleDaemonConfig(File daemonConfigFile) throws ConfigException { File defaultFolder = new File(System.getProperty("user.home"), UserConfig.DEFAULT_FOLDER); FolderTO defaultFolderTO = new FolderTO(); defaultFolderTO.setPath(defaultFolder.getAbsolutePath()); defaultFolderTO.setWatchOptions(new WatchOperationOptions()); return createAndWriteDaemonConfig(daemonConfigFile, Arrays.asList(new FolderTO[] { defaultFolderTO })); }
private void startWatchOperations(Map<File, FolderTO> newWatchedFolderTOs) throws ConfigException, ServiceAlreadyStartedException { for (Map.Entry<File, FolderTO> folderEntry : newWatchedFolderTOs.entrySet()) { File localDir = folderEntry.getKey(); try { Config watchConfig = ConfigHelper.loadConfig(localDir); if (watchConfig != null) { logger.log(Level.INFO, "- Starting watch operation at " + localDir + " ..."); WatchOperationOptions watchOptions = folderEntry.getValue().getWatchOptions(); if (watchOptions == null) { watchOptions = new WatchOperationOptions(); } WatchRunner watchRunner = new WatchRunner(watchConfig, watchOptions, daemonConfig.getPortTO()); watchRunner.start(); watchOperations.put(localDir, watchRunner); } else { logger.log(Level.INFO, "- CANNOT start watch, because no config found at " + localDir + " ..."); } } catch (Exception e) { logger.log(Level.SEVERE, " + Cannot start watch operation at " + localDir + ". IGNORING.", e); } } }
@Override public void run() { try { WatchOperationOptions watchOperationOptions = new WatchOperationOptions(); watchOperationOptions.setAnnouncements(false); watchOperationOptions.setWatcher(false); watchOperationOptions.setInterval(interval); watch(watchOperationOptions); } catch (Exception e) { throw new RuntimeException(e); } } }, "watchOperationsThread");
@Override public WatchOperationOptions parseOptions(String[] operationArgs) throws Exception { WatchOperationOptions operationOptions = new WatchOperationOptions();