Inject single-use configuration dependencies into bean methods
Closes gh-15751
This commit is contained in:
parent
34f28b4cbd
commit
de0c065625
|
|
@ -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.
|
||||
|
|
@ -49,17 +49,11 @@ import org.springframework.context.annotation.Configuration;
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -42,17 +42,11 @@ import org.springframework.context.annotation.Configuration;
|
|||
@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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -56,17 +56,11 @@ import org.springframework.data.cassandra.core.CassandraOperations;
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -53,17 +53,11 @@ import org.springframework.data.cassandra.core.ReactiveCassandraOperations;
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -72,12 +72,6 @@ import org.springframework.web.server.WebFilter;
|
|||
@ConditionalOnCloudPlatform(CloudPlatform.CLOUD_FOUNDRY)
|
||||
public class ReactiveCloudFoundryActuatorAutoConfiguration {
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
ReactiveCloudFoundryActuatorAutoConfiguration(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnEnabledEndpoint
|
||||
|
|
@ -92,12 +86,13 @@ public class ReactiveCloudFoundryActuatorAutoConfiguration {
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -76,12 +76,6 @@ import org.springframework.web.servlet.DispatcherServlet;
|
|||
@ConditionalOnCloudPlatform(CloudPlatform.CLOUD_FOUNDRY)
|
||||
public class CloudFoundryActuatorAutoConfiguration {
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
CloudFoundryActuatorAutoConfiguration(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnEnabledEndpoint
|
||||
|
|
@ -96,12 +90,13 @@ public class CloudFoundryActuatorAutoConfiguration {
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -37,18 +37,12 @@ import org.springframework.context.annotation.Configuration;
|
|||
@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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -52,16 +52,10 @@ import org.springframework.context.annotation.Configuration;
|
|||
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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -52,17 +52,11 @@ import org.springframework.context.annotation.Configuration;
|
|||
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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -54,21 +54,17 @@ import org.springframework.context.annotation.Configuration;
|
|||
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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -53,17 +53,10 @@ import org.springframework.context.annotation.Configuration;
|
|||
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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -53,17 +53,11 @@ import org.springframework.context.annotation.Configuration;
|
|||
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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -29,7 +29,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplicat
|
|||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.JerseyApplicationPath;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
|
|
@ -58,19 +57,11 @@ public class ServletEndpointManagementContextConfiguration {
|
|||
@ConditionalOnClass(DispatcherServlet.class)
|
||||
public static class WebMvcServletEndpointManagementContextConfiguration {
|
||||
|
||||
private final ApplicationContext context;
|
||||
|
||||
public WebMvcServletEndpointManagementContextConfiguration(
|
||||
ApplicationContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ServletEndpointRegistrar servletEndpointRegistrar(
|
||||
WebEndpointProperties properties,
|
||||
ServletEndpointsSupplier servletEndpointsSupplier) {
|
||||
DispatcherServletPath dispatcherServletPath = this.context
|
||||
.getBean(DispatcherServletPath.class);
|
||||
ServletEndpointsSupplier servletEndpointsSupplier,
|
||||
DispatcherServletPath dispatcherServletPath) {
|
||||
return new ServletEndpointRegistrar(
|
||||
dispatcherServletPath.getRelativePath(properties.getBasePath()),
|
||||
servletEndpointsSupplier.getEndpoints());
|
||||
|
|
@ -83,19 +74,11 @@ public class ServletEndpointManagementContextConfiguration {
|
|||
@ConditionalOnMissingClass("org.springframework.web.servlet.DispatcherServlet")
|
||||
public static class JerseyServletEndpointManagementContextConfiguration {
|
||||
|
||||
private final ApplicationContext context;
|
||||
|
||||
public JerseyServletEndpointManagementContextConfiguration(
|
||||
ApplicationContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ServletEndpointRegistrar servletEndpointRegistrar(
|
||||
WebEndpointProperties properties,
|
||||
ServletEndpointsSupplier servletEndpointsSupplier) {
|
||||
JerseyApplicationPath jerseyApplicationPath = this.context
|
||||
.getBean(JerseyApplicationPath.class);
|
||||
ServletEndpointsSupplier servletEndpointsSupplier,
|
||||
JerseyApplicationPath jerseyApplicationPath) {
|
||||
return new ServletEndpointRegistrar(
|
||||
jerseyApplicationPath.getRelativePath(properties.getBasePath()),
|
||||
servletEndpointsSupplier.getEndpoints());
|
||||
|
|
|
|||
|
|
@ -39,18 +39,12 @@ import org.springframework.core.env.Environment;
|
|||
@EnableConfigurationProperties(EnvironmentEndpointProperties.class)
|
||||
public class EnvironmentEndpointAutoConfiguration {
|
||||
|
||||
private final EnvironmentEndpointProperties properties;
|
||||
|
||||
public EnvironmentEndpointAutoConfiguration(
|
||||
EnvironmentEndpointProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public EnvironmentEndpoint environmentEndpoint(Environment environment) {
|
||||
public EnvironmentEndpoint environmentEndpoint(Environment environment,
|
||||
EnvironmentEndpointProperties properties) {
|
||||
EnvironmentEndpoint endpoint = new EnvironmentEndpoint(environment);
|
||||
String[] keysToSanitize = this.properties.getKeysToSanitize();
|
||||
String[] keysToSanitize = properties.getKeysToSanitize();
|
||||
if (keysToSanitize != null) {
|
||||
endpoint.setKeysToSanitize(keysToSanitize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import org.springframework.boot.actuate.health.HealthStatusHttpMapper;
|
|||
import org.springframework.boot.actuate.health.HealthWebEndpointResponseMapper;
|
||||
import org.springframework.boot.actuate.health.OrderedHealthAggregator;
|
||||
import org.springframework.boot.actuate.health.ReactiveHealthEndpointWebExtension;
|
||||
import org.springframework.boot.actuate.health.ReactiveHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.ReactiveHealthIndicatorRegistry;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
|
|
@ -72,21 +71,17 @@ class HealthEndpointWebExtensionConfiguration {
|
|||
@ConditionalOnEnabledEndpoint(endpoint = HealthEndpoint.class)
|
||||
static class ReactiveWebHealthConfiguration {
|
||||
|
||||
private final ReactiveHealthIndicator reactiveHealthIndicator;
|
||||
|
||||
ReactiveWebHealthConfiguration(ObjectProvider<HealthAggregator> healthAggregator,
|
||||
ReactiveHealthIndicatorRegistry registry) {
|
||||
this.reactiveHealthIndicator = new CompositeReactiveHealthIndicator(
|
||||
healthAggregator.getIfAvailable(OrderedHealthAggregator::new),
|
||||
registry);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnBean(HealthEndpoint.class)
|
||||
public ReactiveHealthEndpointWebExtension reactiveHealthEndpointWebExtension(
|
||||
ObjectProvider<HealthAggregator> healthAggregator,
|
||||
ReactiveHealthIndicatorRegistry registry,
|
||||
HealthWebEndpointResponseMapper responseMapper) {
|
||||
return new ReactiveHealthEndpointWebExtension(this.reactiveHealthIndicator,
|
||||
return new ReactiveHealthEndpointWebExtension(
|
||||
new CompositeReactiveHealthIndicator(
|
||||
healthAggregator.getIfAvailable(OrderedHealthAggregator::new),
|
||||
registry),
|
||||
responseMapper);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,12 +49,6 @@ import org.springframework.context.annotation.Configuration;
|
|||
@EnableConfigurationProperties({ HealthIndicatorProperties.class })
|
||||
public class HealthIndicatorAutoConfiguration {
|
||||
|
||||
private final HealthIndicatorProperties properties;
|
||||
|
||||
public HealthIndicatorAutoConfiguration(HealthIndicatorProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean({ HealthIndicator.class, ReactiveHealthIndicator.class })
|
||||
public ApplicationHealthIndicator applicationHealthIndicator() {
|
||||
|
|
@ -63,10 +57,11 @@ public class HealthIndicatorAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(HealthAggregator.class)
|
||||
public OrderedHealthAggregator healthAggregator() {
|
||||
public OrderedHealthAggregator healthAggregator(
|
||||
HealthIndicatorProperties properties) {
|
||||
OrderedHealthAggregator healthAggregator = new OrderedHealthAggregator();
|
||||
if (this.properties.getOrder() != null) {
|
||||
healthAggregator.setStatusOrder(this.properties.getOrder());
|
||||
if (properties.getOrder() != null) {
|
||||
healthAggregator.setStatusOrder(properties.getOrder());
|
||||
}
|
||||
return healthAggregator;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -50,16 +50,10 @@ import org.springframework.context.annotation.Configuration;
|
|||
public class InfluxDbHealthIndicatorAutoConfiguration
|
||||
extends CompositeHealthIndicatorConfiguration<InfluxDbHealthIndicator, InfluxDB> {
|
||||
|
||||
private final Map<String, InfluxDB> influxDbs;
|
||||
|
||||
public InfluxDbHealthIndicatorAutoConfiguration(Map<String, InfluxDB> influxDbs) {
|
||||
this.influxDbs = influxDbs;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "influxDbHealthIndicator")
|
||||
public HealthIndicator influxDbHealthIndicator() {
|
||||
return createHealthIndicator(this.influxDbs);
|
||||
public HealthIndicator influxDbHealthIndicator(Map<String, InfluxDB> influxDbs) {
|
||||
return createHealthIndicator(influxDbs);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,19 +66,28 @@ public class DataSourceHealthIndicatorAutoConfiguration extends
|
|||
CompositeHealthIndicatorConfiguration<DataSourceHealthIndicator, DataSource>
|
||||
implements InitializingBean {
|
||||
|
||||
private final Map<String, DataSource> dataSources;
|
||||
|
||||
private final Collection<DataSourcePoolMetadataProvider> metadataProviders;
|
||||
|
||||
private DataSourcePoolMetadataProvider poolMetadataProvider;
|
||||
|
||||
public DataSourceHealthIndicatorAutoConfiguration(Map<String, DataSource> dataSources,
|
||||
ObjectProvider<DataSourcePoolMetadataProvider> metadataProviders) {
|
||||
this.dataSources = filterDataSources(dataSources);
|
||||
this.metadataProviders = metadataProviders.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
this.poolMetadataProvider = new CompositeDataSourcePoolMetadataProvider(
|
||||
this.metadataProviders);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "dbHealthIndicator")
|
||||
public HealthIndicator dbHealthIndicator(Map<String, DataSource> dataSources) {
|
||||
return createHealthIndicator(filterDataSources(dataSources));
|
||||
}
|
||||
|
||||
private Map<String, DataSource> filterDataSources(
|
||||
Map<String, DataSource> candidates) {
|
||||
if (candidates == null) {
|
||||
|
|
@ -93,18 +102,6 @@ public class DataSourceHealthIndicatorAutoConfiguration extends
|
|||
return dataSources;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
this.poolMetadataProvider = new CompositeDataSourcePoolMetadataProvider(
|
||||
this.metadataProviders);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "dbHealthIndicator")
|
||||
public HealthIndicator dbHealthIndicator() {
|
||||
return createHealthIndicator(this.dataSources);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DataSourceHealthIndicator createHealthIndicator(DataSource source) {
|
||||
return new DataSourceHealthIndicator(source, getValidationQuery(source));
|
||||
|
|
|
|||
|
|
@ -51,17 +51,11 @@ import org.springframework.context.annotation.Configuration;
|
|||
public class JmsHealthIndicatorAutoConfiguration extends
|
||||
CompositeHealthIndicatorConfiguration<JmsHealthIndicator, ConnectionFactory> {
|
||||
|
||||
private final Map<String, ConnectionFactory> connectionFactories;
|
||||
|
||||
public JmsHealthIndicatorAutoConfiguration(
|
||||
Map<String, ConnectionFactory> connectionFactories) {
|
||||
this.connectionFactories = connectionFactories;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "jmsHealthIndicator")
|
||||
public HealthIndicator jmsHealthIndicator() {
|
||||
return createHealthIndicator(this.connectionFactories);
|
||||
public HealthIndicator jmsHealthIndicator(
|
||||
Map<String, ConnectionFactory> connectionFactories) {
|
||||
return createHealthIndicator(connectionFactories);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -50,17 +50,11 @@ import org.springframework.ldap.core.LdapOperations;
|
|||
public class LdapHealthIndicatorAutoConfiguration extends
|
||||
CompositeHealthIndicatorConfiguration<LdapHealthIndicator, LdapOperations> {
|
||||
|
||||
private final Map<String, LdapOperations> ldapOperations;
|
||||
|
||||
public LdapHealthIndicatorAutoConfiguration(
|
||||
Map<String, LdapOperations> ldapOperations) {
|
||||
this.ldapOperations = ldapOperations;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "ldapHealthIndicator")
|
||||
public HealthIndicator ldapHealthIndicator() {
|
||||
return createHealthIndicator(this.ldapOperations);
|
||||
public HealthIndicator ldapHealthIndicator(
|
||||
Map<String, LdapOperations> ldapOperations) {
|
||||
return createHealthIndicator(ldapOperations);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -43,17 +43,12 @@ import org.springframework.util.StringUtils;
|
|||
@EnableConfigurationProperties(LogFileWebEndpointProperties.class)
|
||||
public class LogFileWebEndpointAutoConfiguration {
|
||||
|
||||
private final LogFileWebEndpointProperties properties;
|
||||
|
||||
public LogFileWebEndpointAutoConfiguration(LogFileWebEndpointProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@Conditional(LogFileCondition.class)
|
||||
public LogFileWebEndpoint logFileWebEndpoint(Environment environment) {
|
||||
return new LogFileWebEndpoint(environment, this.properties.getExternalFile());
|
||||
public LogFileWebEndpoint logFileWebEndpoint(Environment environment,
|
||||
LogFileWebEndpointProperties properties) {
|
||||
return new LogFileWebEndpoint(environment, properties.getExternalFile());
|
||||
}
|
||||
|
||||
private static class LogFileCondition extends SpringBootCondition {
|
||||
|
|
|
|||
|
|
@ -49,17 +49,11 @@ import org.springframework.mail.javamail.JavaMailSenderImpl;
|
|||
public class MailHealthIndicatorAutoConfiguration extends
|
||||
CompositeHealthIndicatorConfiguration<MailHealthIndicator, JavaMailSenderImpl> {
|
||||
|
||||
private final Map<String, JavaMailSenderImpl> mailSenders;
|
||||
|
||||
public MailHealthIndicatorAutoConfiguration(
|
||||
Map<String, JavaMailSenderImpl> mailSenders) {
|
||||
this.mailSenders = mailSenders;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "mailHealthIndicator")
|
||||
public HealthIndicator mailHealthIndicator() {
|
||||
return createHealthIndicator(this.mailSenders);
|
||||
public HealthIndicator mailHealthIndicator(
|
||||
Map<String, JavaMailSenderImpl> mailSenders) {
|
||||
return createHealthIndicator(mailSenders);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -18,7 +18,9 @@ package org.springframework.boot.actuate.autoconfigure.metrics.jdbc;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
|
|
@ -28,6 +30,7 @@ import io.micrometer.core.instrument.MeterRegistry;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration;
|
||||
|
|
@ -62,25 +65,22 @@ public class DataSourcePoolMetricsAutoConfiguration {
|
|||
|
||||
private static final String DATASOURCE_SUFFIX = "dataSource";
|
||||
|
||||
private final MeterRegistry registry;
|
||||
|
||||
private final Collection<DataSourcePoolMetadataProvider> metadataProviders;
|
||||
|
||||
DataSourcePoolMetadataMetricsConfiguration(MeterRegistry registry,
|
||||
Collection<DataSourcePoolMetadataProvider> metadataProviders) {
|
||||
this.registry = registry;
|
||||
this.metadataProviders = metadataProviders;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void bindDataSourcesToRegistry(Map<String, DataSource> dataSources) {
|
||||
dataSources.forEach(this::bindDataSourceToRegistry);
|
||||
public void bindDataSourcesToRegistry(Map<String, DataSource> dataSources,
|
||||
MeterRegistry registry,
|
||||
ObjectProvider<DataSourcePoolMetadataProvider> metadataProviders) {
|
||||
List<DataSourcePoolMetadataProvider> metadataProvidersList = metadataProviders
|
||||
.stream().collect(Collectors.toList());
|
||||
dataSources.forEach((name, dataSource) -> bindDataSourceToRegistry(name,
|
||||
dataSource, metadataProvidersList, registry));
|
||||
}
|
||||
|
||||
private void bindDataSourceToRegistry(String beanName, DataSource dataSource) {
|
||||
private void bindDataSourceToRegistry(String beanName, DataSource dataSource,
|
||||
Collection<DataSourcePoolMetadataProvider> metadataProviders,
|
||||
MeterRegistry registry) {
|
||||
String dataSourceName = getDataSourceName(beanName);
|
||||
new DataSourcePoolMetrics(dataSource, this.metadataProviders, dataSourceName,
|
||||
Collections.emptyList()).bindTo(this.registry);
|
||||
new DataSourcePoolMetrics(dataSource, metadataProviders, dataSourceName,
|
||||
Collections.emptyList()).bindTo(registry);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -54,23 +54,19 @@ public class HibernateMetricsAutoConfiguration {
|
|||
|
||||
private static final String ENTITY_MANAGER_FACTORY_SUFFIX = "entityManagerFactory";
|
||||
|
||||
private final MeterRegistry registry;
|
||||
|
||||
public HibernateMetricsAutoConfiguration(MeterRegistry registry) {
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void bindEntityManagerFactoriesToRegistry(
|
||||
Map<String, EntityManagerFactory> entityManagerFactories) {
|
||||
entityManagerFactories.forEach(this::bindEntityManagerFactoryToRegistry);
|
||||
Map<String, EntityManagerFactory> entityManagerFactories,
|
||||
MeterRegistry registry) {
|
||||
entityManagerFactories.forEach((name,
|
||||
factory) -> bindEntityManagerFactoryToRegistry(name, factory, registry));
|
||||
}
|
||||
|
||||
private void bindEntityManagerFactoryToRegistry(String beanName,
|
||||
EntityManagerFactory entityManagerFactory) {
|
||||
EntityManagerFactory entityManagerFactory, MeterRegistry registry) {
|
||||
String entityManagerFactoryName = getEntityManagerFactoryName(beanName);
|
||||
new HibernateMetrics(entityManagerFactory, entityManagerFactoryName,
|
||||
Collections.emptyList()).bindTo(this.registry);
|
||||
Collections.emptyList()).bindTo(registry);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -50,21 +50,15 @@ import org.springframework.core.annotation.Order;
|
|||
@Import({ RestTemplateMetricsConfiguration.class, WebClientMetricsConfiguration.class })
|
||||
public class HttpClientMetricsAutoConfiguration {
|
||||
|
||||
private final MetricsProperties properties;
|
||||
|
||||
public HttpClientMetricsAutoConfiguration(MetricsProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Order(0)
|
||||
public MeterFilter metricsHttpClientUriTagFilter() {
|
||||
String metricName = this.properties.getWeb().getClient().getRequestsMetricName();
|
||||
public MeterFilter metricsHttpClientUriTagFilter(MetricsProperties properties) {
|
||||
String metricName = properties.getWeb().getClient().getRequestsMetricName();
|
||||
MeterFilter denyFilter = new OnlyOnceLoggingDenyMeterFilter(() -> String
|
||||
.format("Reached the maximum number of URI tags for '%s'. Are you using "
|
||||
+ "'uriVariables'?", metricName));
|
||||
return MeterFilter.maximumAllowableTags(metricName, "uri",
|
||||
this.properties.getWeb().getClient().getMaxUriTags(), denyFilter);
|
||||
properties.getWeb().getClient().getMaxUriTags(), denyFilter);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,12 +42,6 @@ import org.springframework.web.client.RestTemplate;
|
|||
@ConditionalOnBean(RestTemplateBuilder.class)
|
||||
class RestTemplateMetricsConfiguration {
|
||||
|
||||
private final MetricsProperties properties;
|
||||
|
||||
RestTemplateMetricsConfiguration(MetricsProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(RestTemplateExchangeTagsProvider.class)
|
||||
public DefaultRestTemplateExchangeTagsProvider restTemplateExchangeTagsProvider() {
|
||||
|
|
@ -57,10 +51,11 @@ class RestTemplateMetricsConfiguration {
|
|||
@Bean
|
||||
public MetricsRestTemplateCustomizer metricsRestTemplateCustomizer(
|
||||
MeterRegistry meterRegistry,
|
||||
RestTemplateExchangeTagsProvider restTemplateExchangeTagsProvider) {
|
||||
RestTemplateExchangeTagsProvider restTemplateExchangeTagsProvider,
|
||||
MetricsProperties properties) {
|
||||
return new MetricsRestTemplateCustomizer(meterRegistry,
|
||||
restTemplateExchangeTagsProvider,
|
||||
this.properties.getWeb().getClient().getRequestsMetricName());
|
||||
properties.getWeb().getClient().getRequestsMetricName());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -51,16 +51,11 @@ import org.springframework.data.mongodb.core.MongoTemplate;
|
|||
public class MongoHealthIndicatorAutoConfiguration extends
|
||||
CompositeHealthIndicatorConfiguration<MongoHealthIndicator, MongoTemplate> {
|
||||
|
||||
private final Map<String, MongoTemplate> mongoTemplates;
|
||||
|
||||
MongoHealthIndicatorAutoConfiguration(Map<String, MongoTemplate> mongoTemplates) {
|
||||
this.mongoTemplates = mongoTemplates;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "mongoHealthIndicator")
|
||||
public HealthIndicator mongoHealthIndicator() {
|
||||
return createHealthIndicator(this.mongoTemplates);
|
||||
public HealthIndicator mongoHealthIndicator(
|
||||
Map<String, MongoTemplate> mongoTemplates) {
|
||||
return createHealthIndicator(mongoTemplates);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -52,17 +52,11 @@ import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
|
|||
public class MongoReactiveHealthIndicatorAutoConfiguration extends
|
||||
CompositeReactiveHealthIndicatorConfiguration<MongoReactiveHealthIndicator, ReactiveMongoTemplate> {
|
||||
|
||||
private final Map<String, ReactiveMongoTemplate> reactiveMongoTemplate;
|
||||
|
||||
MongoReactiveHealthIndicatorAutoConfiguration(
|
||||
Map<String, ReactiveMongoTemplate> reactiveMongoTemplate) {
|
||||
this.reactiveMongoTemplate = reactiveMongoTemplate;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "mongoHealthIndicator")
|
||||
public ReactiveHealthIndicator mongoHealthIndicator() {
|
||||
return createHealthIndicator(this.reactiveMongoTemplate);
|
||||
public ReactiveHealthIndicator mongoHealthIndicator(
|
||||
Map<String, ReactiveMongoTemplate> reactiveMongoTemplates) {
|
||||
return createHealthIndicator(reactiveMongoTemplates);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -51,17 +51,11 @@ import org.springframework.context.annotation.Configuration;
|
|||
public class Neo4jHealthIndicatorAutoConfiguration extends
|
||||
CompositeHealthIndicatorConfiguration<Neo4jHealthIndicator, SessionFactory> {
|
||||
|
||||
private final Map<String, SessionFactory> sessionFactories;
|
||||
|
||||
public Neo4jHealthIndicatorAutoConfiguration(
|
||||
Map<String, SessionFactory> sessionFactories) {
|
||||
this.sessionFactories = sessionFactories;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "neo4jHealthIndicator")
|
||||
public HealthIndicator neo4jHealthIndicator() {
|
||||
return createHealthIndicator(this.sessionFactories);
|
||||
public HealthIndicator neo4jHealthIndicator(
|
||||
Map<String, SessionFactory> sessionFactories) {
|
||||
return createHealthIndicator(sessionFactories);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -53,17 +53,11 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|||
public class RedisHealthIndicatorAutoConfiguration extends
|
||||
CompositeHealthIndicatorConfiguration<RedisHealthIndicator, RedisConnectionFactory> {
|
||||
|
||||
private final Map<String, RedisConnectionFactory> redisConnectionFactories;
|
||||
|
||||
public RedisHealthIndicatorAutoConfiguration(
|
||||
Map<String, RedisConnectionFactory> redisConnectionFactories) {
|
||||
this.redisConnectionFactories = redisConnectionFactories;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "redisHealthIndicator")
|
||||
public HealthIndicator redisHealthIndicator() {
|
||||
return createHealthIndicator(this.redisConnectionFactories);
|
||||
public HealthIndicator redisHealthIndicator(
|
||||
Map<String, RedisConnectionFactory> redisConnectionFactories) {
|
||||
return createHealthIndicator(redisConnectionFactories);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -51,16 +51,10 @@ import org.springframework.context.annotation.Configuration;
|
|||
public class SolrHealthIndicatorAutoConfiguration
|
||||
extends CompositeHealthIndicatorConfiguration<SolrHealthIndicator, SolrClient> {
|
||||
|
||||
private final Map<String, SolrClient> solrClients;
|
||||
|
||||
public SolrHealthIndicatorAutoConfiguration(Map<String, SolrClient> solrClients) {
|
||||
this.solrClients = solrClients;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "solrHealthIndicator")
|
||||
public HealthIndicator solrHealthIndicator() {
|
||||
return createHealthIndicator(this.solrClients);
|
||||
public HealthIndicator solrHealthIndicator(Map<String, SolrClient> solrClients) {
|
||||
return createHealthIndicator(solrClients);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -55,24 +55,14 @@ public class SpringApplicationAdminJmxAutoConfiguration {
|
|||
*/
|
||||
private static final String DEFAULT_JMX_NAME = "org.springframework.boot:type=Admin,name=SpringApplication";
|
||||
|
||||
private final Iterable<MBeanExporter> mbeanExporters;
|
||||
|
||||
private final Environment environment;
|
||||
|
||||
public SpringApplicationAdminJmxAutoConfiguration(
|
||||
ObjectProvider<MBeanExporter> mbeanExporters, Environment environment) {
|
||||
this.mbeanExporters = mbeanExporters;
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SpringApplicationAdminMXBeanRegistrar springApplicationAdminRegistrar()
|
||||
public SpringApplicationAdminMXBeanRegistrar springApplicationAdminRegistrar(
|
||||
ObjectProvider<MBeanExporter> mbeanExporters, Environment environment)
|
||||
throws MalformedObjectNameException {
|
||||
String jmxName = this.environment.getProperty(JMX_NAME_PROPERTY,
|
||||
DEFAULT_JMX_NAME);
|
||||
if (this.mbeanExporters != null) { // Make sure to not register that MBean twice
|
||||
for (MBeanExporter mbeanExporter : this.mbeanExporters) {
|
||||
String jmxName = environment.getProperty(JMX_NAME_PROPERTY, DEFAULT_JMX_NAME);
|
||||
if (mbeanExporters != null) { // Make sure to not register that MBean twice
|
||||
for (MBeanExporter mbeanExporter : mbeanExporters) {
|
||||
mbeanExporter.addExcludedBean(jmxName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -157,53 +157,39 @@ public class RabbitAutoConfiguration {
|
|||
@Import(RabbitConnectionFactoryCreator.class)
|
||||
protected static class RabbitTemplateConfiguration {
|
||||
|
||||
private final RabbitProperties properties;
|
||||
|
||||
private final ObjectProvider<MessageConverter> messageConverter;
|
||||
|
||||
private final ObjectProvider<RabbitRetryTemplateCustomizer> retryTemplateCustomizers;
|
||||
|
||||
public RabbitTemplateConfiguration(RabbitProperties properties,
|
||||
ObjectProvider<MessageConverter> messageConverter,
|
||||
ObjectProvider<RabbitRetryTemplateCustomizer> retryTemplateCustomizers) {
|
||||
this.properties = properties;
|
||||
this.messageConverter = messageConverter;
|
||||
this.retryTemplateCustomizers = retryTemplateCustomizers;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnSingleCandidate(ConnectionFactory.class)
|
||||
@ConditionalOnMissingBean
|
||||
public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) {
|
||||
public RabbitTemplate rabbitTemplate(RabbitProperties properties,
|
||||
ObjectProvider<MessageConverter> messageConverter,
|
||||
ObjectProvider<RabbitRetryTemplateCustomizer> retryTemplateCustomizers,
|
||||
ConnectionFactory connectionFactory) {
|
||||
PropertyMapper map = PropertyMapper.get();
|
||||
RabbitTemplate template = new RabbitTemplate(connectionFactory);
|
||||
MessageConverter messageConverter = this.messageConverter.getIfUnique();
|
||||
if (messageConverter != null) {
|
||||
template.setMessageConverter(messageConverter);
|
||||
}
|
||||
template.setMandatory(determineMandatoryFlag());
|
||||
RabbitProperties.Template properties = this.properties.getTemplate();
|
||||
if (properties.getRetry().isEnabled()) {
|
||||
template.setRetryTemplate(new RetryTemplateFactory(
|
||||
this.retryTemplateCustomizers.orderedStream()
|
||||
messageConverter.ifUnique(template::setMessageConverter);
|
||||
template.setMandatory(determineMandatoryFlag(properties));
|
||||
RabbitProperties.Template templateProperties = properties.getTemplate();
|
||||
if (templateProperties.getRetry().isEnabled()) {
|
||||
template.setRetryTemplate(
|
||||
new RetryTemplateFactory(retryTemplateCustomizers.orderedStream()
|
||||
.collect(Collectors.toList())).createRetryTemplate(
|
||||
properties.getRetry(),
|
||||
templateProperties.getRetry(),
|
||||
RabbitRetryTemplateCustomizer.Target.SENDER));
|
||||
}
|
||||
map.from(properties::getReceiveTimeout).whenNonNull().as(Duration::toMillis)
|
||||
.to(template::setReceiveTimeout);
|
||||
map.from(properties::getReplyTimeout).whenNonNull().as(Duration::toMillis)
|
||||
.to(template::setReplyTimeout);
|
||||
map.from(properties::getExchange).to(template::setExchange);
|
||||
map.from(properties::getRoutingKey).to(template::setRoutingKey);
|
||||
map.from(properties::getDefaultReceiveQueue).whenNonNull()
|
||||
map.from(templateProperties::getReceiveTimeout).whenNonNull()
|
||||
.as(Duration::toMillis).to(template::setReceiveTimeout);
|
||||
map.from(templateProperties::getReplyTimeout).whenNonNull()
|
||||
.as(Duration::toMillis).to(template::setReplyTimeout);
|
||||
map.from(templateProperties::getExchange).to(template::setExchange);
|
||||
map.from(templateProperties::getRoutingKey).to(template::setRoutingKey);
|
||||
map.from(templateProperties::getDefaultReceiveQueue).whenNonNull()
|
||||
.to(template::setDefaultReceiveQueue);
|
||||
return template;
|
||||
}
|
||||
|
||||
private boolean determineMandatoryFlag() {
|
||||
Boolean mandatory = this.properties.getTemplate().getMandatory();
|
||||
return (mandatory != null) ? mandatory : this.properties.isPublisherReturns();
|
||||
private boolean determineMandatoryFlag(RabbitProperties properties) {
|
||||
Boolean mandatory = properties.getTemplate().getMandatory();
|
||||
return (mandatory != null) ? mandatory : properties.isPublisherReturns();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -68,12 +68,8 @@ public class BatchAutoConfiguration {
|
|||
|
||||
private final BatchProperties properties;
|
||||
|
||||
private final JobParametersConverter jobParametersConverter;
|
||||
|
||||
public BatchAutoConfiguration(BatchProperties properties,
|
||||
ObjectProvider<JobParametersConverter> jobParametersConverter) {
|
||||
public BatchAutoConfiguration(BatchProperties properties) {
|
||||
this.properties = properties;
|
||||
this.jobParametersConverter = jobParametersConverter.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
@ -108,7 +104,9 @@ public class BatchAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(JobOperator.class)
|
||||
public SimpleJobOperator jobOperator(JobExplorer jobExplorer, JobLauncher jobLauncher,
|
||||
public SimpleJobOperator jobOperator(
|
||||
ObjectProvider<JobParametersConverter> jobParametersConverter,
|
||||
JobExplorer jobExplorer, JobLauncher jobLauncher,
|
||||
ListableJobLocator jobRegistry, JobRepository jobRepository)
|
||||
throws Exception {
|
||||
SimpleJobOperator factory = new SimpleJobOperator();
|
||||
|
|
@ -116,9 +114,7 @@ public class BatchAutoConfiguration {
|
|||
factory.setJobLauncher(jobLauncher);
|
||||
factory.setJobRegistry(jobRegistry);
|
||||
factory.setJobRepository(jobRepository);
|
||||
if (this.jobParametersConverter != null) {
|
||||
factory.setJobParametersConverter(this.jobParametersConverter);
|
||||
}
|
||||
jobParametersConverter.ifAvailable(factory::setJobParametersConverter);
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -45,57 +45,44 @@ import org.springframework.util.StringUtils;
|
|||
@Conditional({ CacheCondition.class })
|
||||
class CaffeineCacheConfiguration {
|
||||
|
||||
private final CacheProperties cacheProperties;
|
||||
|
||||
private final CacheManagerCustomizers customizers;
|
||||
|
||||
private final Caffeine<Object, Object> caffeine;
|
||||
|
||||
private final CaffeineSpec caffeineSpec;
|
||||
|
||||
private final CacheLoader<Object, Object> cacheLoader;
|
||||
|
||||
CaffeineCacheConfiguration(CacheProperties cacheProperties,
|
||||
@Bean
|
||||
public CaffeineCacheManager cacheManager(CacheProperties cacheProperties,
|
||||
CacheManagerCustomizers customizers,
|
||||
ObjectProvider<Caffeine<Object, Object>> caffeine,
|
||||
ObjectProvider<CaffeineSpec> caffeineSpec,
|
||||
ObjectProvider<CacheLoader<Object, Object>> cacheLoader) {
|
||||
this.cacheProperties = cacheProperties;
|
||||
this.customizers = customizers;
|
||||
this.caffeine = caffeine.getIfAvailable();
|
||||
this.caffeineSpec = caffeineSpec.getIfAvailable();
|
||||
this.cacheLoader = cacheLoader.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CaffeineCacheManager cacheManager() {
|
||||
CaffeineCacheManager cacheManager = createCacheManager();
|
||||
List<String> cacheNames = this.cacheProperties.getCacheNames();
|
||||
CaffeineCacheManager cacheManager = createCacheManager(cacheProperties, caffeine,
|
||||
caffeineSpec, cacheLoader);
|
||||
List<String> cacheNames = cacheProperties.getCacheNames();
|
||||
if (!CollectionUtils.isEmpty(cacheNames)) {
|
||||
cacheManager.setCacheNames(cacheNames);
|
||||
}
|
||||
return this.customizers.customize(cacheManager);
|
||||
return customizers.customize(cacheManager);
|
||||
}
|
||||
|
||||
private CaffeineCacheManager createCacheManager() {
|
||||
private CaffeineCacheManager createCacheManager(CacheProperties cacheProperties,
|
||||
ObjectProvider<Caffeine<Object, Object>> caffeine,
|
||||
ObjectProvider<CaffeineSpec> caffeineSpec,
|
||||
ObjectProvider<CacheLoader<Object, Object>> cacheLoader) {
|
||||
CaffeineCacheManager cacheManager = new CaffeineCacheManager();
|
||||
setCacheBuilder(cacheManager);
|
||||
if (this.cacheLoader != null) {
|
||||
cacheManager.setCacheLoader(this.cacheLoader);
|
||||
}
|
||||
setCacheBuilder(cacheProperties, caffeineSpec.getIfAvailable(),
|
||||
caffeine.getIfAvailable(), cacheManager);
|
||||
cacheLoader.ifAvailable(cacheManager::setCacheLoader);
|
||||
return cacheManager;
|
||||
}
|
||||
|
||||
private void setCacheBuilder(CaffeineCacheManager cacheManager) {
|
||||
String specification = this.cacheProperties.getCaffeine().getSpec();
|
||||
private void setCacheBuilder(CacheProperties cacheProperties,
|
||||
CaffeineSpec caffeineSpec, Caffeine<Object, Object> caffeine,
|
||||
CaffeineCacheManager cacheManager) {
|
||||
String specification = cacheProperties.getCaffeine().getSpec();
|
||||
if (StringUtils.hasText(specification)) {
|
||||
cacheManager.setCacheSpecification(specification);
|
||||
}
|
||||
else if (this.caffeineSpec != null) {
|
||||
cacheManager.setCaffeineSpec(this.caffeineSpec);
|
||||
else if (caffeineSpec != null) {
|
||||
cacheManager.setCaffeineSpec(caffeineSpec);
|
||||
}
|
||||
else if (this.caffeine != null) {
|
||||
cacheManager.setCaffeine(this.caffeine);
|
||||
else if (caffeine != null) {
|
||||
cacheManager.setCaffeine(caffeine);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -47,29 +47,17 @@ import org.springframework.util.StringUtils;
|
|||
@Conditional(CacheCondition.class)
|
||||
public class CouchbaseCacheConfiguration {
|
||||
|
||||
private final CacheProperties cacheProperties;
|
||||
|
||||
private final CacheManagerCustomizers customizers;
|
||||
|
||||
private final Bucket bucket;
|
||||
|
||||
public CouchbaseCacheConfiguration(CacheProperties cacheProperties,
|
||||
CacheManagerCustomizers customizers, Bucket bucket) {
|
||||
this.cacheProperties = cacheProperties;
|
||||
this.customizers = customizers;
|
||||
this.bucket = bucket;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CouchbaseCacheManager cacheManager() {
|
||||
List<String> cacheNames = this.cacheProperties.getCacheNames();
|
||||
CacheBuilder builder = CacheBuilder.newInstance(this.bucket);
|
||||
Couchbase couchbase = this.cacheProperties.getCouchbase();
|
||||
public CouchbaseCacheManager cacheManager(CacheProperties cacheProperties,
|
||||
CacheManagerCustomizers customizers, Bucket bucket) {
|
||||
List<String> cacheNames = cacheProperties.getCacheNames();
|
||||
CacheBuilder builder = CacheBuilder.newInstance(bucket);
|
||||
Couchbase couchbase = cacheProperties.getCouchbase();
|
||||
PropertyMapper.get().from(couchbase::getExpiration).whenNonNull()
|
||||
.asInt(Duration::getSeconds).to(builder::withExpiration);
|
||||
String[] names = StringUtils.toStringArray(cacheNames);
|
||||
CouchbaseCacheManager cacheManager = new CouchbaseCacheManager(builder, names);
|
||||
return this.customizers.customize(cacheManager);
|
||||
return customizers.customize(cacheManager);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -45,26 +45,17 @@ import org.springframework.core.io.Resource;
|
|||
EhCacheCacheConfiguration.ConfigAvailableCondition.class })
|
||||
class EhCacheCacheConfiguration {
|
||||
|
||||
private final CacheProperties cacheProperties;
|
||||
|
||||
private final CacheManagerCustomizers customizers;
|
||||
|
||||
EhCacheCacheConfiguration(CacheProperties cacheProperties,
|
||||
CacheManagerCustomizers customizers) {
|
||||
this.cacheProperties = cacheProperties;
|
||||
this.customizers = customizers;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public EhCacheCacheManager cacheManager(CacheManager ehCacheCacheManager) {
|
||||
return this.customizers.customize(new EhCacheCacheManager(ehCacheCacheManager));
|
||||
public EhCacheCacheManager cacheManager(CacheManagerCustomizers customizers,
|
||||
CacheManager ehCacheCacheManager) {
|
||||
return customizers.customize(new EhCacheCacheManager(ehCacheCacheManager));
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public CacheManager ehCacheCacheManager() {
|
||||
Resource location = this.cacheProperties
|
||||
.resolveConfigLocation(this.cacheProperties.getEhcache().getConfig());
|
||||
public CacheManager ehCacheCacheManager(CacheProperties cacheProperties) {
|
||||
Resource location = cacheProperties
|
||||
.resolveConfigLocation(cacheProperties.getEhcache().getConfig());
|
||||
if (location != null) {
|
||||
return EhCacheManagerUtils.buildCacheManager(location);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -40,17 +40,12 @@ import org.springframework.context.annotation.Configuration;
|
|||
@Conditional(CacheCondition.class)
|
||||
class GenericCacheConfiguration {
|
||||
|
||||
private final CacheManagerCustomizers customizers;
|
||||
|
||||
GenericCacheConfiguration(CacheManagerCustomizers customizers) {
|
||||
this.customizers = customizers;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SimpleCacheManager cacheManager(Collection<Cache> caches) {
|
||||
public SimpleCacheManager cacheManager(CacheManagerCustomizers customizers,
|
||||
Collection<Cache> caches) {
|
||||
SimpleCacheManager cacheManager = new SimpleCacheManager();
|
||||
cacheManager.setCaches(caches);
|
||||
return this.customizers.customize(cacheManager);
|
||||
return customizers.customize(cacheManager);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -50,18 +50,12 @@ import org.springframework.context.annotation.Configuration;
|
|||
@ConditionalOnSingleCandidate(HazelcastInstance.class)
|
||||
class HazelcastCacheConfiguration {
|
||||
|
||||
private final CacheManagerCustomizers customizers;
|
||||
|
||||
HazelcastCacheConfiguration(CacheManagerCustomizers customizers) {
|
||||
this.customizers = customizers;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HazelcastCacheManager cacheManager(HazelcastInstance existingHazelcastInstance)
|
||||
throws IOException {
|
||||
public HazelcastCacheManager cacheManager(CacheManagerCustomizers customizers,
|
||||
HazelcastInstance existingHazelcastInstance) throws IOException {
|
||||
HazelcastCacheManager cacheManager = new HazelcastCacheManager(
|
||||
existingHazelcastInstance);
|
||||
return this.customizers.customize(cacheManager);
|
||||
return customizers.customize(cacheManager);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -49,43 +49,33 @@ import org.springframework.util.CollectionUtils;
|
|||
@Conditional(CacheCondition.class)
|
||||
public class InfinispanCacheConfiguration {
|
||||
|
||||
private final CacheProperties cacheProperties;
|
||||
|
||||
private final CacheManagerCustomizers customizers;
|
||||
|
||||
private final ConfigurationBuilder defaultConfigurationBuilder;
|
||||
|
||||
public InfinispanCacheConfiguration(CacheProperties cacheProperties,
|
||||
CacheManagerCustomizers customizers,
|
||||
ObjectProvider<ConfigurationBuilder> defaultConfigurationBuilder) {
|
||||
this.cacheProperties = cacheProperties;
|
||||
this.customizers = customizers;
|
||||
this.defaultConfigurationBuilder = defaultConfigurationBuilder.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SpringEmbeddedCacheManager cacheManager(
|
||||
public SpringEmbeddedCacheManager cacheManager(CacheManagerCustomizers customizers,
|
||||
EmbeddedCacheManager embeddedCacheManager) {
|
||||
SpringEmbeddedCacheManager cacheManager = new SpringEmbeddedCacheManager(
|
||||
embeddedCacheManager);
|
||||
return this.customizers.customize(cacheManager);
|
||||
return customizers.customize(cacheManager);
|
||||
}
|
||||
|
||||
@Bean(destroyMethod = "stop")
|
||||
@ConditionalOnMissingBean
|
||||
public EmbeddedCacheManager infinispanCacheManager() throws IOException {
|
||||
EmbeddedCacheManager cacheManager = createEmbeddedCacheManager();
|
||||
List<String> cacheNames = this.cacheProperties.getCacheNames();
|
||||
public EmbeddedCacheManager infinispanCacheManager(CacheProperties cacheProperties,
|
||||
ObjectProvider<ConfigurationBuilder> defaultConfigurationBuilder)
|
||||
throws IOException {
|
||||
EmbeddedCacheManager cacheManager = createEmbeddedCacheManager(cacheProperties);
|
||||
List<String> cacheNames = cacheProperties.getCacheNames();
|
||||
if (!CollectionUtils.isEmpty(cacheNames)) {
|
||||
cacheNames.forEach((cacheName) -> cacheManager.defineConfiguration(cacheName,
|
||||
getDefaultCacheConfiguration()));
|
||||
getDefaultCacheConfiguration(
|
||||
defaultConfigurationBuilder.getIfAvailable())));
|
||||
}
|
||||
return cacheManager;
|
||||
}
|
||||
|
||||
private EmbeddedCacheManager createEmbeddedCacheManager() throws IOException {
|
||||
Resource location = this.cacheProperties
|
||||
.resolveConfigLocation(this.cacheProperties.getInfinispan().getConfig());
|
||||
private EmbeddedCacheManager createEmbeddedCacheManager(
|
||||
CacheProperties cacheProperties) throws IOException {
|
||||
Resource location = cacheProperties
|
||||
.resolveConfigLocation(cacheProperties.getInfinispan().getConfig());
|
||||
if (location != null) {
|
||||
try (InputStream in = location.getInputStream()) {
|
||||
return new DefaultCacheManager(in);
|
||||
|
|
@ -94,9 +84,10 @@ public class InfinispanCacheConfiguration {
|
|||
return new DefaultCacheManager();
|
||||
}
|
||||
|
||||
private org.infinispan.configuration.cache.Configuration getDefaultCacheConfiguration() {
|
||||
if (this.defaultConfigurationBuilder != null) {
|
||||
return this.defaultConfigurationBuilder.build();
|
||||
private org.infinispan.configuration.cache.Configuration getDefaultCacheConfiguration(
|
||||
ConfigurationBuilder defaultConfigurationBuilder) {
|
||||
if (defaultConfigurationBuilder != null) {
|
||||
return defaultConfigurationBuilder.build();
|
||||
}
|
||||
return new ConfigurationBuilder().build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -63,61 +63,50 @@ import org.springframework.util.StringUtils;
|
|||
@Import(HazelcastJCacheCustomizationConfiguration.class)
|
||||
class JCacheCacheConfiguration implements BeanClassLoaderAware {
|
||||
|
||||
private final CacheProperties cacheProperties;
|
||||
|
||||
private final CacheManagerCustomizers customizers;
|
||||
|
||||
private final javax.cache.configuration.Configuration<?, ?> defaultCacheConfiguration;
|
||||
|
||||
private final ObjectProvider<JCacheManagerCustomizer> cacheManagerCustomizers;
|
||||
|
||||
private final ObjectProvider<JCachePropertiesCustomizer> cachePropertiesCustomizers;
|
||||
|
||||
private ClassLoader beanClassLoader;
|
||||
|
||||
JCacheCacheConfiguration(CacheProperties cacheProperties,
|
||||
CacheManagerCustomizers customizers,
|
||||
ObjectProvider<javax.cache.configuration.Configuration<?, ?>> defaultCacheConfiguration,
|
||||
ObjectProvider<JCacheManagerCustomizer> cacheManagerCustomizers,
|
||||
ObjectProvider<JCachePropertiesCustomizer> cachePropertiesCustomizers) {
|
||||
this.cacheProperties = cacheProperties;
|
||||
this.customizers = customizers;
|
||||
this.defaultCacheConfiguration = defaultCacheConfiguration.getIfAvailable();
|
||||
this.cacheManagerCustomizers = cacheManagerCustomizers;
|
||||
this.cachePropertiesCustomizers = cachePropertiesCustomizers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JCacheCacheManager cacheManager(CacheManager jCacheCacheManager) {
|
||||
public JCacheCacheManager cacheManager(CacheManagerCustomizers customizers,
|
||||
CacheManager jCacheCacheManager) {
|
||||
JCacheCacheManager cacheManager = new JCacheCacheManager(jCacheCacheManager);
|
||||
return this.customizers.customize(cacheManager);
|
||||
return customizers.customize(cacheManager);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public CacheManager jCacheCacheManager() throws IOException {
|
||||
CacheManager jCacheCacheManager = createCacheManager();
|
||||
List<String> cacheNames = this.cacheProperties.getCacheNames();
|
||||
public CacheManager jCacheCacheManager(CacheProperties cacheProperties,
|
||||
ObjectProvider<javax.cache.configuration.Configuration<?, ?>> defaultCacheConfiguration,
|
||||
ObjectProvider<JCacheManagerCustomizer> cacheManagerCustomizers,
|
||||
ObjectProvider<JCachePropertiesCustomizer> cachePropertiesCustomizers)
|
||||
throws IOException {
|
||||
CacheManager jCacheCacheManager = createCacheManager(cacheProperties,
|
||||
cachePropertiesCustomizers);
|
||||
List<String> cacheNames = cacheProperties.getCacheNames();
|
||||
if (!CollectionUtils.isEmpty(cacheNames)) {
|
||||
for (String cacheName : cacheNames) {
|
||||
jCacheCacheManager.createCache(cacheName, getDefaultCacheConfiguration());
|
||||
jCacheCacheManager.createCache(cacheName, defaultCacheConfiguration
|
||||
.getIfAvailable(MutableConfiguration::new));
|
||||
}
|
||||
}
|
||||
customize(jCacheCacheManager);
|
||||
cacheManagerCustomizers.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(jCacheCacheManager));
|
||||
return jCacheCacheManager;
|
||||
}
|
||||
|
||||
private CacheManager createCacheManager() throws IOException {
|
||||
private CacheManager createCacheManager(CacheProperties cacheProperties,
|
||||
ObjectProvider<JCachePropertiesCustomizer> cachePropertiesCustomizers)
|
||||
throws IOException {
|
||||
CachingProvider cachingProvider = getCachingProvider(
|
||||
this.cacheProperties.getJcache().getProvider());
|
||||
Properties properties = createCacheManagerProperties();
|
||||
Resource configLocation = this.cacheProperties
|
||||
.resolveConfigLocation(this.cacheProperties.getJcache().getConfig());
|
||||
cacheProperties.getJcache().getProvider());
|
||||
Properties properties = createCacheManagerProperties(cachePropertiesCustomizers,
|
||||
cacheProperties);
|
||||
Resource configLocation = cacheProperties
|
||||
.resolveConfigLocation(cacheProperties.getJcache().getConfig());
|
||||
if (configLocation != null) {
|
||||
return cachingProvider.getCacheManager(configLocation.getURI(),
|
||||
this.beanClassLoader, properties);
|
||||
|
|
@ -132,25 +121,15 @@ class JCacheCacheConfiguration implements BeanClassLoaderAware {
|
|||
return Caching.getCachingProvider();
|
||||
}
|
||||
|
||||
private Properties createCacheManagerProperties() {
|
||||
private Properties createCacheManagerProperties(
|
||||
ObjectProvider<JCachePropertiesCustomizer> cachePropertiesCustomizers,
|
||||
CacheProperties cacheProperties) {
|
||||
Properties properties = new Properties();
|
||||
this.cachePropertiesCustomizers.orderedStream().forEach(
|
||||
(customizer) -> customizer.customize(this.cacheProperties, properties));
|
||||
cachePropertiesCustomizers.orderedStream().forEach(
|
||||
(customizer) -> customizer.customize(cacheProperties, properties));
|
||||
return properties;
|
||||
}
|
||||
|
||||
private javax.cache.configuration.Configuration<?, ?> getDefaultCacheConfiguration() {
|
||||
if (this.defaultCacheConfiguration != null) {
|
||||
return this.defaultCacheConfiguration;
|
||||
}
|
||||
return new MutableConfiguration<>();
|
||||
}
|
||||
|
||||
private void customize(CacheManager cacheManager) {
|
||||
this.cacheManagerCustomizers.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(cacheManager));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if JCache is available. This either kicks in if a provider is available
|
||||
* as defined per {@link JCacheProviderAvailableCondition} or if a
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -53,39 +53,35 @@ import org.springframework.data.redis.serializer.RedisSerializationContext.Seria
|
|||
@Conditional(CacheCondition.class)
|
||||
class RedisCacheConfiguration {
|
||||
|
||||
private final CacheProperties cacheProperties;
|
||||
|
||||
private final CacheManagerCustomizers customizerInvoker;
|
||||
|
||||
private final org.springframework.data.redis.cache.RedisCacheConfiguration redisCacheConfiguration;
|
||||
|
||||
RedisCacheConfiguration(CacheProperties cacheProperties,
|
||||
CacheManagerCustomizers customizerInvoker,
|
||||
ObjectProvider<org.springframework.data.redis.cache.RedisCacheConfiguration> redisCacheConfiguration) {
|
||||
this.cacheProperties = cacheProperties;
|
||||
this.customizerInvoker = customizerInvoker;
|
||||
this.redisCacheConfiguration = redisCacheConfiguration.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RedisCacheManager cacheManager(RedisConnectionFactory redisConnectionFactory,
|
||||
public RedisCacheManager cacheManager(CacheProperties cacheProperties,
|
||||
CacheManagerCustomizers cacheManagerCustomizers,
|
||||
ObjectProvider<org.springframework.data.redis.cache.RedisCacheConfiguration> redisCacheConfiguration,
|
||||
RedisConnectionFactory redisConnectionFactory,
|
||||
ResourceLoader resourceLoader) {
|
||||
RedisCacheManagerBuilder builder = RedisCacheManager
|
||||
.builder(redisConnectionFactory)
|
||||
.cacheDefaults(determineConfiguration(resourceLoader.getClassLoader()));
|
||||
List<String> cacheNames = this.cacheProperties.getCacheNames();
|
||||
.cacheDefaults(determineConfiguration(cacheProperties,
|
||||
redisCacheConfiguration, resourceLoader.getClassLoader()));
|
||||
List<String> cacheNames = cacheProperties.getCacheNames();
|
||||
if (!cacheNames.isEmpty()) {
|
||||
builder.initialCacheNames(new LinkedHashSet<>(cacheNames));
|
||||
}
|
||||
return this.customizerInvoker.customize(builder.build());
|
||||
return cacheManagerCustomizers.customize(builder.build());
|
||||
}
|
||||
|
||||
private org.springframework.data.redis.cache.RedisCacheConfiguration determineConfiguration(
|
||||
CacheProperties cacheProperties,
|
||||
ObjectProvider<org.springframework.data.redis.cache.RedisCacheConfiguration> redisCacheConfiguration,
|
||||
ClassLoader classLoader) {
|
||||
if (this.redisCacheConfiguration != null) {
|
||||
return this.redisCacheConfiguration;
|
||||
}
|
||||
Redis redisProperties = this.cacheProperties.getRedis();
|
||||
return redisCacheConfiguration
|
||||
.getIfAvailable(() -> createConfiguration(cacheProperties, classLoader));
|
||||
|
||||
}
|
||||
|
||||
private org.springframework.data.redis.cache.RedisCacheConfiguration createConfiguration(
|
||||
CacheProperties cacheProperties, ClassLoader classLoader) {
|
||||
Redis redisProperties = cacheProperties.getRedis();
|
||||
org.springframework.data.redis.cache.RedisCacheConfiguration config = org.springframework.data.redis.cache.RedisCacheConfiguration
|
||||
.defaultCacheConfig();
|
||||
config = config.serializeValuesWith(SerializationPair
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -36,24 +36,15 @@ import org.springframework.context.annotation.Configuration;
|
|||
@Conditional(CacheCondition.class)
|
||||
class SimpleCacheConfiguration {
|
||||
|
||||
private final CacheProperties cacheProperties;
|
||||
|
||||
private final CacheManagerCustomizers customizerInvoker;
|
||||
|
||||
SimpleCacheConfiguration(CacheProperties cacheProperties,
|
||||
CacheManagerCustomizers customizerInvoker) {
|
||||
this.cacheProperties = cacheProperties;
|
||||
this.customizerInvoker = customizerInvoker;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ConcurrentMapCacheManager cacheManager() {
|
||||
public ConcurrentMapCacheManager cacheManager(CacheProperties cacheProperties,
|
||||
CacheManagerCustomizers cacheManagerCustomizers) {
|
||||
ConcurrentMapCacheManager cacheManager = new ConcurrentMapCacheManager();
|
||||
List<String> cacheNames = this.cacheProperties.getCacheNames();
|
||||
List<String> cacheNames = cacheProperties.getCacheNames();
|
||||
if (!cacheNames.isEmpty()) {
|
||||
cacheManager.setCacheNames(cacheNames);
|
||||
}
|
||||
return this.customizerInvoker.customize(cacheManager);
|
||||
return cacheManagerCustomizers.customize(cacheManager);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -48,22 +48,12 @@ import org.springframework.util.StringUtils;
|
|||
@EnableConfigurationProperties(CassandraProperties.class)
|
||||
public class CassandraAutoConfiguration {
|
||||
|
||||
private final CassandraProperties properties;
|
||||
|
||||
private final ObjectProvider<ClusterBuilderCustomizer> builderCustomizers;
|
||||
|
||||
public CassandraAutoConfiguration(CassandraProperties properties,
|
||||
ObjectProvider<ClusterBuilderCustomizer> builderCustomizers) {
|
||||
this.properties = properties;
|
||||
this.builderCustomizers = builderCustomizers;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@SuppressWarnings("deprecation")
|
||||
public Cluster cassandraCluster() {
|
||||
public Cluster cassandraCluster(CassandraProperties properties,
|
||||
ObjectProvider<ClusterBuilderCustomizer> builderCustomizers) {
|
||||
PropertyMapper map = PropertyMapper.get();
|
||||
CassandraProperties properties = this.properties;
|
||||
Cluster.Builder builder = Cluster.builder()
|
||||
.withClusterName(properties.getClusterName())
|
||||
.withPort(properties.getPort());
|
||||
|
|
@ -72,31 +62,29 @@ public class CassandraAutoConfiguration {
|
|||
map.from(properties::getCompression).whenNonNull().to(builder::withCompression);
|
||||
map.from(properties::getLoadBalancingPolicy).whenNonNull()
|
||||
.as(BeanUtils::instantiateClass).to(builder::withLoadBalancingPolicy);
|
||||
map.from(this::getQueryOptions).to(builder::withQueryOptions);
|
||||
QueryOptions queryOptions = getQueryOptions(properties);
|
||||
map.from(queryOptions).to(builder::withQueryOptions);
|
||||
map.from(properties::getReconnectionPolicy).whenNonNull()
|
||||
.as(BeanUtils::instantiateClass).to(builder::withReconnectionPolicy);
|
||||
map.from(properties::getRetryPolicy).whenNonNull().as(BeanUtils::instantiateClass)
|
||||
.to(builder::withRetryPolicy);
|
||||
map.from(this::getSocketOptions).to(builder::withSocketOptions);
|
||||
SocketOptions socketOptions = getSocketOptions(properties);
|
||||
map.from(socketOptions).to(builder::withSocketOptions);
|
||||
map.from(properties::isSsl).whenTrue().toCall(builder::withSSL);
|
||||
map.from(this::getPoolingOptions).to(builder::withPoolingOptions);
|
||||
PoolingOptions poolingOptions = getPoolingOptions(properties);
|
||||
map.from(poolingOptions).to(builder::withPoolingOptions);
|
||||
map.from(properties::getContactPoints).as(StringUtils::toStringArray)
|
||||
.to(builder::addContactPoints);
|
||||
map.from(properties::isJmxEnabled).whenFalse()
|
||||
.toCall(builder::withoutJMXReporting);
|
||||
customize(builder);
|
||||
builderCustomizers.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(builder));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private void customize(Cluster.Builder builder) {
|
||||
this.builderCustomizers.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(builder));
|
||||
}
|
||||
|
||||
private QueryOptions getQueryOptions() {
|
||||
private QueryOptions getQueryOptions(CassandraProperties properties) {
|
||||
PropertyMapper map = PropertyMapper.get();
|
||||
QueryOptions options = new QueryOptions();
|
||||
CassandraProperties properties = this.properties;
|
||||
map.from(properties::getConsistencyLevel).whenNonNull()
|
||||
.to(options::setConsistencyLevel);
|
||||
map.from(properties::getSerialConsistencyLevel).whenNonNull()
|
||||
|
|
@ -105,27 +93,27 @@ public class CassandraAutoConfiguration {
|
|||
return options;
|
||||
}
|
||||
|
||||
private SocketOptions getSocketOptions() {
|
||||
private SocketOptions getSocketOptions(CassandraProperties properties) {
|
||||
PropertyMapper map = PropertyMapper.get();
|
||||
SocketOptions options = new SocketOptions();
|
||||
map.from(this.properties::getConnectTimeout).whenNonNull()
|
||||
.asInt(Duration::toMillis).to(options::setConnectTimeoutMillis);
|
||||
map.from(this.properties::getReadTimeout).whenNonNull().asInt(Duration::toMillis)
|
||||
map.from(properties::getConnectTimeout).whenNonNull().asInt(Duration::toMillis)
|
||||
.to(options::setConnectTimeoutMillis);
|
||||
map.from(properties::getReadTimeout).whenNonNull().asInt(Duration::toMillis)
|
||||
.to(options::setReadTimeoutMillis);
|
||||
return options;
|
||||
}
|
||||
|
||||
private PoolingOptions getPoolingOptions() {
|
||||
private PoolingOptions getPoolingOptions(CassandraProperties properties) {
|
||||
PropertyMapper map = PropertyMapper.get();
|
||||
CassandraProperties.Pool properties = this.properties.getPool();
|
||||
CassandraProperties.Pool poolProperties = properties.getPool();
|
||||
PoolingOptions options = new PoolingOptions();
|
||||
map.from(properties::getIdleTimeout).whenNonNull().asInt(Duration::getSeconds)
|
||||
map.from(poolProperties::getIdleTimeout).whenNonNull().asInt(Duration::getSeconds)
|
||||
.to(options::setIdleTimeoutSeconds);
|
||||
map.from(properties::getPoolTimeout).whenNonNull().asInt(Duration::toMillis)
|
||||
map.from(poolProperties::getPoolTimeout).whenNonNull().asInt(Duration::toMillis)
|
||||
.to(options::setPoolTimeoutMillis);
|
||||
map.from(properties::getHeartbeatInterval).whenNonNull()
|
||||
map.from(poolProperties::getHeartbeatInterval).whenNonNull()
|
||||
.asInt(Duration::getSeconds).to(options::setHeartbeatIntervalSeconds);
|
||||
map.from(properties::getMaxQueueSize).to(options::setMaxQueueSize);
|
||||
map.from(poolProperties::getMaxQueueSize).to(options::setMaxQueueSize);
|
||||
return options;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -63,31 +63,24 @@ import org.springframework.data.cassandra.core.mapping.SimpleUserTypeResolver;
|
|||
@AutoConfigureAfter(CassandraAutoConfiguration.class)
|
||||
public class CassandraDataAutoConfiguration {
|
||||
|
||||
private final BeanFactory beanFactory;
|
||||
|
||||
private final CassandraProperties properties;
|
||||
|
||||
private final Cluster cluster;
|
||||
|
||||
private final Environment environment;
|
||||
|
||||
public CassandraDataAutoConfiguration(BeanFactory beanFactory,
|
||||
CassandraProperties properties, Cluster cluster, Environment environment) {
|
||||
this.beanFactory = beanFactory;
|
||||
this.properties = properties;
|
||||
this.cluster = cluster;
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public CassandraMappingContext cassandraMapping(
|
||||
public CassandraMappingContext cassandraMapping(BeanFactory beanFactory,
|
||||
CassandraCustomConversions conversions) throws ClassNotFoundException {
|
||||
CassandraMappingContext context = new CassandraMappingContext();
|
||||
List<String> packages = EntityScanPackages.get(this.beanFactory)
|
||||
.getPackageNames();
|
||||
if (packages.isEmpty() && AutoConfigurationPackages.has(this.beanFactory)) {
|
||||
packages = AutoConfigurationPackages.get(this.beanFactory);
|
||||
List<String> packages = EntityScanPackages.get(beanFactory).getPackageNames();
|
||||
if (packages.isEmpty() && AutoConfigurationPackages.has(beanFactory)) {
|
||||
packages = AutoConfigurationPackages.get(beanFactory);
|
||||
}
|
||||
if (!packages.isEmpty()) {
|
||||
context.setInitialEntitySet(CassandraEntityClassScanner.scan(packages));
|
||||
|
|
@ -113,13 +106,13 @@ public class CassandraDataAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(Session.class)
|
||||
public CassandraSessionFactoryBean cassandraSession(CassandraConverter converter)
|
||||
throws Exception {
|
||||
public CassandraSessionFactoryBean cassandraSession(Environment environment,
|
||||
CassandraConverter converter) throws Exception {
|
||||
CassandraSessionFactoryBean session = new CassandraSessionFactoryBean();
|
||||
session.setCluster(this.cluster);
|
||||
session.setConverter(converter);
|
||||
session.setKeyspaceName(this.properties.getKeyspaceName());
|
||||
Binder binder = Binder.get(this.environment);
|
||||
Binder binder = Binder.get(environment);
|
||||
binder.bind("spring.data.cassandra.schema-action", SchemaAction.class)
|
||||
.ifBound(session::setSchemaAction);
|
||||
return session;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -38,24 +38,15 @@ import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
|
|||
@Configuration
|
||||
class MongoDataConfiguration {
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
private final MongoProperties properties;
|
||||
|
||||
MongoDataConfiguration(ApplicationContext applicationContext,
|
||||
MongoProperties properties) {
|
||||
this.applicationContext = applicationContext;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public MongoMappingContext mongoMappingContext(MongoCustomConversions conversions)
|
||||
public MongoMappingContext mongoMappingContext(ApplicationContext applicationContext,
|
||||
MongoProperties properties, MongoCustomConversions conversions)
|
||||
throws ClassNotFoundException {
|
||||
MongoMappingContext context = new MongoMappingContext();
|
||||
context.setInitialEntitySet(new EntityScanner(this.applicationContext)
|
||||
context.setInitialEntitySet(new EntityScanner(applicationContext)
|
||||
.scan(Document.class, Persistent.class));
|
||||
Class<?> strategyClass = this.properties.getFieldNamingStrategy();
|
||||
Class<?> strategyClass = properties.getFieldNamingStrategy();
|
||||
if (strategyClass != null) {
|
||||
context.setFieldNamingStrategy(
|
||||
(FieldNamingStrategy) BeanUtils.instantiateClass(strategyClass));
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -59,17 +59,11 @@ import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
|
|||
@AutoConfigureAfter(MongoReactiveAutoConfiguration.class)
|
||||
public class MongoReactiveDataAutoConfiguration {
|
||||
|
||||
private final MongoProperties properties;
|
||||
|
||||
public MongoReactiveDataAutoConfiguration(MongoProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ReactiveMongoDatabaseFactory.class)
|
||||
public SimpleReactiveMongoDatabaseFactory reactiveMongoDatabaseFactory(
|
||||
MongoClient mongo) {
|
||||
String database = this.properties.getMongoClientDatabase();
|
||||
MongoProperties properties, MongoClient mongo) {
|
||||
String database = properties.getMongoClientDatabase();
|
||||
return new SimpleReactiveMongoDatabaseFactory(mongo, database);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -47,27 +47,24 @@ import org.springframework.util.StringUtils;
|
|||
@ConditionalOnClass({ GenericObjectPool.class, JedisConnection.class, Jedis.class })
|
||||
class JedisConnectionConfiguration extends RedisConnectionConfiguration {
|
||||
|
||||
private final RedisProperties properties;
|
||||
|
||||
private final ObjectProvider<JedisClientConfigurationBuilderCustomizer> builderCustomizers;
|
||||
|
||||
JedisConnectionConfiguration(RedisProperties properties,
|
||||
ObjectProvider<RedisSentinelConfiguration> sentinelConfiguration,
|
||||
ObjectProvider<RedisClusterConfiguration> clusterConfiguration,
|
||||
ObjectProvider<JedisClientConfigurationBuilderCustomizer> builderCustomizers) {
|
||||
ObjectProvider<RedisClusterConfiguration> clusterConfiguration) {
|
||||
super(properties, sentinelConfiguration, clusterConfiguration);
|
||||
this.properties = properties;
|
||||
this.builderCustomizers = builderCustomizers;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(RedisConnectionFactory.class)
|
||||
public JedisConnectionFactory redisConnectionFactory() throws UnknownHostException {
|
||||
return createJedisConnectionFactory();
|
||||
public JedisConnectionFactory redisConnectionFactory(
|
||||
ObjectProvider<JedisClientConfigurationBuilderCustomizer> builderCustomizers)
|
||||
throws UnknownHostException {
|
||||
return createJedisConnectionFactory(builderCustomizers);
|
||||
}
|
||||
|
||||
private JedisConnectionFactory createJedisConnectionFactory() {
|
||||
JedisClientConfiguration clientConfiguration = getJedisClientConfiguration();
|
||||
private JedisConnectionFactory createJedisConnectionFactory(
|
||||
ObjectProvider<JedisClientConfigurationBuilderCustomizer> builderCustomizers) {
|
||||
JedisClientConfiguration clientConfiguration = getJedisClientConfiguration(
|
||||
builderCustomizers);
|
||||
if (getSentinelConfig() != null) {
|
||||
return new JedisConnectionFactory(getSentinelConfig(), clientConfiguration);
|
||||
}
|
||||
|
|
@ -78,27 +75,29 @@ class JedisConnectionConfiguration extends RedisConnectionConfiguration {
|
|||
return new JedisConnectionFactory(getStandaloneConfig(), clientConfiguration);
|
||||
}
|
||||
|
||||
private JedisClientConfiguration getJedisClientConfiguration() {
|
||||
private JedisClientConfiguration getJedisClientConfiguration(
|
||||
ObjectProvider<JedisClientConfigurationBuilderCustomizer> builderCustomizers) {
|
||||
JedisClientConfigurationBuilder builder = applyProperties(
|
||||
JedisClientConfiguration.builder());
|
||||
RedisProperties.Pool pool = this.properties.getJedis().getPool();
|
||||
RedisProperties.Pool pool = getProperties().getJedis().getPool();
|
||||
if (pool != null) {
|
||||
applyPooling(pool, builder);
|
||||
}
|
||||
if (StringUtils.hasText(this.properties.getUrl())) {
|
||||
if (StringUtils.hasText(getProperties().getUrl())) {
|
||||
customizeConfigurationFromUrl(builder);
|
||||
}
|
||||
customize(builder);
|
||||
builderCustomizers.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(builder));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private JedisClientConfigurationBuilder applyProperties(
|
||||
JedisClientConfigurationBuilder builder) {
|
||||
if (this.properties.isSsl()) {
|
||||
if (getProperties().isSsl()) {
|
||||
builder.useSsl();
|
||||
}
|
||||
if (this.properties.getTimeout() != null) {
|
||||
Duration timeout = this.properties.getTimeout();
|
||||
if (getProperties().getTimeout() != null) {
|
||||
Duration timeout = getProperties().getTimeout();
|
||||
builder.readTimeout(timeout).connectTimeout(timeout);
|
||||
}
|
||||
return builder;
|
||||
|
|
@ -122,16 +121,10 @@ class JedisConnectionConfiguration extends RedisConnectionConfiguration {
|
|||
|
||||
private void customizeConfigurationFromUrl(
|
||||
JedisClientConfiguration.JedisClientConfigurationBuilder builder) {
|
||||
ConnectionInfo connectionInfo = parseUrl(this.properties.getUrl());
|
||||
ConnectionInfo connectionInfo = parseUrl(getProperties().getUrl());
|
||||
if (connectionInfo.isUseSsl()) {
|
||||
builder.useSsl();
|
||||
}
|
||||
}
|
||||
|
||||
private void customize(
|
||||
JedisClientConfiguration.JedisClientConfigurationBuilder builder) {
|
||||
this.builderCustomizers.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(builder));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -48,17 +48,10 @@ import org.springframework.util.StringUtils;
|
|||
@ConditionalOnClass(RedisClient.class)
|
||||
class LettuceConnectionConfiguration extends RedisConnectionConfiguration {
|
||||
|
||||
private final RedisProperties properties;
|
||||
|
||||
private final ObjectProvider<LettuceClientConfigurationBuilderCustomizer> builderCustomizers;
|
||||
|
||||
LettuceConnectionConfiguration(RedisProperties properties,
|
||||
ObjectProvider<RedisSentinelConfiguration> sentinelConfigurationProvider,
|
||||
ObjectProvider<RedisClusterConfiguration> clusterConfigurationProvider,
|
||||
ObjectProvider<LettuceClientConfigurationBuilderCustomizer> builderCustomizers) {
|
||||
ObjectProvider<RedisClusterConfiguration> clusterConfigurationProvider) {
|
||||
super(properties, sentinelConfigurationProvider, clusterConfigurationProvider);
|
||||
this.properties = properties;
|
||||
this.builderCustomizers = builderCustomizers;
|
||||
}
|
||||
|
||||
@Bean(destroyMethod = "shutdown")
|
||||
|
|
@ -70,9 +63,11 @@ class LettuceConnectionConfiguration extends RedisConnectionConfiguration {
|
|||
@Bean
|
||||
@ConditionalOnMissingBean(RedisConnectionFactory.class)
|
||||
public LettuceConnectionFactory redisConnectionFactory(
|
||||
ObjectProvider<LettuceClientConfigurationBuilderCustomizer> builderCustomizers,
|
||||
ClientResources clientResources) throws UnknownHostException {
|
||||
LettuceClientConfiguration clientConfig = getLettuceClientConfiguration(
|
||||
clientResources, this.properties.getLettuce().getPool());
|
||||
builderCustomizers, clientResources,
|
||||
getProperties().getLettuce().getPool());
|
||||
return createLettuceConnectionFactory(clientConfig);
|
||||
}
|
||||
|
||||
|
|
@ -89,14 +84,16 @@ class LettuceConnectionConfiguration extends RedisConnectionConfiguration {
|
|||
}
|
||||
|
||||
private LettuceClientConfiguration getLettuceClientConfiguration(
|
||||
ObjectProvider<LettuceClientConfigurationBuilderCustomizer> builderCustomizers,
|
||||
ClientResources clientResources, Pool pool) {
|
||||
LettuceClientConfigurationBuilder builder = createBuilder(pool);
|
||||
applyProperties(builder);
|
||||
if (StringUtils.hasText(this.properties.getUrl())) {
|
||||
if (StringUtils.hasText(getProperties().getUrl())) {
|
||||
customizeConfigurationFromUrl(builder);
|
||||
}
|
||||
builder.clientResources(clientResources);
|
||||
customize(builder);
|
||||
builderCustomizers.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(builder));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
|
@ -109,18 +106,18 @@ class LettuceConnectionConfiguration extends RedisConnectionConfiguration {
|
|||
|
||||
private LettuceClientConfigurationBuilder applyProperties(
|
||||
LettuceClientConfiguration.LettuceClientConfigurationBuilder builder) {
|
||||
if (this.properties.isSsl()) {
|
||||
if (getProperties().isSsl()) {
|
||||
builder.useSsl();
|
||||
}
|
||||
if (this.properties.getTimeout() != null) {
|
||||
builder.commandTimeout(this.properties.getTimeout());
|
||||
if (getProperties().getTimeout() != null) {
|
||||
builder.commandTimeout(getProperties().getTimeout());
|
||||
}
|
||||
if (this.properties.getLettuce() != null) {
|
||||
RedisProperties.Lettuce lettuce = this.properties.getLettuce();
|
||||
if (getProperties().getLettuce() != null) {
|
||||
RedisProperties.Lettuce lettuce = getProperties().getLettuce();
|
||||
if (lettuce.getShutdownTimeout() != null
|
||||
&& !lettuce.getShutdownTimeout().isZero()) {
|
||||
builder.shutdownTimeout(
|
||||
this.properties.getLettuce().getShutdownTimeout());
|
||||
getProperties().getLettuce().getShutdownTimeout());
|
||||
}
|
||||
}
|
||||
return builder;
|
||||
|
|
@ -128,18 +125,12 @@ class LettuceConnectionConfiguration extends RedisConnectionConfiguration {
|
|||
|
||||
private void customizeConfigurationFromUrl(
|
||||
LettuceClientConfiguration.LettuceClientConfigurationBuilder builder) {
|
||||
ConnectionInfo connectionInfo = parseUrl(this.properties.getUrl());
|
||||
ConnectionInfo connectionInfo = parseUrl(getProperties().getUrl());
|
||||
if (connectionInfo.isUseSsl()) {
|
||||
builder.useSsl();
|
||||
}
|
||||
}
|
||||
|
||||
private void customize(
|
||||
LettuceClientConfiguration.LettuceClientConfigurationBuilder builder) {
|
||||
this.builderCustomizers.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(builder));
|
||||
}
|
||||
|
||||
/**
|
||||
* Inner class to allow optional commons-pool2 dependency.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -111,6 +111,10 @@ abstract class RedisConnectionConfiguration {
|
|||
return config;
|
||||
}
|
||||
|
||||
protected final RedisProperties getProperties() {
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
private List<RedisNode> createSentinels(RedisProperties.Sentinel sentinel) {
|
||||
List<RedisNode> nodes = new ArrayList<>();
|
||||
for (String node : sentinel.getNodes()) {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -49,51 +49,38 @@ import org.springframework.util.Assert;
|
|||
@AutoConfigureAfter(GsonAutoConfiguration.class)
|
||||
public class JestAutoConfiguration {
|
||||
|
||||
private final JestProperties properties;
|
||||
|
||||
private final ObjectProvider<Gson> gsonProvider;
|
||||
|
||||
private final ObjectProvider<HttpClientConfigBuilderCustomizer> builderCustomizers;
|
||||
|
||||
public JestAutoConfiguration(JestProperties properties, ObjectProvider<Gson> gson,
|
||||
ObjectProvider<HttpClientConfigBuilderCustomizer> builderCustomizers) {
|
||||
this.properties = properties;
|
||||
this.gsonProvider = gson;
|
||||
this.builderCustomizers = builderCustomizers;
|
||||
}
|
||||
|
||||
@Bean(destroyMethod = "shutdownClient")
|
||||
@ConditionalOnMissingBean
|
||||
public JestClient jestClient() {
|
||||
public JestClient jestClient(JestProperties properties, ObjectProvider<Gson> gson,
|
||||
ObjectProvider<HttpClientConfigBuilderCustomizer> builderCustomizers) {
|
||||
JestClientFactory factory = new JestClientFactory();
|
||||
factory.setHttpClientConfig(createHttpClientConfig());
|
||||
factory.setHttpClientConfig(
|
||||
createHttpClientConfig(properties, gson, builderCustomizers));
|
||||
return factory.getObject();
|
||||
}
|
||||
|
||||
protected HttpClientConfig createHttpClientConfig() {
|
||||
protected HttpClientConfig createHttpClientConfig(JestProperties properties,
|
||||
ObjectProvider<Gson> gson,
|
||||
ObjectProvider<HttpClientConfigBuilderCustomizer> builderCustomizers) {
|
||||
HttpClientConfig.Builder builder = new HttpClientConfig.Builder(
|
||||
this.properties.getUris());
|
||||
properties.getUris());
|
||||
PropertyMapper map = PropertyMapper.get();
|
||||
map.from(this.properties::getUsername).whenHasText().to((username) -> builder
|
||||
.defaultCredentials(username, this.properties.getPassword()));
|
||||
Proxy proxy = this.properties.getProxy();
|
||||
map.from(properties::getUsername).whenHasText().to((username) -> builder
|
||||
.defaultCredentials(username, properties.getPassword()));
|
||||
Proxy proxy = properties.getProxy();
|
||||
map.from(proxy::getHost).whenHasText().to((host) -> {
|
||||
Assert.notNull(proxy.getPort(), "Proxy port must not be null");
|
||||
builder.proxy(new HttpHost(host, proxy.getPort()));
|
||||
});
|
||||
map.from(this.gsonProvider::getIfUnique).whenNonNull().to(builder::gson);
|
||||
map.from(this.properties::isMultiThreaded).to(builder::multiThreaded);
|
||||
map.from(this.properties::getConnectionTimeout).whenNonNull()
|
||||
.asInt(Duration::toMillis).to(builder::connTimeout);
|
||||
map.from(this.properties::getReadTimeout).whenNonNull().asInt(Duration::toMillis)
|
||||
map.from(gson::getIfUnique).whenNonNull().to(builder::gson);
|
||||
map.from(properties::isMultiThreaded).to(builder::multiThreaded);
|
||||
map.from(properties::getConnectionTimeout).whenNonNull().asInt(Duration::toMillis)
|
||||
.to(builder::connTimeout);
|
||||
map.from(properties::getReadTimeout).whenNonNull().asInt(Duration::toMillis)
|
||||
.to(builder::readTimeout);
|
||||
customize(builder);
|
||||
builderCustomizers.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(builder));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private void customize(HttpClientConfig.Builder builder) {
|
||||
this.builderCustomizers.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(builder));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -46,16 +46,6 @@ import org.springframework.context.annotation.Configuration;
|
|||
@EnableConfigurationProperties(RestClientProperties.class)
|
||||
public class RestClientAutoConfiguration {
|
||||
|
||||
private final RestClientProperties properties;
|
||||
|
||||
private final ObjectProvider<RestClientBuilderCustomizer> builderCustomizers;
|
||||
|
||||
public RestClientAutoConfiguration(RestClientProperties properties,
|
||||
ObjectProvider<RestClientBuilderCustomizer> builderCustomizers) {
|
||||
this.properties = properties;
|
||||
this.builderCustomizers = builderCustomizers;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public RestClient restClient(RestClientBuilder builder) {
|
||||
|
|
@ -64,20 +54,21 @@ public class RestClientAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public RestClientBuilder restClientBuilder() {
|
||||
HttpHost[] hosts = this.properties.getUris().stream().map(HttpHost::create)
|
||||
public RestClientBuilder restClientBuilder(RestClientProperties properties,
|
||||
ObjectProvider<RestClientBuilderCustomizer> builderCustomizers) {
|
||||
HttpHost[] hosts = properties.getUris().stream().map(HttpHost::create)
|
||||
.toArray(HttpHost[]::new);
|
||||
RestClientBuilder builder = RestClient.builder(hosts);
|
||||
PropertyMapper map = PropertyMapper.get();
|
||||
map.from(this.properties::getUsername).whenHasText().to((username) -> {
|
||||
map.from(properties::getUsername).whenHasText().to((username) -> {
|
||||
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
|
||||
Credentials credentials = new UsernamePasswordCredentials(
|
||||
this.properties.getUsername(), this.properties.getPassword());
|
||||
properties.getUsername(), properties.getPassword());
|
||||
credentialsProvider.setCredentials(AuthScope.ANY, credentials);
|
||||
builder.setHttpClientConfigCallback((httpClientBuilder) -> httpClientBuilder
|
||||
.setDefaultCredentialsProvider(credentialsProvider));
|
||||
});
|
||||
this.builderCustomizers.orderedStream()
|
||||
builderCustomizers.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(builder));
|
||||
return builder;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -104,25 +104,8 @@ public class FlywayAutoConfiguration {
|
|||
@EnableConfigurationProperties({ DataSourceProperties.class, FlywayProperties.class })
|
||||
public static class FlywayConfiguration {
|
||||
|
||||
private final FlywayProperties properties;
|
||||
|
||||
private final DataSourceProperties dataSourceProperties;
|
||||
|
||||
private final ResourceLoader resourceLoader;
|
||||
|
||||
private final DataSource dataSource;
|
||||
|
||||
private final DataSource flywayDataSource;
|
||||
|
||||
private final FlywayMigrationStrategy migrationStrategy;
|
||||
|
||||
private final List<FlywayConfigurationCustomizer> configurationCustomizers;
|
||||
|
||||
private final List<Callback> callbacks;
|
||||
|
||||
private final List<FlywayCallback> flywayCallbacks;
|
||||
|
||||
public FlywayConfiguration(FlywayProperties properties,
|
||||
@Bean
|
||||
public Flyway flyway(FlywayProperties properties,
|
||||
DataSourceProperties dataSourceProperties, ResourceLoader resourceLoader,
|
||||
ObjectProvider<DataSource> dataSource,
|
||||
@FlywayDataSource ObjectProvider<DataSource> flywayDataSource,
|
||||
|
|
@ -130,141 +113,135 @@ public class FlywayAutoConfiguration {
|
|||
ObjectProvider<FlywayConfigurationCustomizer> fluentConfigurationCustomizers,
|
||||
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.configurationCustomizers = fluentConfigurationCustomizers.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
this.callbacks = callbacks.orderedStream().collect(Collectors.toList());
|
||||
this.flywayCallbacks = flywayCallbacks.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Flyway flyway() {
|
||||
FluentConfiguration configuration = new FluentConfiguration();
|
||||
DataSource dataSource = configureDataSource(configuration);
|
||||
checkLocationExists(dataSource);
|
||||
configureProperties(configuration);
|
||||
configureCallbacks(configuration);
|
||||
this.configurationCustomizers
|
||||
DataSource dataSourceToMigrate = configureDataSource(configuration,
|
||||
properties, dataSourceProperties, flywayDataSource.getIfAvailable(),
|
||||
dataSource.getIfAvailable());
|
||||
checkLocationExists(dataSourceToMigrate, properties, resourceLoader);
|
||||
configureProperties(configuration, properties);
|
||||
List<Callback> orderedCallbacks = callbacks.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
configureCallbacks(configuration, orderedCallbacks);
|
||||
fluentConfigurationCustomizers.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(configuration));
|
||||
Flyway flyway = configuration.load();
|
||||
configureFlywayCallbacks(flyway);
|
||||
List<FlywayCallback> orderedFlywayCallbacks = flywayCallbacks.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
configureFlywayCallbacks(flyway, orderedCallbacks, orderedFlywayCallbacks);
|
||||
return flyway;
|
||||
}
|
||||
|
||||
private DataSource configureDataSource(FluentConfiguration configuration) {
|
||||
if (this.properties.isCreateDataSource()) {
|
||||
String url = getProperty(this.properties::getUrl,
|
||||
this.dataSourceProperties::getUrl);
|
||||
String user = getProperty(this.properties::getUser,
|
||||
this.dataSourceProperties::getUsername);
|
||||
String password = getProperty(this.properties::getPassword,
|
||||
this.dataSourceProperties::getPassword);
|
||||
private DataSource configureDataSource(FluentConfiguration configuration,
|
||||
FlywayProperties properties, DataSourceProperties dataSourceProperties,
|
||||
DataSource flywayDataSource, DataSource dataSource) {
|
||||
if (properties.isCreateDataSource()) {
|
||||
String url = getProperty(properties::getUrl,
|
||||
dataSourceProperties::getUrl);
|
||||
String user = getProperty(properties::getUser,
|
||||
dataSourceProperties::getUsername);
|
||||
String password = getProperty(properties::getPassword,
|
||||
dataSourceProperties::getPassword);
|
||||
configuration.dataSource(url, user, password);
|
||||
if (!CollectionUtils.isEmpty(this.properties.getInitSqls())) {
|
||||
String initSql = StringUtils.collectionToDelimitedString(
|
||||
this.properties.getInitSqls(), "\n");
|
||||
if (!CollectionUtils.isEmpty(properties.getInitSqls())) {
|
||||
String initSql = StringUtils
|
||||
.collectionToDelimitedString(properties.getInitSqls(), "\n");
|
||||
configuration.initSql(initSql);
|
||||
}
|
||||
}
|
||||
else if (this.flywayDataSource != null) {
|
||||
configuration.dataSource(this.flywayDataSource);
|
||||
else if (flywayDataSource != null) {
|
||||
configuration.dataSource(flywayDataSource);
|
||||
}
|
||||
else {
|
||||
configuration.dataSource(this.dataSource);
|
||||
configuration.dataSource(dataSource);
|
||||
}
|
||||
return configuration.getDataSource();
|
||||
}
|
||||
|
||||
private void checkLocationExists(DataSource dataSource) {
|
||||
if (this.properties.isCheckLocation()) {
|
||||
private void checkLocationExists(DataSource dataSource,
|
||||
FlywayProperties properties, ResourceLoader resourceLoader) {
|
||||
if (properties.isCheckLocation()) {
|
||||
String[] locations = new LocationResolver(dataSource)
|
||||
.resolveLocations(this.properties.getLocations());
|
||||
.resolveLocations(properties.getLocations());
|
||||
Assert.state(locations.length != 0,
|
||||
"Migration script locations not configured");
|
||||
boolean exists = hasAtLeastOneLocation(locations);
|
||||
boolean exists = hasAtLeastOneLocation(resourceLoader, locations);
|
||||
Assert.state(exists, () -> "Cannot find migrations location in: "
|
||||
+ Arrays.asList(locations)
|
||||
+ " (please add migrations or check your Flyway configuration)");
|
||||
}
|
||||
}
|
||||
|
||||
private void configureProperties(FluentConfiguration configuration) {
|
||||
private void configureProperties(FluentConfiguration configuration,
|
||||
FlywayProperties properties) {
|
||||
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
||||
String[] locations = new LocationResolver(configuration.getDataSource())
|
||||
.resolveLocations(this.properties.getLocations());
|
||||
.resolveLocations(properties.getLocations());
|
||||
map.from(locations).to(configuration::locations);
|
||||
map.from(this.properties.getEncoding()).to(configuration::encoding);
|
||||
map.from(this.properties.getConnectRetries())
|
||||
.to(configuration::connectRetries);
|
||||
map.from(this.properties.getSchemas()).as(StringUtils::toStringArray)
|
||||
map.from(properties.getEncoding()).to(configuration::encoding);
|
||||
map.from(properties.getConnectRetries()).to(configuration::connectRetries);
|
||||
map.from(properties.getSchemas()).as(StringUtils::toStringArray)
|
||||
.to(configuration::schemas);
|
||||
map.from(this.properties.getTable()).to(configuration::table);
|
||||
map.from(this.properties.getBaselineDescription())
|
||||
map.from(properties.getTable()).to(configuration::table);
|
||||
map.from(properties.getBaselineDescription())
|
||||
.to(configuration::baselineDescription);
|
||||
map.from(this.properties.getBaselineVersion())
|
||||
.to(configuration::baselineVersion);
|
||||
map.from(this.properties.getInstalledBy()).to(configuration::installedBy);
|
||||
map.from(this.properties.getPlaceholders()).to(configuration::placeholders);
|
||||
map.from(this.properties.getPlaceholderPrefix())
|
||||
map.from(properties.getBaselineVersion()).to(configuration::baselineVersion);
|
||||
map.from(properties.getInstalledBy()).to(configuration::installedBy);
|
||||
map.from(properties.getPlaceholders()).to(configuration::placeholders);
|
||||
map.from(properties.getPlaceholderPrefix())
|
||||
.to(configuration::placeholderPrefix);
|
||||
map.from(this.properties.getPlaceholderSuffix())
|
||||
map.from(properties.getPlaceholderSuffix())
|
||||
.to(configuration::placeholderSuffix);
|
||||
map.from(this.properties.isPlaceholderReplacement())
|
||||
map.from(properties.isPlaceholderReplacement())
|
||||
.to(configuration::placeholderReplacement);
|
||||
map.from(this.properties.getSqlMigrationPrefix())
|
||||
map.from(properties.getSqlMigrationPrefix())
|
||||
.to(configuration::sqlMigrationPrefix);
|
||||
map.from(this.properties.getSqlMigrationSuffixes())
|
||||
.as(StringUtils::toStringArray)
|
||||
map.from(properties.getSqlMigrationSuffixes()).as(StringUtils::toStringArray)
|
||||
.to(configuration::sqlMigrationSuffixes);
|
||||
map.from(this.properties.getSqlMigrationSeparator())
|
||||
map.from(properties.getSqlMigrationSeparator())
|
||||
.to(configuration::sqlMigrationSeparator);
|
||||
map.from(this.properties.getRepeatableSqlMigrationPrefix())
|
||||
map.from(properties.getRepeatableSqlMigrationPrefix())
|
||||
.to(configuration::repeatableSqlMigrationPrefix);
|
||||
map.from(this.properties.getTarget()).to(configuration::target);
|
||||
map.from(this.properties.isBaselineOnMigrate())
|
||||
map.from(properties.getTarget()).to(configuration::target);
|
||||
map.from(properties.isBaselineOnMigrate())
|
||||
.to(configuration::baselineOnMigrate);
|
||||
map.from(this.properties.isCleanDisabled()).to(configuration::cleanDisabled);
|
||||
map.from(this.properties.isCleanOnValidationError())
|
||||
map.from(properties.isCleanDisabled()).to(configuration::cleanDisabled);
|
||||
map.from(properties.isCleanOnValidationError())
|
||||
.to(configuration::cleanOnValidationError);
|
||||
map.from(this.properties.isGroup()).to(configuration::group);
|
||||
map.from(this.properties.isIgnoreMissingMigrations())
|
||||
map.from(properties.isGroup()).to(configuration::group);
|
||||
map.from(properties.isIgnoreMissingMigrations())
|
||||
.to(configuration::ignoreMissingMigrations);
|
||||
map.from(this.properties.isIgnoreIgnoredMigrations())
|
||||
map.from(properties.isIgnoreIgnoredMigrations())
|
||||
.to(configuration::ignoreIgnoredMigrations);
|
||||
map.from(this.properties.isIgnorePendingMigrations())
|
||||
map.from(properties.isIgnorePendingMigrations())
|
||||
.to(configuration::ignorePendingMigrations);
|
||||
map.from(this.properties.isIgnoreFutureMigrations())
|
||||
map.from(properties.isIgnoreFutureMigrations())
|
||||
.to(configuration::ignoreFutureMigrations);
|
||||
map.from(this.properties.isMixed()).to(configuration::mixed);
|
||||
map.from(this.properties.isOutOfOrder()).to(configuration::outOfOrder);
|
||||
map.from(this.properties.isSkipDefaultCallbacks())
|
||||
map.from(properties.isMixed()).to(configuration::mixed);
|
||||
map.from(properties.isOutOfOrder()).to(configuration::outOfOrder);
|
||||
map.from(properties.isSkipDefaultCallbacks())
|
||||
.to(configuration::skipDefaultCallbacks);
|
||||
map.from(this.properties.isSkipDefaultResolvers())
|
||||
map.from(properties.isSkipDefaultResolvers())
|
||||
.to(configuration::skipDefaultResolvers);
|
||||
map.from(this.properties.isValidateOnMigrate())
|
||||
map.from(properties.isValidateOnMigrate())
|
||||
.to(configuration::validateOnMigrate);
|
||||
}
|
||||
|
||||
private void configureCallbacks(FluentConfiguration configuration) {
|
||||
if (!this.callbacks.isEmpty()) {
|
||||
configuration.callbacks(this.callbacks.toArray(new Callback[0]));
|
||||
private void configureCallbacks(FluentConfiguration configuration,
|
||||
List<Callback> callbacks) {
|
||||
if (!callbacks.isEmpty()) {
|
||||
configuration.callbacks(callbacks.toArray(new Callback[0]));
|
||||
}
|
||||
}
|
||||
|
||||
private void configureFlywayCallbacks(Flyway flyway) {
|
||||
if (!this.flywayCallbacks.isEmpty()) {
|
||||
if (!this.callbacks.isEmpty()) {
|
||||
private void configureFlywayCallbacks(Flyway flyway, List<Callback> callbacks,
|
||||
List<FlywayCallback> flywayCallbacks) {
|
||||
if (!flywayCallbacks.isEmpty()) {
|
||||
if (!callbacks.isEmpty()) {
|
||||
throw new IllegalStateException(
|
||||
"Found a mixture of Callback and FlywayCallback beans."
|
||||
+ " One type must be used exclusively.");
|
||||
}
|
||||
flyway.setCallbacks(this.flywayCallbacks.toArray(new FlywayCallback[0]));
|
||||
flyway.setCallbacks(flywayCallbacks.toArray(new FlywayCallback[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -274,9 +251,10 @@ public class FlywayAutoConfiguration {
|
|||
return (value != null) ? value : defaultValue.get();
|
||||
}
|
||||
|
||||
private boolean hasAtLeastOneLocation(String... locations) {
|
||||
private boolean hasAtLeastOneLocation(ResourceLoader resourceLoader,
|
||||
String... locations) {
|
||||
for (String location : locations) {
|
||||
if (this.resourceLoader.getResource(normalizePrefix(location)).exists()) {
|
||||
if (resourceLoader.getResource(normalizePrefix(location)).exists()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -289,8 +267,10 @@ public class FlywayAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public FlywayMigrationInitializer flywayInitializer(Flyway flyway) {
|
||||
return new FlywayMigrationInitializer(flyway, this.migrationStrategy);
|
||||
public FlywayMigrationInitializer flywayInitializer(Flyway flyway,
|
||||
ObjectProvider<FlywayMigrationStrategy> migrationStrategy) {
|
||||
return new FlywayMigrationInitializer(flyway,
|
||||
migrationStrategy.getIfAvailable());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -74,14 +74,11 @@ public class GroovyTemplateAutoConfiguration {
|
|||
|
||||
private final GroovyTemplateProperties properties;
|
||||
|
||||
private final MarkupTemplateEngine templateEngine;
|
||||
|
||||
public GroovyMarkupConfiguration(ApplicationContext applicationContext,
|
||||
GroovyTemplateProperties properties,
|
||||
ObjectProvider<MarkupTemplateEngine> templateEngine) {
|
||||
this.applicationContext = applicationContext;
|
||||
this.properties = properties;
|
||||
this.templateEngine = templateEngine.getIfAvailable();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
|
|
@ -124,13 +121,12 @@ public class GroovyTemplateAutoConfiguration {
|
|||
@Bean
|
||||
@ConditionalOnMissingBean(GroovyMarkupConfig.class)
|
||||
@ConfigurationProperties(prefix = "spring.groovy.template.configuration")
|
||||
public GroovyMarkupConfigurer groovyMarkupConfigurer() {
|
||||
public GroovyMarkupConfigurer groovyMarkupConfigurer(
|
||||
ObjectProvider<MarkupTemplateEngine> templateEngine) {
|
||||
GroovyMarkupConfigurer configurer = new GroovyMarkupConfigurer();
|
||||
configurer.setResourceLoaderPath(this.properties.getResourceLoaderPath());
|
||||
configurer.setCacheTemplates(this.properties.isCache());
|
||||
if (this.templateEngine != null) {
|
||||
configurer.setTemplateEngine(this.templateEngine);
|
||||
}
|
||||
templateEngine.ifAvailable(configurer::setTemplateEngine);
|
||||
return configurer;
|
||||
}
|
||||
|
||||
|
|
@ -143,17 +139,12 @@ public class GroovyTemplateAutoConfiguration {
|
|||
@ConditionalOnProperty(name = "spring.groovy.template.enabled", matchIfMissing = true)
|
||||
public static class GroovyWebConfiguration {
|
||||
|
||||
private final GroovyTemplateProperties properties;
|
||||
|
||||
public GroovyWebConfiguration(GroovyTemplateProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "groovyMarkupViewResolver")
|
||||
public GroovyMarkupViewResolver groovyMarkupViewResolver() {
|
||||
public GroovyMarkupViewResolver groovyMarkupViewResolver(
|
||||
GroovyTemplateProperties properties) {
|
||||
GroovyMarkupViewResolver resolver = new GroovyMarkupViewResolver();
|
||||
this.properties.applyToMvcViewResolver(resolver);
|
||||
properties.applyToMvcViewResolver(resolver);
|
||||
return resolver;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -43,19 +43,13 @@ import org.springframework.context.annotation.Configuration;
|
|||
@EnableConfigurationProperties(H2ConsoleProperties.class)
|
||||
public class H2ConsoleAutoConfiguration {
|
||||
|
||||
private final H2ConsoleProperties properties;
|
||||
|
||||
public H2ConsoleAutoConfiguration(H2ConsoleProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ServletRegistrationBean<WebServlet> h2Console() {
|
||||
String path = this.properties.getPath();
|
||||
public ServletRegistrationBean<WebServlet> h2Console(H2ConsoleProperties properties) {
|
||||
String path = properties.getPath();
|
||||
String urlMapping = path + (path.endsWith("/") ? "*" : "/*");
|
||||
ServletRegistrationBean<WebServlet> registration = new ServletRegistrationBean<>(
|
||||
new WebServlet(), urlMapping);
|
||||
H2ConsoleProperties.Settings settings = this.properties.getSettings();
|
||||
H2ConsoleProperties.Settings settings = properties.getSettings();
|
||||
if (settings.isTrace()) {
|
||||
registration.addInitParameter("trace", "");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.http;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
|
|
@ -64,17 +63,12 @@ public class HttpMessageConvertersAutoConfiguration {
|
|||
|
||||
static final String PREFERRED_MAPPER_PROPERTY = "spring.http.converters.preferred-json-mapper";
|
||||
|
||||
private final List<HttpMessageConverter<?>> converters;
|
||||
|
||||
public HttpMessageConvertersAutoConfiguration(
|
||||
ObjectProvider<HttpMessageConverter<?>> convertersProvider) {
|
||||
this.converters = convertersProvider.orderedStream().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public HttpMessageConverters messageConverters() {
|
||||
return new HttpMessageConverters(this.converters);
|
||||
public HttpMessageConverters messageConverters(
|
||||
ObjectProvider<HttpMessageConverter<?>> converters) {
|
||||
return new HttpMessageConverters(
|
||||
converters.orderedStream().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
|
@ -82,17 +76,12 @@ public class HttpMessageConvertersAutoConfiguration {
|
|||
@EnableConfigurationProperties(HttpProperties.class)
|
||||
protected static class StringHttpMessageConverterConfiguration {
|
||||
|
||||
private final HttpProperties.Encoding properties;
|
||||
|
||||
protected StringHttpMessageConverterConfiguration(HttpProperties httpProperties) {
|
||||
this.properties = httpProperties.getEncoding();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public StringHttpMessageConverter stringHttpMessageConverter() {
|
||||
public StringHttpMessageConverter stringHttpMessageConverter(
|
||||
HttpProperties httpProperties) {
|
||||
StringHttpMessageConverter converter = new StringHttpMessageConverter(
|
||||
this.properties.getCharset());
|
||||
httpProperties.getEncoding().getCharset());
|
||||
converter.setWriteAcceptCharset(false);
|
||||
return converter;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -46,16 +46,15 @@ public class InfluxDbAutoConfiguration {
|
|||
|
||||
private static final Log logger = LogFactory.getLog(InfluxDbAutoConfiguration.class);
|
||||
|
||||
private final InfluxDbProperties properties;
|
||||
|
||||
private final OkHttpClient.Builder builder;
|
||||
|
||||
public InfluxDbAutoConfiguration(InfluxDbProperties properties,
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnProperty("spring.influx.url")
|
||||
public InfluxDB influxDb(InfluxDbProperties properties,
|
||||
ObjectProvider<InfluxDbOkHttpClientBuilderProvider> builder,
|
||||
ObjectProvider<OkHttpClient.Builder> deprecatedBuilder) {
|
||||
this.properties = properties;
|
||||
this.builder = determineBuilder(builder.getIfAvailable(),
|
||||
deprecatedBuilder.getIfAvailable());
|
||||
return new InfluxDBImpl(properties.getUrl(), properties.getUser(),
|
||||
properties.getPassword(), determineBuilder(builder.getIfAvailable(),
|
||||
deprecatedBuilder.getIfAvailable()));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
|
@ -75,12 +74,4 @@ public class InfluxDbAutoConfiguration {
|
|||
return new OkHttpClient.Builder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnProperty("spring.influx.url")
|
||||
public InfluxDB influxDb() {
|
||||
return new InfluxDBImpl(this.properties.getUrl(), this.properties.getUser(),
|
||||
this.properties.getPassword(), this.builder);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -19,9 +19,7 @@ package org.springframework.boot.autoconfigure.integration;
|
|||
import javax.management.MBeanServer;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
|
|
@ -32,7 +30,6 @@ import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
|||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
|
@ -81,34 +78,19 @@ public class IntegrationAutoConfiguration {
|
|||
@ConditionalOnMissingBean(value = IntegrationMBeanExporter.class, search = SearchStrategy.CURRENT)
|
||||
@ConditionalOnBean(MBeanServer.class)
|
||||
@ConditionalOnProperty(prefix = "spring.jmx", name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
protected static class IntegrationJmxConfiguration
|
||||
implements EnvironmentAware, BeanFactoryAware {
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
private Environment environment;
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnvironment(Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
protected static class IntegrationJmxConfiguration {
|
||||
|
||||
@Bean
|
||||
public IntegrationMBeanExporter integrationMbeanExporter() {
|
||||
public IntegrationMBeanExporter integrationMbeanExporter(BeanFactory beanFactory,
|
||||
Environment environment) {
|
||||
IntegrationMBeanExporter exporter = new IntegrationMBeanExporter();
|
||||
String defaultDomain = this.environment
|
||||
.getProperty("spring.jmx.default-domain");
|
||||
String defaultDomain = environment.getProperty("spring.jmx.default-domain");
|
||||
if (StringUtils.hasLength(defaultDomain)) {
|
||||
exporter.setDefaultDomain(defaultDomain);
|
||||
}
|
||||
String serverBean = this.environment.getProperty("spring.jmx.server",
|
||||
String serverBean = environment.getProperty("spring.jmx.server",
|
||||
"mbeanServer");
|
||||
exporter.setServer(this.beanFactory.getBean(serverBean, MBeanServer.class));
|
||||
exporter.setServer(beanFactory.getBean(serverBean, MBeanServer.class));
|
||||
return exporter;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -116,16 +116,12 @@ public class JacksonAutoConfiguration {
|
|||
private static final Log logger = LogFactory
|
||||
.getLog(JodaDateTimeJacksonConfiguration.class);
|
||||
|
||||
private final JacksonProperties jacksonProperties;
|
||||
|
||||
JodaDateTimeJacksonConfiguration(JacksonProperties jacksonProperties) {
|
||||
this.jacksonProperties = jacksonProperties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SimpleModule jodaDateTimeSerializationModule() {
|
||||
public SimpleModule jodaDateTimeSerializationModule(
|
||||
JacksonProperties jacksonProperties) {
|
||||
SimpleModule module = new SimpleModule();
|
||||
JacksonJodaDateFormat jacksonJodaFormat = getJacksonJodaDateFormat();
|
||||
JacksonJodaDateFormat jacksonJodaFormat = getJacksonJodaDateFormat(
|
||||
jacksonProperties);
|
||||
if (jacksonJodaFormat != null) {
|
||||
module.addSerializer(DateTime.class,
|
||||
new DateTimeSerializer(jacksonJodaFormat, 0));
|
||||
|
|
@ -133,17 +129,17 @@ public class JacksonAutoConfiguration {
|
|||
return module;
|
||||
}
|
||||
|
||||
private JacksonJodaDateFormat getJacksonJodaDateFormat() {
|
||||
if (this.jacksonProperties.getJodaDateTimeFormat() != null) {
|
||||
private JacksonJodaDateFormat getJacksonJodaDateFormat(
|
||||
JacksonProperties jacksonProperties) {
|
||||
if (jacksonProperties.getJodaDateTimeFormat() != null) {
|
||||
return new JacksonJodaDateFormat(DateTimeFormat
|
||||
.forPattern(this.jacksonProperties.getJodaDateTimeFormat())
|
||||
.forPattern(jacksonProperties.getJodaDateTimeFormat())
|
||||
.withZoneUTC());
|
||||
}
|
||||
if (this.jacksonProperties.getDateFormat() != null) {
|
||||
if (jacksonProperties.getDateFormat() != null) {
|
||||
try {
|
||||
return new JacksonJodaDateFormat(DateTimeFormat
|
||||
.forPattern(this.jacksonProperties.getDateFormat())
|
||||
.withZoneUTC());
|
||||
.forPattern(jacksonProperties.getDateFormat()).withZoneUTC());
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
|
|
@ -175,18 +171,13 @@ public class JacksonAutoConfiguration {
|
|||
@ConditionalOnClass(Jackson2ObjectMapperBuilder.class)
|
||||
static class JacksonObjectMapperBuilderConfiguration {
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
JacksonObjectMapperBuilderConfiguration(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder(
|
||||
ApplicationContext applicationContext,
|
||||
List<Jackson2ObjectMapperBuilderCustomizer> customizers) {
|
||||
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
|
||||
builder.applicationContext(this.applicationContext);
|
||||
builder.applicationContext(applicationContext);
|
||||
customize(builder, customizers);
|
||||
return builder;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -52,26 +52,14 @@ public class DataSourceTransactionManagerAutoConfiguration {
|
|||
@ConditionalOnSingleCandidate(DataSource.class)
|
||||
static class DataSourceTransactionManagerConfiguration {
|
||||
|
||||
private final DataSource dataSource;
|
||||
|
||||
private final TransactionManagerCustomizers transactionManagerCustomizers;
|
||||
|
||||
DataSourceTransactionManagerConfiguration(DataSource dataSource,
|
||||
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
|
||||
this.dataSource = dataSource;
|
||||
this.transactionManagerCustomizers = transactionManagerCustomizers
|
||||
.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(PlatformTransactionManager.class)
|
||||
public DataSourceTransactionManager transactionManager(
|
||||
DataSourceProperties properties) {
|
||||
public DataSourceTransactionManager transactionManager(DataSource dataSource,
|
||||
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
|
||||
DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(
|
||||
this.dataSource);
|
||||
if (this.transactionManagerCustomizers != null) {
|
||||
this.transactionManagerCustomizers.customize(transactionManager);
|
||||
}
|
||||
dataSource);
|
||||
transactionManagerCustomizers.ifAvailable(
|
||||
(customizers) -> customizers.customize(transactionManager));
|
||||
return transactionManager;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.jdbc;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.jdbc.EmbeddedDatabaseConnection;
|
||||
|
|
@ -37,34 +35,18 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
|||
@EnableConfigurationProperties(DataSourceProperties.class)
|
||||
public class EmbeddedDataSourceConfiguration implements BeanClassLoaderAware {
|
||||
|
||||
private EmbeddedDatabase database;
|
||||
|
||||
private ClassLoader classLoader;
|
||||
|
||||
private final DataSourceProperties properties;
|
||||
|
||||
public EmbeddedDataSourceConfiguration(DataSourceProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
this.classLoader = classLoader;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public EmbeddedDatabase dataSource() {
|
||||
this.database = new EmbeddedDatabaseBuilder()
|
||||
@Bean(destroyMethod = "shutdown")
|
||||
public EmbeddedDatabase dataSource(DataSourceProperties properties) {
|
||||
return new EmbeddedDatabaseBuilder()
|
||||
.setType(EmbeddedDatabaseConnection.get(this.classLoader).getType())
|
||||
.setName(this.properties.determineDatabaseName()).build();
|
||||
return this.database;
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void close() {
|
||||
if (this.database != null) {
|
||||
this.database.shutdown();
|
||||
}
|
||||
.setName(properties.determineDatabaseName()).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -53,21 +53,13 @@ public class JdbcTemplateAutoConfiguration {
|
|||
@Configuration
|
||||
static class JdbcTemplateConfiguration {
|
||||
|
||||
private final DataSource dataSource;
|
||||
|
||||
private final JdbcProperties properties;
|
||||
|
||||
JdbcTemplateConfiguration(DataSource dataSource, JdbcProperties properties) {
|
||||
this.dataSource = dataSource;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
@ConditionalOnMissingBean(JdbcOperations.class)
|
||||
public JdbcTemplate jdbcTemplate() {
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(this.dataSource);
|
||||
JdbcProperties.Template template = this.properties.getTemplate();
|
||||
public JdbcTemplate jdbcTemplate(DataSource dataSource,
|
||||
JdbcProperties properties) {
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
JdbcProperties.Template template = properties.getTemplate();
|
||||
jdbcTemplate.setFetchSize(template.getFetchSize());
|
||||
jdbcTemplate.setMaxRows(template.getMaxRows());
|
||||
if (template.getQueryTimeout() != null) {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -48,24 +48,20 @@ import org.springframework.jmx.support.JmxUtils;
|
|||
@EnableConfigurationProperties(DataSourceProperties.class)
|
||||
public class JndiDataSourceAutoConfiguration {
|
||||
|
||||
private final ApplicationContext context;
|
||||
|
||||
public JndiDataSourceAutoConfiguration(ApplicationContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Bean(destroyMethod = "")
|
||||
@ConditionalOnMissingBean
|
||||
public DataSource dataSource(DataSourceProperties properties) {
|
||||
public DataSource dataSource(DataSourceProperties properties,
|
||||
ApplicationContext context) {
|
||||
JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup();
|
||||
DataSource dataSource = dataSourceLookup.getDataSource(properties.getJndiName());
|
||||
excludeMBeanIfNecessary(dataSource, "dataSource");
|
||||
excludeMBeanIfNecessary(dataSource, "dataSource", context);
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
private void excludeMBeanIfNecessary(Object candidate, String beanName) {
|
||||
for (MBeanExporter mbeanExporter : this.context
|
||||
.getBeansOfType(MBeanExporter.class).values()) {
|
||||
private void excludeMBeanIfNecessary(Object candidate, String beanName,
|
||||
ApplicationContext context) {
|
||||
for (MBeanExporter mbeanExporter : context.getBeansOfType(MBeanExporter.class)
|
||||
.values()) {
|
||||
if (JmxUtils.isMBean(candidate.getClass())) {
|
||||
mbeanExporter.addExcludedBean(beanName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -61,28 +61,14 @@ import org.springframework.util.StringUtils;
|
|||
@ConditionalOnMissingBean(DataSource.class)
|
||||
public class XADataSourceAutoConfiguration implements BeanClassLoaderAware {
|
||||
|
||||
private final XADataSourceWrapper wrapper;
|
||||
|
||||
private final DataSourceProperties properties;
|
||||
|
||||
private final XADataSource xaDataSource;
|
||||
|
||||
private ClassLoader classLoader;
|
||||
|
||||
public XADataSourceAutoConfiguration(XADataSourceWrapper wrapper,
|
||||
DataSourceProperties properties, ObjectProvider<XADataSource> xaDataSource) {
|
||||
this.wrapper = wrapper;
|
||||
this.properties = properties;
|
||||
this.xaDataSource = xaDataSource.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() throws Exception {
|
||||
XADataSource xaDataSource = this.xaDataSource;
|
||||
if (xaDataSource == null) {
|
||||
xaDataSource = createXaDataSource();
|
||||
}
|
||||
return this.wrapper.wrapDataSource(xaDataSource);
|
||||
public DataSource dataSource(XADataSourceWrapper wrapper,
|
||||
DataSourceProperties properties, ObjectProvider<XADataSource> xaDataSource)
|
||||
throws Exception {
|
||||
return wrapper.wrapDataSource(
|
||||
xaDataSource.getIfAvailable(() -> createXaDataSource(properties)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -90,16 +76,16 @@ public class XADataSourceAutoConfiguration implements BeanClassLoaderAware {
|
|||
this.classLoader = classLoader;
|
||||
}
|
||||
|
||||
private XADataSource createXaDataSource() {
|
||||
String className = this.properties.getXa().getDataSourceClassName();
|
||||
private XADataSource createXaDataSource(DataSourceProperties properties) {
|
||||
String className = properties.getXa().getDataSourceClassName();
|
||||
if (!StringUtils.hasLength(className)) {
|
||||
className = DatabaseDriver.fromJdbcUrl(this.properties.determineUrl())
|
||||
className = DatabaseDriver.fromJdbcUrl(properties.determineUrl())
|
||||
.getXaDataSourceClassName();
|
||||
}
|
||||
Assert.state(StringUtils.hasLength(className),
|
||||
"No XA DataSource class name specified");
|
||||
XADataSource dataSource = createXaDataSourceInstance(className);
|
||||
bindXaProperties(dataSource, this.properties);
|
||||
bindXaProperties(dataSource, properties);
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
|
|
@ -125,9 +111,9 @@ public class XADataSourceAutoConfiguration implements BeanClassLoaderAware {
|
|||
private ConfigurationPropertySource getBinderSource(
|
||||
DataSourceProperties dataSourceProperties) {
|
||||
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
|
||||
source.put("user", this.properties.determineUsername());
|
||||
source.put("password", this.properties.determinePassword());
|
||||
source.put("url", this.properties.determineUrl());
|
||||
source.put("user", dataSourceProperties.determineUsername());
|
||||
source.put("password", dataSourceProperties.determinePassword());
|
||||
source.put("url", dataSourceProperties.determineUrl());
|
||||
source.putAll(dataSourceProperties.getXa().getProperties());
|
||||
ConfigurationPropertyNameAliases aliases = new ConfigurationPropertyNameAliases();
|
||||
aliases.addAliases("user", "username");
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -55,28 +55,23 @@ public class JndiConnectionFactoryAutoConfiguration {
|
|||
private static final String[] JNDI_LOCATIONS = { "java:/JmsXA",
|
||||
"java:/XAConnectionFactory" };
|
||||
|
||||
private final JmsProperties properties;
|
||||
|
||||
private final JndiLocatorDelegate jndiLocatorDelegate;
|
||||
|
||||
public JndiConnectionFactoryAutoConfiguration(JmsProperties properties) {
|
||||
this.properties = properties;
|
||||
this.jndiLocatorDelegate = JndiLocatorDelegate.createDefaultResourceRefLocator();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ConnectionFactory connectionFactory() throws NamingException {
|
||||
if (StringUtils.hasLength(this.properties.getJndiName())) {
|
||||
return this.jndiLocatorDelegate.lookup(this.properties.getJndiName(),
|
||||
public ConnectionFactory connectionFactory(JmsProperties properties)
|
||||
throws NamingException {
|
||||
JndiLocatorDelegate jndiLocatorDelegate = JndiLocatorDelegate
|
||||
.createDefaultResourceRefLocator();
|
||||
if (StringUtils.hasLength(properties.getJndiName())) {
|
||||
return jndiLocatorDelegate.lookup(properties.getJndiName(),
|
||||
ConnectionFactory.class);
|
||||
}
|
||||
return findJndiConnectionFactory();
|
||||
return findJndiConnectionFactory(jndiLocatorDelegate);
|
||||
}
|
||||
|
||||
private ConnectionFactory findJndiConnectionFactory() {
|
||||
private ConnectionFactory findJndiConnectionFactory(
|
||||
JndiLocatorDelegate jndiLocatorDelegate) {
|
||||
for (String name : JNDI_LOCATIONS) {
|
||||
try {
|
||||
return this.jndiLocatorDelegate.lookup(name, ConnectionFactory.class);
|
||||
return jndiLocatorDelegate.lookup(name, ConnectionFactory.class);
|
||||
}
|
||||
catch (NamingException ex) {
|
||||
// Swallow and continue
|
||||
|
|
|
|||
|
|
@ -54,16 +54,12 @@ class ActiveMQConnectionFactoryConfiguration {
|
|||
@ConditionalOnProperty(prefix = "spring.activemq.pool", name = "enabled", havingValue = "false", matchIfMissing = true)
|
||||
static class SimpleConnectionFactoryConfiguration {
|
||||
|
||||
private final JmsProperties jmsProperties;
|
||||
|
||||
private final ActiveMQProperties properties;
|
||||
|
||||
private final List<ActiveMQConnectionFactoryCustomizer> connectionFactoryCustomizers;
|
||||
|
||||
SimpleConnectionFactoryConfiguration(JmsProperties jmsProperties,
|
||||
ActiveMQProperties properties,
|
||||
SimpleConnectionFactoryConfiguration(ActiveMQProperties properties,
|
||||
ObjectProvider<ActiveMQConnectionFactoryCustomizer> connectionFactoryCustomizers) {
|
||||
this.jmsProperties = jmsProperties;
|
||||
this.properties = properties;
|
||||
this.connectionFactoryCustomizers = connectionFactoryCustomizers
|
||||
.orderedStream().collect(Collectors.toList());
|
||||
|
|
@ -71,8 +67,9 @@ class ActiveMQConnectionFactoryConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "spring.jms.cache", name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
public CachingConnectionFactory cachingJmsConnectionFactory() {
|
||||
JmsProperties.Cache cacheProperties = this.jmsProperties.getCache();
|
||||
public CachingConnectionFactory cachingJmsConnectionFactory(
|
||||
JmsProperties jmsProperties) {
|
||||
JmsProperties.Cache cacheProperties = jmsProperties.getCache();
|
||||
CachingConnectionFactory connectionFactory = new CachingConnectionFactory(
|
||||
createConnectionFactory());
|
||||
connectionFactory.setCacheConsumers(cacheProperties.isConsumers());
|
||||
|
|
|
|||
|
|
@ -48,23 +48,21 @@ class ArtemisConnectionFactoryConfiguration {
|
|||
@ConditionalOnProperty(prefix = "spring.artemis.pool", name = "enabled", havingValue = "false", matchIfMissing = true)
|
||||
static class SimpleConnectionFactoryConfiguration {
|
||||
|
||||
private final JmsProperties jmsProperties;
|
||||
|
||||
private final ArtemisProperties properties;
|
||||
|
||||
private final ListableBeanFactory beanFactory;
|
||||
|
||||
SimpleConnectionFactoryConfiguration(JmsProperties jmsProperties,
|
||||
ArtemisProperties properties, ListableBeanFactory beanFactory) {
|
||||
this.jmsProperties = jmsProperties;
|
||||
SimpleConnectionFactoryConfiguration(ArtemisProperties properties,
|
||||
ListableBeanFactory beanFactory) {
|
||||
this.properties = properties;
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "spring.jms.cache", name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
public CachingConnectionFactory cachingJmsConnectionFactory() {
|
||||
JmsProperties.Cache cacheProperties = this.jmsProperties.getCache();
|
||||
public CachingConnectionFactory cachingJmsConnectionFactory(
|
||||
JmsProperties jmsProperties) {
|
||||
JmsProperties.Cache cacheProperties = jmsProperties.getCache();
|
||||
CachingConnectionFactory connectionFactory = new CachingConnectionFactory(
|
||||
createConnectionFactory());
|
||||
connectionFactory.setCacheConsumers(cacheProperties.isConsumers());
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.jms.artemis;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -49,22 +48,8 @@ class ArtemisEmbeddedServerConfiguration {
|
|||
|
||||
private final ArtemisProperties properties;
|
||||
|
||||
private final ObjectProvider<ArtemisConfigurationCustomizer> configurationCustomizers;
|
||||
|
||||
private final List<JMSQueueConfiguration> queuesConfiguration;
|
||||
|
||||
private final List<TopicConfiguration> topicsConfiguration;
|
||||
|
||||
ArtemisEmbeddedServerConfiguration(ArtemisProperties properties,
|
||||
ObjectProvider<ArtemisConfigurationCustomizer> configurationCustomizers,
|
||||
ObjectProvider<JMSQueueConfiguration> queuesConfiguration,
|
||||
ObjectProvider<TopicConfiguration> topicsConfiguration) {
|
||||
ArtemisEmbeddedServerConfiguration(ArtemisProperties properties) {
|
||||
this.properties = properties;
|
||||
this.configurationCustomizers = configurationCustomizers;
|
||||
this.queuesConfiguration = queuesConfiguration.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
this.topicsConfiguration = topicsConfiguration.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
@ -78,35 +63,33 @@ class ArtemisEmbeddedServerConfiguration {
|
|||
@ConditionalOnMissingBean
|
||||
public EmbeddedJMS artemisServer(
|
||||
org.apache.activemq.artemis.core.config.Configuration configuration,
|
||||
JMSConfiguration jmsConfiguration) {
|
||||
JMSConfiguration jmsConfiguration,
|
||||
ObjectProvider<ArtemisConfigurationCustomizer> configurationCustomizers) {
|
||||
EmbeddedJMS server = new EmbeddedJMS();
|
||||
customize(configuration);
|
||||
configurationCustomizers.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(configuration));
|
||||
server.setConfiguration(configuration);
|
||||
server.setJmsConfiguration(jmsConfiguration);
|
||||
server.setRegistry(new ArtemisNoOpBindingRegistry());
|
||||
return server;
|
||||
}
|
||||
|
||||
private void customize(
|
||||
org.apache.activemq.artemis.core.config.Configuration configuration) {
|
||||
this.configurationCustomizers.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(configuration));
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public JMSConfiguration artemisJmsConfiguration() {
|
||||
public JMSConfiguration artemisJmsConfiguration(
|
||||
ObjectProvider<JMSQueueConfiguration> queuesConfiguration,
|
||||
ObjectProvider<TopicConfiguration> topicsConfiguration) {
|
||||
JMSConfiguration configuration = new JMSConfigurationImpl();
|
||||
addAll(configuration.getQueueConfigurations(), this.queuesConfiguration);
|
||||
addAll(configuration.getTopicConfigurations(), this.topicsConfiguration);
|
||||
addAll(configuration.getQueueConfigurations(), queuesConfiguration);
|
||||
addAll(configuration.getTopicConfigurations(), topicsConfiguration);
|
||||
addQueues(configuration, this.properties.getEmbedded().getQueues());
|
||||
addTopics(configuration, this.properties.getEmbedded().getTopics());
|
||||
return configuration;
|
||||
}
|
||||
|
||||
private <T> void addAll(List<T> list, Collection<? extends T> items) {
|
||||
private <T> void addAll(List<T> list, ObjectProvider<T> items) {
|
||||
if (items != null) {
|
||||
list.addAll(items);
|
||||
list.addAll(items.orderedStream().collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -18,15 +18,12 @@ package org.springframework.boot.autoconfigure.jmx;
|
|||
|
||||
import javax.management.MBeanServer;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.EnableMBeanExport;
|
||||
|
|
@ -54,33 +51,26 @@ import org.springframework.util.StringUtils;
|
|||
@Configuration
|
||||
@ConditionalOnClass({ MBeanExporter.class })
|
||||
@ConditionalOnProperty(prefix = "spring.jmx", name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
public class JmxAutoConfiguration implements EnvironmentAware, BeanFactoryAware {
|
||||
public class JmxAutoConfiguration {
|
||||
|
||||
private Environment environment;
|
||||
private final Environment environment;
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
public void setEnvironment(Environment environment) {
|
||||
public JmxAutoConfiguration(Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
@ConditionalOnMissingBean(value = MBeanExporter.class, search = SearchStrategy.CURRENT)
|
||||
public AnnotationMBeanExporter mbeanExporter(ObjectNamingStrategy namingStrategy) {
|
||||
public AnnotationMBeanExporter mbeanExporter(ObjectNamingStrategy namingStrategy,
|
||||
BeanFactory beanFactory) {
|
||||
AnnotationMBeanExporter exporter = new AnnotationMBeanExporter();
|
||||
exporter.setRegistrationPolicy(RegistrationPolicy.FAIL_ON_EXISTING);
|
||||
exporter.setNamingStrategy(namingStrategy);
|
||||
String serverBean = this.environment.getProperty("spring.jmx.server",
|
||||
"mbeanServer");
|
||||
if (StringUtils.hasLength(serverBean)) {
|
||||
exporter.setServer(this.beanFactory.getBean(serverBean, MBeanServer.class));
|
||||
exporter.setServer(beanFactory.getBean(serverBean, MBeanServer.class));
|
||||
}
|
||||
return exporter;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -90,56 +90,6 @@ public class JooqAutoConfiguration {
|
|||
@EnableConfigurationProperties(JooqProperties.class)
|
||||
public static class DslContextConfiguration {
|
||||
|
||||
private final JooqProperties properties;
|
||||
|
||||
private final ConnectionProvider connection;
|
||||
|
||||
private final DataSource dataSource;
|
||||
|
||||
private final TransactionProvider transactionProvider;
|
||||
|
||||
private final RecordMapperProvider recordMapperProvider;
|
||||
|
||||
private final RecordUnmapperProvider recordUnmapperProvider;
|
||||
|
||||
private final Settings settings;
|
||||
|
||||
private final RecordListenerProvider[] recordListenerProviders;
|
||||
|
||||
private final ExecuteListenerProvider[] executeListenerProviders;
|
||||
|
||||
private final VisitListenerProvider[] visitListenerProviders;
|
||||
|
||||
private final TransactionListenerProvider[] transactionListenerProviders;
|
||||
|
||||
private final ExecutorProvider executorProvider;
|
||||
|
||||
public DslContextConfiguration(JooqProperties properties,
|
||||
ConnectionProvider connectionProvider, DataSource dataSource,
|
||||
ObjectProvider<TransactionProvider> transactionProvider,
|
||||
ObjectProvider<RecordMapperProvider> recordMapperProvider,
|
||||
ObjectProvider<RecordUnmapperProvider> recordUnmapperProvider,
|
||||
ObjectProvider<Settings> settings,
|
||||
ObjectProvider<RecordListenerProvider[]> recordListenerProviders,
|
||||
ExecuteListenerProvider[] executeListenerProviders,
|
||||
ObjectProvider<VisitListenerProvider[]> visitListenerProviders,
|
||||
ObjectProvider<TransactionListenerProvider[]> transactionListenerProviders,
|
||||
ObjectProvider<ExecutorProvider> executorProvider) {
|
||||
this.properties = properties;
|
||||
this.connection = connectionProvider;
|
||||
this.dataSource = dataSource;
|
||||
this.transactionProvider = transactionProvider.getIfAvailable();
|
||||
this.recordMapperProvider = recordMapperProvider.getIfAvailable();
|
||||
this.recordUnmapperProvider = recordUnmapperProvider.getIfAvailable();
|
||||
this.settings = settings.getIfAvailable();
|
||||
this.recordListenerProviders = recordListenerProviders.getIfAvailable();
|
||||
this.executeListenerProviders = executeListenerProviders;
|
||||
this.visitListenerProviders = visitListenerProviders.getIfAvailable();
|
||||
this.transactionListenerProviders = transactionListenerProviders
|
||||
.getIfAvailable();
|
||||
this.executorProvider = executorProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DefaultDSLContext dslContext(org.jooq.Configuration configuration) {
|
||||
return new DefaultDSLContext(configuration);
|
||||
|
|
@ -147,30 +97,33 @@ public class JooqAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(org.jooq.Configuration.class)
|
||||
public DefaultConfiguration jooqConfiguration() {
|
||||
public DefaultConfiguration jooqConfiguration(JooqProperties properties,
|
||||
ConnectionProvider connectionProvider, DataSource dataSource,
|
||||
ObjectProvider<TransactionProvider> transactionProvider,
|
||||
ObjectProvider<RecordMapperProvider> recordMapperProvider,
|
||||
ObjectProvider<RecordUnmapperProvider> recordUnmapperProvider,
|
||||
ObjectProvider<Settings> settings,
|
||||
ObjectProvider<RecordListenerProvider> recordListenerProviders,
|
||||
ObjectProvider<ExecuteListenerProvider> executeListenerProviders,
|
||||
ObjectProvider<VisitListenerProvider> visitListenerProviders,
|
||||
ObjectProvider<TransactionListenerProvider> transactionListenerProviders,
|
||||
ObjectProvider<ExecutorProvider> executorProvider) {
|
||||
DefaultConfiguration configuration = new DefaultConfiguration();
|
||||
configuration.set(this.properties.determineSqlDialect(this.dataSource));
|
||||
configuration.set(this.connection);
|
||||
if (this.transactionProvider != null) {
|
||||
configuration.set(this.transactionProvider);
|
||||
}
|
||||
if (this.recordMapperProvider != null) {
|
||||
configuration.set(this.recordMapperProvider);
|
||||
}
|
||||
if (this.recordUnmapperProvider != null) {
|
||||
configuration.set(this.recordUnmapperProvider);
|
||||
}
|
||||
if (this.settings != null) {
|
||||
configuration.set(this.settings);
|
||||
}
|
||||
if (this.executorProvider != null) {
|
||||
configuration.set(this.executorProvider);
|
||||
}
|
||||
configuration.set(this.recordListenerProviders);
|
||||
configuration.set(this.executeListenerProviders);
|
||||
configuration.set(this.visitListenerProviders);
|
||||
configuration
|
||||
.setTransactionListenerProvider(this.transactionListenerProviders);
|
||||
configuration.set(properties.determineSqlDialect(dataSource));
|
||||
configuration.set(connectionProvider);
|
||||
transactionProvider.ifAvailable(configuration::set);
|
||||
recordMapperProvider.ifAvailable(configuration::set);
|
||||
recordUnmapperProvider.ifAvailable(configuration::set);
|
||||
settings.ifAvailable(configuration::set);
|
||||
executorProvider.ifAvailable(configuration::set);
|
||||
configuration.set(recordListenerProviders.orderedStream()
|
||||
.toArray(RecordListenerProvider[]::new));
|
||||
configuration.set(executeListenerProviders.orderedStream()
|
||||
.toArray(ExecuteListenerProvider[]::new));
|
||||
configuration.set(visitListenerProviders.orderedStream()
|
||||
.toArray(VisitListenerProvider[]::new));
|
||||
configuration.setTransactionListenerProvider(transactionListenerProviders
|
||||
.orderedStream().toArray(TransactionListenerProvider[]::new));
|
||||
return configuration;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -58,24 +58,19 @@ public class KafkaAutoConfiguration {
|
|||
|
||||
private final KafkaProperties properties;
|
||||
|
||||
private final RecordMessageConverter messageConverter;
|
||||
|
||||
public KafkaAutoConfiguration(KafkaProperties properties,
|
||||
ObjectProvider<RecordMessageConverter> messageConverter) {
|
||||
public KafkaAutoConfiguration(KafkaProperties properties) {
|
||||
this.properties = properties;
|
||||
this.messageConverter = messageConverter.getIfUnique();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(KafkaTemplate.class)
|
||||
public KafkaTemplate<?, ?> kafkaTemplate(
|
||||
ProducerFactory<Object, Object> kafkaProducerFactory,
|
||||
ProducerListener<Object, Object> kafkaProducerListener) {
|
||||
ProducerListener<Object, Object> kafkaProducerListener,
|
||||
ObjectProvider<RecordMessageConverter> messageConverter) {
|
||||
KafkaTemplate<Object, Object> kafkaTemplate = new KafkaTemplate<>(
|
||||
kafkaProducerFactory);
|
||||
if (this.messageConverter != null) {
|
||||
kafkaTemplate.setMessageConverter(this.messageConverter);
|
||||
}
|
||||
messageConverter.ifUnique(kafkaTemplate::setMessageConverter);
|
||||
kafkaTemplate.setProducerListener(kafkaProducerListener);
|
||||
kafkaTemplate.setDefaultTopic(this.properties.getTemplate().getDefaultTopic());
|
||||
return kafkaTemplate;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -42,26 +42,18 @@ import org.springframework.ldap.core.support.LdapContextSource;
|
|||
@EnableConfigurationProperties(LdapProperties.class)
|
||||
public class LdapAutoConfiguration {
|
||||
|
||||
private final LdapProperties properties;
|
||||
|
||||
private final Environment environment;
|
||||
|
||||
public LdapAutoConfiguration(LdapProperties properties, Environment environment) {
|
||||
this.properties = properties;
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public LdapContextSource ldapContextSource() {
|
||||
public LdapContextSource ldapContextSource(LdapProperties properties,
|
||||
Environment environment) {
|
||||
LdapContextSource source = new LdapContextSource();
|
||||
source.setUserDn(this.properties.getUsername());
|
||||
source.setPassword(this.properties.getPassword());
|
||||
source.setAnonymousReadOnly(this.properties.getAnonymousReadOnly());
|
||||
source.setBase(this.properties.getBase());
|
||||
source.setUrls(this.properties.determineUrls(this.environment));
|
||||
source.setUserDn(properties.getUsername());
|
||||
source.setPassword(properties.getPassword());
|
||||
source.setAnonymousReadOnly(properties.getAnonymousReadOnly());
|
||||
source.setBase(properties.getBase());
|
||||
source.setUrls(properties.determineUrls(environment));
|
||||
source.setBaseEnvironmentProperties(
|
||||
Collections.unmodifiableMap(this.properties.getBaseEnvironment()));
|
||||
Collections.unmodifiableMap(properties.getBaseEnvironment()));
|
||||
return source;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -80,38 +80,29 @@ public class EmbeddedLdapAutoConfiguration {
|
|||
|
||||
private final EmbeddedLdapProperties embeddedProperties;
|
||||
|
||||
private final LdapProperties properties;
|
||||
|
||||
private final ConfigurableApplicationContext applicationContext;
|
||||
|
||||
private final Environment environment;
|
||||
|
||||
private InMemoryDirectoryServer server;
|
||||
|
||||
public EmbeddedLdapAutoConfiguration(EmbeddedLdapProperties embeddedProperties,
|
||||
LdapProperties properties, ConfigurableApplicationContext applicationContext,
|
||||
Environment environment) {
|
||||
public EmbeddedLdapAutoConfiguration(EmbeddedLdapProperties embeddedProperties) {
|
||||
this.embeddedProperties = embeddedProperties;
|
||||
this.properties = properties;
|
||||
this.applicationContext = applicationContext;
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@DependsOn("directoryServer")
|
||||
@ConditionalOnMissingBean
|
||||
public LdapContextSource ldapContextSource() {
|
||||
public LdapContextSource ldapContextSource(Environment environment,
|
||||
LdapProperties properties) {
|
||||
LdapContextSource source = new LdapContextSource();
|
||||
if (hasCredentials(this.embeddedProperties.getCredential())) {
|
||||
source.setUserDn(this.embeddedProperties.getCredential().getUsername());
|
||||
source.setPassword(this.embeddedProperties.getCredential().getPassword());
|
||||
}
|
||||
source.setUrls(this.properties.determineUrls(this.environment));
|
||||
source.setUrls(properties.determineUrls(environment));
|
||||
return source;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public InMemoryDirectoryServer directoryServer() throws LDAPException {
|
||||
public InMemoryDirectoryServer directoryServer(ApplicationContext applicationContext)
|
||||
throws LDAPException {
|
||||
String[] baseDn = StringUtils.toStringArray(this.embeddedProperties.getBaseDn());
|
||||
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(baseDn);
|
||||
if (hasCredentials(this.embeddedProperties.getCredential())) {
|
||||
|
|
@ -124,9 +115,9 @@ public class EmbeddedLdapAutoConfiguration {
|
|||
.createLDAPConfig("LDAP", this.embeddedProperties.getPort());
|
||||
config.setListenerConfigs(listenerConfig);
|
||||
this.server = new InMemoryDirectoryServer(config);
|
||||
importLdif();
|
||||
importLdif(applicationContext);
|
||||
this.server.startListening();
|
||||
setPortProperty(this.applicationContext, this.server.getListenPort());
|
||||
setPortProperty(applicationContext, this.server.getListenPort());
|
||||
return this.server;
|
||||
}
|
||||
|
||||
|
|
@ -158,11 +149,11 @@ public class EmbeddedLdapAutoConfiguration {
|
|||
&& StringUtils.hasText(credential.getPassword());
|
||||
}
|
||||
|
||||
private void importLdif() throws LDAPException {
|
||||
private void importLdif(ApplicationContext applicationContext) throws LDAPException {
|
||||
String location = this.embeddedProperties.getLdif();
|
||||
if (StringUtils.hasText(location)) {
|
||||
try {
|
||||
Resource resource = this.applicationContext.getResource(location);
|
||||
Resource resource = applicationContext.getResource(location);
|
||||
if (resource.exists()) {
|
||||
try (InputStream inputStream = resource.getInputStream()) {
|
||||
this.server.importFromLDIF(true, new LDIFReader(inputStream));
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -83,23 +83,12 @@ public class LiquibaseAutoConfiguration {
|
|||
|
||||
private final LiquibaseProperties properties;
|
||||
|
||||
private final DataSourceProperties dataSourceProperties;
|
||||
|
||||
private final ResourceLoader resourceLoader;
|
||||
|
||||
private final DataSource dataSource;
|
||||
|
||||
private final DataSource liquibaseDataSource;
|
||||
|
||||
public LiquibaseConfiguration(LiquibaseProperties properties,
|
||||
DataSourceProperties dataSourceProperties, ResourceLoader resourceLoader,
|
||||
ObjectProvider<DataSource> dataSource,
|
||||
@LiquibaseDataSource ObjectProvider<DataSource> liquibaseDataSource) {
|
||||
ResourceLoader resourceLoader) {
|
||||
this.properties = properties;
|
||||
this.dataSourceProperties = dataSourceProperties;
|
||||
this.resourceLoader = resourceLoader;
|
||||
this.dataSource = dataSource.getIfUnique();
|
||||
this.liquibaseDataSource = liquibaseDataSource.getIfAvailable();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
|
|
@ -115,8 +104,12 @@ public class LiquibaseAutoConfiguration {
|
|||
}
|
||||
|
||||
@Bean
|
||||
public SpringLiquibase liquibase() {
|
||||
SpringLiquibase liquibase = createSpringLiquibase();
|
||||
public SpringLiquibase liquibase(DataSourceProperties dataSourceProperties,
|
||||
ObjectProvider<DataSource> dataSource,
|
||||
@LiquibaseDataSource ObjectProvider<DataSource> liquibaseDataSource) {
|
||||
SpringLiquibase liquibase = createSpringLiquibase(
|
||||
liquibaseDataSource.getIfAvailable(), dataSource.getIfUnique(),
|
||||
dataSourceProperties);
|
||||
liquibase.setChangeLog(this.properties.getChangeLog());
|
||||
liquibase.setContexts(this.properties.getContexts());
|
||||
liquibase.setDefaultSchema(this.properties.getDefaultSchema());
|
||||
|
|
@ -135,35 +128,39 @@ public class LiquibaseAutoConfiguration {
|
|||
return liquibase;
|
||||
}
|
||||
|
||||
private SpringLiquibase createSpringLiquibase() {
|
||||
DataSource liquibaseDataSource = getDataSource();
|
||||
private SpringLiquibase createSpringLiquibase(DataSource liquibaseDatasource,
|
||||
DataSource dataSource, DataSourceProperties dataSourceProperties) {
|
||||
DataSource liquibaseDataSource = getDataSource(liquibaseDatasource,
|
||||
dataSource);
|
||||
if (liquibaseDataSource != null) {
|
||||
SpringLiquibase liquibase = new SpringLiquibase();
|
||||
liquibase.setDataSource(liquibaseDataSource);
|
||||
return liquibase;
|
||||
}
|
||||
SpringLiquibase liquibase = new DataSourceClosingSpringLiquibase();
|
||||
liquibase.setDataSource(createNewDataSource());
|
||||
liquibase.setDataSource(createNewDataSource(dataSourceProperties));
|
||||
return liquibase;
|
||||
}
|
||||
|
||||
private DataSource getDataSource() {
|
||||
if (this.liquibaseDataSource != null) {
|
||||
return this.liquibaseDataSource;
|
||||
private DataSource getDataSource(DataSource liquibaseDataSource,
|
||||
DataSource dataSource) {
|
||||
if (liquibaseDataSource != null) {
|
||||
return liquibaseDataSource;
|
||||
}
|
||||
if (this.properties.getUrl() == null && this.properties.getUser() == null) {
|
||||
return this.dataSource;
|
||||
return dataSource;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private DataSource createNewDataSource() {
|
||||
private DataSource createNewDataSource(
|
||||
DataSourceProperties dataSourceProperties) {
|
||||
String url = getProperty(this.properties::getUrl,
|
||||
this.dataSourceProperties::getUrl);
|
||||
dataSourceProperties::getUrl);
|
||||
String user = getProperty(this.properties::getUser,
|
||||
this.dataSourceProperties::getUsername);
|
||||
dataSourceProperties::getUsername);
|
||||
String password = getProperty(this.properties::getPassword,
|
||||
this.dataSourceProperties::getPassword);
|
||||
dataSourceProperties::getPassword);
|
||||
return DataSourceBuilder.create().url(url).username(user).password(password)
|
||||
.build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -37,33 +37,27 @@ import org.springframework.mail.javamail.JavaMailSenderImpl;
|
|||
@ConditionalOnProperty(prefix = "spring.mail", name = "host")
|
||||
class MailSenderPropertiesConfiguration {
|
||||
|
||||
private final MailProperties properties;
|
||||
|
||||
MailSenderPropertiesConfiguration(MailProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public JavaMailSenderImpl mailSender() {
|
||||
public JavaMailSenderImpl mailSender(MailProperties properties) {
|
||||
JavaMailSenderImpl sender = new JavaMailSenderImpl();
|
||||
applyProperties(sender);
|
||||
applyProperties(properties, sender);
|
||||
return sender;
|
||||
}
|
||||
|
||||
private void applyProperties(JavaMailSenderImpl sender) {
|
||||
sender.setHost(this.properties.getHost());
|
||||
if (this.properties.getPort() != null) {
|
||||
sender.setPort(this.properties.getPort());
|
||||
private void applyProperties(MailProperties properties, JavaMailSenderImpl sender) {
|
||||
sender.setHost(properties.getHost());
|
||||
if (properties.getPort() != null) {
|
||||
sender.setPort(properties.getPort());
|
||||
}
|
||||
sender.setUsername(this.properties.getUsername());
|
||||
sender.setPassword(this.properties.getPassword());
|
||||
sender.setProtocol(this.properties.getProtocol());
|
||||
if (this.properties.getDefaultEncoding() != null) {
|
||||
sender.setDefaultEncoding(this.properties.getDefaultEncoding().name());
|
||||
sender.setUsername(properties.getUsername());
|
||||
sender.setPassword(properties.getPassword());
|
||||
sender.setProtocol(properties.getProtocol());
|
||||
if (properties.getDefaultEncoding() != null) {
|
||||
sender.setDefaultEncoding(properties.getDefaultEncoding().name());
|
||||
}
|
||||
if (!this.properties.getProperties().isEmpty()) {
|
||||
sender.setJavaMailProperties(asProperties(this.properties.getProperties()));
|
||||
if (!properties.getProperties().isEmpty()) {
|
||||
sender.setJavaMailProperties(asProperties(properties.getProperties()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.mongo;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import com.mongodb.MongoClient;
|
||||
import com.mongodb.MongoClientOptions;
|
||||
|
||||
|
|
@ -45,31 +43,13 @@ import org.springframework.core.env.Environment;
|
|||
@ConditionalOnMissingBean(type = "org.springframework.data.mongodb.MongoDbFactory")
|
||||
public class MongoAutoConfiguration {
|
||||
|
||||
private final MongoClientOptions options;
|
||||
|
||||
private final MongoClientFactory factory;
|
||||
|
||||
private MongoClient mongo;
|
||||
|
||||
public MongoAutoConfiguration(MongoProperties properties,
|
||||
ObjectProvider<MongoClientOptions> options, Environment environment) {
|
||||
this.options = options.getIfAvailable();
|
||||
this.factory = new MongoClientFactory(properties, environment);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void close() {
|
||||
if (this.mongo != null) {
|
||||
this.mongo.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(type = { "com.mongodb.MongoClient",
|
||||
"com.mongodb.client.MongoClient" })
|
||||
public MongoClient mongo() {
|
||||
this.mongo = this.factory.createMongoClient(this.options);
|
||||
return this.mongo;
|
||||
public MongoClient mongo(MongoProperties properties,
|
||||
ObjectProvider<MongoClientOptions> options, Environment environment) {
|
||||
return new MongoClientFactory(properties, environment)
|
||||
.createMongoClient(options.getIfAvailable());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -18,8 +18,6 @@ package org.springframework.boot.autoconfigure.mongo;
|
|||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import com.mongodb.MongoClientSettings;
|
||||
import com.mongodb.connection.netty.NettyStreamFactoryFactory;
|
||||
import com.mongodb.reactivestreams.client.MongoClient;
|
||||
|
|
@ -49,31 +47,16 @@ import org.springframework.core.env.Environment;
|
|||
@EnableConfigurationProperties(MongoProperties.class)
|
||||
public class MongoReactiveAutoConfiguration {
|
||||
|
||||
private final MongoClientSettings settings;
|
||||
|
||||
private MongoClient mongo;
|
||||
|
||||
public MongoReactiveAutoConfiguration(ObjectProvider<MongoClientSettings> settings) {
|
||||
this.settings = settings.getIfAvailable();
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void close() {
|
||||
if (this.mongo != null) {
|
||||
this.mongo.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public MongoClient reactiveStreamsMongoClient(MongoProperties properties,
|
||||
Environment environment,
|
||||
ObjectProvider<MongoClientSettingsBuilderCustomizer> builderCustomizers) {
|
||||
ObjectProvider<MongoClientSettingsBuilderCustomizer> builderCustomizers,
|
||||
ObjectProvider<MongoClientSettings> settings) {
|
||||
ReactiveMongoClientFactory factory = new ReactiveMongoClientFactory(properties,
|
||||
environment,
|
||||
builderCustomizers.orderedStream().collect(Collectors.toList()));
|
||||
this.mongo = factory.createMongoClient(this.settings);
|
||||
return this.mongo;
|
||||
return factory.createMongoClient(settings.getIfAvailable());
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
|
|
|||
|
|
@ -92,30 +92,20 @@ public class EmbeddedMongoAutoConfiguration {
|
|||
|
||||
private final MongoProperties properties;
|
||||
|
||||
private final EmbeddedMongoProperties embeddedProperties;
|
||||
|
||||
private final ApplicationContext context;
|
||||
|
||||
private final IRuntimeConfig runtimeConfig;
|
||||
|
||||
public EmbeddedMongoAutoConfiguration(MongoProperties properties,
|
||||
EmbeddedMongoProperties embeddedProperties, ApplicationContext context,
|
||||
IRuntimeConfig runtimeConfig) {
|
||||
EmbeddedMongoProperties embeddedProperties) {
|
||||
this.properties = properties;
|
||||
this.embeddedProperties = embeddedProperties;
|
||||
this.context = context;
|
||||
this.runtimeConfig = runtimeConfig;
|
||||
}
|
||||
|
||||
@Bean(initMethod = "start", destroyMethod = "stop")
|
||||
@ConditionalOnMissingBean
|
||||
public MongodExecutable embeddedMongoServer(IMongodConfig mongodConfig)
|
||||
throws IOException {
|
||||
public MongodExecutable embeddedMongoServer(IMongodConfig mongodConfig,
|
||||
IRuntimeConfig runtimeConfig, ApplicationContext context) throws IOException {
|
||||
Integer configuredPort = this.properties.getPort();
|
||||
if (configuredPort == null || configuredPort == 0) {
|
||||
setEmbeddedPort(mongodConfig.net().getPort());
|
||||
setEmbeddedPort(context, mongodConfig.net().getPort());
|
||||
}
|
||||
MongodStarter mongodStarter = getMongodStarter(this.runtimeConfig);
|
||||
MongodStarter mongodStarter = getMongodStarter(runtimeConfig);
|
||||
return mongodStarter.prepare(mongodConfig);
|
||||
}
|
||||
|
||||
|
|
@ -128,10 +118,11 @@ public class EmbeddedMongoAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public IMongodConfig embeddedMongoConfiguration() throws IOException {
|
||||
public IMongodConfig embeddedMongoConfiguration(
|
||||
EmbeddedMongoProperties embeddedProperties) throws IOException {
|
||||
MongodConfigBuilder builder = new MongodConfigBuilder()
|
||||
.version(determineVersion());
|
||||
EmbeddedMongoProperties.Storage storage = this.embeddedProperties.getStorage();
|
||||
.version(determineVersion(embeddedProperties));
|
||||
EmbeddedMongoProperties.Storage storage = embeddedProperties.getStorage();
|
||||
if (storage != null) {
|
||||
String databaseDir = storage.getDatabaseDir();
|
||||
String replSetName = storage.getReplSetName();
|
||||
|
|
@ -151,20 +142,19 @@ public class EmbeddedMongoAutoConfiguration {
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
private IFeatureAwareVersion determineVersion() {
|
||||
if (this.embeddedProperties.getFeatures() == null) {
|
||||
private IFeatureAwareVersion determineVersion(
|
||||
EmbeddedMongoProperties embeddedProperties) {
|
||||
if (embeddedProperties.getFeatures() == null) {
|
||||
for (Version version : Version.values()) {
|
||||
if (version.asInDownloadPath()
|
||||
.equals(this.embeddedProperties.getVersion())) {
|
||||
if (version.asInDownloadPath().equals(embeddedProperties.getVersion())) {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
return Versions.withFeatures(
|
||||
new GenericVersion(this.embeddedProperties.getVersion()));
|
||||
return Versions
|
||||
.withFeatures(new GenericVersion(embeddedProperties.getVersion()));
|
||||
}
|
||||
return Versions.withFeatures(
|
||||
new GenericVersion(this.embeddedProperties.getVersion()),
|
||||
this.embeddedProperties.getFeatures().toArray(new Feature[0]));
|
||||
return Versions.withFeatures(new GenericVersion(embeddedProperties.getVersion()),
|
||||
embeddedProperties.getFeatures().toArray(new Feature[0]));
|
||||
}
|
||||
|
||||
private InetAddress getHost() throws UnknownHostException {
|
||||
|
|
@ -175,8 +165,8 @@ public class EmbeddedMongoAutoConfiguration {
|
|||
return InetAddress.getByName(this.properties.getHost());
|
||||
}
|
||||
|
||||
private void setEmbeddedPort(int port) {
|
||||
setPortProperty(this.context, port);
|
||||
private void setEmbeddedPort(ApplicationContext context, int port) {
|
||||
setPortProperty(context, port);
|
||||
}
|
||||
|
||||
private void setPortProperty(ApplicationContext currentContext, int port) {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -52,14 +52,11 @@ public class MustacheAutoConfiguration {
|
|||
|
||||
private final MustacheProperties mustache;
|
||||
|
||||
private final Environment environment;
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
public MustacheAutoConfiguration(MustacheProperties mustache, Environment environment,
|
||||
public MustacheAutoConfiguration(MustacheProperties mustache,
|
||||
ApplicationContext applicationContext) {
|
||||
this.mustache = mustache;
|
||||
this.environment = environment;
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
|
|
@ -78,14 +75,15 @@ public class MustacheAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public Mustache.Compiler mustacheCompiler(TemplateLoader mustacheTemplateLoader) {
|
||||
public Mustache.Compiler mustacheCompiler(TemplateLoader mustacheTemplateLoader,
|
||||
Environment environment) {
|
||||
return Mustache.compiler().withLoader(mustacheTemplateLoader)
|
||||
.withCollector(collector());
|
||||
.withCollector(collector(environment));
|
||||
}
|
||||
|
||||
private Collector collector() {
|
||||
private Collector collector(Environment environment) {
|
||||
MustacheEnvironmentCollector collector = new MustacheEnvironmentCollector();
|
||||
collector.setEnvironment(this.environment);
|
||||
collector.setEnvironment(environment);
|
||||
return collector;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -30,21 +30,16 @@ import org.springframework.core.Ordered;
|
|||
@ConditionalOnWebApplication(type = Type.REACTIVE)
|
||||
class MustacheReactiveWebConfiguration {
|
||||
|
||||
private final MustacheProperties mustache;
|
||||
|
||||
protected MustacheReactiveWebConfiguration(MustacheProperties mustache) {
|
||||
this.mustache = mustache;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public MustacheViewResolver mustacheViewResolver(Compiler mustacheCompiler) {
|
||||
public MustacheViewResolver mustacheViewResolver(Compiler mustacheCompiler,
|
||||
MustacheProperties mustache) {
|
||||
MustacheViewResolver resolver = new MustacheViewResolver(mustacheCompiler);
|
||||
resolver.setPrefix(this.mustache.getPrefix());
|
||||
resolver.setSuffix(this.mustache.getSuffix());
|
||||
resolver.setViewNames(this.mustache.getViewNames());
|
||||
resolver.setRequestContextAttribute(this.mustache.getRequestContextAttribute());
|
||||
resolver.setCharset(this.mustache.getCharsetName());
|
||||
resolver.setPrefix(mustache.getPrefix());
|
||||
resolver.setSuffix(mustache.getSuffix());
|
||||
resolver.setViewNames(mustache.getViewNames());
|
||||
resolver.setRequestContextAttribute(mustache.getRequestContextAttribute());
|
||||
resolver.setCharset(mustache.getCharsetName());
|
||||
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 10);
|
||||
return resolver;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -30,18 +30,13 @@ import org.springframework.core.Ordered;
|
|||
@ConditionalOnWebApplication(type = Type.SERVLET)
|
||||
class MustacheServletWebConfiguration {
|
||||
|
||||
private final MustacheProperties mustache;
|
||||
|
||||
protected MustacheServletWebConfiguration(MustacheProperties mustache) {
|
||||
this.mustache = mustache;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public MustacheViewResolver mustacheViewResolver(Compiler mustacheCompiler) {
|
||||
public MustacheViewResolver mustacheViewResolver(Compiler mustacheCompiler,
|
||||
MustacheProperties mustache) {
|
||||
MustacheViewResolver resolver = new MustacheViewResolver(mustacheCompiler);
|
||||
this.mustache.applyToMvcViewResolver(resolver);
|
||||
resolver.setCharset(this.mustache.getCharsetName());
|
||||
mustache.applyToMvcViewResolver(resolver);
|
||||
resolver.setCharset(mustache.getCharsetName());
|
||||
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 10);
|
||||
return resolver;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ import org.hibernate.cfg.AvailableSettings;
|
|||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
|
||||
import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.jdbc.SchemaManagementProvider;
|
||||
import org.springframework.boot.jdbc.metadata.CompositeDataSourcePoolMetadataProvider;
|
||||
|
|
@ -90,15 +89,13 @@ class HibernateJpaConfiguration extends JpaBaseConfiguration {
|
|||
HibernateJpaConfiguration(DataSource dataSource, JpaProperties jpaProperties,
|
||||
ConfigurableListableBeanFactory beanFactory,
|
||||
ObjectProvider<JtaTransactionManager> jtaTransactionManager,
|
||||
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers,
|
||||
HibernateProperties hibernateProperties,
|
||||
ObjectProvider<Collection<DataSourcePoolMetadataProvider>> metadataProviders,
|
||||
ObjectProvider<SchemaManagementProvider> providers,
|
||||
ObjectProvider<PhysicalNamingStrategy> physicalNamingStrategy,
|
||||
ObjectProvider<ImplicitNamingStrategy> implicitNamingStrategy,
|
||||
ObjectProvider<HibernatePropertiesCustomizer> hibernatePropertiesCustomizers) {
|
||||
super(dataSource, jpaProperties, jtaTransactionManager,
|
||||
transactionManagerCustomizers);
|
||||
super(dataSource, jpaProperties, jtaTransactionManager);
|
||||
this.hibernateProperties = hibernateProperties;
|
||||
this.defaultDdlAutoProvider = new HibernateDefaultDdlAutoProvider(providers);
|
||||
this.poolMetadataProvider = new CompositeDataSourcePoolMetadataProvider(
|
||||
|
|
|
|||
|
|
@ -81,27 +81,22 @@ public abstract class JpaBaseConfiguration implements BeanFactoryAware {
|
|||
|
||||
private final JtaTransactionManager jtaTransactionManager;
|
||||
|
||||
private final TransactionManagerCustomizers transactionManagerCustomizers;
|
||||
|
||||
private ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
protected JpaBaseConfiguration(DataSource dataSource, JpaProperties properties,
|
||||
ObjectProvider<JtaTransactionManager> jtaTransactionManager,
|
||||
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
|
||||
ObjectProvider<JtaTransactionManager> jtaTransactionManager) {
|
||||
this.dataSource = dataSource;
|
||||
this.properties = properties;
|
||||
this.jtaTransactionManager = jtaTransactionManager.getIfAvailable();
|
||||
this.transactionManagerCustomizers = transactionManagerCustomizers
|
||||
.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public PlatformTransactionManager transactionManager() {
|
||||
public PlatformTransactionManager transactionManager(
|
||||
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
|
||||
JpaTransactionManager transactionManager = new JpaTransactionManager();
|
||||
if (this.transactionManagerCustomizers != null) {
|
||||
this.transactionManagerCustomizers.customize(transactionManager);
|
||||
}
|
||||
transactionManagerCustomizers
|
||||
.ifAvailable((customizers) -> customizers.customize(transactionManager));
|
||||
return transactionManager;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,61 +60,37 @@ import org.springframework.transaction.PlatformTransactionManager;
|
|||
HibernateJpaAutoConfiguration.class })
|
||||
public class QuartzAutoConfiguration {
|
||||
|
||||
private final QuartzProperties properties;
|
||||
|
||||
private final ObjectProvider<SchedulerFactoryBeanCustomizer> customizers;
|
||||
|
||||
private final JobDetail[] jobDetails;
|
||||
|
||||
private final Map<String, Calendar> calendars;
|
||||
|
||||
private final Trigger[] triggers;
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
public QuartzAutoConfiguration(QuartzProperties properties,
|
||||
ObjectProvider<SchedulerFactoryBeanCustomizer> customizers,
|
||||
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;
|
||||
this.triggers = triggers.getIfAvailable();
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SchedulerFactoryBean quartzScheduler() {
|
||||
public SchedulerFactoryBean quartzScheduler(QuartzProperties properties,
|
||||
ObjectProvider<SchedulerFactoryBeanCustomizer> customizers,
|
||||
ObjectProvider<JobDetail> jobDetails, Map<String, Calendar> calendars,
|
||||
ObjectProvider<Trigger> triggers, ApplicationContext applicationContext) {
|
||||
SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
|
||||
SpringBeanJobFactory jobFactory = new SpringBeanJobFactory();
|
||||
jobFactory.setApplicationContext(this.applicationContext);
|
||||
jobFactory.setApplicationContext(applicationContext);
|
||||
schedulerFactoryBean.setJobFactory(jobFactory);
|
||||
if (this.properties.getSchedulerName() != null) {
|
||||
schedulerFactoryBean.setSchedulerName(this.properties.getSchedulerName());
|
||||
if (properties.getSchedulerName() != null) {
|
||||
schedulerFactoryBean.setSchedulerName(properties.getSchedulerName());
|
||||
}
|
||||
schedulerFactoryBean.setAutoStartup(this.properties.isAutoStartup());
|
||||
schedulerFactoryBean.setAutoStartup(properties.isAutoStartup());
|
||||
schedulerFactoryBean
|
||||
.setStartupDelay((int) this.properties.getStartupDelay().getSeconds());
|
||||
.setStartupDelay((int) properties.getStartupDelay().getSeconds());
|
||||
schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(
|
||||
this.properties.isWaitForJobsToCompleteOnShutdown());
|
||||
properties.isWaitForJobsToCompleteOnShutdown());
|
||||
schedulerFactoryBean
|
||||
.setOverwriteExistingJobs(this.properties.isOverwriteExistingJobs());
|
||||
if (!this.properties.getProperties().isEmpty()) {
|
||||
.setOverwriteExistingJobs(properties.isOverwriteExistingJobs());
|
||||
if (!properties.getProperties().isEmpty()) {
|
||||
schedulerFactoryBean
|
||||
.setQuartzProperties(asProperties(this.properties.getProperties()));
|
||||
.setQuartzProperties(asProperties(properties.getProperties()));
|
||||
}
|
||||
if (this.jobDetails != null && this.jobDetails.length > 0) {
|
||||
schedulerFactoryBean.setJobDetails(this.jobDetails);
|
||||
}
|
||||
if (this.calendars != null && !this.calendars.isEmpty()) {
|
||||
schedulerFactoryBean.setCalendars(this.calendars);
|
||||
}
|
||||
if (this.triggers != null && this.triggers.length > 0) {
|
||||
schedulerFactoryBean.setTriggers(this.triggers);
|
||||
}
|
||||
customize(schedulerFactoryBean);
|
||||
schedulerFactoryBean
|
||||
.setJobDetails(jobDetails.orderedStream().toArray(JobDetail[]::new));
|
||||
schedulerFactoryBean.setCalendars(calendars);
|
||||
schedulerFactoryBean
|
||||
.setTriggers(triggers.orderedStream().toArray(Trigger[]::new));
|
||||
customizers.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(schedulerFactoryBean));
|
||||
return schedulerFactoryBean;
|
||||
}
|
||||
|
||||
|
|
@ -124,11 +100,6 @@ public class QuartzAutoConfiguration {
|
|||
return properties;
|
||||
}
|
||||
|
||||
private void customize(SchedulerFactoryBean schedulerFactoryBean) {
|
||||
this.customizers.orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(schedulerFactoryBean));
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnSingleCandidate(DataSource.class)
|
||||
protected static class JdbcStoreTypeConfiguration {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -58,19 +58,14 @@ import org.springframework.security.oauth2.client.web.server.ServerOAuth2Authori
|
|||
@ConditionalOnClass({ Flux.class, EnableWebFluxSecurity.class, ClientRegistration.class })
|
||||
public class ReactiveOAuth2ClientAutoConfiguration {
|
||||
|
||||
private final OAuth2ClientProperties properties;
|
||||
|
||||
public ReactiveOAuth2ClientAutoConfiguration(OAuth2ClientProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Conditional(ClientsConfiguredCondition.class)
|
||||
@ConditionalOnMissingBean(ReactiveClientRegistrationRepository.class)
|
||||
public InMemoryReactiveClientRegistrationRepository clientRegistrationRepository() {
|
||||
public InMemoryReactiveClientRegistrationRepository clientRegistrationRepository(
|
||||
OAuth2ClientProperties properties) {
|
||||
List<ClientRegistration> registrations = new ArrayList<>(
|
||||
OAuth2ClientPropertiesRegistrationAdapter
|
||||
.getClientRegistrations(this.properties).values());
|
||||
.getClientRegistrations(properties).values());
|
||||
return new InMemoryReactiveClientRegistrationRepository(registrations);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -42,18 +42,13 @@ import org.springframework.security.oauth2.client.registration.InMemoryClientReg
|
|||
@Conditional(ClientsConfiguredCondition.class)
|
||||
class OAuth2ClientRegistrationRepositoryConfiguration {
|
||||
|
||||
private final OAuth2ClientProperties properties;
|
||||
|
||||
OAuth2ClientRegistrationRepositoryConfiguration(OAuth2ClientProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ClientRegistrationRepository.class)
|
||||
public InMemoryClientRegistrationRepository clientRegistrationRepository() {
|
||||
public InMemoryClientRegistrationRepository clientRegistrationRepository(
|
||||
OAuth2ClientProperties properties) {
|
||||
List<ClientRegistration> registrations = new ArrayList<>(
|
||||
OAuth2ClientPropertiesRegistrationAdapter
|
||||
.getClientRegistrations(this.properties).values());
|
||||
.getClientRegistrations(properties).values());
|
||||
return new InMemoryClientRegistrationRepository(registrations);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -33,17 +33,12 @@ import org.springframework.security.web.server.SecurityWebFilterChain;
|
|||
@ConditionalOnBean(ReactiveJwtDecoder.class)
|
||||
class ReactiveOAuth2ResourceServerWebSecurityConfiguration {
|
||||
|
||||
private final ReactiveJwtDecoder jwtDecoder;
|
||||
|
||||
ReactiveOAuth2ResourceServerWebSecurityConfiguration(ReactiveJwtDecoder jwtDecoder) {
|
||||
this.jwtDecoder = jwtDecoder;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http,
|
||||
ReactiveJwtDecoder jwtDecoder) {
|
||||
http.authorizeExchange().anyExchange().authenticated().and()
|
||||
.oauth2ResourceServer().jwt().jwtDecoder(this.jwtDecoder);
|
||||
.oauth2ResourceServer().jwt().jwtDecoder(jwtDecoder);
|
||||
return http.build();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -43,22 +43,16 @@ import org.springframework.context.annotation.Configuration;
|
|||
@EnableConfigurationProperties(SendGridProperties.class)
|
||||
public class SendGridAutoConfiguration {
|
||||
|
||||
private final SendGridProperties properties;
|
||||
|
||||
public SendGridAutoConfiguration(SendGridProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SendGrid sendGrid() {
|
||||
if (this.properties.isProxyConfigured()) {
|
||||
HttpHost proxy = new HttpHost(this.properties.getProxy().getHost(),
|
||||
this.properties.getProxy().getPort());
|
||||
return new SendGrid(this.properties.getApiKey(),
|
||||
public SendGrid sendGrid(SendGridProperties properties) {
|
||||
if (properties.isProxyConfigured()) {
|
||||
HttpHost proxy = new HttpHost(properties.getProxy().getHost(),
|
||||
properties.getProxy().getPort());
|
||||
return new SendGrid(properties.getApiKey(),
|
||||
new Client(HttpClientBuilder.create().setProxy(proxy).build()));
|
||||
}
|
||||
return new SendGrid(this.properties.getApiKey());
|
||||
return new SendGrid(properties.getApiKey());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -32,7 +32,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Solr 4.x.
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Solr.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @since 1.1.0
|
||||
|
|
@ -42,27 +42,14 @@ import org.springframework.util.StringUtils;
|
|||
@EnableConfigurationProperties(SolrProperties.class)
|
||||
public class SolrAutoConfiguration {
|
||||
|
||||
private final SolrProperties properties;
|
||||
|
||||
private SolrClient solrClient;
|
||||
|
||||
public SolrAutoConfiguration(SolrProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SolrClient solrClient() {
|
||||
this.solrClient = createSolrClient();
|
||||
return this.solrClient;
|
||||
}
|
||||
|
||||
private SolrClient createSolrClient() {
|
||||
if (StringUtils.hasText(this.properties.getZkHost())) {
|
||||
return new CloudSolrClient.Builder(Arrays.asList(this.properties.getZkHost()),
|
||||
public SolrClient solrClient(SolrProperties properties) {
|
||||
if (StringUtils.hasText(properties.getZkHost())) {
|
||||
return new CloudSolrClient.Builder(Arrays.asList(properties.getZkHost()),
|
||||
Optional.empty()).build();
|
||||
}
|
||||
return new HttpSolrClient.Builder(this.properties.getHost()).build();
|
||||
return new HttpSolrClient.Builder(properties.getHost()).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,36 +51,24 @@ public class TaskExecutionAutoConfiguration {
|
|||
*/
|
||||
public static final String APPLICATION_TASK_EXECUTOR_BEAN_NAME = "applicationTaskExecutor";
|
||||
|
||||
private final TaskExecutionProperties properties;
|
||||
|
||||
private final ObjectProvider<TaskExecutorCustomizer> taskExecutorCustomizers;
|
||||
|
||||
private final ObjectProvider<TaskDecorator> taskDecorator;
|
||||
|
||||
public TaskExecutionAutoConfiguration(TaskExecutionProperties properties,
|
||||
ObjectProvider<TaskExecutorCustomizer> taskExecutorCustomizers,
|
||||
ObjectProvider<TaskDecorator> taskDecorator) {
|
||||
this.properties = properties;
|
||||
this.taskExecutorCustomizers = taskExecutorCustomizers;
|
||||
this.taskDecorator = taskDecorator;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public TaskExecutorBuilder taskExecutorBuilder() {
|
||||
TaskExecutionProperties.Pool pool = this.properties.getPool();
|
||||
public TaskExecutorBuilder taskExecutorBuilder(TaskExecutionProperties properties,
|
||||
ObjectProvider<TaskExecutorCustomizer> taskExecutorCustomizers,
|
||||
ObjectProvider<TaskDecorator> taskDecorator) {
|
||||
TaskExecutionProperties.Pool pool = properties.getPool();
|
||||
TaskExecutorBuilder builder = new TaskExecutorBuilder();
|
||||
builder = builder.queueCapacity(pool.getQueueCapacity());
|
||||
builder = builder.corePoolSize(pool.getCoreSize());
|
||||
builder = builder.maxPoolSize(pool.getMaxSize());
|
||||
builder = builder.allowCoreThreadTimeOut(pool.isAllowCoreThreadTimeout());
|
||||
builder = builder.keepAlive(pool.getKeepAlive());
|
||||
Shutdown shutdown = this.properties.getShutdown();
|
||||
Shutdown shutdown = properties.getShutdown();
|
||||
builder = builder.awaitTermination(shutdown.isAwaitTermination());
|
||||
builder = builder.awaitTerminationPeriod(shutdown.getAwaitTerminationPeriod());
|
||||
builder = builder.threadNamePrefix(this.properties.getThreadNamePrefix());
|
||||
builder = builder.customizers(this.taskExecutorCustomizers);
|
||||
builder = builder.taskDecorator(this.taskDecorator.getIfUnique());
|
||||
builder = builder.threadNamePrefix(properties.getThreadNamePrefix());
|
||||
builder = builder.customizers(taskExecutorCustomizers);
|
||||
builder = builder.taskDecorator(taskDecorator.getIfUnique());
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.thymeleaf;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
|
@ -136,29 +135,17 @@ public class ThymeleafAutoConfiguration {
|
|||
@Configuration
|
||||
protected static class ThymeleafDefaultConfiguration {
|
||||
|
||||
private final ThymeleafProperties properties;
|
||||
|
||||
private final Collection<ITemplateResolver> templateResolvers;
|
||||
|
||||
private final ObjectProvider<IDialect> dialects;
|
||||
|
||||
public ThymeleafDefaultConfiguration(ThymeleafProperties properties,
|
||||
Collection<ITemplateResolver> templateResolvers,
|
||||
ObjectProvider<IDialect> dialectsProvider) {
|
||||
this.properties = properties;
|
||||
this.templateResolvers = templateResolvers;
|
||||
this.dialects = dialectsProvider;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SpringTemplateEngine templateEngine() {
|
||||
public SpringTemplateEngine templateEngine(ThymeleafProperties properties,
|
||||
ObjectProvider<ITemplateResolver> templateResolvers,
|
||||
ObjectProvider<IDialect> dialects) {
|
||||
SpringTemplateEngine engine = new SpringTemplateEngine();
|
||||
engine.setEnableSpringELCompiler(this.properties.isEnableSpringElCompiler());
|
||||
engine.setEnableSpringELCompiler(properties.isEnableSpringElCompiler());
|
||||
engine.setRenderHiddenMarkersBeforeCheckboxes(
|
||||
this.properties.isRenderHiddenMarkersBeforeCheckboxes());
|
||||
this.templateResolvers.forEach(engine::addTemplateResolver);
|
||||
this.dialects.orderedStream().forEach(engine::addDialect);
|
||||
properties.isRenderHiddenMarkersBeforeCheckboxes());
|
||||
templateResolvers.orderedStream().forEach(engine::addTemplateResolver);
|
||||
dialects.orderedStream().forEach(engine::addDialect);
|
||||
return engine;
|
||||
}
|
||||
|
||||
|
|
@ -182,33 +169,24 @@ public class ThymeleafAutoConfiguration {
|
|||
@Configuration
|
||||
static class ThymeleafViewResolverConfiguration {
|
||||
|
||||
private final ThymeleafProperties properties;
|
||||
|
||||
private final SpringTemplateEngine templateEngine;
|
||||
|
||||
ThymeleafViewResolverConfiguration(ThymeleafProperties properties,
|
||||
SpringTemplateEngine templateEngine) {
|
||||
this.properties = properties;
|
||||
this.templateEngine = templateEngine;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "thymeleafViewResolver")
|
||||
public ThymeleafViewResolver thymeleafViewResolver() {
|
||||
public ThymeleafViewResolver thymeleafViewResolver(
|
||||
ThymeleafProperties properties, SpringTemplateEngine templateEngine) {
|
||||
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
|
||||
resolver.setTemplateEngine(this.templateEngine);
|
||||
resolver.setCharacterEncoding(this.properties.getEncoding().name());
|
||||
resolver.setTemplateEngine(templateEngine);
|
||||
resolver.setCharacterEncoding(properties.getEncoding().name());
|
||||
resolver.setContentType(
|
||||
appendCharset(this.properties.getServlet().getContentType(),
|
||||
appendCharset(properties.getServlet().getContentType(),
|
||||
resolver.getCharacterEncoding()));
|
||||
resolver.setProducePartialOutputWhileProcessing(this.properties
|
||||
.getServlet().isProducePartialOutputWhileProcessing());
|
||||
resolver.setExcludedViewNames(this.properties.getExcludedViewNames());
|
||||
resolver.setViewNames(this.properties.getViewNames());
|
||||
resolver.setProducePartialOutputWhileProcessing(
|
||||
properties.getServlet().isProducePartialOutputWhileProcessing());
|
||||
resolver.setExcludedViewNames(properties.getExcludedViewNames());
|
||||
resolver.setViewNames(properties.getViewNames());
|
||||
// This resolver acts as a fallback resolver (e.g. like a
|
||||
// InternalResourceViewResolver) so it needs to have low precedence
|
||||
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5);
|
||||
resolver.setCache(this.properties.isCache());
|
||||
resolver.setCache(properties.isCache());
|
||||
return resolver;
|
||||
}
|
||||
|
||||
|
|
@ -231,29 +209,17 @@ public class ThymeleafAutoConfiguration {
|
|||
@ConditionalOnProperty(name = "spring.thymeleaf.enabled", matchIfMissing = true)
|
||||
static class ThymeleafReactiveConfiguration {
|
||||
|
||||
private final ThymeleafProperties properties;
|
||||
|
||||
private final Collection<ITemplateResolver> templateResolvers;
|
||||
|
||||
private final ObjectProvider<IDialect> dialects;
|
||||
|
||||
ThymeleafReactiveConfiguration(ThymeleafProperties properties,
|
||||
Collection<ITemplateResolver> templateResolvers,
|
||||
ObjectProvider<IDialect> dialectsProvider) {
|
||||
this.properties = properties;
|
||||
this.templateResolvers = templateResolvers;
|
||||
this.dialects = dialectsProvider;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ISpringWebFluxTemplateEngine.class)
|
||||
public SpringWebFluxTemplateEngine templateEngine() {
|
||||
public SpringWebFluxTemplateEngine templateEngine(ThymeleafProperties properties,
|
||||
ObjectProvider<ITemplateResolver> templateResolvers,
|
||||
ObjectProvider<IDialect> dialects) {
|
||||
SpringWebFluxTemplateEngine engine = new SpringWebFluxTemplateEngine();
|
||||
engine.setEnableSpringELCompiler(this.properties.isEnableSpringElCompiler());
|
||||
engine.setEnableSpringELCompiler(properties.isEnableSpringElCompiler());
|
||||
engine.setRenderHiddenMarkersBeforeCheckboxes(
|
||||
this.properties.isRenderHiddenMarkersBeforeCheckboxes());
|
||||
this.templateResolvers.forEach(engine::addTemplateResolver);
|
||||
this.dialects.orderedStream().forEach(engine::addDialect);
|
||||
properties.isRenderHiddenMarkersBeforeCheckboxes());
|
||||
templateResolvers.orderedStream().forEach(engine::addTemplateResolver);
|
||||
dialects.orderedStream().forEach(engine::addDialect);
|
||||
return engine;
|
||||
}
|
||||
|
||||
|
|
@ -264,20 +230,15 @@ public class ThymeleafAutoConfiguration {
|
|||
@ConditionalOnProperty(name = "spring.thymeleaf.enabled", matchIfMissing = true)
|
||||
static class ThymeleafWebFluxConfiguration {
|
||||
|
||||
private final ThymeleafProperties properties;
|
||||
|
||||
ThymeleafWebFluxConfiguration(ThymeleafProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "thymeleafReactiveViewResolver")
|
||||
public ThymeleafReactiveViewResolver thymeleafViewResolver(
|
||||
ISpringWebFluxTemplateEngine templateEngine) {
|
||||
ISpringWebFluxTemplateEngine templateEngine,
|
||||
ThymeleafProperties properties) {
|
||||
ThymeleafReactiveViewResolver resolver = new ThymeleafReactiveViewResolver();
|
||||
resolver.setTemplateEngine(templateEngine);
|
||||
mapProperties(this.properties, resolver);
|
||||
mapReactiveProperties(this.properties.getReactive(), resolver);
|
||||
mapProperties(properties, resolver);
|
||||
mapReactiveProperties(properties.getReactive(), resolver);
|
||||
// This resolver acts as a fallback resolver (e.g. like a
|
||||
// InternalResourceViewResolver) so it needs to have low precedence
|
||||
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -64,17 +64,11 @@ public class TransactionAutoConfiguration {
|
|||
@ConditionalOnSingleCandidate(PlatformTransactionManager.class)
|
||||
public static class TransactionTemplateConfiguration {
|
||||
|
||||
private final PlatformTransactionManager transactionManager;
|
||||
|
||||
public TransactionTemplateConfiguration(
|
||||
PlatformTransactionManager transactionManager) {
|
||||
this.transactionManager = transactionManager;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public TransactionTemplate transactionTemplate() {
|
||||
return new TransactionTemplate(this.transactionManager);
|
||||
public TransactionTemplate transactionTemplate(
|
||||
PlatformTransactionManager transactionManager) {
|
||||
return new TransactionTemplate(transactionManager);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -61,34 +61,24 @@ import org.springframework.util.StringUtils;
|
|||
@ConditionalOnMissingBean(PlatformTransactionManager.class)
|
||||
class AtomikosJtaConfiguration {
|
||||
|
||||
private final JtaProperties jtaProperties;
|
||||
|
||||
private final TransactionManagerCustomizers transactionManagerCustomizers;
|
||||
|
||||
AtomikosJtaConfiguration(JtaProperties jtaProperties,
|
||||
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
|
||||
this.jtaProperties = jtaProperties;
|
||||
this.transactionManagerCustomizers = transactionManagerCustomizers
|
||||
.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean(initMethod = "init", destroyMethod = "shutdownWait")
|
||||
@ConditionalOnMissingBean(UserTransactionService.class)
|
||||
public UserTransactionServiceImp userTransactionService(
|
||||
AtomikosProperties atomikosProperties) {
|
||||
AtomikosProperties atomikosProperties, JtaProperties jtaProperties) {
|
||||
Properties properties = new Properties();
|
||||
if (StringUtils.hasText(this.jtaProperties.getTransactionManagerId())) {
|
||||
if (StringUtils.hasText(jtaProperties.getTransactionManagerId())) {
|
||||
properties.setProperty("com.atomikos.icatch.tm_unique_name",
|
||||
this.jtaProperties.getTransactionManagerId());
|
||||
jtaProperties.getTransactionManagerId());
|
||||
}
|
||||
properties.setProperty("com.atomikos.icatch.log_base_dir", getLogBaseDir());
|
||||
properties.setProperty("com.atomikos.icatch.log_base_dir",
|
||||
getLogBaseDir(jtaProperties));
|
||||
properties.putAll(atomikosProperties.asProperties());
|
||||
return new UserTransactionServiceImp(properties);
|
||||
}
|
||||
|
||||
private String getLogBaseDir() {
|
||||
if (StringUtils.hasLength(this.jtaProperties.getLogDir())) {
|
||||
return this.jtaProperties.getLogDir();
|
||||
private String getLogBaseDir(JtaProperties jtaProperties) {
|
||||
if (StringUtils.hasLength(jtaProperties.getLogDir())) {
|
||||
return jtaProperties.getLogDir();
|
||||
}
|
||||
File home = new ApplicationHome().getDir();
|
||||
return new File(home, "transaction-logs").getAbsolutePath();
|
||||
|
|
@ -118,12 +108,12 @@ class AtomikosJtaConfiguration {
|
|||
|
||||
@Bean
|
||||
public JtaTransactionManager transactionManager(UserTransaction userTransaction,
|
||||
TransactionManager transactionManager) {
|
||||
TransactionManager transactionManager,
|
||||
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
|
||||
JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(
|
||||
userTransaction, transactionManager);
|
||||
if (this.transactionManagerCustomizers != null) {
|
||||
this.transactionManagerCustomizers.customize(jtaTransactionManager);
|
||||
}
|
||||
transactionManagerCustomizers.ifAvailable(
|
||||
(customizers) -> customizers.customize(jtaTransactionManager));
|
||||
return jtaTransactionManager;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -20,6 +20,7 @@ import java.io.File;
|
|||
|
||||
import javax.jms.Message;
|
||||
import javax.transaction.TransactionManager;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import bitronix.tm.BitronixTransactionManager;
|
||||
import bitronix.tm.TransactionManagerServices;
|
||||
|
|
@ -58,35 +59,24 @@ import org.springframework.util.StringUtils;
|
|||
@ConditionalOnMissingBean(PlatformTransactionManager.class)
|
||||
class BitronixJtaConfiguration {
|
||||
|
||||
private final JtaProperties jtaProperties;
|
||||
|
||||
private final TransactionManagerCustomizers transactionManagerCustomizers;
|
||||
|
||||
BitronixJtaConfiguration(JtaProperties jtaProperties,
|
||||
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
|
||||
this.jtaProperties = jtaProperties;
|
||||
this.transactionManagerCustomizers = transactionManagerCustomizers
|
||||
.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConfigurationProperties(prefix = "spring.jta.bitronix.properties")
|
||||
public bitronix.tm.Configuration bitronixConfiguration() {
|
||||
public bitronix.tm.Configuration bitronixConfiguration(JtaProperties jtaProperties) {
|
||||
bitronix.tm.Configuration config = TransactionManagerServices.getConfiguration();
|
||||
if (StringUtils.hasText(this.jtaProperties.getTransactionManagerId())) {
|
||||
config.setServerId(this.jtaProperties.getTransactionManagerId());
|
||||
if (StringUtils.hasText(jtaProperties.getTransactionManagerId())) {
|
||||
config.setServerId(jtaProperties.getTransactionManagerId());
|
||||
}
|
||||
File logBaseDir = getLogBaseDir();
|
||||
File logBaseDir = getLogBaseDir(jtaProperties);
|
||||
config.setLogPart1Filename(new File(logBaseDir, "part1.btm").getAbsolutePath());
|
||||
config.setLogPart2Filename(new File(logBaseDir, "part2.btm").getAbsolutePath());
|
||||
config.setDisableJmx(true);
|
||||
return config;
|
||||
}
|
||||
|
||||
private File getLogBaseDir() {
|
||||
if (StringUtils.hasLength(this.jtaProperties.getLogDir())) {
|
||||
return new File(this.jtaProperties.getLogDir());
|
||||
private File getLogBaseDir(JtaProperties jtaProperties) {
|
||||
if (StringUtils.hasLength(jtaProperties.getLogDir())) {
|
||||
return new File(jtaProperties.getLogDir());
|
||||
}
|
||||
File home = new ApplicationHome().getDir();
|
||||
return new File(home, "transaction-logs");
|
||||
|
|
@ -113,13 +103,13 @@ class BitronixJtaConfiguration {
|
|||
}
|
||||
|
||||
@Bean
|
||||
public JtaTransactionManager transactionManager(
|
||||
TransactionManager transactionManager) {
|
||||
public JtaTransactionManager transactionManager(UserTransaction userTransaction,
|
||||
TransactionManager transactionManager,
|
||||
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
|
||||
JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(
|
||||
transactionManager);
|
||||
if (this.transactionManagerCustomizers != null) {
|
||||
this.transactionManagerCustomizers.customize(jtaTransactionManager);
|
||||
}
|
||||
userTransaction, transactionManager);
|
||||
transactionManagerCustomizers.ifAvailable(
|
||||
(customizers) -> customizers.customize(jtaTransactionManager));
|
||||
return jtaTransactionManager;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -43,21 +43,13 @@ import org.springframework.transaction.jta.JtaTransactionManager;
|
|||
@ConditionalOnMissingBean(PlatformTransactionManager.class)
|
||||
class JndiJtaConfiguration {
|
||||
|
||||
private final TransactionManagerCustomizers transactionManagerCustomizers;
|
||||
|
||||
JndiJtaConfiguration(
|
||||
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
|
||||
this.transactionManagerCustomizers = transactionManagerCustomizers
|
||||
.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JtaTransactionManager transactionManager() {
|
||||
public JtaTransactionManager transactionManager(
|
||||
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
|
||||
JtaTransactionManager jtaTransactionManager = new JtaTransactionManagerFactoryBean()
|
||||
.getObject();
|
||||
if (this.transactionManagerCustomizers != null) {
|
||||
this.transactionManagerCustomizers.customize(jtaTransactionManager);
|
||||
}
|
||||
transactionManagerCustomizers.ifAvailable(
|
||||
(customizers) -> customizers.customize(jtaTransactionManager));
|
||||
return jtaTransactionManager;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ import org.springframework.boot.web.client.RestTemplateCustomizer;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
|
|
@ -51,29 +50,19 @@ import org.springframework.web.client.RestTemplate;
|
|||
@Conditional(NotReactiveWebApplicationCondition.class)
|
||||
public class RestTemplateAutoConfiguration {
|
||||
|
||||
private final ObjectProvider<HttpMessageConverters> messageConverters;
|
||||
|
||||
private final ObjectProvider<RestTemplateCustomizer> restTemplateCustomizers;
|
||||
|
||||
public RestTemplateAutoConfiguration(
|
||||
ObjectProvider<HttpMessageConverters> messageConverters,
|
||||
ObjectProvider<RestTemplateCustomizer> restTemplateCustomizers) {
|
||||
this.messageConverters = messageConverters;
|
||||
this.restTemplateCustomizers = restTemplateCustomizers;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public RestTemplateBuilder restTemplateBuilder() {
|
||||
public RestTemplateBuilder restTemplateBuilder(
|
||||
ObjectProvider<HttpMessageConverters> messageConverters,
|
||||
ObjectProvider<RestTemplateCustomizer> restTemplateCustomizers) {
|
||||
RestTemplateBuilder builder = new RestTemplateBuilder();
|
||||
HttpMessageConverters converters = this.messageConverters.getIfUnique();
|
||||
HttpMessageConverters converters = messageConverters.getIfUnique();
|
||||
if (converters != null) {
|
||||
builder = builder.messageConverters(converters.getConverters());
|
||||
}
|
||||
|
||||
List<RestTemplateCustomizer> customizers = this.restTemplateCustomizers
|
||||
.orderedStream().collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(customizers)) {
|
||||
List<RestTemplateCustomizer> customizers = restTemplateCustomizers.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
if (!customizers.isEmpty()) {
|
||||
builder = builder.customizers(customizers);
|
||||
}
|
||||
return builder;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.web.reactive.error;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
|
|
@ -57,38 +56,25 @@ public class ErrorWebFluxAutoConfiguration {
|
|||
|
||||
private final ServerProperties serverProperties;
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
private final ResourceProperties resourceProperties;
|
||||
|
||||
private final List<ViewResolver> viewResolvers;
|
||||
|
||||
private final ServerCodecConfigurer serverCodecConfigurer;
|
||||
|
||||
public ErrorWebFluxAutoConfiguration(ServerProperties serverProperties,
|
||||
ResourceProperties resourceProperties,
|
||||
ObjectProvider<ViewResolver> viewResolversProvider,
|
||||
ServerCodecConfigurer serverCodecConfigurer,
|
||||
ApplicationContext applicationContext) {
|
||||
public ErrorWebFluxAutoConfiguration(ServerProperties serverProperties) {
|
||||
this.serverProperties = serverProperties;
|
||||
this.applicationContext = applicationContext;
|
||||
this.resourceProperties = resourceProperties;
|
||||
this.viewResolvers = viewResolversProvider.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
this.serverCodecConfigurer = serverCodecConfigurer;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(value = ErrorWebExceptionHandler.class, search = SearchStrategy.CURRENT)
|
||||
@Order(-1)
|
||||
public ErrorWebExceptionHandler errorWebExceptionHandler(
|
||||
ErrorAttributes errorAttributes) {
|
||||
ErrorAttributes errorAttributes, ResourceProperties resourceProperties,
|
||||
ObjectProvider<ViewResolver> viewResolvers,
|
||||
ServerCodecConfigurer serverCodecConfigurer,
|
||||
ApplicationContext applicationContext) {
|
||||
DefaultErrorWebExceptionHandler exceptionHandler = new DefaultErrorWebExceptionHandler(
|
||||
errorAttributes, this.resourceProperties,
|
||||
this.serverProperties.getError(), this.applicationContext);
|
||||
exceptionHandler.setViewResolvers(this.viewResolvers);
|
||||
exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
|
||||
exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
|
||||
errorAttributes, resourceProperties, this.serverProperties.getError(),
|
||||
applicationContext);
|
||||
exceptionHandler.setViewResolvers(
|
||||
viewResolvers.orderedStream().collect(Collectors.toList()));
|
||||
exceptionHandler.setMessageWriters(serverCodecConfigurer.getWriters());
|
||||
exceptionHandler.setMessageReaders(serverCodecConfigurer.getReaders());
|
||||
return exceptionHandler;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -85,27 +85,18 @@ public class DispatcherServletAutoConfiguration {
|
|||
@EnableConfigurationProperties({ HttpProperties.class, WebMvcProperties.class })
|
||||
protected static class DispatcherServletConfiguration {
|
||||
|
||||
private final HttpProperties httpProperties;
|
||||
|
||||
private final WebMvcProperties webMvcProperties;
|
||||
|
||||
public DispatcherServletConfiguration(HttpProperties httpProperties,
|
||||
WebMvcProperties webMvcProperties) {
|
||||
this.httpProperties = httpProperties;
|
||||
this.webMvcProperties = webMvcProperties;
|
||||
}
|
||||
|
||||
@Bean(name = DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)
|
||||
public DispatcherServlet dispatcherServlet() {
|
||||
public DispatcherServlet dispatcherServlet(HttpProperties httpProperties,
|
||||
WebMvcProperties webMvcProperties) {
|
||||
DispatcherServlet dispatcherServlet = new DispatcherServlet();
|
||||
dispatcherServlet.setDispatchOptionsRequest(
|
||||
this.webMvcProperties.isDispatchOptionsRequest());
|
||||
dispatcherServlet.setDispatchTraceRequest(
|
||||
this.webMvcProperties.isDispatchTraceRequest());
|
||||
webMvcProperties.isDispatchOptionsRequest());
|
||||
dispatcherServlet
|
||||
.setDispatchTraceRequest(webMvcProperties.isDispatchTraceRequest());
|
||||
dispatcherServlet.setThrowExceptionIfNoHandlerFound(
|
||||
this.webMvcProperties.isThrowExceptionIfNoHandlerFound());
|
||||
dispatcherServlet.setEnableLoggingRequestDetails(
|
||||
this.httpProperties.isLogRequestDetails());
|
||||
webMvcProperties.isThrowExceptionIfNoHandlerFound());
|
||||
dispatcherServlet
|
||||
.setEnableLoggingRequestDetails(httpProperties.isLogRequestDetails());
|
||||
return dispatcherServlet;
|
||||
}
|
||||
|
||||
|
|
@ -126,29 +117,17 @@ public class DispatcherServletAutoConfiguration {
|
|||
@Import(DispatcherServletConfiguration.class)
|
||||
protected static class DispatcherServletRegistrationConfiguration {
|
||||
|
||||
private final WebMvcProperties webMvcProperties;
|
||||
|
||||
private final MultipartConfigElement multipartConfig;
|
||||
|
||||
public DispatcherServletRegistrationConfiguration(
|
||||
WebMvcProperties webMvcProperties,
|
||||
ObjectProvider<MultipartConfigElement> multipartConfigProvider) {
|
||||
this.webMvcProperties = webMvcProperties;
|
||||
this.multipartConfig = multipartConfigProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean(name = DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME)
|
||||
@ConditionalOnBean(value = DispatcherServlet.class, name = DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)
|
||||
public DispatcherServletRegistrationBean dispatcherServletRegistration(
|
||||
DispatcherServlet dispatcherServlet) {
|
||||
DispatcherServlet dispatcherServlet, WebMvcProperties webMvcProperties,
|
||||
ObjectProvider<MultipartConfigElement> multipartConfig) {
|
||||
DispatcherServletRegistrationBean registration = new DispatcherServletRegistrationBean(
|
||||
dispatcherServlet, this.webMvcProperties.getServlet().getPath());
|
||||
dispatcherServlet, webMvcProperties.getServlet().getPath());
|
||||
registration.setName(DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
|
||||
registration.setLoadOnStartup(
|
||||
this.webMvcProperties.getServlet().getLoadOnStartup());
|
||||
if (this.multipartConfig != null) {
|
||||
registration.setMultipartConfig(this.multipartConfig);
|
||||
}
|
||||
registration
|
||||
.setLoadOnStartup(webMvcProperties.getServlet().getLoadOnStartup());
|
||||
multipartConfig.ifAvailable(registration::setMultipartConfig);
|
||||
return registration;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -17,7 +17,6 @@
|
|||
package org.springframework.boot.autoconfigure.web.servlet.error;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -92,17 +91,8 @@ public class ErrorMvcAutoConfiguration {
|
|||
|
||||
private final ServerProperties serverProperties;
|
||||
|
||||
private final DispatcherServletPath dispatcherServletPath;
|
||||
|
||||
private final List<ErrorViewResolver> errorViewResolvers;
|
||||
|
||||
public ErrorMvcAutoConfiguration(ServerProperties serverProperties,
|
||||
DispatcherServletPath dispatcherServletPath,
|
||||
ObjectProvider<ErrorViewResolver> errorViewResolvers) {
|
||||
public ErrorMvcAutoConfiguration(ServerProperties serverProperties) {
|
||||
this.serverProperties = serverProperties;
|
||||
this.dispatcherServletPath = dispatcherServletPath;
|
||||
this.errorViewResolvers = errorViewResolvers.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
@ -114,14 +104,16 @@ public class ErrorMvcAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT)
|
||||
public BasicErrorController basicErrorController(ErrorAttributes errorAttributes) {
|
||||
public BasicErrorController basicErrorController(ErrorAttributes errorAttributes,
|
||||
ObjectProvider<ErrorViewResolver> errorViewResolvers) {
|
||||
return new BasicErrorController(errorAttributes, this.serverProperties.getError(),
|
||||
this.errorViewResolvers);
|
||||
errorViewResolvers.orderedStream().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ErrorPageCustomizer errorPageCustomizer() {
|
||||
return new ErrorPageCustomizer(this.serverProperties, this.dispatcherServletPath);
|
||||
public ErrorPageCustomizer errorPageCustomizer(
|
||||
DispatcherServletPath dispatcherServletPath) {
|
||||
return new ErrorPageCustomizer(this.serverProperties, dispatcherServletPath);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -66,22 +66,16 @@ import org.springframework.xml.xsd.SimpleXsdSchema;
|
|||
@AutoConfigureAfter(ServletWebServerFactoryAutoConfiguration.class)
|
||||
public class WebServicesAutoConfiguration {
|
||||
|
||||
private final WebServicesProperties properties;
|
||||
|
||||
public WebServicesAutoConfiguration(WebServicesProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ServletRegistrationBean<MessageDispatcherServlet> messageDispatcherServlet(
|
||||
ApplicationContext applicationContext) {
|
||||
ApplicationContext applicationContext, WebServicesProperties properties) {
|
||||
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
|
||||
servlet.setApplicationContext(applicationContext);
|
||||
String path = this.properties.getPath();
|
||||
String path = properties.getPath();
|
||||
String urlMapping = path + (path.endsWith("/") ? "*" : "/*");
|
||||
ServletRegistrationBean<MessageDispatcherServlet> registration = new ServletRegistrationBean<>(
|
||||
servlet, urlMapping);
|
||||
WebServicesProperties.Servlet servletProperties = this.properties.getServlet();
|
||||
WebServicesProperties.Servlet servletProperties = properties.getServlet();
|
||||
registration.setLoadOnStartup(servletProperties.getLoadOnStartup());
|
||||
servletProperties.getInit().forEach(registration::addInitParameter);
|
||||
return registration;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue