@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; }
@Override public void run(String... args) throws Exception { if (!environment.acceptsProfiles("production") && !environment.acceptsProfiles("test")) { AtomicBoolean registered = (AtomicBoolean) Restarter.getInstance().getOrAddAttribute("yarnStarted", AtomicBoolean::new); boolean alreadyRun = registered.getAndSet(true); if (!alreadyRun) { startFrontend(); } } }
/** * Called to restart the application. * @param urls the updated URLs * @param files the updated files */ protected void restart(Set<URL> urls, ClassLoaderFiles files) { Restarter restarter = Restarter.getInstance(); restarter.addUrls(urls); restarter.addClassLoaderFiles(files); restarter.restart(); }
private void run(String[] args) { Restarter.initialize(args, RestartInitializer.NONE); SpringApplication application = new SpringApplication( RemoteClientConfiguration.class); application.setWebEnvironment(false); application.setBanner(getBanner()); application.setInitializers(getInitializers()); application.setListeners(getListeners()); application.run(args); waitIndefinitely(); }
@Bean @RestartScope @ConditionalOnMissingBean public LiveReloadServer liveReloadServer() { return new LiveReloadServer(this.properties.getLivereload().getPort(), Restarter.getInstance().getThreadFactory()); }
@EventListener public void onClassPathChanged(ClassPathChangedEvent event) { if (event.isRestartRequired()) { Restarter.getInstance().restart( new FileWatchingFailureHandler(fileSystemWatcherFactory())); } }
@Bean @ConditionalOnMissingBean public ClassPathFileSystemWatcher classPathFileSystemWatcher() { URL[] urls = Restarter.getInstance().getInitialUrls(); ClassPathFileSystemWatcher watcher = new ClassPathFileSystemWatcher( fileSystemWatcherFactory(), classPathRestartStrategy(), urls); watcher.setStopWatcherOnRestart(true); return watcher; }
private ConfigurableApplicationContext initializeAndRun(Class<?> config, Map<String, Object> properties, String... args) { Restarter.initialize(new String[0], false, new MockRestartInitializer(), false); SpringApplication application = new SpringApplication(config); application.setDefaultProperties(getDefaultProperties(properties)); application.setWebEnvironment(false); ConfigurableApplicationContext context = application.run(args); return context; }
private boolean isRestarterInitialized() { try { Restarter restarter = Restarter.getInstance(); return (restarter != null && restarter.getInitialUrls() != null); } catch (NoClassDefFoundError | Exception ex) { return false; } }