Stop using ObjectProvider<List> and ObjectProvider<Collection>
Closes gh-14467
This commit is contained in:
parent
5323095e44
commit
cc6cf880cf
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
package org.springframework.boot.actuate.autoconfigure.endpoint.jmx;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
|
||||
|
|
@ -75,11 +74,11 @@ public class JmxEndpointAutoConfiguration {
|
|||
@ConditionalOnMissingBean(JmxEndpointsSupplier.class)
|
||||
public JmxEndpointDiscoverer jmxAnnotationEndpointDiscoverer(
|
||||
ParameterValueMapper parameterValueMapper,
|
||||
ObjectProvider<Collection<OperationInvokerAdvisor>> invokerAdvisors,
|
||||
ObjectProvider<Collection<EndpointFilter<ExposableJmxEndpoint>>> filters) {
|
||||
ObjectProvider<OperationInvokerAdvisor> invokerAdvisors,
|
||||
ObjectProvider<EndpointFilter<ExposableJmxEndpoint>> filters) {
|
||||
return new JmxEndpointDiscoverer(this.applicationContext, parameterValueMapper,
|
||||
invokerAdvisors.getIfAvailable(Collections::emptyList),
|
||||
filters.getIfAvailable(Collections::emptyList));
|
||||
invokerAdvisors.orderedStream().collect(Collectors.toList()),
|
||||
filters.orderedStream().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import java.util.Arrays;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
|
||||
|
|
@ -95,12 +96,12 @@ public class WebEndpointAutoConfiguration {
|
|||
public WebEndpointDiscoverer webEndpointDiscoverer(
|
||||
ParameterValueMapper parameterValueMapper,
|
||||
EndpointMediaTypes endpointMediaTypes, PathMapper webEndpointPathMapper,
|
||||
ObjectProvider<Collection<OperationInvokerAdvisor>> invokerAdvisors,
|
||||
ObjectProvider<Collection<EndpointFilter<ExposableWebEndpoint>>> filters) {
|
||||
ObjectProvider<OperationInvokerAdvisor> invokerAdvisors,
|
||||
ObjectProvider<EndpointFilter<ExposableWebEndpoint>> filters) {
|
||||
return new WebEndpointDiscoverer(this.applicationContext, parameterValueMapper,
|
||||
endpointMediaTypes, webEndpointPathMapper,
|
||||
invokerAdvisors.getIfAvailable(Collections::emptyList),
|
||||
filters.getIfAvailable(Collections::emptyList));
|
||||
invokerAdvisors.orderedStream().collect(Collectors.toList()),
|
||||
filters.orderedStream().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
@ -144,10 +145,10 @@ public class WebEndpointAutoConfiguration {
|
|||
@ConditionalOnMissingBean(ServletEndpointsSupplier.class)
|
||||
public ServletEndpointDiscoverer servletEndpointDiscoverer(
|
||||
ApplicationContext applicationContext, PathMapper webEndpointPathMapper,
|
||||
ObjectProvider<Collection<EndpointFilter<ExposableServletEndpoint>>> filters) {
|
||||
ObjectProvider<EndpointFilter<ExposableServletEndpoint>> filters) {
|
||||
return new ServletEndpointDiscoverer(applicationContext,
|
||||
webEndpointPathMapper,
|
||||
filters.getIfAvailable(Collections::emptyList));
|
||||
filters.orderedStream().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
package org.springframework.boot.actuate.autoconfigure.info;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
|
|
@ -42,9 +41,9 @@ public class InfoEndpointAutoConfiguration {
|
|||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnEnabledEndpoint
|
||||
public InfoEndpoint infoEndpoint(
|
||||
ObjectProvider<List<InfoContributor>> infoContributors) {
|
||||
return new InfoEndpoint(infoContributors.getIfAvailable(Collections::emptyList));
|
||||
public InfoEndpoint infoEndpoint(ObjectProvider<InfoContributor> infoContributors) {
|
||||
return new InfoEndpoint(
|
||||
infoContributors.orderedStream().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.springframework.boot.actuate.autoconfigure.jdbc;
|
|||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
|
|
@ -73,9 +74,10 @@ public class DataSourceHealthIndicatorAutoConfiguration extends
|
|||
|
||||
public DataSourceHealthIndicatorAutoConfiguration(
|
||||
ObjectProvider<Map<String, DataSource>> dataSources,
|
||||
ObjectProvider<Collection<DataSourcePoolMetadataProvider>> metadataProviders) {
|
||||
ObjectProvider<DataSourcePoolMetadataProvider> metadataProviders) {
|
||||
this.dataSources = filterDataSources(dataSources.getIfAvailable());
|
||||
this.metadataProviders = metadataProviders.getIfAvailable();
|
||||
this.metadataProviders = metadataProviders.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Map<String, DataSource> filterDataSources(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
package org.springframework.boot.actuate.autoconfigure.scheduling;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
|
|
@ -41,8 +40,9 @@ public class ScheduledTasksEndpointAutoConfiguration {
|
|||
@ConditionalOnMissingBean
|
||||
@ConditionalOnEnabledEndpoint
|
||||
public ScheduledTasksEndpoint scheduledTasksEndpoint(
|
||||
ObjectProvider<List<ScheduledTaskHolder>> holders) {
|
||||
return new ScheduledTasksEndpoint(holders.getIfAvailable(Collections::emptyList));
|
||||
ObjectProvider<ScheduledTaskHolder> holders) {
|
||||
return new ScheduledTasksEndpoint(
|
||||
holders.orderedStream().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
package org.springframework.boot.actuate.autoconfigure.web.jersey;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.glassfish.jersey.servlet.ServletContainer;
|
||||
|
|
@ -48,12 +47,11 @@ import org.springframework.context.annotation.Bean;
|
|||
@ConditionalOnMissingClass("org.springframework.web.servlet.DispatcherServlet")
|
||||
public class JerseyManagementChildContextConfiguration {
|
||||
|
||||
private final List<ResourceConfigCustomizer> resourceConfigCustomizers;
|
||||
private final Stream<ResourceConfigCustomizer> resourceConfigCustomizers;
|
||||
|
||||
public JerseyManagementChildContextConfiguration(
|
||||
ObjectProvider<List<ResourceConfigCustomizer>> resourceConfigCustomizers) {
|
||||
this.resourceConfigCustomizers = resourceConfigCustomizers
|
||||
.getIfAvailable(Collections::emptyList);
|
||||
ObjectProvider<ResourceConfigCustomizer> resourceConfigCustomizers) {
|
||||
this.resourceConfigCustomizers = resourceConfigCustomizers.orderedStream();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
@ -65,9 +63,8 @@ public class JerseyManagementChildContextConfiguration {
|
|||
@Bean
|
||||
public ResourceConfig endpointResourceConfig() {
|
||||
ResourceConfig resourceConfig = new ResourceConfig();
|
||||
for (ResourceConfigCustomizer customizer : this.resourceConfigCustomizers) {
|
||||
customizer.customize(resourceConfig);
|
||||
}
|
||||
this.resourceConfigCustomizers
|
||||
.forEach((customizer) -> customizer.customize(resourceConfig));
|
||||
return resourceConfig;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
package org.springframework.boot.actuate.autoconfigure.web.mappings;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
|
|
@ -50,9 +49,9 @@ public class MappingsEndpointAutoConfiguration {
|
|||
@Bean
|
||||
@ConditionalOnEnabledEndpoint
|
||||
public MappingsEndpoint mappingsEndpoint(ApplicationContext applicationContext,
|
||||
ObjectProvider<Collection<MappingDescriptionProvider>> descriptionProviders) {
|
||||
ObjectProvider<MappingDescriptionProvider> descriptionProviders) {
|
||||
return new MappingsEndpoint(
|
||||
descriptionProviders.getIfAvailable(Collections::emptyList),
|
||||
descriptionProviders.orderedStream().collect(Collectors.toList()),
|
||||
applicationContext);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.management.MalformedObjectNameException;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
|
|
@ -57,13 +55,13 @@ public class SpringApplicationAdminJmxAutoConfiguration {
|
|||
*/
|
||||
private static final String DEFAULT_JMX_NAME = "org.springframework.boot:type=Admin,name=SpringApplication";
|
||||
|
||||
private final List<MBeanExporter> mbeanExporters;
|
||||
private final Iterable<MBeanExporter> mbeanExporters;
|
||||
|
||||
private final Environment environment;
|
||||
|
||||
public SpringApplicationAdminJmxAutoConfiguration(
|
||||
ObjectProvider<List<MBeanExporter>> mbeanExporters, Environment environment) {
|
||||
this.mbeanExporters = mbeanExporters.getIfAvailable();
|
||||
ObjectProvider<MBeanExporter> mbeanExporters, Environment environment) {
|
||||
this.mbeanExporters = mbeanExporters;
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.amqp;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
|
||||
import org.springframework.amqp.rabbit.config.DirectRabbitListenerContainerFactory;
|
||||
|
|
@ -47,13 +47,13 @@ class RabbitAnnotationDrivenConfiguration {
|
|||
|
||||
private final ObjectProvider<MessageRecoverer> messageRecoverer;
|
||||
|
||||
private final ObjectProvider<List<RabbitRetryTemplateCustomizer>> retryTemplateCustomizers;
|
||||
private final ObjectProvider<RabbitRetryTemplateCustomizer> retryTemplateCustomizers;
|
||||
|
||||
private final RabbitProperties properties;
|
||||
|
||||
RabbitAnnotationDrivenConfiguration(ObjectProvider<MessageConverter> messageConverter,
|
||||
ObjectProvider<MessageRecoverer> messageRecoverer,
|
||||
ObjectProvider<List<RabbitRetryTemplateCustomizer>> retryTemplateCustomizers,
|
||||
ObjectProvider<RabbitRetryTemplateCustomizer> retryTemplateCustomizers,
|
||||
RabbitProperties properties) {
|
||||
this.messageConverter = messageConverter;
|
||||
this.messageRecoverer = messageRecoverer;
|
||||
|
|
@ -67,8 +67,8 @@ class RabbitAnnotationDrivenConfiguration {
|
|||
SimpleRabbitListenerContainerFactoryConfigurer configurer = new SimpleRabbitListenerContainerFactoryConfigurer();
|
||||
configurer.setMessageConverter(this.messageConverter.getIfUnique());
|
||||
configurer.setMessageRecoverer(this.messageRecoverer.getIfUnique());
|
||||
configurer.setRetryTemplateCustomizers(
|
||||
this.retryTemplateCustomizers.getIfAvailable());
|
||||
configurer.setRetryTemplateCustomizers(this.retryTemplateCustomizers
|
||||
.orderedStream().collect(Collectors.toList()));
|
||||
configurer.setRabbitProperties(this.properties);
|
||||
return configurer;
|
||||
}
|
||||
|
|
@ -90,8 +90,8 @@ class RabbitAnnotationDrivenConfiguration {
|
|||
DirectRabbitListenerContainerFactoryConfigurer configurer = new DirectRabbitListenerContainerFactoryConfigurer();
|
||||
configurer.setMessageConverter(this.messageConverter.getIfUnique());
|
||||
configurer.setMessageRecoverer(this.messageRecoverer.getIfUnique());
|
||||
configurer.setRetryTemplateCustomizers(
|
||||
this.retryTemplateCustomizers.getIfAvailable());
|
||||
configurer.setRetryTemplateCustomizers(this.retryTemplateCustomizers
|
||||
.orderedStream().collect(Collectors.toList()));
|
||||
configurer.setRabbitProperties(this.properties);
|
||||
return configurer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.springframework.boot.autoconfigure.amqp;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.rabbitmq.client.Channel;
|
||||
|
||||
|
|
@ -161,11 +161,11 @@ public class RabbitAutoConfiguration {
|
|||
|
||||
private final ObjectProvider<MessageConverter> messageConverter;
|
||||
|
||||
private final ObjectProvider<List<RabbitRetryTemplateCustomizer>> retryTemplateCustomizers;
|
||||
private final ObjectProvider<RabbitRetryTemplateCustomizer> retryTemplateCustomizers;
|
||||
|
||||
public RabbitTemplateConfiguration(RabbitProperties properties,
|
||||
ObjectProvider<MessageConverter> messageConverter,
|
||||
ObjectProvider<List<RabbitRetryTemplateCustomizer>> retryTemplateCustomizers) {
|
||||
ObjectProvider<RabbitRetryTemplateCustomizer> retryTemplateCustomizers) {
|
||||
this.properties = properties;
|
||||
this.messageConverter = messageConverter;
|
||||
this.retryTemplateCustomizers = retryTemplateCustomizers;
|
||||
|
|
@ -185,8 +185,9 @@ public class RabbitAutoConfiguration {
|
|||
RabbitProperties.Template properties = this.properties.getTemplate();
|
||||
if (properties.getRetry().isEnabled()) {
|
||||
template.setRetryTemplate(new RetryTemplateFactory(
|
||||
this.retryTemplateCustomizers.getIfAvailable())
|
||||
.createRetryTemplate(properties.getRetry(),
|
||||
this.retryTemplateCustomizers.orderedStream()
|
||||
.collect(Collectors.toList())).createRetryTemplate(
|
||||
properties.getRetry(),
|
||||
RabbitRetryTemplateCustomizer.Target.SENDER));
|
||||
}
|
||||
map.from(properties::getReceiveTimeout).whenNonNull().as(Duration::toMillis)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.cache;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
|
|
@ -67,8 +67,9 @@ public class CacheAutoConfiguration {
|
|||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public CacheManagerCustomizers cacheManagerCustomizers(
|
||||
ObjectProvider<List<CacheManagerCustomizer<?>>> customizers) {
|
||||
return new CacheManagerCustomizers(customizers.getIfAvailable());
|
||||
ObjectProvider<CacheManagerCustomizer<?>> customizers) {
|
||||
return new CacheManagerCustomizers(
|
||||
customizers.orderedStream().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import java.io.IOException;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.cache.CacheManager;
|
||||
import javax.cache.Caching;
|
||||
|
|
@ -42,7 +43,6 @@ import org.springframework.context.annotation.Conditional;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
|
|
@ -70,22 +70,22 @@ class JCacheCacheConfiguration implements BeanClassLoaderAware {
|
|||
|
||||
private final javax.cache.configuration.Configuration<?, ?> defaultCacheConfiguration;
|
||||
|
||||
private final List<JCacheManagerCustomizer> cacheManagerCustomizers;
|
||||
private final Stream<JCacheManagerCustomizer> cacheManagerCustomizers;
|
||||
|
||||
private final List<JCachePropertiesCustomizer> cachePropertiesCustomizers;
|
||||
private final Stream<JCachePropertiesCustomizer> cachePropertiesCustomizers;
|
||||
|
||||
private ClassLoader beanClassLoader;
|
||||
|
||||
JCacheCacheConfiguration(CacheProperties cacheProperties,
|
||||
CacheManagerCustomizers customizers,
|
||||
ObjectProvider<javax.cache.configuration.Configuration<?, ?>> defaultCacheConfiguration,
|
||||
ObjectProvider<List<JCacheManagerCustomizer>> cacheManagerCustomizers,
|
||||
ObjectProvider<List<JCachePropertiesCustomizer>> cachePropertiesCustomizers) {
|
||||
ObjectProvider<JCacheManagerCustomizer> cacheManagerCustomizers,
|
||||
ObjectProvider<JCachePropertiesCustomizer> cachePropertiesCustomizers) {
|
||||
this.cacheProperties = cacheProperties;
|
||||
this.customizers = customizers;
|
||||
this.defaultCacheConfiguration = defaultCacheConfiguration.getIfAvailable();
|
||||
this.cacheManagerCustomizers = cacheManagerCustomizers.getIfAvailable();
|
||||
this.cachePropertiesCustomizers = cachePropertiesCustomizers.getIfAvailable();
|
||||
this.cacheManagerCustomizers = cacheManagerCustomizers.orderedStream();
|
||||
this.cachePropertiesCustomizers = cachePropertiesCustomizers.orderedStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -135,11 +135,8 @@ class JCacheCacheConfiguration implements BeanClassLoaderAware {
|
|||
|
||||
private Properties createCacheManagerProperties() {
|
||||
Properties properties = new Properties();
|
||||
if (this.cachePropertiesCustomizers != null) {
|
||||
for (JCachePropertiesCustomizer customizer : this.cachePropertiesCustomizers) {
|
||||
customizer.customize(this.cacheProperties, properties);
|
||||
}
|
||||
}
|
||||
this.cachePropertiesCustomizers.forEach(
|
||||
(customizer) -> customizer.customize(this.cacheProperties, properties));
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
|
@ -151,12 +148,8 @@ class JCacheCacheConfiguration implements BeanClassLoaderAware {
|
|||
}
|
||||
|
||||
private void customize(CacheManager cacheManager) {
|
||||
if (this.cacheManagerCustomizers != null) {
|
||||
AnnotationAwareOrderComparator.sort(this.cacheManagerCustomizers);
|
||||
for (JCacheManagerCustomizer customizer : this.cacheManagerCustomizers) {
|
||||
customizer.customize(cacheManager);
|
||||
}
|
||||
}
|
||||
this.cacheManagerCustomizers
|
||||
.forEach((customizer) -> customizer.customize(cacheManager));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.springframework.boot.autoconfigure.cassandra;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.datastax.driver.core.Cluster;
|
||||
import com.datastax.driver.core.PoolingOptions;
|
||||
|
|
@ -51,12 +51,12 @@ public class CassandraAutoConfiguration {
|
|||
|
||||
private final CassandraProperties properties;
|
||||
|
||||
private final List<ClusterBuilderCustomizer> builderCustomizers;
|
||||
private final Stream<ClusterBuilderCustomizer> builderCustomizers;
|
||||
|
||||
public CassandraAutoConfiguration(CassandraProperties properties,
|
||||
ObjectProvider<List<ClusterBuilderCustomizer>> builderCustomizers) {
|
||||
ObjectProvider<ClusterBuilderCustomizer> builderCustomizers) {
|
||||
this.properties = properties;
|
||||
this.builderCustomizers = builderCustomizers.getIfAvailable();
|
||||
this.builderCustomizers = builderCustomizers.orderedStream();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
@ -88,11 +88,7 @@ public class CassandraAutoConfiguration {
|
|||
}
|
||||
|
||||
private void customize(Cluster.Builder builder) {
|
||||
if (this.builderCustomizers != null) {
|
||||
for (ClusterBuilderCustomizer customizer : this.builderCustomizers) {
|
||||
customizer.customize(builder);
|
||||
}
|
||||
}
|
||||
this.builderCustomizers.forEach((customizer) -> customizer.customize(builder));
|
||||
}
|
||||
|
||||
private QueryOptions getQueryOptions() {
|
||||
|
|
|
|||
|
|
@ -70,15 +70,10 @@ public class Neo4jDataAutoConfiguration {
|
|||
@Bean
|
||||
public SessionFactory sessionFactory(org.neo4j.ogm.config.Configuration configuration,
|
||||
ApplicationContext applicationContext,
|
||||
ObjectProvider<List<EventListener>> eventListeners) {
|
||||
ObjectProvider<EventListener> eventListeners) {
|
||||
SessionFactory sessionFactory = new SessionFactory(configuration,
|
||||
getPackagesToScan(applicationContext));
|
||||
List<EventListener> providedEventListeners = eventListeners.getIfAvailable();
|
||||
if (providedEventListeners != null) {
|
||||
for (EventListener eventListener : providedEventListeners) {
|
||||
sessionFactory.register(eventListener);
|
||||
}
|
||||
}
|
||||
eventListeners.stream().forEach(sessionFactory::register);
|
||||
return sessionFactory;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -18,8 +18,7 @@ package org.springframework.boot.autoconfigure.data.redis;
|
|||
|
||||
import java.net.UnknownHostException;
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.pool2.impl.GenericObjectPool;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
|
@ -51,16 +50,15 @@ class JedisConnectionConfiguration extends RedisConnectionConfiguration {
|
|||
|
||||
private final RedisProperties properties;
|
||||
|
||||
private final List<JedisClientConfigurationBuilderCustomizer> builderCustomizers;
|
||||
private final Stream<JedisClientConfigurationBuilderCustomizer> builderCustomizers;
|
||||
|
||||
JedisConnectionConfiguration(RedisProperties properties,
|
||||
ObjectProvider<RedisSentinelConfiguration> sentinelConfiguration,
|
||||
ObjectProvider<RedisClusterConfiguration> clusterConfiguration,
|
||||
ObjectProvider<List<JedisClientConfigurationBuilderCustomizer>> builderCustomizers) {
|
||||
ObjectProvider<JedisClientConfigurationBuilderCustomizer> builderCustomizers) {
|
||||
super(properties, sentinelConfiguration, clusterConfiguration);
|
||||
this.properties = properties;
|
||||
this.builderCustomizers = builderCustomizers
|
||||
.getIfAvailable(Collections::emptyList);
|
||||
this.builderCustomizers = builderCustomizers.orderedStream();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
@ -133,9 +131,7 @@ class JedisConnectionConfiguration extends RedisConnectionConfiguration {
|
|||
|
||||
private void customize(
|
||||
JedisClientConfiguration.JedisClientConfigurationBuilder builder) {
|
||||
for (JedisClientConfigurationBuilderCustomizer customizer : this.builderCustomizers) {
|
||||
customizer.customize(builder);
|
||||
}
|
||||
this.builderCustomizers.forEach((customizer) -> customizer.customize(builder));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@
|
|||
package org.springframework.boot.autoconfigure.data.redis;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import io.lettuce.core.RedisClient;
|
||||
import io.lettuce.core.resource.ClientResources;
|
||||
|
|
@ -52,16 +51,15 @@ class LettuceConnectionConfiguration extends RedisConnectionConfiguration {
|
|||
|
||||
private final RedisProperties properties;
|
||||
|
||||
private final List<LettuceClientConfigurationBuilderCustomizer> builderCustomizers;
|
||||
private final Stream<LettuceClientConfigurationBuilderCustomizer> builderCustomizers;
|
||||
|
||||
LettuceConnectionConfiguration(RedisProperties properties,
|
||||
ObjectProvider<RedisSentinelConfiguration> sentinelConfigurationProvider,
|
||||
ObjectProvider<RedisClusterConfiguration> clusterConfigurationProvider,
|
||||
ObjectProvider<List<LettuceClientConfigurationBuilderCustomizer>> builderCustomizers) {
|
||||
ObjectProvider<LettuceClientConfigurationBuilderCustomizer> builderCustomizers) {
|
||||
super(properties, sentinelConfigurationProvider, clusterConfigurationProvider);
|
||||
this.properties = properties;
|
||||
this.builderCustomizers = builderCustomizers
|
||||
.getIfAvailable(Collections::emptyList);
|
||||
this.builderCustomizers = builderCustomizers.orderedStream();
|
||||
}
|
||||
|
||||
@Bean(destroyMethod = "shutdown")
|
||||
|
|
@ -139,9 +137,7 @@ class LettuceConnectionConfiguration extends RedisConnectionConfiguration {
|
|||
|
||||
private void customize(
|
||||
LettuceClientConfiguration.LettuceClientConfigurationBuilder builder) {
|
||||
for (LettuceClientConfigurationBuilderCustomizer customizer : this.builderCustomizers) {
|
||||
customizer.customize(builder);
|
||||
}
|
||||
this.builderCustomizers.forEach((customizer) -> customizer.customize(builder));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.springframework.boot.autoconfigure.elasticsearch.jest;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import io.searchbox.client.JestClient;
|
||||
|
|
@ -54,13 +54,13 @@ public class JestAutoConfiguration {
|
|||
|
||||
private final ObjectProvider<Gson> gsonProvider;
|
||||
|
||||
private final List<HttpClientConfigBuilderCustomizer> builderCustomizers;
|
||||
private final Stream<HttpClientConfigBuilderCustomizer> builderCustomizers;
|
||||
|
||||
public JestAutoConfiguration(JestProperties properties, ObjectProvider<Gson> gson,
|
||||
ObjectProvider<List<HttpClientConfigBuilderCustomizer>> builderCustomizers) {
|
||||
ObjectProvider<HttpClientConfigBuilderCustomizer> builderCustomizers) {
|
||||
this.properties = properties;
|
||||
this.gsonProvider = gson;
|
||||
this.builderCustomizers = builderCustomizers.getIfAvailable();
|
||||
this.builderCustomizers = builderCustomizers.orderedStream();
|
||||
}
|
||||
|
||||
@Bean(destroyMethod = "shutdownClient")
|
||||
|
|
@ -93,11 +93,7 @@ public class JestAutoConfiguration {
|
|||
}
|
||||
|
||||
private void customize(HttpClientConfig.Builder builder) {
|
||||
if (this.builderCustomizers != null) {
|
||||
for (HttpClientConfigBuilderCustomizer customizer : this.builderCustomizers) {
|
||||
customizer.customize(builder);
|
||||
}
|
||||
}
|
||||
this.builderCustomizers.forEach((customizer) -> customizer.customize(builder));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.elasticsearch.rest;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.auth.AuthScope;
|
||||
|
|
@ -51,13 +50,12 @@ public class RestClientAutoConfiguration {
|
|||
|
||||
private final RestClientProperties properties;
|
||||
|
||||
private final List<RestClientBuilderCustomizer> builderCustomizers;
|
||||
private final Stream<RestClientBuilderCustomizer> builderCustomizers;
|
||||
|
||||
public RestClientAutoConfiguration(RestClientProperties properties,
|
||||
ObjectProvider<List<RestClientBuilderCustomizer>> builderCustomizers) {
|
||||
ObjectProvider<RestClientBuilderCustomizer> builderCustomizers) {
|
||||
this.properties = properties;
|
||||
this.builderCustomizers = builderCustomizers
|
||||
.getIfAvailable(Collections::emptyList);
|
||||
this.builderCustomizers = builderCustomizers.orderedStream();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.sql.DataSource;
|
||||
|
|
@ -92,9 +93,8 @@ public class FlywayAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
public FlywaySchemaManagementProvider flywayDefaultDdlModeProvider(
|
||||
ObjectProvider<List<Flyway>> flyways) {
|
||||
return new FlywaySchemaManagementProvider(
|
||||
flyways.getIfAvailable(Collections::emptyList));
|
||||
ObjectProvider<Flyway> flyways) {
|
||||
return new FlywaySchemaManagementProvider(flyways);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
|
@ -123,16 +123,17 @@ public class FlywayAutoConfiguration {
|
|||
ObjectProvider<DataSource> dataSource,
|
||||
@FlywayDataSource ObjectProvider<DataSource> flywayDataSource,
|
||||
ObjectProvider<FlywayMigrationStrategy> migrationStrategy,
|
||||
ObjectProvider<List<Callback>> callbacks,
|
||||
ObjectProvider<List<FlywayCallback>> flywayCallbacks) {
|
||||
ObjectProvider<Callback> callbacks,
|
||||
ObjectProvider<FlywayCallback> flywayCallbacks) {
|
||||
this.properties = properties;
|
||||
this.dataSourceProperties = dataSourceProperties;
|
||||
this.resourceLoader = resourceLoader;
|
||||
this.dataSource = dataSource.getIfUnique();
|
||||
this.flywayDataSource = flywayDataSource.getIfAvailable();
|
||||
this.migrationStrategy = migrationStrategy.getIfAvailable();
|
||||
this.callbacks = callbacks.getIfAvailable(Collections::emptyList);
|
||||
this.flywayCallbacks = flywayCallbacks.getIfAvailable(Collections::emptyList);
|
||||
this.callbacks = callbacks.orderedStream().collect(Collectors.toList());
|
||||
this.flywayCallbacks = flywayCallbacks.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.flyway;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
|
|
@ -33,20 +33,18 @@ import org.springframework.boot.jdbc.SchemaManagementProvider;
|
|||
*/
|
||||
class FlywaySchemaManagementProvider implements SchemaManagementProvider {
|
||||
|
||||
private final List<Flyway> flywayInstances;
|
||||
private final Iterable<Flyway> flywayInstances;
|
||||
|
||||
FlywaySchemaManagementProvider(List<Flyway> flywayInstances) {
|
||||
FlywaySchemaManagementProvider(Iterable<Flyway> flywayInstances) {
|
||||
this.flywayInstances = flywayInstances;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchemaManagement getSchemaManagement(DataSource dataSource) {
|
||||
for (Flyway flywayInstance : this.flywayInstances) {
|
||||
if (dataSource.equals(flywayInstance.getDataSource())) {
|
||||
return SchemaManagement.MANAGED;
|
||||
}
|
||||
}
|
||||
return SchemaManagement.UNMANAGED;
|
||||
return StreamSupport.stream(this.flywayInstances.spliterator(), false)
|
||||
.map(Flyway::getDataSource).filter(dataSource::equals).findFirst()
|
||||
.map((managedDataSource) -> SchemaManagement.MANAGED)
|
||||
.orElse(SchemaManagement.UNMANAGED);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.http;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
|
|
@ -61,15 +61,14 @@ public class HttpMessageConvertersAutoConfiguration {
|
|||
private final List<HttpMessageConverter<?>> converters;
|
||||
|
||||
public HttpMessageConvertersAutoConfiguration(
|
||||
ObjectProvider<List<HttpMessageConverter<?>>> convertersProvider) {
|
||||
this.converters = convertersProvider.getIfAvailable();
|
||||
ObjectProvider<HttpMessageConverter<?>> convertersProvider) {
|
||||
this.converters = convertersProvider.orderedStream().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public HttpMessageConverters messageConverters() {
|
||||
return new HttpMessageConverters(
|
||||
(this.converters != null) ? this.converters : Collections.emptyList());
|
||||
return new HttpMessageConverters(this.converters);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.springframework.boot.autoconfigure.jersey;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.servlet.DispatcherType;
|
||||
|
|
@ -60,7 +60,6 @@ import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
|
@ -94,15 +93,15 @@ public class JerseyAutoConfiguration implements ServletContextAware {
|
|||
|
||||
private final ResourceConfig config;
|
||||
|
||||
private final List<ResourceConfigCustomizer> customizers;
|
||||
private final Stream<ResourceConfigCustomizer> customizers;
|
||||
|
||||
private String path;
|
||||
|
||||
public JerseyAutoConfiguration(JerseyProperties jersey, ResourceConfig config,
|
||||
ObjectProvider<List<ResourceConfigCustomizer>> customizers) {
|
||||
ObjectProvider<ResourceConfigCustomizer> customizers) {
|
||||
this.jersey = jersey;
|
||||
this.config = config;
|
||||
this.customizers = customizers.getIfAvailable();
|
||||
this.customizers = customizers.orderedStream();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
|
|
@ -122,12 +121,7 @@ public class JerseyAutoConfiguration implements ServletContextAware {
|
|||
}
|
||||
|
||||
private void customize() {
|
||||
if (this.customizers != null) {
|
||||
AnnotationAwareOrderComparator.sort(this.customizers);
|
||||
for (ResourceConfigCustomizer customizer : this.customizers) {
|
||||
customizer.customize(this.config);
|
||||
}
|
||||
}
|
||||
this.customizers.forEach((customizer) -> customizer.customize(this.config));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.boot.autoconfigure.jms.activemq;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
|
||||
|
|
@ -61,11 +62,11 @@ class ActiveMQConnectionFactoryConfiguration {
|
|||
|
||||
SimpleConnectionFactoryConfiguration(JmsProperties jmsProperties,
|
||||
ActiveMQProperties properties,
|
||||
ObjectProvider<List<ActiveMQConnectionFactoryCustomizer>> connectionFactoryCustomizers) {
|
||||
ObjectProvider<ActiveMQConnectionFactoryCustomizer> connectionFactoryCustomizers) {
|
||||
this.jmsProperties = jmsProperties;
|
||||
this.properties = properties;
|
||||
this.connectionFactoryCustomizers = connectionFactoryCustomizers
|
||||
.getIfAvailable();
|
||||
.orderedStream().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
@ -102,9 +103,10 @@ class ActiveMQConnectionFactoryConfiguration {
|
|||
@ConditionalOnProperty(prefix = "spring.activemq.pool", name = "enabled", havingValue = "true", matchIfMissing = false)
|
||||
public JmsPoolConnectionFactory pooledJmsConnectionFactory(
|
||||
ActiveMQProperties properties,
|
||||
ObjectProvider<List<ActiveMQConnectionFactoryCustomizer>> factoryCustomizers) {
|
||||
ObjectProvider<ActiveMQConnectionFactoryCustomizer> factoryCustomizers) {
|
||||
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactoryFactory(
|
||||
properties, factoryCustomizers.getIfAvailable())
|
||||
properties,
|
||||
factoryCustomizers.orderedStream().collect(Collectors.toList()))
|
||||
.createConnectionFactory(ActiveMQConnectionFactory.class);
|
||||
return new JmsPoolConnectionFactoryFactory(properties.getPool())
|
||||
.createPooledConnectionFactory(connectionFactory);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.jms.activemq;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.transaction.TransactionManager;
|
||||
|
|
@ -50,10 +50,11 @@ class ActiveMQXAConnectionFactoryConfiguration {
|
|||
@Primary
|
||||
@Bean(name = { "jmsConnectionFactory", "xaJmsConnectionFactory" })
|
||||
public ConnectionFactory jmsConnectionFactory(ActiveMQProperties properties,
|
||||
ObjectProvider<List<ActiveMQConnectionFactoryCustomizer>> factoryCustomizers,
|
||||
ObjectProvider<ActiveMQConnectionFactoryCustomizer> factoryCustomizers,
|
||||
XAConnectionFactoryWrapper wrapper) throws Exception {
|
||||
ActiveMQXAConnectionFactory connectionFactory = new ActiveMQConnectionFactoryFactory(
|
||||
properties, factoryCustomizers.getIfAvailable())
|
||||
properties,
|
||||
factoryCustomizers.orderedStream().collect(Collectors.toList()))
|
||||
.createConnectionFactory(ActiveMQXAConnectionFactory.class);
|
||||
return wrapper.wrapConnectionFactory(connectionFactory);
|
||||
}
|
||||
|
|
@ -62,9 +63,9 @@ class ActiveMQXAConnectionFactoryConfiguration {
|
|||
@ConditionalOnProperty(prefix = "spring.activemq.pool", name = "enabled", havingValue = "false", matchIfMissing = true)
|
||||
public ActiveMQConnectionFactory nonXaJmsConnectionFactory(
|
||||
ActiveMQProperties properties,
|
||||
ObjectProvider<List<ActiveMQConnectionFactoryCustomizer>> factoryCustomizers) {
|
||||
ObjectProvider<ActiveMQConnectionFactoryCustomizer> factoryCustomizers) {
|
||||
return new ActiveMQConnectionFactoryFactory(properties,
|
||||
factoryCustomizers.getIfAvailable())
|
||||
factoryCustomizers.orderedStream().collect(Collectors.toList()))
|
||||
.createConnectionFactory(ActiveMQConnectionFactory.class);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -18,6 +18,8 @@ package org.springframework.boot.autoconfigure.jms.artemis;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.activemq.artemis.jms.server.config.JMSConfiguration;
|
||||
import org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration;
|
||||
|
|
@ -33,7 +35,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
|||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
|
||||
/**
|
||||
* Configuration used to create the embedded Artemis server.
|
||||
|
|
@ -49,20 +50,22 @@ class ArtemisEmbeddedServerConfiguration {
|
|||
|
||||
private final ArtemisProperties properties;
|
||||
|
||||
private final List<ArtemisConfigurationCustomizer> configurationCustomizers;
|
||||
private final Stream<ArtemisConfigurationCustomizer> configurationCustomizers;
|
||||
|
||||
private final List<JMSQueueConfiguration> queuesConfiguration;
|
||||
|
||||
private final List<TopicConfiguration> topicsConfiguration;
|
||||
|
||||
ArtemisEmbeddedServerConfiguration(ArtemisProperties properties,
|
||||
ObjectProvider<List<ArtemisConfigurationCustomizer>> configurationCustomizers,
|
||||
ObjectProvider<List<JMSQueueConfiguration>> queuesConfiguration,
|
||||
ObjectProvider<List<TopicConfiguration>> topicsConfiguration) {
|
||||
ObjectProvider<ArtemisConfigurationCustomizer> configurationCustomizers,
|
||||
ObjectProvider<JMSQueueConfiguration> queuesConfiguration,
|
||||
ObjectProvider<TopicConfiguration> topicsConfiguration) {
|
||||
this.properties = properties;
|
||||
this.configurationCustomizers = configurationCustomizers.getIfAvailable();
|
||||
this.queuesConfiguration = queuesConfiguration.getIfAvailable();
|
||||
this.topicsConfiguration = topicsConfiguration.getIfAvailable();
|
||||
this.configurationCustomizers = configurationCustomizers.orderedStream();
|
||||
this.queuesConfiguration = queuesConfiguration.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
this.topicsConfiguration = topicsConfiguration.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
@ -87,12 +90,8 @@ class ArtemisEmbeddedServerConfiguration {
|
|||
|
||||
private void customize(
|
||||
org.apache.activemq.artemis.core.config.Configuration configuration) {
|
||||
if (this.configurationCustomizers != null) {
|
||||
AnnotationAwareOrderComparator.sort(this.configurationCustomizers);
|
||||
for (ArtemisConfigurationCustomizer customizer : this.configurationCustomizers) {
|
||||
customizer.customize(configuration);
|
||||
}
|
||||
}
|
||||
this.configurationCustomizers
|
||||
.forEach((customizer) -> customizer.customize(configuration));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
package org.springframework.boot.autoconfigure.liquibase;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
|
@ -75,9 +73,8 @@ public class LiquibaseAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
public LiquibaseSchemaManagementProvider liquibaseDefaultDdlModeProvider(
|
||||
ObjectProvider<List<SpringLiquibase>> liquibases) {
|
||||
return new LiquibaseSchemaManagementProvider(
|
||||
liquibases.getIfAvailable(Collections::emptyList));
|
||||
ObjectProvider<SpringLiquibase> liquibases) {
|
||||
return new LiquibaseSchemaManagementProvider(liquibases);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -16,12 +16,13 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.liquibase;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import liquibase.integration.spring.SpringLiquibase;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.jdbc.SchemaManagement;
|
||||
import org.springframework.boot.jdbc.SchemaManagementProvider;
|
||||
|
||||
|
|
@ -33,20 +34,18 @@ import org.springframework.boot.jdbc.SchemaManagementProvider;
|
|||
*/
|
||||
class LiquibaseSchemaManagementProvider implements SchemaManagementProvider {
|
||||
|
||||
private final List<SpringLiquibase> liquibaseInstances;
|
||||
private final Iterable<SpringLiquibase> liquibaseInstances;
|
||||
|
||||
LiquibaseSchemaManagementProvider(List<SpringLiquibase> liquibases) {
|
||||
LiquibaseSchemaManagementProvider(ObjectProvider<SpringLiquibase> liquibases) {
|
||||
this.liquibaseInstances = liquibases;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchemaManagement getSchemaManagement(DataSource dataSource) {
|
||||
for (SpringLiquibase liquibaseInstance : this.liquibaseInstances) {
|
||||
if (dataSource.equals(liquibaseInstance.getDataSource())) {
|
||||
return SchemaManagement.MANAGED;
|
||||
}
|
||||
}
|
||||
return SchemaManagement.UNMANAGED;
|
||||
return StreamSupport.stream(this.liquibaseInstances.spliterator(), false)
|
||||
.map(SpringLiquibase::getDataSource).filter(dataSource::equals)
|
||||
.findFirst().map((managedDataSource) -> SchemaManagement.MANAGED)
|
||||
.orElse(SchemaManagement.UNMANAGED);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.mongo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
|
|
@ -68,9 +68,10 @@ public class MongoReactiveAutoConfiguration {
|
|||
@ConditionalOnMissingBean
|
||||
public MongoClient reactiveStreamsMongoClient(MongoProperties properties,
|
||||
Environment environment,
|
||||
ObjectProvider<List<MongoClientSettingsBuilderCustomizer>> builderCustomizers) {
|
||||
ObjectProvider<MongoClientSettingsBuilderCustomizer> builderCustomizers) {
|
||||
ReactiveMongoClientFactory factory = new ReactiveMongoClientFactory(properties,
|
||||
environment, builderCustomizers.getIfAvailable());
|
||||
environment,
|
||||
builderCustomizers.orderedStream().collect(Collectors.toList()));
|
||||
this.mongo = factory.createMongoClient(this.settings);
|
||||
return this.mongo;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.orm.jpa;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
|
|
@ -32,9 +32,9 @@ import org.springframework.boot.jdbc.SchemaManagementProvider;
|
|||
*/
|
||||
class HibernateDefaultDdlAutoProvider implements SchemaManagementProvider {
|
||||
|
||||
private final List<SchemaManagementProvider> providers;
|
||||
private final Iterable<SchemaManagementProvider> providers;
|
||||
|
||||
HibernateDefaultDdlAutoProvider(List<SchemaManagementProvider> providers) {
|
||||
HibernateDefaultDdlAutoProvider(Iterable<SchemaManagementProvider> providers) {
|
||||
this.providers = providers;
|
||||
}
|
||||
|
||||
|
|
@ -52,13 +52,10 @@ class HibernateDefaultDdlAutoProvider implements SchemaManagementProvider {
|
|||
|
||||
@Override
|
||||
public SchemaManagement getSchemaManagement(DataSource dataSource) {
|
||||
for (SchemaManagementProvider provider : this.providers) {
|
||||
SchemaManagement schemaManagement = provider.getSchemaManagement(dataSource);
|
||||
if (SchemaManagement.MANAGED.equals(schemaManagement)) {
|
||||
return schemaManagement;
|
||||
}
|
||||
}
|
||||
return SchemaManagement.UNMANAGED;
|
||||
return StreamSupport.stream(this.providers.spliterator(), false)
|
||||
.map((provider) -> provider.getSchemaManagement(dataSource))
|
||||
.filter(SchemaManagement.MANAGED::equals).findFirst()
|
||||
.orElse(SchemaManagement.UNMANAGED);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@ package org.springframework.boot.autoconfigure.orm.jpa;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
|
|
@ -89,21 +89,20 @@ class HibernateJpaConfiguration extends JpaBaseConfiguration {
|
|||
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers,
|
||||
HibernateProperties hibernateProperties,
|
||||
ObjectProvider<Collection<DataSourcePoolMetadataProvider>> metadataProviders,
|
||||
ObjectProvider<List<SchemaManagementProvider>> providers,
|
||||
ObjectProvider<SchemaManagementProvider> providers,
|
||||
ObjectProvider<PhysicalNamingStrategy> physicalNamingStrategy,
|
||||
ObjectProvider<ImplicitNamingStrategy> implicitNamingStrategy,
|
||||
ObjectProvider<List<HibernatePropertiesCustomizer>> hibernatePropertiesCustomizers) {
|
||||
ObjectProvider<HibernatePropertiesCustomizer> hibernatePropertiesCustomizers) {
|
||||
super(dataSource, jpaProperties, jtaTransactionManager,
|
||||
transactionManagerCustomizers);
|
||||
this.hibernateProperties = hibernateProperties;
|
||||
this.defaultDdlAutoProvider = new HibernateDefaultDdlAutoProvider(
|
||||
providers.getIfAvailable(Collections::emptyList));
|
||||
this.defaultDdlAutoProvider = new HibernateDefaultDdlAutoProvider(providers);
|
||||
this.poolMetadataProvider = new CompositeDataSourcePoolMetadataProvider(
|
||||
metadataProviders.getIfAvailable());
|
||||
this.hibernatePropertiesCustomizers = determineHibernatePropertiesCustomizers(
|
||||
physicalNamingStrategy.getIfAvailable(),
|
||||
implicitNamingStrategy.getIfAvailable(),
|
||||
hibernatePropertiesCustomizers.getIfAvailable(Collections::emptyList));
|
||||
implicitNamingStrategy.getIfAvailable(), hibernatePropertiesCustomizers
|
||||
.orderedStream().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
private List<HibernatePropertiesCustomizer> determineHibernatePropertiesCustomizers(
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.orm.jpa;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -121,14 +120,12 @@ public abstract class JpaBaseConfiguration implements BeanFactoryAware {
|
|||
public EntityManagerFactoryBuilder entityManagerFactoryBuilder(
|
||||
JpaVendorAdapter jpaVendorAdapter,
|
||||
ObjectProvider<PersistenceUnitManager> persistenceUnitManager,
|
||||
ObjectProvider<List<EntityManagerFactoryBuilderCustomizer>> customizers) {
|
||||
ObjectProvider<EntityManagerFactoryBuilderCustomizer> customizers) {
|
||||
EntityManagerFactoryBuilder builder = new EntityManagerFactoryBuilder(
|
||||
jpaVendorAdapter, this.properties.getProperties(),
|
||||
persistenceUnitManager.getIfAvailable());
|
||||
for (EntityManagerFactoryBuilderCustomizer customizer : customizers
|
||||
.getIfAvailable(Collections::emptyList)) {
|
||||
customizer.customize(builder);
|
||||
}
|
||||
customizers.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(builder));
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.quartz;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ public class QuartzAutoConfiguration {
|
|||
|
||||
private final QuartzProperties properties;
|
||||
|
||||
private final List<SchedulerFactoryBeanCustomizer> customizers;
|
||||
private final Stream<SchedulerFactoryBeanCustomizer> customizers;
|
||||
|
||||
private final JobDetail[] jobDetails;
|
||||
|
||||
|
|
@ -72,12 +72,12 @@ public class QuartzAutoConfiguration {
|
|||
private final ApplicationContext applicationContext;
|
||||
|
||||
public QuartzAutoConfiguration(QuartzProperties properties,
|
||||
ObjectProvider<List<SchedulerFactoryBeanCustomizer>> customizers,
|
||||
ObjectProvider<SchedulerFactoryBeanCustomizer> customizers,
|
||||
ObjectProvider<JobDetail[]> jobDetails,
|
||||
ObjectProvider<Map<String, Calendar>> calendars,
|
||||
ObjectProvider<Trigger[]> triggers, ApplicationContext applicationContext) {
|
||||
this.properties = properties;
|
||||
this.customizers = customizers.getIfAvailable();
|
||||
this.customizers = customizers.orderedStream();
|
||||
this.jobDetails = jobDetails.getIfAvailable();
|
||||
this.calendars = calendars.getIfAvailable();
|
||||
this.triggers = triggers.getIfAvailable();
|
||||
|
|
@ -124,11 +124,8 @@ public class QuartzAutoConfiguration {
|
|||
}
|
||||
|
||||
private void customize(SchedulerFactoryBean schedulerFactoryBean) {
|
||||
if (this.customizers != null) {
|
||||
for (SchedulerFactoryBeanCustomizer customizer : this.customizers) {
|
||||
customizer.customize(schedulerFactoryBean);
|
||||
}
|
||||
}
|
||||
this.customizers
|
||||
.forEach((customizer) -> customizer.customize(schedulerFactoryBean));
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
package org.springframework.boot.autoconfigure.thymeleaf;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
|
|
@ -136,14 +136,14 @@ public class ThymeleafAutoConfiguration {
|
|||
|
||||
private final Collection<ITemplateResolver> templateResolvers;
|
||||
|
||||
private final Collection<IDialect> dialects;
|
||||
private final Stream<IDialect> dialects;
|
||||
|
||||
public ThymeleafDefaultConfiguration(ThymeleafProperties properties,
|
||||
Collection<ITemplateResolver> templateResolvers,
|
||||
ObjectProvider<Collection<IDialect>> dialectsProvider) {
|
||||
ObjectProvider<IDialect> dialectsProvider) {
|
||||
this.properties = properties;
|
||||
this.templateResolvers = templateResolvers;
|
||||
this.dialects = dialectsProvider.getIfAvailable(Collections::emptyList);
|
||||
this.dialects = dialectsProvider.orderedStream();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
@ -224,14 +224,14 @@ public class ThymeleafAutoConfiguration {
|
|||
|
||||
private final Collection<ITemplateResolver> templateResolvers;
|
||||
|
||||
private final Collection<IDialect> dialects;
|
||||
private final Stream<IDialect> dialects;
|
||||
|
||||
ThymeleafReactiveConfiguration(ThymeleafProperties properties,
|
||||
Collection<ITemplateResolver> templateResolvers,
|
||||
ObjectProvider<Collection<IDialect>> dialectsProvider) {
|
||||
ObjectProvider<IDialect> dialectsProvider) {
|
||||
this.properties = properties;
|
||||
this.templateResolvers = templateResolvers;
|
||||
this.dialects = dialectsProvider.getIfAvailable(Collections::emptyList);
|
||||
this.dialects = dialectsProvider.orderedStream();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.transaction;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
|
|
@ -55,8 +55,9 @@ public class TransactionAutoConfiguration {
|
|||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public TransactionManagerCustomizers platformTransactionManagerCustomizers(
|
||||
ObjectProvider<List<PlatformTransactionManagerCustomizer<?>>> customizers) {
|
||||
return new TransactionManagerCustomizers(customizers.getIfAvailable());
|
||||
ObjectProvider<PlatformTransactionManagerCustomizer<?>> customizers) {
|
||||
return new TransactionManagerCustomizers(
|
||||
customizers.orderedStream().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.web.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
|
|
@ -30,7 +30,6 @@ import org.springframework.boot.web.client.RestTemplateBuilder;
|
|||
import org.springframework.boot.web.client.RestTemplateCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
|
|
@ -48,11 +47,11 @@ public class RestTemplateAutoConfiguration {
|
|||
|
||||
private final ObjectProvider<HttpMessageConverters> messageConverters;
|
||||
|
||||
private final ObjectProvider<List<RestTemplateCustomizer>> restTemplateCustomizers;
|
||||
private final ObjectProvider<RestTemplateCustomizer> restTemplateCustomizers;
|
||||
|
||||
public RestTemplateAutoConfiguration(
|
||||
ObjectProvider<HttpMessageConverters> messageConverters,
|
||||
ObjectProvider<List<RestTemplateCustomizer>> restTemplateCustomizers) {
|
||||
ObjectProvider<RestTemplateCustomizer> restTemplateCustomizers) {
|
||||
this.messageConverters = messageConverters;
|
||||
this.restTemplateCustomizers = restTemplateCustomizers;
|
||||
}
|
||||
|
|
@ -65,11 +64,10 @@ public class RestTemplateAutoConfiguration {
|
|||
if (converters != null) {
|
||||
builder = builder.messageConverters(converters.getConverters());
|
||||
}
|
||||
|
||||
List<RestTemplateCustomizer> customizers = this.restTemplateCustomizers
|
||||
.getIfAvailable();
|
||||
.orderedStream().collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(customizers)) {
|
||||
customizers = new ArrayList<>(customizers);
|
||||
AnnotationAwareOrderComparator.sort(customizers);
|
||||
builder = builder.customizers(customizers);
|
||||
}
|
||||
return builder;
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ package org.springframework.boot.autoconfigure.web.reactive;
|
|||
|
||||
import java.time.Duration;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
|
@ -46,7 +46,6 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.core.convert.converter.GenericConverter;
|
||||
import org.springframework.format.Formatter;
|
||||
|
|
@ -115,43 +114,39 @@ public class WebFluxAutoConfiguration {
|
|||
|
||||
private final ListableBeanFactory beanFactory;
|
||||
|
||||
private final List<HandlerMethodArgumentResolver> argumentResolvers;
|
||||
private final Stream<HandlerMethodArgumentResolver> argumentResolvers;
|
||||
|
||||
private final List<CodecCustomizer> codecCustomizers;
|
||||
private final Stream<CodecCustomizer> codecCustomizers;
|
||||
|
||||
private final ResourceHandlerRegistrationCustomizer resourceHandlerRegistrationCustomizer;
|
||||
|
||||
private final List<ViewResolver> viewResolvers;
|
||||
private final Stream<ViewResolver> viewResolvers;
|
||||
|
||||
public WebFluxConfig(ResourceProperties resourceProperties,
|
||||
WebFluxProperties webFluxProperties, ListableBeanFactory beanFactory,
|
||||
ObjectProvider<List<HandlerMethodArgumentResolver>> resolvers,
|
||||
ObjectProvider<List<CodecCustomizer>> codecCustomizers,
|
||||
ObjectProvider<HandlerMethodArgumentResolver> resolvers,
|
||||
ObjectProvider<CodecCustomizer> codecCustomizers,
|
||||
ObjectProvider<ResourceHandlerRegistrationCustomizer> resourceHandlerRegistrationCustomizer,
|
||||
ObjectProvider<List<ViewResolver>> viewResolvers) {
|
||||
ObjectProvider<ViewResolver> viewResolvers) {
|
||||
this.resourceProperties = resourceProperties;
|
||||
this.webFluxProperties = webFluxProperties;
|
||||
this.beanFactory = beanFactory;
|
||||
this.argumentResolvers = resolvers.getIfAvailable();
|
||||
this.codecCustomizers = codecCustomizers.getIfAvailable();
|
||||
this.argumentResolvers = resolvers.orderedStream();
|
||||
this.codecCustomizers = codecCustomizers.orderedStream();
|
||||
this.resourceHandlerRegistrationCustomizer = resourceHandlerRegistrationCustomizer
|
||||
.getIfAvailable();
|
||||
this.viewResolvers = viewResolvers.getIfAvailable();
|
||||
this.viewResolvers = viewResolvers.orderedStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {
|
||||
if (this.argumentResolvers != null) {
|
||||
this.argumentResolvers.forEach(configurer::addCustomResolver);
|
||||
}
|
||||
this.argumentResolvers.forEach(configurer::addCustomResolver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
|
||||
if (this.codecCustomizers != null) {
|
||||
this.codecCustomizers
|
||||
.forEach((customizer) -> customizer.customize(configurer));
|
||||
}
|
||||
this.codecCustomizers
|
||||
.forEach((customizer) -> customizer.customize(configurer));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -186,10 +181,7 @@ public class WebFluxAutoConfiguration {
|
|||
|
||||
@Override
|
||||
public void configureViewResolvers(ViewResolverRegistry registry) {
|
||||
if (this.viewResolvers != null) {
|
||||
AnnotationAwareOrderComparator.sort(this.viewResolvers);
|
||||
this.viewResolvers.forEach(registry::viewResolver);
|
||||
}
|
||||
this.viewResolvers.forEach(registry::viewResolver);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.web.reactive.error;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
|
|
@ -67,14 +67,14 @@ public class ErrorWebFluxAutoConfiguration {
|
|||
|
||||
public ErrorWebFluxAutoConfiguration(ServerProperties serverProperties,
|
||||
ResourceProperties resourceProperties,
|
||||
ObjectProvider<List<ViewResolver>> viewResolversProvider,
|
||||
ObjectProvider<ViewResolver> viewResolversProvider,
|
||||
ServerCodecConfigurer serverCodecConfigurer,
|
||||
ApplicationContext applicationContext) {
|
||||
this.serverProperties = serverProperties;
|
||||
this.applicationContext = applicationContext;
|
||||
this.resourceProperties = resourceProperties;
|
||||
this.viewResolvers = viewResolversProvider
|
||||
.getIfAvailable(() -> Collections.emptyList());
|
||||
this.viewResolvers = viewResolversProvider.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
this.serverCodecConfigurer = serverCodecConfigurer;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.web.reactive.function.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
|
|
@ -31,9 +30,7 @@ import org.springframework.boot.web.reactive.function.client.WebClientCustomizer
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
/**
|
||||
|
|
@ -56,15 +53,10 @@ public class WebClientAutoConfiguration {
|
|||
private final WebClient.Builder webClientBuilder;
|
||||
|
||||
public WebClientAutoConfiguration(
|
||||
ObjectProvider<List<WebClientCustomizer>> customizerProvider) {
|
||||
ObjectProvider<WebClientCustomizer> customizerProvider) {
|
||||
this.webClientBuilder = WebClient.builder();
|
||||
List<WebClientCustomizer> customizers = customizerProvider.getIfAvailable();
|
||||
if (!CollectionUtils.isEmpty(customizers)) {
|
||||
customizers = new ArrayList<>(customizers);
|
||||
AnnotationAwareOrderComparator.sort(customizers);
|
||||
customizers
|
||||
.forEach((customizer) -> customizer.customize(this.webClientBuilder));
|
||||
}
|
||||
customizerProvider.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(this.webClientBuilder));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
@ -103,10 +104,11 @@ public class ErrorMvcAutoConfiguration {
|
|||
|
||||
public ErrorMvcAutoConfiguration(ServerProperties serverProperties,
|
||||
DispatcherServletPath dispatcherServletPath,
|
||||
ObjectProvider<List<ErrorViewResolver>> errorViewResolversProvider) {
|
||||
ObjectProvider<ErrorViewResolver> errorViewResolvers) {
|
||||
this.serverProperties = serverProperties;
|
||||
this.dispatcherServletPath = dispatcherServletPath;
|
||||
this.errorViewResolvers = errorViewResolversProvider.getIfAvailable();
|
||||
this.errorViewResolvers = errorViewResolvers.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.webservices.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
|
|
@ -27,7 +27,6 @@ import org.springframework.boot.webservices.client.WebServiceTemplateBuilder;
|
|||
import org.springframework.boot.webservices.client.WebServiceTemplateCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.oxm.Marshaller;
|
||||
import org.springframework.oxm.Unmarshaller;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
|
@ -43,10 +42,10 @@ import org.springframework.ws.client.core.WebServiceTemplate;
|
|||
@ConditionalOnClass({ WebServiceTemplate.class, Unmarshaller.class, Marshaller.class })
|
||||
public class WebServiceTemplateAutoConfiguration {
|
||||
|
||||
private final ObjectProvider<List<WebServiceTemplateCustomizer>> webServiceTemplateCustomizers;
|
||||
private final ObjectProvider<WebServiceTemplateCustomizer> webServiceTemplateCustomizers;
|
||||
|
||||
public WebServiceTemplateAutoConfiguration(
|
||||
ObjectProvider<List<WebServiceTemplateCustomizer>> webServiceTemplateCustomizers) {
|
||||
ObjectProvider<WebServiceTemplateCustomizer> webServiceTemplateCustomizers) {
|
||||
this.webServiceTemplateCustomizers = webServiceTemplateCustomizers;
|
||||
}
|
||||
|
||||
|
|
@ -55,10 +54,8 @@ public class WebServiceTemplateAutoConfiguration {
|
|||
public WebServiceTemplateBuilder webServiceTemplateBuilder() {
|
||||
WebServiceTemplateBuilder builder = new WebServiceTemplateBuilder();
|
||||
List<WebServiceTemplateCustomizer> customizers = this.webServiceTemplateCustomizers
|
||||
.getIfAvailable();
|
||||
.orderedStream().collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(customizers)) {
|
||||
customizers = new ArrayList<>(customizers);
|
||||
AnnotationAwareOrderComparator.sort(customizers);
|
||||
builder = builder.customizers(customizers);
|
||||
}
|
||||
return builder;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
package org.springframework.boot.test.autoconfigure.restdocs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.restassured.builder.RequestSpecBuilder;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
|
||||
|
|
@ -60,17 +58,13 @@ public class RestDocsAutoConfiguration {
|
|||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public MockMvcRestDocumentationConfigurer restDocsMockMvcConfigurer(
|
||||
ObjectProvider<List<RestDocsMockMvcConfigurationCustomizer>> configurationCustomizerProvider,
|
||||
ObjectProvider<RestDocsMockMvcConfigurationCustomizer> configurationCustomizers,
|
||||
RestDocumentationContextProvider contextProvider) {
|
||||
MockMvcRestDocumentationConfigurer configurer = MockMvcRestDocumentation
|
||||
.documentationConfiguration(contextProvider);
|
||||
List<RestDocsMockMvcConfigurationCustomizer> configurationCustomizers = configurationCustomizerProvider
|
||||
.getIfAvailable();
|
||||
if (configurationCustomizers != null) {
|
||||
configurationCustomizers
|
||||
.forEach((configurationCustomizer) -> configurationCustomizer
|
||||
.customize(configurer));
|
||||
}
|
||||
configurationCustomizers.orderedStream()
|
||||
.forEach((configurationCustomizer) -> configurationCustomizer
|
||||
.customize(configurer));
|
||||
return configurer;
|
||||
}
|
||||
|
||||
|
|
@ -94,17 +88,13 @@ public class RestDocsAutoConfiguration {
|
|||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public RequestSpecification restDocsRestAssuredConfigurer(
|
||||
ObjectProvider<List<RestDocsRestAssuredConfigurationCustomizer>> configurationCustomizerProvider,
|
||||
ObjectProvider<RestDocsRestAssuredConfigurationCustomizer> configurationCustomizers,
|
||||
RestDocumentationContextProvider contextProvider) {
|
||||
RestAssuredRestDocumentationConfigurer configurer = RestAssuredRestDocumentation
|
||||
.documentationConfiguration(contextProvider);
|
||||
List<RestDocsRestAssuredConfigurationCustomizer> configurationCustomizers = configurationCustomizerProvider
|
||||
.getIfAvailable();
|
||||
if (configurationCustomizers != null) {
|
||||
configurationCustomizers
|
||||
.forEach((configurationCustomizer) -> configurationCustomizer
|
||||
.customize(configurer));
|
||||
}
|
||||
configurationCustomizers.orderedStream()
|
||||
.forEach((configurationCustomizer) -> configurationCustomizer
|
||||
.customize(configurer));
|
||||
return new RequestSpecBuilder().addFilter(configurer).build();
|
||||
}
|
||||
|
||||
|
|
@ -125,17 +115,13 @@ public class RestDocsAutoConfiguration {
|
|||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public WebTestClientRestDocumentationConfigurer restDocsWebTestClientConfigurer(
|
||||
ObjectProvider<List<RestDocsWebTestClientConfigurationCustomizer>> configurationCustomizerProvider,
|
||||
ObjectProvider<RestDocsWebTestClientConfigurationCustomizer> configurationCustomizers,
|
||||
RestDocumentationContextProvider contextProvider) {
|
||||
WebTestClientRestDocumentationConfigurer configurer = WebTestClientRestDocumentation
|
||||
.documentationConfiguration(contextProvider);
|
||||
List<RestDocsWebTestClientConfigurationCustomizer> configurationCustomizers = configurationCustomizerProvider
|
||||
.getIfAvailable();
|
||||
if (configurationCustomizers != null) {
|
||||
configurationCustomizers
|
||||
.forEach((configurationCustomizer) -> configurationCustomizer
|
||||
.customize(configurer));
|
||||
}
|
||||
configurationCustomizers.orderedStream()
|
||||
.forEach((configurationCustomizer) -> configurationCustomizer
|
||||
.customize(configurer));
|
||||
return configurer;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,9 +16,8 @@
|
|||
|
||||
package org.springframework.boot.test.autoconfigure.web.reactive;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
|
|
@ -74,9 +73,9 @@ public class WebTestClientAutoConfiguration {
|
|||
@Bean
|
||||
@ConfigurationProperties(prefix = "spring.test.webtestclient")
|
||||
public SpringBootWebTestClientBuilderCustomizer springBootWebTestClientBuilderCustomizer(
|
||||
ObjectProvider<Collection<CodecCustomizer>> codecCustomizers) {
|
||||
ObjectProvider<CodecCustomizer> codecCustomizers) {
|
||||
return new SpringBootWebTestClientBuilderCustomizer(
|
||||
codecCustomizers.getIfAvailable(Collections::emptyList));
|
||||
codecCustomizers.orderedStream().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue