Commit c84a0f53 authored by Stephane Nicoll's avatar Stephane Nicoll

Merge pull request #15798 from ayudovin

* pr/15798:
  Polish "Inject Map directly rather than via ObjectProvider"
  Inject Map directly rather than via ObjectProvider
parents 9d609ab1 ede23caa
...@@ -16,10 +16,8 @@ ...@@ -16,10 +16,8 @@
package org.springframework.boot.actuate.autoconfigure.cache; package org.springframework.boot.actuate.autoconfigure.cache;
import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint; import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
import org.springframework.boot.actuate.cache.CachesEndpoint; import org.springframework.boot.actuate.cache.CachesEndpoint;
import org.springframework.boot.actuate.cache.CachesEndpointWebExtension; import org.springframework.boot.actuate.cache.CachesEndpointWebExtension;
...@@ -48,9 +46,8 @@ public class CachesEndpointAutoConfiguration { ...@@ -48,9 +46,8 @@ public class CachesEndpointAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public CachesEndpoint cachesEndpoint( public CachesEndpoint cachesEndpoint(Map<String, CacheManager> cacheManagers) {
ObjectProvider<Map<String, CacheManager>> cacheManagers) { return new CachesEndpoint(cacheManagers);
return new CachesEndpoint(cacheManagers.getIfAvailable(LinkedHashMap::new));
} }
@Bean @Bean
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -16,12 +16,10 @@ ...@@ -16,12 +16,10 @@
package org.springframework.boot.actuate.autoconfigure.health; package org.springframework.boot.actuate.autoconfigure.health;
import java.util.Collections;
import java.util.Map; import java.util.Map;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.health.ApplicationHealthIndicator; import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
import org.springframework.boot.actuate.health.HealthAggregator; import org.springframework.boot.actuate.health.HealthAggregator;
import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.actuate.health.HealthIndicator;
...@@ -87,13 +85,11 @@ public class HealthIndicatorAutoConfiguration { ...@@ -87,13 +85,11 @@ public class HealthIndicatorAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public ReactiveHealthIndicatorRegistry reactiveHealthIndicatorRegistry( public ReactiveHealthIndicatorRegistry reactiveHealthIndicatorRegistry(
ObjectProvider<Map<String, ReactiveHealthIndicator>> reactiveHealthIndicators, Map<String, ReactiveHealthIndicator> reactiveHealthIndicators,
ObjectProvider<Map<String, HealthIndicator>> healthIndicators) { Map<String, HealthIndicator> healthIndicators) {
return new ReactiveHealthIndicatorRegistryFactory() return new ReactiveHealthIndicatorRegistryFactory()
.createReactiveHealthIndicatorRegistry( .createReactiveHealthIndicatorRegistry(reactiveHealthIndicators,
reactiveHealthIndicators healthIndicators);
.getIfAvailable(Collections::emptyMap),
healthIndicators.getIfAvailable(Collections::emptyMap));
} }
} }
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -72,10 +72,9 @@ public class DataSourceHealthIndicatorAutoConfiguration extends ...@@ -72,10 +72,9 @@ public class DataSourceHealthIndicatorAutoConfiguration extends
private DataSourcePoolMetadataProvider poolMetadataProvider; private DataSourcePoolMetadataProvider poolMetadataProvider;
public DataSourceHealthIndicatorAutoConfiguration( public DataSourceHealthIndicatorAutoConfiguration(Map<String, DataSource> dataSources,
ObjectProvider<Map<String, DataSource>> dataSources,
ObjectProvider<DataSourcePoolMetadataProvider> metadataProviders) { ObjectProvider<DataSourcePoolMetadataProvider> metadataProviders) {
this.dataSources = filterDataSources(dataSources.getIfAvailable()); this.dataSources = filterDataSources(dataSources);
this.metadataProviders = metadataProviders.orderedStream() this.metadataProviders = metadataProviders.orderedStream()
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -20,7 +20,6 @@ import java.util.Map; ...@@ -20,7 +20,6 @@ import java.util.Map;
import javax.jms.ConnectionFactory; 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.CompositeHealthIndicatorConfiguration;
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator; import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration;
...@@ -55,8 +54,8 @@ public class JmsHealthIndicatorAutoConfiguration extends ...@@ -55,8 +54,8 @@ public class JmsHealthIndicatorAutoConfiguration extends
private final Map<String, ConnectionFactory> connectionFactories; private final Map<String, ConnectionFactory> connectionFactories;
public JmsHealthIndicatorAutoConfiguration( public JmsHealthIndicatorAutoConfiguration(
ObjectProvider<Map<String, ConnectionFactory>> connectionFactories) { Map<String, ConnectionFactory> connectionFactories) {
this.connectionFactories = connectionFactories.getIfAvailable(); this.connectionFactories = connectionFactories;
} }
@Bean @Bean
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.mail; ...@@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.mail;
import java.util.Map; 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.CompositeHealthIndicatorConfiguration;
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator; import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration;
...@@ -53,8 +52,8 @@ public class MailHealthIndicatorAutoConfiguration extends ...@@ -53,8 +52,8 @@ public class MailHealthIndicatorAutoConfiguration extends
private final Map<String, JavaMailSenderImpl> mailSenders; private final Map<String, JavaMailSenderImpl> mailSenders;
public MailHealthIndicatorAutoConfiguration( public MailHealthIndicatorAutoConfiguration(
ObjectProvider<Map<String, JavaMailSenderImpl>> mailSenders) { Map<String, JavaMailSenderImpl> mailSenders) {
this.mailSenders = mailSenders.getIfAvailable(); this.mailSenders = mailSenders;
} }
@Bean @Bean
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -74,13 +74,12 @@ public class QuartzAutoConfiguration { ...@@ -74,13 +74,12 @@ public class QuartzAutoConfiguration {
public QuartzAutoConfiguration(QuartzProperties properties, public QuartzAutoConfiguration(QuartzProperties properties,
ObjectProvider<SchedulerFactoryBeanCustomizer> customizers, ObjectProvider<SchedulerFactoryBeanCustomizer> customizers,
ObjectProvider<JobDetail[]> jobDetails, ObjectProvider<JobDetail[]> jobDetails, Map<String, Calendar> calendars,
ObjectProvider<Map<String, Calendar>> calendars,
ObjectProvider<Trigger[]> triggers, ApplicationContext applicationContext) { ObjectProvider<Trigger[]> triggers, ApplicationContext applicationContext) {
this.properties = properties; this.properties = properties;
this.customizers = customizers; this.customizers = customizers;
this.jobDetails = jobDetails.getIfAvailable(); this.jobDetails = jobDetails.getIfAvailable();
this.calendars = calendars.getIfAvailable(); this.calendars = calendars;
this.triggers = triggers.getIfAvailable(); this.triggers = triggers.getIfAvailable();
this.applicationContext = applicationContext; this.applicationContext = applicationContext;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment