Reduce need for bean method proxying and disable where not needed

Closes gh-9068
This commit is contained in:
Andy Wilkinson
2019-02-08 14:51:38 +00:00
parent 0f71f22f3c
commit 68bfb020aa
887 changed files with 2574 additions and 2542 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* Copyright 2012-2019 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.
@@ -56,7 +56,7 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
*/
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
@Conditional(DevToolsDataSourceCondition.class)
@Configuration
@Configuration(proxyBeanMethods = false)
public class DevToolsDataSourceAutoConfiguration {
@Bean
@@ -71,7 +71,7 @@ public class DevToolsDataSourceAutoConfiguration {
* {@link javax.persistence.EntityManagerFactory} beans depend on the
* {@code inMemoryDatabaseShutdownExecutor} bean.
*/
@Configuration
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(LocalContainerEntityManagerFactoryBean.class)
@ConditionalOnBean(AbstractEntityManagerFactoryBean.class)
static class DatabaseShutdownExecutorJpaDependencyConfiguration

View File

@@ -32,7 +32,7 @@ import org.springframework.core.Ordered;
* @author Andy Wilkinson
* @since 2.2.0
*/
@Configuration
@Configuration(proxyBeanMethods = false)
public class EagerInitializationAutoConfiguration {
@Bean

View File

@@ -52,7 +52,7 @@ import org.springframework.util.StringUtils;
* @author Vladimir Tsanev
* @since 1.3.0
*/
@Configuration
@Configuration(proxyBeanMethods = false)
@ConditionalOnInitializedRestarter
@EnableConfigurationProperties(DevToolsProperties.class)
public class LocalDevToolsAutoConfiguration {
@@ -60,7 +60,7 @@ public class LocalDevToolsAutoConfiguration {
/**
* Local LiveReload configuration.
*/
@Configuration
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(prefix = "spring.devtools.livereload", name = "enabled", matchIfMissing = true)
static class LiveReloadConfiguration {
@@ -89,10 +89,9 @@ public class LocalDevToolsAutoConfiguration {
/**
* Local Restart Configuration.
*/
@Configuration
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(prefix = "spring.devtools.restart", name = "enabled", matchIfMissing = true)
static class RestartConfiguration
implements ApplicationListener<ClassPathChangedEvent> {
static class RestartConfiguration {
private final DevToolsProperties properties;
@@ -100,20 +99,25 @@ public class LocalDevToolsAutoConfiguration {
this.properties = properties;
}
@Override
public void onApplicationEvent(ClassPathChangedEvent event) {
if (event.isRestartRequired()) {
Restarter.getInstance().restart(
new FileWatchingFailureHandler(fileSystemWatcherFactory()));
}
@Bean
public ApplicationListener<ClassPathChangedEvent> restartingClassPathChangedEventListener(
FileSystemWatcherFactory fileSystemWatcherFactory) {
return (event) -> {
if (event.isRestartRequired()) {
Restarter.getInstance().restart(
new FileWatchingFailureHandler(fileSystemWatcherFactory));
}
};
}
@Bean
@ConditionalOnMissingBean
public ClassPathFileSystemWatcher classPathFileSystemWatcher() {
public ClassPathFileSystemWatcher classPathFileSystemWatcher(
FileSystemWatcherFactory fileSystemWatcherFactory,
ClassPathRestartStrategy classPathRestartStrategy) {
URL[] urls = Restarter.getInstance().getInitialUrls();
ClassPathFileSystemWatcher watcher = new ClassPathFileSystemWatcher(
fileSystemWatcherFactory(), classPathRestartStrategy(), urls);
fileSystemWatcherFactory, classPathRestartStrategy, urls);
watcher.setStopWatcherOnRestart(true);
return watcher;
}

View File

@@ -54,7 +54,7 @@ import org.springframework.http.server.ServerHttpRequest;
* @author Andy Wilkinson
* @since 1.3.0
*/
@Configuration
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(prefix = "spring.devtools.remote", name = "secret")
@ConditionalOnClass({ Filter.class, ServerHttpRequest.class })
@EnableConfigurationProperties({ ServerProperties.class, DevToolsProperties.class })
@@ -100,7 +100,7 @@ public class RemoteDevToolsAutoConfiguration {
/**
* Configuration for remote update and restarts.
*/
@Configuration
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(prefix = "spring.devtools.remote.restart", name = "enabled", matchIfMissing = true)
static class RemoteRestartConfiguration {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* Copyright 2012-2019 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.
@@ -67,7 +67,7 @@ import org.springframework.util.StringUtils;
* @since 1.3.0
* @see org.springframework.boot.devtools.RemoteSpringApplication
*/
@Configuration
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(DevToolsProperties.class)
public class RemoteClientConfiguration implements InitializingBean {
@@ -129,10 +129,9 @@ public class RemoteClientConfiguration implements InitializingBean {
/**
* LiveReload configuration.
*/
@Configuration
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(prefix = "spring.devtools.livereload", name = "enabled", matchIfMissing = true)
static class LiveReloadConfiguration
implements ApplicationListener<ClassPathChangedEvent> {
static class LiveReloadConfiguration {
@Autowired
private DevToolsProperties properties;
@@ -156,11 +155,15 @@ public class RemoteClientConfiguration implements InitializingBean {
Restarter.getInstance().getThreadFactory());
}
@Override
public void onApplicationEvent(ClassPathChangedEvent event) {
String url = this.remoteUrl + this.properties.getRemote().getContextPath();
this.executor.execute(new DelayedLiveReloadTrigger(optionalLiveReloadServer(),
this.clientHttpRequestFactory, url));
@Bean
public ApplicationListener<ClassPathChangedEvent> liveReloadTriggeringClassPathChangedEventListener(
OptionalLiveReloadServer optionalLiveReloadServer) {
return (event) -> {
String url = this.remoteUrl
+ this.properties.getRemote().getContextPath();
this.executor.execute(new DelayedLiveReloadTrigger(
optionalLiveReloadServer, this.clientHttpRequestFactory, url));
};
}
@Bean
@@ -177,7 +180,7 @@ public class RemoteClientConfiguration implements InitializingBean {
/**
* Client configuration for remote update and restarts.
*/
@Configuration
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(prefix = "spring.devtools.remote.restart", name = "enabled", matchIfMissing = true)
static class RemoteRestartClientConfiguration {
@@ -188,14 +191,16 @@ public class RemoteClientConfiguration implements InitializingBean {
private String remoteUrl;
@Bean
public ClassPathFileSystemWatcher classPathFileSystemWatcher() {
public ClassPathFileSystemWatcher classPathFileSystemWatcher(
FileSystemWatcherFactory fileSystemWatcherFactory,
ClassPathRestartStrategy classPathRestartStrategy) {
DefaultRestartInitializer restartInitializer = new DefaultRestartInitializer();
URL[] urls = restartInitializer.getInitialUrls(Thread.currentThread());
if (urls == null) {
urls = new URL[0];
}
return new ClassPathFileSystemWatcher(getFileSystemWatcherFactory(),
classPathRestartStrategy(), urls);
return new ClassPathFileSystemWatcher(fileSystemWatcherFactory,
classPathRestartStrategy, urls);
}
@Bean