Skip to content

Commit de0c065

Browse files
committed
Inject single-use configuration dependencies into bean methods
Closes gh-15751
1 parent 34f28b4 commit de0c065

File tree

106 files changed

+933
-1861
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+933
-1861
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/amqp/RabbitHealthIndicatorAutoConfiguration.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -49,17 +49,11 @@
4949
public class RabbitHealthIndicatorAutoConfiguration extends
5050
CompositeHealthIndicatorConfiguration<RabbitHealthIndicator, RabbitTemplate> {
5151

52-
private final Map<String, RabbitTemplate> rabbitTemplates;
53-
54-
public RabbitHealthIndicatorAutoConfiguration(
55-
Map<String, RabbitTemplate> rabbitTemplates) {
56-
this.rabbitTemplates = rabbitTemplates;
57-
}
58-
5952
@Bean
6053
@ConditionalOnMissingBean(name = "rabbitHealthIndicator")
61-
public HealthIndicator rabbitHealthIndicator() {
62-
return createHealthIndicator(this.rabbitTemplates);
54+
public HealthIndicator rabbitHealthIndicator(
55+
Map<String, RabbitTemplate> rabbitTemplates) {
56+
return createHealthIndicator(rabbitTemplates);
6357
}
6458

6559
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/audit/AuditAutoConfiguration.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -42,17 +42,11 @@
4242
@Configuration
4343
public class AuditAutoConfiguration {
4444

45-
private final AuditEventRepository auditEventRepository;
46-
47-
public AuditAutoConfiguration(
48-
ObjectProvider<AuditEventRepository> auditEventRepository) {
49-
this.auditEventRepository = auditEventRepository.getIfAvailable();
50-
}
51-
5245
@Bean
5346
@ConditionalOnMissingBean(AbstractAuditListener.class)
54-
public AuditListener auditListener() throws Exception {
55-
return new AuditListener(this.auditEventRepository);
47+
public AuditListener auditListener(
48+
ObjectProvider<AuditEventRepository> auditEventRepository) throws Exception {
49+
return new AuditListener(auditEventRepository.getIfAvailable());
5650
}
5751

5852
@Bean

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cassandra/CassandraHealthIndicatorAutoConfiguration.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,17 +56,11 @@
5656
public class CassandraHealthIndicatorAutoConfiguration extends
5757
CompositeHealthIndicatorConfiguration<CassandraHealthIndicator, CassandraOperations> {
5858

59-
private final Map<String, CassandraOperations> cassandraOperations;
60-
61-
public CassandraHealthIndicatorAutoConfiguration(
62-
Map<String, CassandraOperations> cassandraOperations) {
63-
this.cassandraOperations = cassandraOperations;
64-
}
65-
6659
@Bean
6760
@ConditionalOnMissingBean(name = "cassandraHealthIndicator")
68-
public HealthIndicator cassandraHealthIndicator() {
69-
return createHealthIndicator(this.cassandraOperations);
61+
public HealthIndicator cassandraHealthIndicator(
62+
Map<String, CassandraOperations> cassandraOperations) {
63+
return createHealthIndicator(cassandraOperations);
7064
}
7165

7266
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cassandra/CassandraReactiveHealthIndicatorAutoConfiguration.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -53,17 +53,11 @@
5353
public class CassandraReactiveHealthIndicatorAutoConfiguration extends
5454
CompositeReactiveHealthIndicatorConfiguration<CassandraReactiveHealthIndicator, ReactiveCassandraOperations> {
5555

56-
private final Map<String, ReactiveCassandraOperations> reactiveCassandraOperations;
57-
58-
public CassandraReactiveHealthIndicatorAutoConfiguration(
59-
Map<String, ReactiveCassandraOperations> reactiveCassandraOperations) {
60-
this.reactiveCassandraOperations = reactiveCassandraOperations;
61-
}
62-
6356
@Bean
6457
@ConditionalOnMissingBean(name = "cassandraReactiveHealthIndicator")
65-
public ReactiveHealthIndicator cassandraHealthIndicator() {
66-
return createHealthIndicator(this.reactiveCassandraOperations);
58+
public ReactiveHealthIndicator cassandraHealthIndicator(
59+
Map<String, ReactiveCassandraOperations> reactiveCassandraOperations) {
60+
return createHealthIndicator(reactiveCassandraOperations);
6761
}
6862

6963
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -72,12 +72,6 @@
7272
@ConditionalOnCloudPlatform(CloudPlatform.CLOUD_FOUNDRY)
7373
public class ReactiveCloudFoundryActuatorAutoConfiguration {
7474

75-
private final ApplicationContext applicationContext;
76-
77-
ReactiveCloudFoundryActuatorAutoConfiguration(ApplicationContext applicationContext) {
78-
this.applicationContext = applicationContext;
79-
}
80-
8175
@Bean
8276
@ConditionalOnMissingBean
8377
@ConditionalOnEnabledEndpoint
@@ -92,12 +86,13 @@ public CloudFoundryReactiveHealthEndpointWebExtension cloudFoundryReactiveHealth
9286
public CloudFoundryWebFluxEndpointHandlerMapping cloudFoundryWebFluxEndpointHandlerMapping(
9387
ParameterValueMapper parameterMapper, EndpointMediaTypes endpointMediaTypes,
9488
WebClient.Builder webClientBuilder,
95-
ControllerEndpointsSupplier controllerEndpointsSupplier) {
89+
ControllerEndpointsSupplier controllerEndpointsSupplier,
90+
ApplicationContext applicationContext) {
9691
CloudFoundryWebEndpointDiscoverer endpointDiscoverer = new CloudFoundryWebEndpointDiscoverer(
97-
this.applicationContext, parameterMapper, endpointMediaTypes, null,
92+
applicationContext, parameterMapper, endpointMediaTypes, null,
9893
Collections.emptyList(), Collections.emptyList());
9994
CloudFoundrySecurityInterceptor securityInterceptor = getSecurityInterceptor(
100-
webClientBuilder, this.applicationContext.getEnvironment());
95+
webClientBuilder, applicationContext.getEnvironment());
10196
Collection<ExposableWebEndpoint> webEndpoints = endpointDiscoverer.getEndpoints();
10297
List<ExposableEndpoint<?>> allEndpoints = new ArrayList<>();
10398
allEndpoints.addAll(webEndpoints);

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -76,12 +76,6 @@
7676
@ConditionalOnCloudPlatform(CloudPlatform.CLOUD_FOUNDRY)
7777
public class CloudFoundryActuatorAutoConfiguration {
7878

79-
private final ApplicationContext applicationContext;
80-
81-
CloudFoundryActuatorAutoConfiguration(ApplicationContext applicationContext) {
82-
this.applicationContext = applicationContext;
83-
}
84-
8579
@Bean
8680
@ConditionalOnMissingBean
8781
@ConditionalOnEnabledEndpoint
@@ -96,12 +90,13 @@ public CloudFoundryWebEndpointServletHandlerMapping cloudFoundryWebEndpointServl
9690
ParameterValueMapper parameterMapper, EndpointMediaTypes endpointMediaTypes,
9791
RestTemplateBuilder restTemplateBuilder,
9892
ServletEndpointsSupplier servletEndpointsSupplier,
99-
ControllerEndpointsSupplier controllerEndpointsSupplier) {
93+
ControllerEndpointsSupplier controllerEndpointsSupplier,
94+
ApplicationContext applicationContext) {
10095
CloudFoundryWebEndpointDiscoverer discoverer = new CloudFoundryWebEndpointDiscoverer(
101-
this.applicationContext, parameterMapper, endpointMediaTypes, null,
96+
applicationContext, parameterMapper, endpointMediaTypes, null,
10297
Collections.emptyList(), Collections.emptyList());
10398
CloudFoundrySecurityInterceptor securityInterceptor = getSecurityInterceptor(
104-
restTemplateBuilder, this.applicationContext.getEnvironment());
99+
restTemplateBuilder, applicationContext.getEnvironment());
105100
Collection<ExposableWebEndpoint> webEndpoints = discoverer.getEndpoints();
106101
List<ExposableEndpoint<?>> allEndpoints = new ArrayList<>();
107102
allEndpoints.addAll(webEndpoints);

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/context/properties/ConfigurationPropertiesReportEndpointAutoConfiguration.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,12 @@
3737
@EnableConfigurationProperties(ConfigurationPropertiesReportEndpointProperties.class)
3838
public class ConfigurationPropertiesReportEndpointAutoConfiguration {
3939

40-
private final ConfigurationPropertiesReportEndpointProperties properties;
41-
42-
public ConfigurationPropertiesReportEndpointAutoConfiguration(
43-
ConfigurationPropertiesReportEndpointProperties properties) {
44-
this.properties = properties;
45-
}
46-
4740
@Bean
4841
@ConditionalOnMissingBean
49-
public ConfigurationPropertiesReportEndpoint configurationPropertiesReportEndpoint() {
42+
public ConfigurationPropertiesReportEndpoint configurationPropertiesReportEndpoint(
43+
ConfigurationPropertiesReportEndpointProperties properties) {
5044
ConfigurationPropertiesReportEndpoint endpoint = new ConfigurationPropertiesReportEndpoint();
51-
String[] keysToSanitize = this.properties.getKeysToSanitize();
45+
String[] keysToSanitize = properties.getKeysToSanitize();
5246
if (keysToSanitize != null) {
5347
endpoint.setKeysToSanitize(keysToSanitize);
5448
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/couchbase/CouchbaseHealthIndicatorAutoConfiguration.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -52,16 +52,10 @@
5252
public class CouchbaseHealthIndicatorAutoConfiguration
5353
extends CompositeHealthIndicatorConfiguration<CouchbaseHealthIndicator, Cluster> {
5454

55-
private final Map<String, Cluster> clusters;
56-
57-
public CouchbaseHealthIndicatorAutoConfiguration(Map<String, Cluster> clusters) {
58-
this.clusters = clusters;
59-
}
60-
6155
@Bean
6256
@ConditionalOnMissingBean(name = "couchbaseHealthIndicator")
63-
public HealthIndicator couchbaseHealthIndicator() {
64-
return createHealthIndicator(this.clusters);
57+
public HealthIndicator couchbaseHealthIndicator(Map<String, Cluster> clusters) {
58+
return createHealthIndicator(clusters);
6559
}
6660

6761
@Override

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/couchbase/CouchbaseReactiveHealthIndicatorAutoConfiguration.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -52,17 +52,11 @@
5252
public class CouchbaseReactiveHealthIndicatorAutoConfiguration extends
5353
CompositeReactiveHealthIndicatorConfiguration<CouchbaseReactiveHealthIndicator, Cluster> {
5454

55-
private final Map<String, Cluster> clusters;
56-
57-
public CouchbaseReactiveHealthIndicatorAutoConfiguration(
58-
Map<String, Cluster> clusters) {
59-
this.clusters = clusters;
60-
}
61-
6255
@Bean
6356
@ConditionalOnMissingBean(name = "couchbaseReactiveHealthIndicator")
64-
public ReactiveHealthIndicator couchbaseReactiveHealthIndicator() {
65-
return createHealthIndicator(this.clusters);
57+
public ReactiveHealthIndicator couchbaseReactiveHealthIndicator(
58+
Map<String, Cluster> clusters) {
59+
return createHealthIndicator(clusters);
6660
}
6761

6862
@Override

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticSearchClientHealthIndicatorAutoConfiguration.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,21 +54,17 @@
5454
public class ElasticSearchClientHealthIndicatorAutoConfiguration extends
5555
CompositeHealthIndicatorConfiguration<ElasticsearchHealthIndicator, Client> {
5656

57-
private final Map<String, Client> clients;
58-
5957
private final ElasticsearchHealthIndicatorProperties properties;
6058

6159
public ElasticSearchClientHealthIndicatorAutoConfiguration(
62-
Map<String, Client> clients,
6360
ElasticsearchHealthIndicatorProperties properties) {
64-
this.clients = clients;
6561
this.properties = properties;
6662
}
6763

6864
@Bean
6965
@ConditionalOnMissingBean(name = "elasticsearchHealthIndicator")
70-
public HealthIndicator elasticsearchHealthIndicator() {
71-
return createHealthIndicator(this.clients);
66+
public HealthIndicator elasticsearchHealthIndicator(Map<String, Client> clients) {
67+
return createHealthIndicator(clients);
7268
}
7369

7470
@Override

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticSearchJestHealthIndicatorAutoConfiguration.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -53,17 +53,10 @@
5353
public class ElasticSearchJestHealthIndicatorAutoConfiguration extends
5454
CompositeHealthIndicatorConfiguration<ElasticsearchJestHealthIndicator, JestClient> {
5555

56-
private final Map<String, JestClient> clients;
57-
58-
public ElasticSearchJestHealthIndicatorAutoConfiguration(
59-
Map<String, JestClient> clients) {
60-
this.clients = clients;
61-
}
62-
6356
@Bean
6457
@ConditionalOnMissingBean(name = "elasticsearchHealthIndicator")
65-
public HealthIndicator elasticsearchHealthIndicator() {
66-
return createHealthIndicator(this.clients);
58+
public HealthIndicator elasticsearchHealthIndicator(Map<String, JestClient> clients) {
59+
return createHealthIndicator(clients);
6760
}
6861

6962
@Override

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticSearchRestHealthIndicatorAutoConfiguration.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -53,17 +53,11 @@
5353
public class ElasticSearchRestHealthIndicatorAutoConfiguration extends
5454
CompositeHealthIndicatorConfiguration<ElasticsearchRestHealthIndicator, RestClient> {
5555

56-
private final Map<String, RestClient> clients;
57-
58-
public ElasticSearchRestHealthIndicatorAutoConfiguration(
59-
Map<String, RestClient> clients) {
60-
this.clients = clients;
61-
}
62-
6356
@Bean
6457
@ConditionalOnMissingBean(name = "elasticsearchRestHealthIndicator")
65-
public HealthIndicator elasticsearchRestHealthIndicator() {
66-
return createHealthIndicator(this.clients);
58+
public HealthIndicator elasticsearchRestHealthIndicator(
59+
Map<String, RestClient> clients) {
60+
return createHealthIndicator(clients);
6761
}
6862

6963
@Override

0 commit comments

Comments
 (0)