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

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.
@@ -86,7 +86,7 @@ public class RemoteUrlPropertyExtractorTests {
return application.run(args);
}
@Configuration
@Configuration(proxyBeanMethods = false)
static class Config {
}

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.
@@ -116,7 +116,7 @@ public abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
return context;
}
@Configuration
@Configuration(proxyBeanMethods = false)
static class SingleDataSourceConfiguration {
@Bean
@@ -126,7 +126,7 @@ public abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
}
@Configuration
@Configuration(proxyBeanMethods = false)
static class MultipleDataSourcesConfiguration {
@Bean
@@ -141,7 +141,7 @@ public abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
}
@Configuration
@Configuration(proxyBeanMethods = false)
static class DataSourceSpyConfiguration {
@Bean

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.
@@ -271,14 +271,14 @@ public class LocalDevToolsAutoConfigurationTests {
return properties;
}
@Configuration
@Configuration(proxyBeanMethods = false)
@Import({ ServletWebServerFactoryAutoConfiguration.class,
LocalDevToolsAutoConfiguration.class, ThymeleafAutoConfiguration.class })
public static class Config {
}
@Configuration
@Configuration(proxyBeanMethods = false)
@ImportAutoConfiguration({ ServletWebServerFactoryAutoConfiguration.class,
LocalDevToolsAutoConfiguration.class, ThymeleafAutoConfiguration.class })
public static class ConfigWithMockLiveReload {
@@ -290,14 +290,14 @@ public class LocalDevToolsAutoConfigurationTests {
}
@Configuration
@Configuration(proxyBeanMethods = false)
@Import({ ServletWebServerFactoryAutoConfiguration.class,
LocalDevToolsAutoConfiguration.class, ResourceProperties.class })
public static class WebResourcesConfig {
}
@Configuration
@Configuration(proxyBeanMethods = false)
public static class SessionRedisTemplateConfig {
@Bean

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.
@@ -181,7 +181,7 @@ public class RemoteDevToolsAutoConfigurationTests {
this.context.refresh();
}
@Configuration
@Configuration(proxyBeanMethods = false)
@Import(RemoteDevToolsAutoConfiguration.class)
static class Config {

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.
@@ -91,7 +91,7 @@ public class ClassPathFileSystemWatcherTests {
context.close();
}
@Configuration
@Configuration(proxyBeanMethods = false)
public static class Config {
public final Environment environment;
@@ -101,12 +101,13 @@ public class ClassPathFileSystemWatcherTests {
}
@Bean
public ClassPathFileSystemWatcher watcher() {
public ClassPathFileSystemWatcher watcher(
ClassPathRestartStrategy restartStrategy) {
FileSystemWatcher watcher = new FileSystemWatcher(false,
Duration.ofMillis(100), Duration.ofMillis(10));
URL[] urls = this.environment.getProperty("urls", URL[].class);
return new ClassPathFileSystemWatcher(
new MockFileSystemWatcherFactory(watcher), restartStrategy(), urls);
new MockFileSystemWatcherFactory(watcher), restartStrategy, urls);
}
@Bean

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.
@@ -114,18 +114,18 @@ public class DevToolPropertiesIntegrationTests {
.isEqualTo(ErrorProperties.IncludeStacktrace.ALWAYS.toString());
}
@Configuration
@Configuration(proxyBeanMethods = false)
static class TestConfiguration {
}
@Configuration
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty("spring.h2.console.enabled")
static class ClassConditionConfiguration {
}
@Configuration
@Configuration(proxyBeanMethods = false)
static class BeanConditionConfiguration {
@Bean

View File

@@ -94,7 +94,7 @@ public class HttpTunnelIntegrationTests {
tunnelContext.close();
}
@Configuration
@Configuration(proxyBeanMethods = false)
@EnableWebMvc
static class ServerConfiguration {
@@ -128,7 +128,7 @@ public class HttpTunnelIntegrationTests {
}
@org.springframework.context.annotation.Configuration
@org.springframework.context.annotation.Configuration(proxyBeanMethods = false)
static class TunnelConfiguration {
@Bean

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.
@@ -160,7 +160,7 @@ public class RemoteClientConfigurationTests {
this.clientContext.refresh();
}
@Configuration
@Configuration(proxyBeanMethods = false)
static class Config {
@Bean
@@ -183,7 +183,7 @@ public class RemoteClientConfigurationTests {
}
@Configuration
@Configuration(proxyBeanMethods = false)
static class ClientConfig {
@Bean

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.
@@ -91,7 +91,7 @@ public class OnInitializedRestarterConditionTests {
}
@Configuration
@Configuration(proxyBeanMethods = false)
public static class Config {
@Bean

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 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.
@@ -59,7 +59,7 @@ public class RestartScopeInitializerTests {
return application.run();
}
@Configuration
@Configuration(proxyBeanMethods = false)
public static class Config {
@Bean