Skip to content

Commit

Permalink
Inject single-use configuration dependencies into bean methods
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Feb 20, 2019
1 parent 34f28b4 commit de0c065
Show file tree
Hide file tree
Showing 106 changed files with 933 additions and 1,861 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -49,17 +49,11 @@
public class RabbitHealthIndicatorAutoConfiguration extends
CompositeHealthIndicatorConfiguration<RabbitHealthIndicator, RabbitTemplate> {

private final Map<String, RabbitTemplate> rabbitTemplates;

public RabbitHealthIndicatorAutoConfiguration(
Map<String, RabbitTemplate> rabbitTemplates) {
this.rabbitTemplates = rabbitTemplates;
}

@Bean
@ConditionalOnMissingBean(name = "rabbitHealthIndicator")
public HealthIndicator rabbitHealthIndicator() {
return createHealthIndicator(this.rabbitTemplates);
public HealthIndicator rabbitHealthIndicator(
Map<String, RabbitTemplate> rabbitTemplates) {
return createHealthIndicator(rabbitTemplates);
}

}
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -42,17 +42,11 @@
@Configuration
public class AuditAutoConfiguration {

private final AuditEventRepository auditEventRepository;

public AuditAutoConfiguration(
ObjectProvider<AuditEventRepository> auditEventRepository) {
this.auditEventRepository = auditEventRepository.getIfAvailable();
}

@Bean
@ConditionalOnMissingBean(AbstractAuditListener.class)
public AuditListener auditListener() throws Exception {
return new AuditListener(this.auditEventRepository);
public AuditListener auditListener(
ObjectProvider<AuditEventRepository> auditEventRepository) throws Exception {
return new AuditListener(auditEventRepository.getIfAvailable());
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -56,17 +56,11 @@
public class CassandraHealthIndicatorAutoConfiguration extends
CompositeHealthIndicatorConfiguration<CassandraHealthIndicator, CassandraOperations> {

private final Map<String, CassandraOperations> cassandraOperations;

public CassandraHealthIndicatorAutoConfiguration(
Map<String, CassandraOperations> cassandraOperations) {
this.cassandraOperations = cassandraOperations;
}

@Bean
@ConditionalOnMissingBean(name = "cassandraHealthIndicator")
public HealthIndicator cassandraHealthIndicator() {
return createHealthIndicator(this.cassandraOperations);
public HealthIndicator cassandraHealthIndicator(
Map<String, CassandraOperations> cassandraOperations) {
return createHealthIndicator(cassandraOperations);
}

}
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -53,17 +53,11 @@
public class CassandraReactiveHealthIndicatorAutoConfiguration extends
CompositeReactiveHealthIndicatorConfiguration<CassandraReactiveHealthIndicator, ReactiveCassandraOperations> {

private final Map<String, ReactiveCassandraOperations> reactiveCassandraOperations;

public CassandraReactiveHealthIndicatorAutoConfiguration(
Map<String, ReactiveCassandraOperations> reactiveCassandraOperations) {
this.reactiveCassandraOperations = reactiveCassandraOperations;
}

@Bean
@ConditionalOnMissingBean(name = "cassandraReactiveHealthIndicator")
public ReactiveHealthIndicator cassandraHealthIndicator() {
return createHealthIndicator(this.reactiveCassandraOperations);
public ReactiveHealthIndicator cassandraHealthIndicator(
Map<String, ReactiveCassandraOperations> reactiveCassandraOperations) {
return createHealthIndicator(reactiveCassandraOperations);
}

}
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -72,12 +72,6 @@
@ConditionalOnCloudPlatform(CloudPlatform.CLOUD_FOUNDRY)
public class ReactiveCloudFoundryActuatorAutoConfiguration {

private final ApplicationContext applicationContext;

ReactiveCloudFoundryActuatorAutoConfiguration(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}

@Bean
@ConditionalOnMissingBean
@ConditionalOnEnabledEndpoint
Expand All @@ -92,12 +86,13 @@ public CloudFoundryReactiveHealthEndpointWebExtension cloudFoundryReactiveHealth
public CloudFoundryWebFluxEndpointHandlerMapping cloudFoundryWebFluxEndpointHandlerMapping(
ParameterValueMapper parameterMapper, EndpointMediaTypes endpointMediaTypes,
WebClient.Builder webClientBuilder,
ControllerEndpointsSupplier controllerEndpointsSupplier) {
ControllerEndpointsSupplier controllerEndpointsSupplier,
ApplicationContext applicationContext) {
CloudFoundryWebEndpointDiscoverer endpointDiscoverer = new CloudFoundryWebEndpointDiscoverer(
this.applicationContext, parameterMapper, endpointMediaTypes, null,
applicationContext, parameterMapper, endpointMediaTypes, null,
Collections.emptyList(), Collections.emptyList());
CloudFoundrySecurityInterceptor securityInterceptor = getSecurityInterceptor(
webClientBuilder, this.applicationContext.getEnvironment());
webClientBuilder, applicationContext.getEnvironment());
Collection<ExposableWebEndpoint> webEndpoints = endpointDiscoverer.getEndpoints();
List<ExposableEndpoint<?>> allEndpoints = new ArrayList<>();
allEndpoints.addAll(webEndpoints);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -76,12 +76,6 @@
@ConditionalOnCloudPlatform(CloudPlatform.CLOUD_FOUNDRY)
public class CloudFoundryActuatorAutoConfiguration {

private final ApplicationContext applicationContext;

CloudFoundryActuatorAutoConfiguration(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}

@Bean
@ConditionalOnMissingBean
@ConditionalOnEnabledEndpoint
Expand All @@ -96,12 +90,13 @@ public CloudFoundryWebEndpointServletHandlerMapping cloudFoundryWebEndpointServl
ParameterValueMapper parameterMapper, EndpointMediaTypes endpointMediaTypes,
RestTemplateBuilder restTemplateBuilder,
ServletEndpointsSupplier servletEndpointsSupplier,
ControllerEndpointsSupplier controllerEndpointsSupplier) {
ControllerEndpointsSupplier controllerEndpointsSupplier,
ApplicationContext applicationContext) {
CloudFoundryWebEndpointDiscoverer discoverer = new CloudFoundryWebEndpointDiscoverer(
this.applicationContext, parameterMapper, endpointMediaTypes, null,
applicationContext, parameterMapper, endpointMediaTypes, null,
Collections.emptyList(), Collections.emptyList());
CloudFoundrySecurityInterceptor securityInterceptor = getSecurityInterceptor(
restTemplateBuilder, this.applicationContext.getEnvironment());
restTemplateBuilder, applicationContext.getEnvironment());
Collection<ExposableWebEndpoint> webEndpoints = discoverer.getEndpoints();
List<ExposableEndpoint<?>> allEndpoints = new ArrayList<>();
allEndpoints.addAll(webEndpoints);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,12 @@
@EnableConfigurationProperties(ConfigurationPropertiesReportEndpointProperties.class)
public class ConfigurationPropertiesReportEndpointAutoConfiguration {

private final ConfigurationPropertiesReportEndpointProperties properties;

public ConfigurationPropertiesReportEndpointAutoConfiguration(
ConfigurationPropertiesReportEndpointProperties properties) {
this.properties = properties;
}

@Bean
@ConditionalOnMissingBean
public ConfigurationPropertiesReportEndpoint configurationPropertiesReportEndpoint() {
public ConfigurationPropertiesReportEndpoint configurationPropertiesReportEndpoint(
ConfigurationPropertiesReportEndpointProperties properties) {
ConfigurationPropertiesReportEndpoint endpoint = new ConfigurationPropertiesReportEndpoint();
String[] keysToSanitize = this.properties.getKeysToSanitize();
String[] keysToSanitize = properties.getKeysToSanitize();
if (keysToSanitize != null) {
endpoint.setKeysToSanitize(keysToSanitize);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -52,16 +52,10 @@
public class CouchbaseHealthIndicatorAutoConfiguration
extends CompositeHealthIndicatorConfiguration<CouchbaseHealthIndicator, Cluster> {

private final Map<String, Cluster> clusters;

public CouchbaseHealthIndicatorAutoConfiguration(Map<String, Cluster> clusters) {
this.clusters = clusters;
}

@Bean
@ConditionalOnMissingBean(name = "couchbaseHealthIndicator")
public HealthIndicator couchbaseHealthIndicator() {
return createHealthIndicator(this.clusters);
public HealthIndicator couchbaseHealthIndicator(Map<String, Cluster> clusters) {
return createHealthIndicator(clusters);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -52,17 +52,11 @@
public class CouchbaseReactiveHealthIndicatorAutoConfiguration extends
CompositeReactiveHealthIndicatorConfiguration<CouchbaseReactiveHealthIndicator, Cluster> {

private final Map<String, Cluster> clusters;

public CouchbaseReactiveHealthIndicatorAutoConfiguration(
Map<String, Cluster> clusters) {
this.clusters = clusters;
}

@Bean
@ConditionalOnMissingBean(name = "couchbaseReactiveHealthIndicator")
public ReactiveHealthIndicator couchbaseReactiveHealthIndicator() {
return createHealthIndicator(this.clusters);
public ReactiveHealthIndicator couchbaseReactiveHealthIndicator(
Map<String, Cluster> clusters) {
return createHealthIndicator(clusters);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -54,21 +54,17 @@
public class ElasticSearchClientHealthIndicatorAutoConfiguration extends
CompositeHealthIndicatorConfiguration<ElasticsearchHealthIndicator, Client> {

private final Map<String, Client> clients;

private final ElasticsearchHealthIndicatorProperties properties;

public ElasticSearchClientHealthIndicatorAutoConfiguration(
Map<String, Client> clients,
ElasticsearchHealthIndicatorProperties properties) {
this.clients = clients;
this.properties = properties;
}

@Bean
@ConditionalOnMissingBean(name = "elasticsearchHealthIndicator")
public HealthIndicator elasticsearchHealthIndicator() {
return createHealthIndicator(this.clients);
public HealthIndicator elasticsearchHealthIndicator(Map<String, Client> clients) {
return createHealthIndicator(clients);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -53,17 +53,10 @@
public class ElasticSearchJestHealthIndicatorAutoConfiguration extends
CompositeHealthIndicatorConfiguration<ElasticsearchJestHealthIndicator, JestClient> {

private final Map<String, JestClient> clients;

public ElasticSearchJestHealthIndicatorAutoConfiguration(
Map<String, JestClient> clients) {
this.clients = clients;
}

@Bean
@ConditionalOnMissingBean(name = "elasticsearchHealthIndicator")
public HealthIndicator elasticsearchHealthIndicator() {
return createHealthIndicator(this.clients);
public HealthIndicator elasticsearchHealthIndicator(Map<String, JestClient> clients) {
return createHealthIndicator(clients);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -53,17 +53,11 @@
public class ElasticSearchRestHealthIndicatorAutoConfiguration extends
CompositeHealthIndicatorConfiguration<ElasticsearchRestHealthIndicator, RestClient> {

private final Map<String, RestClient> clients;

public ElasticSearchRestHealthIndicatorAutoConfiguration(
Map<String, RestClient> clients) {
this.clients = clients;
}

@Bean
@ConditionalOnMissingBean(name = "elasticsearchRestHealthIndicator")
public HealthIndicator elasticsearchRestHealthIndicator() {
return createHealthIndicator(this.clients);
public HealthIndicator elasticsearchRestHealthIndicator(
Map<String, RestClient> clients) {
return createHealthIndicator(clients);
}

@Override
Expand Down
Loading

0 comments on commit de0c065

Please sign in to comment.