@Test public void shouldNotStartWhenFileSourceIsUI() throws IOException { when(configurationService.getConfigSource()).thenReturn(ConfigSource.UI); configFileMonitor.init(); verify(configurationService, never()).processExistingConfigs(anyList()); verify(fileMonitor, never()).run(); }
@PostConstruct public void init() throws IOException { BootstrapConfig bootstrapConfig = configurationService.loadBootstrapConfig(); if (bootstrapConfig != null && bootstrapConfig.getConfigSource() == ConfigSource.FILE) { if (fileMonitor == null) { fileMonitor = new DefaultFileMonitor(this); fileMonitor.setRecursive(true); } fileMonitor.setDelay(DELAY); final List<File> files = new ArrayList<>(); try { files.addAll(configLoader.findExistingConfigs()); } catch (MotechConfigurationException ex) { LOGGER.error(ex.getMessage(), ex); return; } configurationService.processExistingConfigs(files); startFileMonitor(); } }
ConfigFileMonitor implements FileListener { @PostConstruct public void init() throws IOException { BootstrapConfig bootstrapConfig = configurationService.loadBootstrapConfig(); if (bootstrapConfig != null && bootstrapConfig.getConfigSource() == ConfigSource.FILE) { if (fileMonitor == null) { fileMonitor = new DefaultFileMonitor(this); fileMonitor.setRecursive(true); } fileMonitor.setDelay(DELAY); final List<File> files = new ArrayList<>(); try { files.addAll(configLoader.findExistingConfigs()); } catch (MotechConfigurationException ex) { LOGGER.error(ex.getMessage(), ex); return; } configurationService.processExistingConfigs(files); startFileMonitor(); } } }
ConfigFileMonitor implements FileListener { @PostConstruct public void init() throws IOException { BootstrapConfig bootstrapConfig = configurationService.loadBootstrapConfig(); if (bootstrapConfig != null && bootstrapConfig.getConfigSource() == ConfigSource.FILE) { if (fileMonitor == null) { fileMonitor = new DefaultFileMonitor(this); fileMonitor.setRecursive(true); } fileMonitor.setDelay(DELAY); final List<File> files = new ArrayList<>(); try { files.addAll(configLoader.findExistingConfigs()); } catch (MotechConfigurationException ex) { LOGGER.error(ex.getMessage(), ex); return; } configurationService.processExistingConfigs(files); startFileMonitor(); } }  }
ConfigFileMonitor implements FileListener { @PostConstruct public void init() throws IOException { BootstrapConfig bootstrapConfig = configurationService.loadBootstrapConfig(); if (bootstrapConfig != null && bootstrapConfig.getConfigSource() == ConfigSource.FILE) { if (fileMonitor == null) { fileMonitor = new DefaultFileMonitor(this); fileMonitor.setRecursive(true); } fileMonitor.setDelay(DELAY); final List<File> files = new ArrayList<>(); try { files.addAll(configLoader.findExistingConfigs()); } catch (MotechConfigurationException ex) { LOGGER.error(ex.getMessage(), ex); return; } configurationService.processExistingConfigs(files); startFileMonitor(); } }  void setFileMonitor(DefaultFileMonitor fileMonitor); @PostConstruct void init(); @Override void fileCreated(FileChangeEvent fileChangeEvent); @Override void fileChanged(FileChangeEvent fileChangeEvent); @Override void fileDeleted(FileChangeEvent fileChangeEvent); @PreDestroy void stop(); void updateFileMonitor(); }
ConfigFileMonitor implements FileListener { @PostConstruct public void init() throws IOException { BootstrapConfig bootstrapConfig = configurationService.loadBootstrapConfig(); if (bootstrapConfig != null && bootstrapConfig.getConfigSource() == ConfigSource.FILE) { if (fileMonitor == null) { fileMonitor = new DefaultFileMonitor(this); fileMonitor.setRecursive(true); } fileMonitor.setDelay(DELAY); final List<File> files = new ArrayList<>(); try { files.addAll(configLoader.findExistingConfigs()); } catch (MotechConfigurationException ex) { LOGGER.error(ex.getMessage(), ex); return; } configurationService.processExistingConfigs(files); startFileMonitor(); } }  void setFileMonitor(DefaultFileMonitor fileMonitor); @PostConstruct void init(); @Override void fileCreated(FileChangeEvent fileChangeEvent); @Override void fileChanged(FileChangeEvent fileChangeEvent); @Override void fileDeleted(FileChangeEvent fileChangeEvent); @PreDestroy void stop(); void updateFileMonitor();  }