|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright 2012-2020 the original author or authors.
|
|
|
|
|
* Copyright 2012-2022 the original author or authors.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
@ -20,6 +20,9 @@ import java.io.File;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
@ -44,6 +47,7 @@ import org.springframework.context.annotation.Lazy;
|
|
|
|
|
import org.springframework.context.event.ContextRefreshedEvent;
|
|
|
|
|
import org.springframework.context.event.GenericApplicationListener;
|
|
|
|
|
import org.springframework.core.ResolvableType;
|
|
|
|
|
import org.springframework.core.log.LogMessage;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -101,13 +105,9 @@ public class LocalDevToolsAutoConfiguration {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
ApplicationListener<ClassPathChangedEvent> restartingClassPathChangedEventListener(
|
|
|
|
|
RestartingClassPathChangeChangedEventListener restartingClassPathChangedEventListener(
|
|
|
|
|
FileSystemWatcherFactory fileSystemWatcherFactory) {
|
|
|
|
|
return (event) -> {
|
|
|
|
|
if (event.isRestartRequired()) {
|
|
|
|
|
Restarter.getInstance().restart(new FileWatchingFailureHandler(fileSystemWatcherFactory));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
return new RestartingClassPathChangeChangedEventListener(fileSystemWatcherFactory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
@ -194,4 +194,24 @@ public class LocalDevToolsAutoConfiguration {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static class RestartingClassPathChangeChangedEventListener implements ApplicationListener<ClassPathChangedEvent> {
|
|
|
|
|
|
|
|
|
|
private static final Log logger = LogFactory.getLog(RestartingClassPathChangeChangedEventListener.class);
|
|
|
|
|
|
|
|
|
|
private final FileSystemWatcherFactory fileSystemWatcherFactory;
|
|
|
|
|
|
|
|
|
|
RestartingClassPathChangeChangedEventListener(FileSystemWatcherFactory fileSystemWatcherFactory) {
|
|
|
|
|
this.fileSystemWatcherFactory = fileSystemWatcherFactory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onApplicationEvent(ClassPathChangedEvent event) {
|
|
|
|
|
if (event.isRestartRequired()) {
|
|
|
|
|
logger.info(LogMessage.format("Restarting due to %s", event.overview()));
|
|
|
|
|
Restarter.getInstance().restart(new FileWatchingFailureHandler(this.fileSystemWatcherFactory));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|