@Override public Outcome handle(Throwable failure) { CountDownLatch latch = new CountDownLatch(1); FileSystemWatcher watcher = this.fileSystemWatcherFactory.getFileSystemWatcher(); watcher.addSourceFolders( new ClassPathFolders(Restarter.getInstance().getInitialUrls())); watcher.addListener(new Listener(latch)); watcher.start(); try { latch.await(); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } return Outcome.RETRY; }
@Override public Outcome handle(Throwable failure) { CountDownLatch latch = new CountDownLatch(1); FileSystemWatcher watcher = this.fileSystemWatcherFactory.getFileSystemWatcher(); watcher.addSourceFolders( new ClassPathFolders(Restarter.getInstance().getInitialUrls())); watcher.addListener(new Listener(latch)); watcher.start(); try { latch.await(); } catch (InterruptedException ex) { // Ignore } return Outcome.RETRY; }
@Override public Outcome handle(Throwable failure) { failure.printStackTrace(); CountDownLatch latch = new CountDownLatch(1); FileSystemWatcher watcher = this.fileSystemWatcherFactory.getFileSystemWatcher(); watcher.addSourceFolders( new ClassPathFolders(Restarter.getInstance().getInitialUrls())); watcher.addListener(new Listener(latch)); watcher.start(); try { latch.await(); } catch (InterruptedException ex) { // Ignore } return Outcome.RETRY; }
@Bean public FileSystemWatcherFactory fileSystemWatcherFactory() { return new FileSystemWatcherFactory() { @Override public FileSystemWatcher getFileSystemWatcher() { return newFileSystemWatcher(); } }; }
private FileSystemWatcher newFileSystemWatcher() { Restart restartProperties = this.properties.getRestart(); FileSystemWatcher watcher = new FileSystemWatcher(true, restartProperties.getPollInterval(), restartProperties.getQuietPeriod()); String triggerFile = restartProperties.getTriggerFile(); if (StringUtils.hasLength(triggerFile)) { watcher.setTriggerFilter(new TriggerFileFilter(triggerFile)); } List<File> additionalPaths = restartProperties.getAdditionalPaths(); for (File path : additionalPaths) { watcher.addSourceFolder(path.getAbsoluteFile()); } return watcher; }
@Bean public FileSystemWatcherFactory getFileSystemWatcherFactory() { return new FileSystemWatcherFactory() { @Override public FileSystemWatcher getFileSystemWatcher() { return newFileSystemWatcher(); } }; }
private FileSystemWatcher newFileSystemWatcher() { Restart restartProperties = this.properties.getRestart(); FileSystemWatcher watcher = new FileSystemWatcher(true, restartProperties.getPollInterval(), restartProperties.getQuietPeriod()); String triggerFile = restartProperties.getTriggerFile(); if (StringUtils.hasLength(triggerFile)) { watcher.setTriggerFilter(new TriggerFileFilter(triggerFile)); } return watcher; }
@Override public void afterPropertiesSet() throws Exception { if (this.restartStrategy != null) { FileSystemWatcher watcherToStop = null; if (this.stopWatcherOnRestart) { watcherToStop = this.fileSystemWatcher; } this.fileSystemWatcher.addListener(new ClassPathFileChangeListener( this.applicationContext, this.restartStrategy, watcherToStop)); } this.fileSystemWatcher.start(); }
/** * Create a new {@link ClassPathFileChangeListener} instance. * @param eventPublisher the event publisher used send events * @param restartStrategy the restart strategy to use * @param fileSystemWatcherToStop the file system watcher to stop on a restart (or * {@code null}) */ ClassPathFileChangeListener(ApplicationEventPublisher eventPublisher, ClassPathRestartStrategy restartStrategy, FileSystemWatcher fileSystemWatcherToStop) { Assert.notNull(eventPublisher, "EventPublisher must not be null"); Assert.notNull(restartStrategy, "RestartStrategy must not be null"); this.eventPublisher = eventPublisher; this.restartStrategy = restartStrategy; this.fileSystemWatcherToStop = fileSystemWatcherToStop; }
MockFileSystemWatcherFactory(FileSystemWatcher watcher) { this.watcher = watcher; }
@Override public FileSystemWatcher getFileSystemWatcher() { return this.watcher; }