Inject Map directly rather than via ObjectProvider

See gh-15798
pull/15889/head
ayudovin 6 years ago committed by Stephane Nicoll
parent 9d609ab1ba
commit 3a2e85ce75

@ -16,10 +16,8 @@
package org.springframework.boot.actuate.autoconfigure.cache;
import java.util.LinkedHashMap;
import java.util.Map;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
import org.springframework.boot.actuate.cache.CachesEndpoint;
import org.springframework.boot.actuate.cache.CachesEndpointWebExtension;
@ -48,9 +46,8 @@ public class CachesEndpointAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public CachesEndpoint cachesEndpoint(
ObjectProvider<Map<String, CacheManager>> cacheManagers) {
return new CachesEndpoint(cacheManagers.getIfAvailable(LinkedHashMap::new));
public CachesEndpoint cachesEndpoint(Map<String, CacheManager> cacheManagers) {
return new CachesEndpoint(cacheManagers);
}
@Bean

@ -16,12 +16,10 @@
package org.springframework.boot.actuate.autoconfigure.health;
import java.util.Collections;
import java.util.Map;
import reactor.core.publisher.Flux;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
import org.springframework.boot.actuate.health.HealthAggregator;
import org.springframework.boot.actuate.health.HealthIndicator;
@ -87,13 +85,11 @@ public class HealthIndicatorAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public ReactiveHealthIndicatorRegistry reactiveHealthIndicatorRegistry(
ObjectProvider<Map<String, ReactiveHealthIndicator>> reactiveHealthIndicators,
ObjectProvider<Map<String, HealthIndicator>> healthIndicators) {
Map<String, ReactiveHealthIndicator> reactiveHealthIndicators,
Map<String, HealthIndicator> healthIndicators) {
return new ReactiveHealthIndicatorRegistryFactory()
.createReactiveHealthIndicatorRegistry(
reactiveHealthIndicators
.getIfAvailable(Collections::emptyMap),
healthIndicators.getIfAvailable(Collections::emptyMap));
.createReactiveHealthIndicatorRegistry(reactiveHealthIndicators,
healthIndicators);
}
}

@ -72,10 +72,9 @@ public class DataSourceHealthIndicatorAutoConfiguration extends
private DataSourcePoolMetadataProvider poolMetadataProvider;
public DataSourceHealthIndicatorAutoConfiguration(
ObjectProvider<Map<String, DataSource>> dataSources,
public DataSourceHealthIndicatorAutoConfiguration(Map<String, DataSource> dataSources,
ObjectProvider<DataSourcePoolMetadataProvider> metadataProviders) {
this.dataSources = filterDataSources(dataSources.getIfAvailable());
this.dataSources = filterDataSources(dataSources);
this.metadataProviders = metadataProviders.orderedStream()
.collect(Collectors.toList());
}

@ -20,7 +20,6 @@ import java.util.Map;
import javax.jms.ConnectionFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.autoconfigure.health.CompositeHealthIndicatorConfiguration;
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration;
@ -55,8 +54,8 @@ public class JmsHealthIndicatorAutoConfiguration extends
private final Map<String, ConnectionFactory> connectionFactories;
public JmsHealthIndicatorAutoConfiguration(
ObjectProvider<Map<String, ConnectionFactory>> connectionFactories) {
this.connectionFactories = connectionFactories.getIfAvailable();
Map<String, ConnectionFactory> connectionFactories) {
this.connectionFactories = connectionFactories;
}
@Bean

@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.mail;
import java.util.Map;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.autoconfigure.health.CompositeHealthIndicatorConfiguration;
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration;
@ -53,8 +52,8 @@ public class MailHealthIndicatorAutoConfiguration extends
private final Map<String, JavaMailSenderImpl> mailSenders;
public MailHealthIndicatorAutoConfiguration(
ObjectProvider<Map<String, JavaMailSenderImpl>> mailSenders) {
this.mailSenders = mailSenders.getIfAvailable();
Map<String, JavaMailSenderImpl> mailSenders) {
this.mailSenders = mailSenders;
}
@Bean

@ -74,13 +74,12 @@ public class QuartzAutoConfiguration {
public QuartzAutoConfiguration(QuartzProperties properties,
ObjectProvider<SchedulerFactoryBeanCustomizer> customizers,
ObjectProvider<JobDetail[]> jobDetails,
ObjectProvider<Map<String, Calendar>> calendars,
ObjectProvider<JobDetail[]> jobDetails, Map<String, Calendar> calendars,
ObjectProvider<Trigger[]> triggers, ApplicationContext applicationContext) {
this.properties = properties;
this.customizers = customizers;
this.jobDetails = jobDetails.getIfAvailable();
this.calendars = calendars.getIfAvailable();
this.calendars = calendars;
this.triggers = triggers.getIfAvailable();
this.applicationContext = applicationContext;
}

Loading…
Cancel
Save