Commit 0d124e98 authored by Andy Wilkinson's avatar Andy Wilkinson

Remove use of field injection from spring-boot-devtools

Closes gh-17442
parent bd22ca02
...@@ -28,7 +28,7 @@ import org.apache.commons.logging.Log; ...@@ -28,7 +28,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
...@@ -131,20 +131,21 @@ public class RemoteClientConfiguration implements InitializingBean { ...@@ -131,20 +131,21 @@ public class RemoteClientConfiguration implements InitializingBean {
@ConditionalOnProperty(prefix = "spring.devtools.livereload", name = "enabled", matchIfMissing = true) @ConditionalOnProperty(prefix = "spring.devtools.livereload", name = "enabled", matchIfMissing = true)
static class LiveReloadConfiguration { static class LiveReloadConfiguration {
@Autowired private final DevToolsProperties properties;
private DevToolsProperties properties;
@Autowired(required = false) private final ClientHttpRequestFactory clientHttpRequestFactory;
private LiveReloadServer liveReloadServer;
@Autowired private final String remoteUrl;
private ClientHttpRequestFactory clientHttpRequestFactory;
@Value("${remoteUrl}")
private String remoteUrl;
private ExecutorService executor = Executors.newSingleThreadExecutor(); private ExecutorService executor = Executors.newSingleThreadExecutor();
LiveReloadConfiguration(DevToolsProperties properties, ClientHttpRequestFactory clientHttpRequestFactory,
@Value("${remoteUrl}") String remoteUrl) {
this.properties = properties;
this.clientHttpRequestFactory = clientHttpRequestFactory;
this.remoteUrl = remoteUrl;
}
@Bean @Bean
@RestartScope @RestartScope
@ConditionalOnMissingBean @ConditionalOnMissingBean
...@@ -164,8 +165,8 @@ public class RemoteClientConfiguration implements InitializingBean { ...@@ -164,8 +165,8 @@ public class RemoteClientConfiguration implements InitializingBean {
} }
@Bean @Bean
OptionalLiveReloadServer optionalLiveReloadServer() { OptionalLiveReloadServer optionalLiveReloadServer(ObjectProvider<LiveReloadServer> liveReloadServer) {
return new OptionalLiveReloadServer(this.liveReloadServer); return new OptionalLiveReloadServer(liveReloadServer.getIfAvailable());
} }
final ExecutorService getExecutor() { final ExecutorService getExecutor() {
...@@ -181,11 +182,11 @@ public class RemoteClientConfiguration implements InitializingBean { ...@@ -181,11 +182,11 @@ public class RemoteClientConfiguration implements InitializingBean {
@ConditionalOnProperty(prefix = "spring.devtools.remote.restart", name = "enabled", matchIfMissing = true) @ConditionalOnProperty(prefix = "spring.devtools.remote.restart", name = "enabled", matchIfMissing = true)
static class RemoteRestartClientConfiguration { static class RemoteRestartClientConfiguration {
@Autowired private final DevToolsProperties properties;
private DevToolsProperties properties;
@Value("${remoteUrl}") RemoteRestartClientConfiguration(DevToolsProperties properties) {
private String remoteUrl; this.properties = properties;
}
@Bean @Bean
ClassPathFileSystemWatcher classPathFileSystemWatcher(FileSystemWatcherFactory fileSystemWatcherFactory, ClassPathFileSystemWatcher classPathFileSystemWatcher(FileSystemWatcherFactory fileSystemWatcherFactory,
...@@ -220,8 +221,9 @@ public class RemoteClientConfiguration implements InitializingBean { ...@@ -220,8 +221,9 @@ public class RemoteClientConfiguration implements InitializingBean {
} }
@Bean @Bean
ClassPathChangeUploader classPathChangeUploader(ClientHttpRequestFactory requestFactory) { ClassPathChangeUploader classPathChangeUploader(ClientHttpRequestFactory requestFactory,
String url = this.remoteUrl + this.properties.getRemote().getContextPath() + "/restart"; @Value("${remoteUrl}") String remoteUrl) {
String url = remoteUrl + this.properties.getRemote().getContextPath() + "/restart";
return new ClassPathChangeUploader(url, requestFactory); return new ClassPathChangeUploader(url, requestFactory);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment