Complete the move to constructor injection in configuration classes
This is a follow-on from the work done in 5009933
. Now that SPR-14015
has been fixed, constructor injection can also be used for parameterised
dependencies, including optional dependencies that are injected via
an ObjectProvider.
Closes gh-5306
This commit is contained in:
parent
cb2ad7fb87
commit
19d8c5e6f6
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.springframework.boot.actuate.autoconfigure;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.actuate.audit.AuditEvent;
|
||||
import org.springframework.boot.actuate.audit.AuditEventRepository;
|
||||
import org.springframework.boot.actuate.audit.InMemoryAuditEventRepository;
|
||||
|
@ -40,8 +40,12 @@ import org.springframework.context.annotation.Configuration;
|
|||
@Configuration
|
||||
public class AuditAutoConfiguration {
|
||||
|
||||
@Autowired(required = false)
|
||||
private final AuditEventRepository auditEventRepository = new InMemoryAuditEventRepository();
|
||||
private final AuditEventRepository auditEventRepository;
|
||||
|
||||
public AuditAutoConfiguration(
|
||||
ObjectProvider<AuditEventRepository> auditEventRepositoryProvider) {
|
||||
this.auditEventRepository = auditEventRepositoryProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuditListener auditListener() throws Exception {
|
||||
|
@ -64,10 +68,12 @@ public class AuditAutoConfiguration {
|
|||
|
||||
@ConditionalOnMissingBean(AuditEventRepository.class)
|
||||
protected static class AuditEventRepositoryConfiguration {
|
||||
|
||||
@Bean
|
||||
public InMemoryAuditEventRepository auditEventRepository() throws Exception {
|
||||
return new InMemoryAuditEventRepository();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.crsh.vfs.spi.AbstractFSDriver;
|
|||
import org.crsh.vfs.spi.FSDriver;
|
||||
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.actuate.autoconfigure.ShellProperties.CrshShellAuthenticationProperties;
|
||||
|
@ -115,34 +116,16 @@ import org.springframework.util.StringUtils;
|
|||
* @see ShellProperties
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({ PluginLifeCycle.class })
|
||||
@EnableConfigurationProperties({ ShellProperties.class })
|
||||
@ConditionalOnClass(PluginLifeCycle.class)
|
||||
@EnableConfigurationProperties(ShellProperties.class)
|
||||
@AutoConfigureAfter({ SecurityAutoConfiguration.class,
|
||||
ManagementWebSecurityAutoConfiguration.class })
|
||||
public class CrshAutoConfiguration {
|
||||
|
||||
@Autowired
|
||||
private ShellProperties properties;
|
||||
private final ShellProperties properties;
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "shell", name = "auth", havingValue = "jaas")
|
||||
@ConditionalOnMissingBean(CrshShellAuthenticationProperties.class)
|
||||
public JaasAuthenticationProperties jaasAuthenticationProperties() {
|
||||
return new JaasAuthenticationProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "shell", name = "auth", havingValue = "key")
|
||||
@ConditionalOnMissingBean(CrshShellAuthenticationProperties.class)
|
||||
public KeyAuthenticationProperties keyAuthenticationProperties() {
|
||||
return new KeyAuthenticationProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "shell", name = "auth", havingValue = "simple", matchIfMissing = true)
|
||||
@ConditionalOnMissingBean(CrshShellAuthenticationProperties.class)
|
||||
public SimpleAuthenticationProperties simpleAuthenticationProperties() {
|
||||
return new SimpleAuthenticationProperties();
|
||||
public CrshAutoConfiguration(ShellProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
@ -153,17 +136,46 @@ public class CrshAutoConfiguration {
|
|||
return bootstrapBean;
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class CrshAdditionalPropertiesConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "shell", name = "auth", havingValue = "jaas")
|
||||
@ConditionalOnMissingBean(CrshShellAuthenticationProperties.class)
|
||||
public JaasAuthenticationProperties jaasAuthenticationProperties() {
|
||||
return new JaasAuthenticationProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "shell", name = "auth", havingValue = "key")
|
||||
@ConditionalOnMissingBean(CrshShellAuthenticationProperties.class)
|
||||
public KeyAuthenticationProperties keyAuthenticationProperties() {
|
||||
return new KeyAuthenticationProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "shell", name = "auth", havingValue = "simple", matchIfMissing = true)
|
||||
@ConditionalOnMissingBean(CrshShellAuthenticationProperties.class)
|
||||
public SimpleAuthenticationProperties simpleAuthenticationProperties() {
|
||||
return new SimpleAuthenticationProperties();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to configure CRaSH to authenticate against Spring Security.
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "shell", name = "auth", havingValue = "spring", matchIfMissing = true)
|
||||
@ConditionalOnBean(AuthenticationManager.class)
|
||||
@AutoConfigureAfter(CrshAutoConfiguration.class)
|
||||
public static class AuthenticationManagerAdapterAutoConfiguration {
|
||||
public static class AuthenticationManagerAdapterConfiguration {
|
||||
|
||||
@Autowired(required = false)
|
||||
private ManagementServerProperties management;
|
||||
private final ManagementServerProperties management;
|
||||
|
||||
public AuthenticationManagerAdapterConfiguration(
|
||||
ObjectProvider<ManagementServerProperties> managementProvider) {
|
||||
this.management = managementProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManagerAdapter shellAuthenticationManager() {
|
||||
|
|
|
@ -19,14 +19,13 @@ package org.springframework.boot.actuate.autoconfigure;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import liquibase.integration.spring.SpringLiquibase;
|
||||
import org.flywaydb.core.Flyway;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.actuate.endpoint.AutoConfigurationReportEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.BeansEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.ConfigurationPropertiesReportEndpoint;
|
||||
|
@ -82,20 +81,28 @@ import org.springframework.web.servlet.handler.AbstractHandlerMethodMapping;
|
|||
@EnableConfigurationProperties(EndpointProperties.class)
|
||||
public class EndpointAutoConfiguration {
|
||||
|
||||
@Autowired(required = false)
|
||||
private HealthAggregator healthAggregator = new OrderedHealthAggregator();
|
||||
private final HealthAggregator healthAggregator;
|
||||
|
||||
@Autowired(required = false)
|
||||
private Map<String, HealthIndicator> healthIndicators = new HashMap<String, HealthIndicator>();
|
||||
private final Map<String, HealthIndicator> healthIndicators;
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<InfoContributor> infoContributors = new ArrayList<InfoContributor>();
|
||||
private final List<InfoContributor> infoContributors;
|
||||
|
||||
@Autowired(required = false)
|
||||
private Collection<PublicMetrics> publicMetrics;
|
||||
private final Collection<PublicMetrics> publicMetrics;
|
||||
|
||||
@Autowired(required = false)
|
||||
private TraceRepository traceRepository = new InMemoryTraceRepository();
|
||||
private final TraceRepository traceRepository;
|
||||
|
||||
public EndpointAutoConfiguration(
|
||||
ObjectProvider<HealthAggregator> healthAggregatorProvider,
|
||||
ObjectProvider<Map<String, HealthIndicator>> healthIndicatorsProvider,
|
||||
ObjectProvider<List<InfoContributor>> infoContributorsProvider,
|
||||
ObjectProvider<Collection<PublicMetrics>> publicMetricsProvider,
|
||||
ObjectProvider<TraceRepository> traceRepositoryProvider) {
|
||||
this.healthAggregator = healthAggregatorProvider.getIfAvailable();
|
||||
this.healthIndicators = healthIndicatorsProvider.getIfAvailable();
|
||||
this.infoContributors = infoContributorsProvider.getIfAvailable();
|
||||
this.publicMetrics = publicMetricsProvider.getIfAvailable();
|
||||
this.traceRepository = traceRepositoryProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
|
@ -106,7 +113,12 @@ public class EndpointAutoConfiguration {
|
|||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public HealthEndpoint healthEndpoint() {
|
||||
return new HealthEndpoint(this.healthAggregator, this.healthIndicators);
|
||||
return new HealthEndpoint(
|
||||
this.healthAggregator == null ? new OrderedHealthAggregator()
|
||||
: this.healthAggregator,
|
||||
this.healthIndicators == null
|
||||
? Collections.<String, HealthIndicator>emptyMap()
|
||||
: this.healthIndicators);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
@ -118,7 +130,8 @@ public class EndpointAutoConfiguration {
|
|||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public InfoEndpoint infoEndpoint() throws Exception {
|
||||
return new InfoEndpoint(this.infoContributors);
|
||||
return new InfoEndpoint(this.infoContributors == null
|
||||
? Collections.<InfoContributor>emptyList() : this.infoContributors);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
@ -135,7 +148,8 @@ public class EndpointAutoConfiguration {
|
|||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public TraceEndpoint traceEndpoint() {
|
||||
return new TraceEndpoint(this.traceRepository);
|
||||
return new TraceEndpoint(this.traceRepository == null
|
||||
? new InMemoryTraceRepository() : this.traceRepository);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 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,7 +20,7 @@ import javax.management.MBeanServer;
|
|||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.actuate.autoconfigure.EndpointMBeanExportAutoConfiguration.JmxEnabledCondition;
|
||||
import org.springframework.boot.actuate.endpoint.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter;
|
||||
|
@ -52,11 +52,15 @@ import org.springframework.util.StringUtils;
|
|||
@EnableConfigurationProperties(EndpointMBeanExportProperties.class)
|
||||
public class EndpointMBeanExportAutoConfiguration {
|
||||
|
||||
@Autowired
|
||||
private EndpointMBeanExportProperties properties = new EndpointMBeanExportProperties();
|
||||
private final EndpointMBeanExportProperties properties;
|
||||
|
||||
@Autowired(required = false)
|
||||
private ObjectMapper objectMapper;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public EndpointMBeanExportAutoConfiguration(EndpointMBeanExportProperties properties,
|
||||
ObjectProvider<ObjectMapper> objectMapperProvider) {
|
||||
this.properties = properties;
|
||||
this.objectMapper = objectMapperProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public EndpointMBeanExporter endpointMBeanExporter(MBeanServer server) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.client.Client;
|
|||
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.CassandraHealthIndicator;
|
||||
|
@ -174,8 +175,12 @@ public class HealthIndicatorAutoConfiguration {
|
|||
public static class CassandraHealthIndicatorConfiguration extends
|
||||
CompositeHealthIndicatorConfiguration<CassandraHealthIndicator, CassandraOperations> {
|
||||
|
||||
@Autowired
|
||||
private Map<String, CassandraOperations> cassandraOperations;
|
||||
private final Map<String, CassandraOperations> cassandraOperations;
|
||||
|
||||
public CassandraHealthIndicatorConfiguration(
|
||||
Map<String, CassandraOperations> cassandraOperations) {
|
||||
this.cassandraOperations = cassandraOperations;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "cassandraHealthIndicator")
|
||||
|
@ -192,8 +197,12 @@ public class HealthIndicatorAutoConfiguration {
|
|||
public static class CouchbaseHealthIndicatorConfiguration extends
|
||||
CompositeHealthIndicatorConfiguration<CouchbaseHealthIndicator, CouchbaseOperations> {
|
||||
|
||||
@Autowired
|
||||
private Map<String, CouchbaseOperations> couchbaseOperations;
|
||||
private final Map<String, CouchbaseOperations> couchbaseOperations;
|
||||
|
||||
public CouchbaseHealthIndicatorConfiguration(
|
||||
Map<String, CouchbaseOperations> couchbaseOperations) {
|
||||
this.couchbaseOperations = couchbaseOperations;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "couchbaseHealthIndicator")
|
||||
|
@ -211,14 +220,19 @@ public class HealthIndicatorAutoConfiguration {
|
|||
CompositeHealthIndicatorConfiguration<DataSourceHealthIndicator, DataSource>
|
||||
implements InitializingBean {
|
||||
|
||||
@Autowired(required = false)
|
||||
private Map<String, DataSource> dataSources;
|
||||
private final Map<String, DataSource> dataSources;
|
||||
|
||||
@Autowired(required = false)
|
||||
private Collection<DataSourcePoolMetadataProvider> metadataProviders;
|
||||
private final Collection<DataSourcePoolMetadataProvider> metadataProviders;
|
||||
|
||||
private DataSourcePoolMetadataProvider poolMetadataProvider;
|
||||
|
||||
public DataSourcesHealthIndicatorConfiguration(
|
||||
ObjectProvider<Map<String, DataSource>> dataSourcesProvider,
|
||||
ObjectProvider<Collection<DataSourcePoolMetadataProvider>> metadataProvidersProvider) {
|
||||
this.dataSources = dataSourcesProvider.getIfAvailable();
|
||||
this.metadataProviders = metadataProvidersProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
this.poolMetadataProvider = new DataSourcePoolMetadataProviders(
|
||||
|
@ -250,8 +264,12 @@ public class HealthIndicatorAutoConfiguration {
|
|||
public static class MongoHealthIndicatorConfiguration extends
|
||||
CompositeHealthIndicatorConfiguration<MongoHealthIndicator, MongoTemplate> {
|
||||
|
||||
@Autowired
|
||||
private Map<String, MongoTemplate> mongoTemplates;
|
||||
private final Map<String, MongoTemplate> mongoTemplates;
|
||||
|
||||
public MongoHealthIndicatorConfiguration(
|
||||
Map<String, MongoTemplate> mongoTemplates) {
|
||||
this.mongoTemplates = mongoTemplates;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "mongoHealthIndicator")
|
||||
|
@ -267,8 +285,12 @@ public class HealthIndicatorAutoConfiguration {
|
|||
public static class RedisHealthIndicatorConfiguration extends
|
||||
CompositeHealthIndicatorConfiguration<RedisHealthIndicator, RedisConnectionFactory> {
|
||||
|
||||
@Autowired
|
||||
private Map<String, RedisConnectionFactory> redisConnectionFactories;
|
||||
private final Map<String, RedisConnectionFactory> redisConnectionFactories;
|
||||
|
||||
public RedisHealthIndicatorConfiguration(
|
||||
Map<String, RedisConnectionFactory> redisConnectionFactories) {
|
||||
this.redisConnectionFactories = redisConnectionFactories;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "redisHealthIndicator")
|
||||
|
@ -284,8 +306,12 @@ public class HealthIndicatorAutoConfiguration {
|
|||
public static class RabbitHealthIndicatorConfiguration extends
|
||||
CompositeHealthIndicatorConfiguration<RabbitHealthIndicator, RabbitTemplate> {
|
||||
|
||||
@Autowired
|
||||
private Map<String, RabbitTemplate> rabbitTemplates;
|
||||
private final Map<String, RabbitTemplate> rabbitTemplates;
|
||||
|
||||
public RabbitHealthIndicatorConfiguration(
|
||||
Map<String, RabbitTemplate> rabbitTemplates) {
|
||||
this.rabbitTemplates = rabbitTemplates;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "rabbitHealthIndicator")
|
||||
|
@ -301,8 +327,11 @@ public class HealthIndicatorAutoConfiguration {
|
|||
public static class SolrHealthIndicatorConfiguration extends
|
||||
CompositeHealthIndicatorConfiguration<SolrHealthIndicator, SolrClient> {
|
||||
|
||||
@Autowired
|
||||
private Map<String, SolrClient> solrClients;
|
||||
private final Map<String, SolrClient> solrClients;
|
||||
|
||||
public SolrHealthIndicatorConfiguration(Map<String, SolrClient> solrClients) {
|
||||
this.solrClients = solrClients;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "solrHealthIndicator")
|
||||
|
@ -336,8 +365,12 @@ public class HealthIndicatorAutoConfiguration {
|
|||
public static class MailHealthIndicatorConfiguration extends
|
||||
CompositeHealthIndicatorConfiguration<MailHealthIndicator, JavaMailSenderImpl> {
|
||||
|
||||
@Autowired(required = false)
|
||||
private Map<String, JavaMailSenderImpl> mailSenders;
|
||||
private final Map<String, JavaMailSenderImpl> mailSenders;
|
||||
|
||||
public MailHealthIndicatorConfiguration(
|
||||
ObjectProvider<Map<String, JavaMailSenderImpl>> mailSendersProvider) {
|
||||
this.mailSenders = mailSendersProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "mailHealthIndicator")
|
||||
|
@ -353,8 +386,12 @@ public class HealthIndicatorAutoConfiguration {
|
|||
public static class JmsHealthIndicatorConfiguration extends
|
||||
CompositeHealthIndicatorConfiguration<JmsHealthIndicator, ConnectionFactory> {
|
||||
|
||||
@Autowired(required = false)
|
||||
private Map<String, ConnectionFactory> connectionFactories;
|
||||
private final Map<String, ConnectionFactory> connectionFactories;
|
||||
|
||||
public JmsHealthIndicatorConfiguration(
|
||||
ObjectProvider<Map<String, ConnectionFactory>> connectionFactoriesProvider) {
|
||||
this.connectionFactories = connectionFactoriesProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "jmsHealthIndicator")
|
||||
|
@ -371,11 +408,15 @@ public class HealthIndicatorAutoConfiguration {
|
|||
public static class ElasticsearchHealthIndicatorConfiguration extends
|
||||
CompositeHealthIndicatorConfiguration<ElasticsearchHealthIndicator, Client> {
|
||||
|
||||
@Autowired
|
||||
private Map<String, Client> clients;
|
||||
private final Map<String, Client> clients;
|
||||
|
||||
@Autowired
|
||||
private ElasticsearchHealthIndicatorProperties properties;
|
||||
private final ElasticsearchHealthIndicatorProperties properties;
|
||||
|
||||
public ElasticsearchHealthIndicatorConfiguration(Map<String, Client> clients,
|
||||
ElasticsearchHealthIndicatorProperties properties) {
|
||||
this.clients = clients;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "elasticsearchHealthIndicator")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 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.
|
||||
|
@ -25,6 +25,7 @@ import java.util.Set;
|
|||
import javax.annotation.PostConstruct;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.endpoint.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping;
|
||||
|
@ -108,11 +109,16 @@ public class ManagementWebSecurityAutoConfiguration {
|
|||
protected static class ManagementSecurityPropertiesConfiguration
|
||||
implements SecurityPrerequisite {
|
||||
|
||||
@Autowired(required = false)
|
||||
private SecurityProperties security;
|
||||
private final SecurityProperties security;
|
||||
|
||||
@Autowired(required = false)
|
||||
private ManagementServerProperties management;
|
||||
private final ManagementServerProperties management;
|
||||
|
||||
public ManagementSecurityPropertiesConfiguration(
|
||||
ObjectProvider<SecurityProperties> securityProvider,
|
||||
ObjectProvider<ManagementServerProperties> managementProvider) {
|
||||
this.security = securityProvider.getIfAvailable();
|
||||
this.management = managementProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
@ -232,14 +238,19 @@ public class ManagementWebSecurityAutoConfiguration {
|
|||
protected static class ManagementWebSecurityConfigurerAdapter
|
||||
extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
private SecurityProperties security;
|
||||
private final SecurityProperties security;
|
||||
|
||||
@Autowired
|
||||
private ManagementServerProperties management;
|
||||
private final ManagementServerProperties management;
|
||||
|
||||
@Autowired(required = false)
|
||||
private ManagementContextResolver contextResolver;
|
||||
private final ManagementContextResolver contextResolver;
|
||||
|
||||
public ManagementWebSecurityConfigurerAdapter(SecurityProperties security,
|
||||
ManagementServerProperties management,
|
||||
ObjectProvider<ManagementContextResolver> contextResolverProvider) {
|
||||
this.security = security;
|
||||
this.management = management;
|
||||
this.contextResolver = contextResolverProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.actuate.endpoint.MetricsEndpointMetricReader;
|
||||
import org.springframework.boot.actuate.metrics.export.Exporter;
|
||||
|
@ -55,22 +55,27 @@ import org.springframework.util.CollectionUtils;
|
|||
@EnableConfigurationProperties
|
||||
public class MetricExportAutoConfiguration {
|
||||
|
||||
@Autowired
|
||||
private MetricExportProperties properties;
|
||||
private final MetricExportProperties properties;
|
||||
|
||||
@Autowired(required = false)
|
||||
private MetricsEndpointMetricReader endpointReader;
|
||||
private final MetricsEndpointMetricReader endpointReader;
|
||||
|
||||
@Autowired(required = false)
|
||||
@ExportMetricReader
|
||||
private List<MetricReader> readers;
|
||||
private final List<MetricReader> readers;
|
||||
|
||||
@Autowired(required = false)
|
||||
@ExportMetricWriter
|
||||
private Map<String, GaugeWriter> writers = Collections.emptyMap();
|
||||
private final Map<String, GaugeWriter> writers;
|
||||
|
||||
@Autowired(required = false)
|
||||
private Map<String, Exporter> exporters = Collections.emptyMap();
|
||||
private final Map<String, Exporter> exporters;
|
||||
|
||||
public MetricExportAutoConfiguration(MetricExportProperties properties,
|
||||
ObjectProvider<MetricsEndpointMetricReader> endpointReaderProvider,
|
||||
@ExportMetricReader ObjectProvider<List<MetricReader>> readersProvider,
|
||||
@ExportMetricWriter ObjectProvider<Map<String, GaugeWriter>> writersProvider,
|
||||
ObjectProvider<Map<String, Exporter>> exportersProvider) {
|
||||
this.properties = properties;
|
||||
this.endpointReader = endpointReaderProvider.getIfAvailable();
|
||||
this.readers = readersProvider.getIfAvailable();
|
||||
this.writers = writersProvider.getIfAvailable();
|
||||
this.exporters = exportersProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "metricWritersMetricExporter")
|
||||
|
@ -81,16 +86,19 @@ public class MetricExportAutoConfiguration {
|
|||
reader = new CompositeMetricReader(
|
||||
this.readers.toArray(new MetricReader[this.readers.size()]));
|
||||
}
|
||||
if (reader == null && this.exporters.isEmpty()) {
|
||||
if (reader == null && CollectionUtils.isEmpty(this.exporters)) {
|
||||
return new NoOpSchedulingConfigurer();
|
||||
}
|
||||
MetricExporters exporters = new MetricExporters(this.properties);
|
||||
if (reader != null) {
|
||||
writers.putAll(this.writers);
|
||||
if (!CollectionUtils.isEmpty(this.writers)) {
|
||||
writers.putAll(this.writers);
|
||||
}
|
||||
exporters.setReader(reader);
|
||||
exporters.setWriters(writers);
|
||||
}
|
||||
exporters.setExporters(this.exporters);
|
||||
exporters.setExporters(this.exporters == null
|
||||
? Collections.<String, Exporter>emptyMap() : this.exporters);
|
||||
return exporters;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 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.actuate.autoconfigure;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.Servlet;
|
||||
|
@ -24,7 +23,7 @@ import javax.sql.DataSource;
|
|||
|
||||
import org.apache.catalina.startup.Tomcat;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.actuate.cache.CacheStatisticsProvider;
|
||||
import org.springframework.boot.actuate.endpoint.CachePublicMetrics;
|
||||
import org.springframework.boot.actuate.endpoint.DataSourcePublicMetrics;
|
||||
|
@ -71,9 +70,12 @@ import org.springframework.lang.UsesJava7;
|
|||
IntegrationAutoConfiguration.class })
|
||||
public class PublicMetricsAutoConfiguration {
|
||||
|
||||
@Autowired(required = false)
|
||||
@ExportMetricReader
|
||||
private List<MetricReader> metricReaders = Collections.emptyList();
|
||||
private final List<MetricReader> metricReaders;
|
||||
|
||||
public PublicMetricsAutoConfiguration(
|
||||
@ExportMetricReader ObjectProvider<List<MetricReader>> metricReadersProvider) {
|
||||
this.metricReaders = metricReadersProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SystemPublicMetrics systemPublicMetrics() {
|
||||
|
@ -82,8 +84,10 @@ public class PublicMetricsAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
public MetricReaderPublicMetrics metricReaderPublicMetrics() {
|
||||
return new MetricReaderPublicMetrics(new CompositeMetricReader(
|
||||
this.metricReaders.toArray(new MetricReader[0])));
|
||||
return new MetricReaderPublicMetrics(
|
||||
new CompositeMetricReader(this.metricReaders == null ? new MetricReader[0]
|
||||
: this.metricReaders
|
||||
.toArray(new MetricReader[this.metricReaders.size()])));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -33,6 +33,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.autoconfigure.EndpointMvcIntegrationTests.Application;
|
||||
import org.springframework.boot.actuate.endpoint.Endpoint;
|
||||
|
@ -120,6 +121,13 @@ public class EndpointMvcIntegrationTests {
|
|||
@RestController
|
||||
protected static class Application {
|
||||
|
||||
private final List<HttpMessageConverter<?>> converters;
|
||||
|
||||
public Application(
|
||||
ObjectProvider<List<HttpMessageConverter<?>>> convertersProvider) {
|
||||
this.converters = convertersProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@RequestMapping("/{name}/{env}/{bar}")
|
||||
public Map<String, Object> master(@PathVariable String name,
|
||||
@PathVariable String env, @PathVariable String label) {
|
||||
|
@ -132,13 +140,11 @@ public class EndpointMvcIntegrationTests {
|
|||
return Collections.singletonMap("foo", (Object) "bar");
|
||||
}
|
||||
|
||||
@Autowired(required = false)
|
||||
private final List<HttpMessageConverter<?>> converters = Collections.emptyList();
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public HttpMessageConverters messageConverters() {
|
||||
return new HttpMessageConverters(this.converters);
|
||||
return new HttpMessageConverters(this.converters == null
|
||||
? Collections.<HttpMessageConverter<?>>emptyList() : this.converters);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 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,7 @@ package org.springframework.boot.autoconfigure.admin;
|
|||
|
||||
import javax.management.MalformedObjectNameException;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.admin.SpringApplicationAdminMXBean;
|
||||
import org.springframework.boot.admin.SpringApplicationAdminMXBeanRegistrar;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
|
@ -53,11 +53,16 @@ public class SpringApplicationAdminJmxAutoConfiguration {
|
|||
*/
|
||||
private static final String DEFAULT_JMX_NAME = "org.springframework.boot:type=Admin,name=SpringApplication";
|
||||
|
||||
@Autowired(required = false)
|
||||
private MBeanExporter mbeanExporter;
|
||||
private final MBeanExporter mbeanExporter;
|
||||
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
private final Environment environment;
|
||||
|
||||
public SpringApplicationAdminJmxAutoConfiguration(
|
||||
ObjectProvider<MBeanExporter> mbeanExporterProvider,
|
||||
Environment environment) {
|
||||
this.mbeanExporter = mbeanExporterProvider.getIfAvailable();
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SpringApplicationAdminMXBeanRegistrar springApplicationAdminRegistrar()
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFacto
|
|||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
@ -39,11 +38,15 @@ import org.springframework.context.annotation.Configuration;
|
|||
@ConditionalOnClass(EnableRabbit.class)
|
||||
class RabbitAnnotationDrivenConfiguration {
|
||||
|
||||
@Autowired
|
||||
private ObjectProvider<MessageConverter> messageConverter;
|
||||
private final ObjectProvider<MessageConverter> messageConverter;
|
||||
|
||||
@Autowired
|
||||
private RabbitProperties properties;
|
||||
private final RabbitProperties properties;
|
||||
|
||||
RabbitAnnotationDrivenConfiguration(ObjectProvider<MessageConverter> messageConverter,
|
||||
RabbitProperties properties) {
|
||||
this.messageConverter = messageConverter;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.springframework.amqp.rabbit.core.RabbitMessagingTemplate;
|
|||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
|
@ -144,11 +143,16 @@ public class RabbitAutoConfiguration {
|
|||
@Import(RabbitConnectionFactoryCreator.class)
|
||||
protected static class RabbitTemplateConfiguration {
|
||||
|
||||
@Autowired
|
||||
private ObjectProvider<MessageConverter> messageConverter;
|
||||
private final ObjectProvider<MessageConverter> messageConverter;
|
||||
|
||||
@Autowired
|
||||
private RabbitProperties properties;
|
||||
private final RabbitProperties properties;
|
||||
|
||||
public RabbitTemplateConfiguration(
|
||||
ObjectProvider<MessageConverter> messageConverter,
|
||||
RabbitProperties properties) {
|
||||
this.messageConverter = messageConverter;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnSingleCandidate(ConnectionFactory.class)
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.springframework.batch.core.launch.JobLauncher;
|
|||
import org.springframework.batch.core.launch.JobOperator;
|
||||
import org.springframework.batch.core.launch.support.SimpleJobOperator;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.ExitCodeGenerator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
|
@ -64,11 +64,15 @@ import org.springframework.util.StringUtils;
|
|||
@EnableConfigurationProperties(BatchProperties.class)
|
||||
public class BatchAutoConfiguration {
|
||||
|
||||
@Autowired
|
||||
private BatchProperties properties;
|
||||
private final BatchProperties properties;
|
||||
|
||||
@Autowired(required = false)
|
||||
private JobParametersConverter jobParametersConverter;
|
||||
private final JobParametersConverter jobParametersConverter;
|
||||
|
||||
public BatchAutoConfiguration(BatchProperties properties,
|
||||
ObjectProvider<JobParametersConverter> jobParametersConverterProvider) {
|
||||
this.properties = properties;
|
||||
this.jobParametersConverter = jobParametersConverterProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
|
|
|
@ -22,7 +22,7 @@ import com.github.benmanes.caffeine.cache.CacheLoader;
|
|||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.CaffeineSpec;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.cache.CacheManager;
|
||||
|
@ -45,20 +45,27 @@ import org.springframework.util.StringUtils;
|
|||
@Conditional({ CacheCondition.class })
|
||||
class CaffeineCacheConfiguration {
|
||||
|
||||
@Autowired
|
||||
private CacheProperties cacheProperties;
|
||||
private final CacheProperties cacheProperties;
|
||||
|
||||
@Autowired
|
||||
private CacheManagerCustomizers customizers;
|
||||
private final CacheManagerCustomizers customizers;
|
||||
|
||||
@Autowired(required = false)
|
||||
private Caffeine<Object, Object> caffeine;
|
||||
private final Caffeine<Object, Object> caffeine;
|
||||
|
||||
@Autowired(required = false)
|
||||
private CaffeineSpec caffeineSpec;
|
||||
private final CaffeineSpec caffeineSpec;
|
||||
|
||||
@Autowired(required = false)
|
||||
private CacheLoader<Object, Object> cacheLoader;
|
||||
private final CacheLoader<Object, Object> cacheLoader;
|
||||
|
||||
CaffeineCacheConfiguration(CacheProperties cacheProperties,
|
||||
CacheManagerCustomizers customizers,
|
||||
ObjectProvider<Caffeine<Object, Object>> caffeineProvider,
|
||||
ObjectProvider<CaffeineSpec> caffeineSpecProvider,
|
||||
ObjectProvider<CacheLoader<Object, Object>> cacheLoaderProvider) {
|
||||
this.cacheProperties = cacheProperties;
|
||||
this.customizers = customizers;
|
||||
this.caffeine = caffeineProvider.getIfAvailable();
|
||||
this.caffeineSpec = caffeineSpecProvider.getIfAvailable();
|
||||
this.cacheLoader = cacheLoaderProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CaffeineCacheManager caffeineCacheManager() {
|
||||
|
|
|
@ -22,7 +22,7 @@ import com.google.common.cache.CacheBuilder;
|
|||
import com.google.common.cache.CacheBuilderSpec;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.cache.CacheManager;
|
||||
|
@ -45,20 +45,27 @@ import org.springframework.util.StringUtils;
|
|||
@Conditional(CacheCondition.class)
|
||||
class GuavaCacheConfiguration {
|
||||
|
||||
@Autowired
|
||||
private CacheProperties cacheProperties;
|
||||
private final CacheProperties cacheProperties;
|
||||
|
||||
@Autowired
|
||||
private CacheManagerCustomizers customizers;
|
||||
private final CacheManagerCustomizers customizers;
|
||||
|
||||
@Autowired(required = false)
|
||||
private CacheBuilder<Object, Object> cacheBuilder;
|
||||
private final CacheBuilder<Object, Object> cacheBuilder;
|
||||
|
||||
@Autowired(required = false)
|
||||
private CacheBuilderSpec cacheBuilderSpec;
|
||||
private final CacheBuilderSpec cacheBuilderSpec;
|
||||
|
||||
@Autowired(required = false)
|
||||
private CacheLoader<Object, Object> cacheLoader;
|
||||
private final CacheLoader<Object, Object> cacheLoader;
|
||||
|
||||
GuavaCacheConfiguration(CacheProperties cacheProperties,
|
||||
CacheManagerCustomizers customizers,
|
||||
ObjectProvider<CacheBuilder<Object, Object>> cacheBuilderProvider,
|
||||
ObjectProvider<CacheBuilderSpec> cacheBuilderSpecProvider,
|
||||
ObjectProvider<CacheLoader<Object, Object>> cacheLoaderProvider) {
|
||||
this.cacheProperties = cacheProperties;
|
||||
this.customizers = customizers;
|
||||
this.cacheBuilder = cacheBuilderProvider.getIfAvailable();
|
||||
this.cacheBuilderSpec = cacheBuilderSpecProvider.getIfAvailable();
|
||||
this.cacheLoader = cacheLoaderProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public GuavaCacheManager cacheManager() {
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.infinispan.manager.DefaultCacheManager;
|
|||
import org.infinispan.manager.EmbeddedCacheManager;
|
||||
import org.infinispan.spring.provider.SpringEmbeddedCacheManager;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.cache.CacheManager;
|
||||
|
@ -48,14 +48,20 @@ import org.springframework.util.CollectionUtils;
|
|||
@Conditional(CacheCondition.class)
|
||||
public class InfinispanCacheConfiguration {
|
||||
|
||||
@Autowired
|
||||
private CacheProperties cacheProperties;
|
||||
private final CacheProperties cacheProperties;
|
||||
|
||||
@Autowired
|
||||
private CacheManagerCustomizers customizers;
|
||||
private final CacheManagerCustomizers customizers;
|
||||
|
||||
@Autowired(required = false)
|
||||
private ConfigurationBuilder defaultConfigurationBuilder;
|
||||
private final ConfigurationBuilder defaultConfigurationBuilder;
|
||||
|
||||
public InfinispanCacheConfiguration(CacheProperties cacheProperties,
|
||||
CacheManagerCustomizers customizers,
|
||||
ObjectProvider<ConfigurationBuilder> defaultConfigurationBuilderProvider) {
|
||||
this.cacheProperties = cacheProperties;
|
||||
this.customizers = customizers;
|
||||
this.defaultConfigurationBuilder = defaultConfigurationBuilderProvider
|
||||
.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SpringEmbeddedCacheManager cacheManager(
|
||||
|
|
|
@ -26,7 +26,7 @@ import javax.cache.Caching;
|
|||
import javax.cache.configuration.MutableConfiguration;
|
||||
import javax.cache.spi.CachingProvider;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
|
@ -60,17 +60,24 @@ import org.springframework.util.StringUtils;
|
|||
JCacheCacheConfiguration.JCacheAvailableCondition.class })
|
||||
class JCacheCacheConfiguration {
|
||||
|
||||
@Autowired
|
||||
private CacheProperties cacheProperties;
|
||||
private final CacheProperties cacheProperties;
|
||||
|
||||
@Autowired
|
||||
private CacheManagerCustomizers customizers;
|
||||
private final CacheManagerCustomizers customizers;
|
||||
|
||||
@Autowired(required = false)
|
||||
private javax.cache.configuration.Configuration<?, ?> defaultCacheConfiguration;
|
||||
private final javax.cache.configuration.Configuration<?, ?> defaultCacheConfiguration;
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<JCacheManagerCustomizer> cacheManagerCustomizers;
|
||||
private final List<JCacheManagerCustomizer> cacheManagerCustomizers;
|
||||
|
||||
JCacheCacheConfiguration(CacheProperties cacheProperties,
|
||||
CacheManagerCustomizers customizers,
|
||||
ObjectProvider<javax.cache.configuration.Configuration<?, ?>> defaultCacheConfigurationProvider,
|
||||
ObjectProvider<List<JCacheManagerCustomizer>> cacheManagerCustomizersProvider) {
|
||||
this.cacheProperties = cacheProperties;
|
||||
this.customizers = customizers;
|
||||
this.defaultCacheConfiguration = defaultCacheConfigurationProvider
|
||||
.getIfAvailable();
|
||||
this.cacheManagerCustomizers = cacheManagerCustomizersProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JCacheCacheManager cacheManager(CacheManager jCacheCacheManager) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.data.couchbase;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
@ -38,11 +38,15 @@ import org.springframework.data.couchbase.repository.support.IndexManager;
|
|||
@ConditionalOnBean(CouchbaseConfigurer.class)
|
||||
class SpringBootCouchbaseDataConfiguration extends AbstractCouchbaseDataConfiguration {
|
||||
|
||||
@Autowired
|
||||
private CouchbaseDataProperties properties;
|
||||
private final CouchbaseDataProperties properties;
|
||||
|
||||
@Autowired(required = false)
|
||||
private CouchbaseConfigurer couchbaseConfigurer;
|
||||
private final CouchbaseConfigurer couchbaseConfigurer;
|
||||
|
||||
SpringBootCouchbaseDataConfiguration(CouchbaseDataProperties properties,
|
||||
ObjectProvider<CouchbaseConfigurer> couchbaseConfigurerProvider) {
|
||||
this.properties = properties;
|
||||
this.couchbaseConfigurer = couchbaseConfigurerProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CouchbaseConfigurer couchbaseConfigurer() {
|
||||
|
|
|
@ -27,7 +27,7 @@ import javax.sql.DataSource;
|
|||
import org.flywaydb.core.Flyway;
|
||||
import org.flywaydb.core.api.MigrationVersion;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
|
@ -44,7 +44,6 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.converter.GenericConverter;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
|
@ -80,21 +79,27 @@ public class FlywayAutoConfiguration {
|
|||
@EnableConfigurationProperties(FlywayProperties.class)
|
||||
public static class FlywayConfiguration {
|
||||
|
||||
@Autowired
|
||||
private FlywayProperties properties = new FlywayProperties();
|
||||
private final FlywayProperties properties;
|
||||
|
||||
@Autowired
|
||||
private ResourceLoader resourceLoader = new DefaultResourceLoader();
|
||||
private final ResourceLoader resourceLoader;
|
||||
|
||||
@Autowired(required = false)
|
||||
private DataSource dataSource;
|
||||
private final DataSource dataSource;
|
||||
|
||||
@Autowired(required = false)
|
||||
@FlywayDataSource
|
||||
private DataSource flywayDataSource;
|
||||
private final DataSource flywayDataSource;
|
||||
|
||||
@Autowired(required = false)
|
||||
private FlywayMigrationStrategy migrationStrategy;
|
||||
private final FlywayMigrationStrategy migrationStrategy;
|
||||
|
||||
public FlywayConfiguration(FlywayProperties properties,
|
||||
ResourceLoader resourceLoader,
|
||||
ObjectProvider<DataSource> dataSourceProvider,
|
||||
@FlywayDataSource ObjectProvider<DataSource> flywayDataSourceProvider,
|
||||
ObjectProvider<FlywayMigrationStrategy> migrationStrategyProvider) {
|
||||
this.properties = properties;
|
||||
this.resourceLoader = resourceLoader;
|
||||
this.dataSource = dataSourceProvider.getIfUnique();
|
||||
this.flywayDataSource = flywayDataSourceProvider.getIfAvailable();
|
||||
this.migrationStrategy = migrationStrategyProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void checkLocationExists() {
|
||||
|
|
|
@ -26,7 +26,7 @@ import groovy.text.markup.MarkupTemplateEngine;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
|
@ -69,14 +69,19 @@ public class GroovyTemplateAutoConfiguration {
|
|||
@ConditionalOnClass(GroovyMarkupConfigurer.class)
|
||||
public static class GroovyMarkupConfiguration {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
@Autowired
|
||||
private GroovyTemplateProperties properties;
|
||||
private final GroovyTemplateProperties properties;
|
||||
|
||||
@Autowired(required = false)
|
||||
private MarkupTemplateEngine templateEngine;
|
||||
private final MarkupTemplateEngine templateEngine;
|
||||
|
||||
public GroovyMarkupConfiguration(ApplicationContext applicationContext,
|
||||
GroovyTemplateProperties properties,
|
||||
ObjectProvider<MarkupTemplateEngine> templateEngineProvider) {
|
||||
this.applicationContext = applicationContext;
|
||||
this.properties = properties;
|
||||
this.templateEngine = templateEngineProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void checkTemplateLocationExists() {
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.apache.tomcat.jdbc.pool.DataSourceProxy;
|
|||
|
||||
import org.springframework.beans.factory.BeanFactoryUtils;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
|
@ -113,8 +112,11 @@ public class DataSourceAutoConfiguration {
|
|||
@Conditional(DataSourceAutoConfiguration.DataSourceAvailableCondition.class)
|
||||
protected static class JdbcTemplateConfiguration {
|
||||
|
||||
@Autowired(required = false)
|
||||
private DataSource dataSource;
|
||||
private final DataSource dataSource;
|
||||
|
||||
public JdbcTemplateConfiguration(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(JdbcOperations.class)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 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,6 @@ package org.springframework.boot.autoconfigure.jdbc;
|
|||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
|
@ -46,14 +45,22 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||
@AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE)
|
||||
public class DataSourceTransactionManagerAutoConfiguration {
|
||||
|
||||
@Autowired(required = false)
|
||||
private DataSource dataSource;
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(PlatformTransactionManager.class)
|
||||
@Configuration
|
||||
@ConditionalOnBean(DataSource.class)
|
||||
public DataSourceTransactionManager transactionManager() {
|
||||
return new DataSourceTransactionManager(this.dataSource);
|
||||
static class DataSourceTransactionManagerConfiguration {
|
||||
|
||||
private final DataSource dataSource;
|
||||
|
||||
DataSourceTransactionManagerConfiguration(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(PlatformTransactionManager.class)
|
||||
public DataSourceTransactionManager transactionManager() {
|
||||
return new DataSourceTransactionManager(this.dataSource);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ConditionalOnMissingBean(AbstractTransactionManagementConfiguration.class)
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.glassfish.jersey.server.ResourceConfig;
|
|||
import org.glassfish.jersey.servlet.ServletContainer;
|
||||
import org.glassfish.jersey.servlet.ServletProperties;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
|
@ -88,17 +89,21 @@ public class JerseyAutoConfiguration implements ServletContextAware {
|
|||
|
||||
private static final Log logger = LogFactory.getLog(JerseyAutoConfiguration.class);
|
||||
|
||||
@Autowired
|
||||
private JerseyProperties jersey;
|
||||
private final JerseyProperties jersey;
|
||||
|
||||
@Autowired
|
||||
private ResourceConfig config;
|
||||
private final ResourceConfig config;
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<ResourceConfigCustomizer> customizers;
|
||||
private final List<ResourceConfigCustomizer> customizers;
|
||||
|
||||
private String path;
|
||||
|
||||
public JerseyAutoConfiguration(JerseyProperties jersey, ResourceConfig config,
|
||||
ObjectProvider<List<ResourceConfigCustomizer>> customizersProvider) {
|
||||
this.jersey = jersey;
|
||||
this.config = config;
|
||||
this.customizers = customizersProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void path() {
|
||||
resolveApplicationPath();
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.jms;
|
|||
import javax.jms.ConnectionFactory;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnJndi;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
|
@ -44,17 +43,23 @@ import org.springframework.transaction.jta.JtaTransactionManager;
|
|||
@ConditionalOnClass(EnableJms.class)
|
||||
class JmsAnnotationDrivenConfiguration {
|
||||
|
||||
@Autowired
|
||||
private ObjectProvider<DestinationResolver> destinationResolver;
|
||||
private final ObjectProvider<DestinationResolver> destinationResolver;
|
||||
|
||||
@Autowired
|
||||
private ObjectProvider<JtaTransactionManager> transactionManager;
|
||||
private final ObjectProvider<JtaTransactionManager> transactionManager;
|
||||
|
||||
@Autowired
|
||||
private ObjectProvider<MessageConverter> messageConverter;
|
||||
private final ObjectProvider<MessageConverter> messageConverter;
|
||||
|
||||
@Autowired
|
||||
private JmsProperties properties;
|
||||
private final JmsProperties properties;
|
||||
|
||||
JmsAnnotationDrivenConfiguration(
|
||||
ObjectProvider<DestinationResolver> destinationResolver,
|
||||
ObjectProvider<JtaTransactionManager> transactionManager,
|
||||
ObjectProvider<MessageConverter> messageConverter, JmsProperties properties) {
|
||||
this.destinationResolver = destinationResolver;
|
||||
this.transactionManager = transactionManager;
|
||||
this.messageConverter = messageConverter;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.jms;
|
|||
import javax.jms.ConnectionFactory;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
|
@ -50,14 +49,19 @@ public class JmsAutoConfiguration {
|
|||
@Configuration
|
||||
protected static class JmsTemplateConfiguration {
|
||||
|
||||
@Autowired
|
||||
private JmsProperties properties;
|
||||
private final JmsProperties properties;
|
||||
|
||||
@Autowired
|
||||
private ObjectProvider<DestinationResolver> destinationResolver;
|
||||
private final ObjectProvider<DestinationResolver> destinationResolver;
|
||||
|
||||
@Autowired
|
||||
private ObjectProvider<MessageConverter> messageConverter;
|
||||
private final ObjectProvider<MessageConverter> messageConverter;
|
||||
|
||||
public JmsTemplateConfiguration(JmsProperties properties,
|
||||
ObjectProvider<DestinationResolver> destinationResolver,
|
||||
ObjectProvider<MessageConverter> messageConverter) {
|
||||
this.properties = properties;
|
||||
this.destinationResolver = destinationResolver;
|
||||
this.messageConverter = messageConverter;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 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.
|
||||
|
@ -27,7 +27,7 @@ import org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationI
|
|||
import org.apache.activemq.artemis.jms.server.config.impl.TopicConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
|
@ -47,17 +47,23 @@ import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
|||
@ConditionalOnProperty(prefix = "spring.artemis.embedded", name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
class ArtemisEmbeddedServerConfiguration {
|
||||
|
||||
@Autowired
|
||||
private ArtemisProperties properties;
|
||||
private final ArtemisProperties properties;
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<ArtemisConfigurationCustomizer> configurationCustomizers;
|
||||
private final List<ArtemisConfigurationCustomizer> configurationCustomizers;
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<JMSQueueConfiguration> queuesConfiguration;
|
||||
private final List<JMSQueueConfiguration> queuesConfiguration;
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<TopicConfiguration> topicsConfiguration;
|
||||
private final List<TopicConfiguration> topicsConfiguration;
|
||||
|
||||
ArtemisEmbeddedServerConfiguration(ArtemisProperties properties,
|
||||
ObjectProvider<List<ArtemisConfigurationCustomizer>> configurationCustomizersProvider,
|
||||
ObjectProvider<List<JMSQueueConfiguration>> queuesConfigurationProvider,
|
||||
ObjectProvider<List<TopicConfiguration>> topicsConfigurationProvider) {
|
||||
this.properties = properties;
|
||||
this.configurationCustomizers = configurationCustomizersProvider.getIfAvailable();
|
||||
this.queuesConfiguration = queuesConfigurationProvider.getIfAvailable();
|
||||
this.topicsConfiguration = topicsConfigurationProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2016 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.
|
||||
|
@ -27,7 +27,7 @@ import org.hornetq.jms.server.config.impl.JMSQueueConfigurationImpl;
|
|||
import org.hornetq.jms.server.config.impl.TopicConfigurationImpl;
|
||||
import org.hornetq.jms.server.embedded.EmbeddedJMS;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
|
@ -47,17 +47,23 @@ import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
|||
@ConditionalOnProperty(prefix = "spring.hornetq.embedded", name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
class HornetQEmbeddedServerConfiguration {
|
||||
|
||||
@Autowired
|
||||
private HornetQProperties properties;
|
||||
private final HornetQProperties properties;
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<HornetQConfigurationCustomizer> configurationCustomizers;
|
||||
private final List<HornetQConfigurationCustomizer> configurationCustomizers;
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<JMSQueueConfiguration> queuesConfiguration;
|
||||
private final List<JMSQueueConfiguration> queuesConfiguration;
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<TopicConfiguration> topicsConfiguration;
|
||||
private final List<TopicConfiguration> topicsConfiguration;
|
||||
|
||||
HornetQEmbeddedServerConfiguration(HornetQProperties properties,
|
||||
ObjectProvider<List<HornetQConfigurationCustomizer>> configurationCustomizersProvider,
|
||||
ObjectProvider<List<JMSQueueConfiguration>> queuesConfigurationProvider,
|
||||
ObjectProvider<List<TopicConfiguration>> topicsConfigurationProvider) {
|
||||
this.properties = properties;
|
||||
this.configurationCustomizers = configurationCustomizersProvider.getIfAvailable();
|
||||
this.queuesConfiguration = queuesConfigurationProvider.getIfAvailable();
|
||||
this.topicsConfiguration = topicsConfigurationProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 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.
|
||||
|
@ -31,7 +31,7 @@ import org.jooq.impl.DefaultConfiguration;
|
|||
import org.jooq.impl.DefaultDSLContext;
|
||||
import org.jooq.impl.DefaultExecuteListenerProvider;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
|
@ -81,29 +81,40 @@ public class JooqAutoConfiguration {
|
|||
@EnableConfigurationProperties(JooqProperties.class)
|
||||
public static class DslContextConfiguration {
|
||||
|
||||
@Autowired
|
||||
private JooqProperties properties = new JooqProperties();
|
||||
private final JooqProperties properties;
|
||||
|
||||
@Autowired
|
||||
private ConnectionProvider connectionProvider;
|
||||
private final ConnectionProvider connectionProvider;
|
||||
|
||||
@Autowired(required = false)
|
||||
private TransactionProvider transactionProvider;
|
||||
private final TransactionProvider transactionProvider;
|
||||
|
||||
@Autowired(required = false)
|
||||
private RecordMapperProvider recordMapperProvider;
|
||||
private final RecordMapperProvider recordMapperProvider;
|
||||
|
||||
@Autowired(required = false)
|
||||
private Settings settings;
|
||||
private final Settings settings;
|
||||
|
||||
@Autowired(required = false)
|
||||
private RecordListenerProvider[] recordListenerProviders;
|
||||
private final RecordListenerProvider[] recordListenerProviders;
|
||||
|
||||
@Autowired
|
||||
private ExecuteListenerProvider[] executeListenerProviders;
|
||||
private final ExecuteListenerProvider[] executeListenerProviders;
|
||||
|
||||
@Autowired(required = false)
|
||||
private VisitListenerProvider[] visitListenerProviders;
|
||||
private final VisitListenerProvider[] visitListenerProviders;
|
||||
|
||||
public DslContextConfiguration(JooqProperties properties,
|
||||
ConnectionProvider connectionProvider,
|
||||
ObjectProvider<TransactionProvider> transactionProviderProvider,
|
||||
ObjectProvider<RecordMapperProvider> recordMapperProviderProvider,
|
||||
ObjectProvider<Settings> settingsProvider,
|
||||
ObjectProvider<RecordListenerProvider[]> recordListenerProvidersProvider,
|
||||
ExecuteListenerProvider[] executeListenerProviders,
|
||||
ObjectProvider<VisitListenerProvider[]> visitListenerProvidersProvider) {
|
||||
this.properties = properties;
|
||||
this.connectionProvider = connectionProvider;
|
||||
this.transactionProvider = transactionProviderProvider.getIfAvailable();
|
||||
this.recordMapperProvider = recordMapperProviderProvider.getIfAvailable();
|
||||
this.settings = settingsProvider.getIfAvailable();
|
||||
this.recordListenerProviders = recordListenerProvidersProvider
|
||||
.getIfAvailable();
|
||||
this.executeListenerProviders = executeListenerProviders;
|
||||
this.visitListenerProviders = visitListenerProvidersProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DefaultDSLContext dslContext(org.jooq.Configuration configuration) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 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.
|
||||
|
@ -23,7 +23,7 @@ import javax.activation.MimeType;
|
|||
import javax.mail.Session;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
|
@ -54,11 +54,15 @@ import org.springframework.mail.javamail.JavaMailSenderImpl;
|
|||
@Import(JndiSessionConfiguration.class)
|
||||
public class MailSenderAutoConfiguration {
|
||||
|
||||
@Autowired
|
||||
private MailProperties properties;
|
||||
private final MailProperties properties;
|
||||
|
||||
@Autowired(required = false)
|
||||
private Session session;
|
||||
private final Session session;
|
||||
|
||||
public MailSenderAutoConfiguration(MailProperties properties,
|
||||
ObjectProvider<Session> sessionProvider) {
|
||||
this.properties = properties;
|
||||
this.session = sessionProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JavaMailSenderImpl mailSender() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 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.
|
||||
|
@ -23,7 +23,7 @@ import javax.annotation.PreDestroy;
|
|||
import com.mongodb.MongoClient;
|
||||
import com.mongodb.MongoClientOptions;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
|
@ -45,17 +45,21 @@ import org.springframework.core.env.Environment;
|
|||
@ConditionalOnMissingBean(type = "org.springframework.data.mongodb.MongoDbFactory")
|
||||
public class MongoAutoConfiguration {
|
||||
|
||||
@Autowired
|
||||
private MongoProperties properties;
|
||||
private final MongoProperties properties;
|
||||
|
||||
@Autowired(required = false)
|
||||
private MongoClientOptions options;
|
||||
private final MongoClientOptions options;
|
||||
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
private final Environment environment;
|
||||
|
||||
private MongoClient mongo;
|
||||
|
||||
public MongoAutoConfiguration(MongoProperties properties,
|
||||
ObjectProvider<MongoClientOptions> optionsProvider, Environment environment) {
|
||||
this.properties = properties;
|
||||
this.options = optionsProvider.getIfAvailable();
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void close() {
|
||||
if (this.mongo != null) {
|
||||
|
|
|
@ -47,7 +47,6 @@ import de.flapdoodle.embed.process.store.ArtifactStoreBuilder;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
|
@ -83,37 +82,21 @@ public class EmbeddedMongoAutoConfiguration {
|
|||
private static final byte[] IP6_LOOPBACK_ADDRESS = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 1 };
|
||||
|
||||
@Autowired
|
||||
private MongoProperties properties;
|
||||
private final MongoProperties properties;
|
||||
|
||||
@Autowired
|
||||
private EmbeddedMongoProperties embeddedProperties;
|
||||
private final EmbeddedMongoProperties embeddedProperties;
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
private final ApplicationContext context;
|
||||
|
||||
@Autowired(required = false)
|
||||
private IRuntimeConfig runtimeConfig;
|
||||
private final IRuntimeConfig runtimeConfig;
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnClass(Logger.class)
|
||||
public IRuntimeConfig embeddedMongoRuntimeConfig() {
|
||||
Logger logger = LoggerFactory
|
||||
.getLogger(getClass().getPackage().getName() + ".EmbeddedMongo");
|
||||
ProcessOutput processOutput = new ProcessOutput(
|
||||
Processors.logTo(logger, Slf4jLevel.INFO),
|
||||
Processors.logTo(logger, Slf4jLevel.ERROR), Processors.named("[console>]",
|
||||
Processors.logTo(logger, Slf4jLevel.DEBUG)));
|
||||
return new RuntimeConfigBuilder().defaultsWithLogger(Command.MongoD, logger)
|
||||
.processOutput(processOutput).artifactStore(getArtifactStore(logger))
|
||||
.build();
|
||||
}
|
||||
|
||||
private ArtifactStoreBuilder getArtifactStore(Logger logger) {
|
||||
return new ExtractedArtifactStoreBuilder().defaults(Command.MongoD)
|
||||
.download(new DownloadConfigBuilder().defaultsForCommand(Command.MongoD)
|
||||
.progressListener(new Slf4jProgressListener(logger)).build());
|
||||
public EmbeddedMongoAutoConfiguration(MongoProperties properties,
|
||||
EmbeddedMongoProperties embeddedProperties, ApplicationContext context,
|
||||
IRuntimeConfig runtimeConfig) {
|
||||
this.properties = properties;
|
||||
this.embeddedProperties = embeddedProperties;
|
||||
this.context = context;
|
||||
this.runtimeConfig = runtimeConfig;
|
||||
}
|
||||
|
||||
@Bean(initMethod = "start", destroyMethod = "stop")
|
||||
|
@ -194,6 +177,33 @@ public class EmbeddedMongoAutoConfiguration {
|
|||
return (Map<String, Object>) propertySource.getSource();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass(Logger.class)
|
||||
@ConditionalOnMissingBean(IRuntimeConfig.class)
|
||||
static class RuntimeConfigConfiguration {
|
||||
|
||||
@Bean
|
||||
public IRuntimeConfig embeddedMongoRuntimeConfig() {
|
||||
Logger logger = LoggerFactory
|
||||
.getLogger(getClass().getPackage().getName() + ".EmbeddedMongo");
|
||||
ProcessOutput processOutput = new ProcessOutput(
|
||||
Processors.logTo(logger, Slf4jLevel.INFO),
|
||||
Processors.logTo(logger, Slf4jLevel.ERROR), Processors.named(
|
||||
"[console>]", Processors.logTo(logger, Slf4jLevel.DEBUG)));
|
||||
return new RuntimeConfigBuilder().defaultsWithLogger(Command.MongoD, logger)
|
||||
.processOutput(processOutput).artifactStore(getArtifactStore(logger))
|
||||
.build();
|
||||
}
|
||||
|
||||
private ArtifactStoreBuilder getArtifactStore(Logger logger) {
|
||||
return new ExtractedArtifactStoreBuilder().defaults(Command.MongoD)
|
||||
.download(new DownloadConfigBuilder()
|
||||
.defaultsForCommand(Command.MongoD)
|
||||
.progressListener(new Slf4jProgressListener(logger)).build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional configuration to ensure that {@link MongoClient} beans depend on the
|
||||
* {@code embeddedMongoServer} bean.
|
||||
|
|
|
@ -25,7 +25,7 @@ import javax.annotation.PostConstruct;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
|
@ -68,17 +68,23 @@ public class OAuth2AuthorizationServerConfiguration
|
|||
private static final Log logger = LogFactory
|
||||
.getLog(OAuth2AuthorizationServerConfiguration.class);
|
||||
|
||||
@Autowired
|
||||
private BaseClientDetails details;
|
||||
private final BaseClientDetails details;
|
||||
|
||||
@Autowired
|
||||
private AuthenticationManager authenticationManager;
|
||||
private final AuthenticationManager authenticationManager;
|
||||
|
||||
@Autowired(required = false)
|
||||
private TokenStore tokenStore;
|
||||
private final TokenStore tokenStore;
|
||||
|
||||
@Autowired
|
||||
private AuthorizationServerProperties properties;
|
||||
private final AuthorizationServerProperties properties;
|
||||
|
||||
public OAuth2AuthorizationServerConfiguration(BaseClientDetails details,
|
||||
AuthenticationManager authenticationManager,
|
||||
ObjectProvider<TokenStore> tokenStoreProvider,
|
||||
AuthorizationServerProperties properties) {
|
||||
this.details = details;
|
||||
this.authenticationManager = authenticationManager;
|
||||
this.tokenStore = tokenStoreProvider.getIfAvailable();
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
|
||||
|
|
|
@ -18,14 +18,13 @@ package org.springframework.boot.autoconfigure.security.oauth2.resource;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
|
@ -67,6 +66,7 @@ import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenCo
|
|||
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
|
||||
import org.springframework.social.connect.ConnectionFactoryLocator;
|
||||
import org.springframework.social.connect.support.OAuth2ConnectionFactory;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.client.ResourceAccessException;
|
||||
|
@ -98,38 +98,43 @@ public class ResourceServerTokenServicesConfiguration {
|
|||
.setAccessTokenUri("Not a URI " + "because there is no client");
|
||||
}
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<UserInfoRestTemplateCustomizer> customizers = Collections
|
||||
.emptyList();
|
||||
private final List<UserInfoRestTemplateCustomizer> customizers;
|
||||
|
||||
@Autowired(required = false)
|
||||
private OAuth2ProtectedResourceDetails details;
|
||||
private final OAuth2ProtectedResourceDetails details;
|
||||
|
||||
@Autowired(required = false)
|
||||
private OAuth2ClientContext oauth2ClientContext;
|
||||
private final OAuth2ClientContext oauth2ClientContext;
|
||||
|
||||
public UserInfoRestTemplateConfiguration(
|
||||
ObjectProvider<List<UserInfoRestTemplateCustomizer>> customizersProvider,
|
||||
ObjectProvider<OAuth2ProtectedResourceDetails> detailsProvider,
|
||||
ObjectProvider<OAuth2ClientContext> oauth2ClientContextProvider) {
|
||||
this.customizers = customizersProvider.getIfAvailable();
|
||||
this.details = detailsProvider.getIfAvailable();
|
||||
this.oauth2ClientContext = oauth2ClientContextProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean(name = "userInfoRestTemplate")
|
||||
public OAuth2RestTemplate userInfoRestTemplate() {
|
||||
if (this.details == null) {
|
||||
this.details = DEFAULT_RESOURCE_DETAILS;
|
||||
}
|
||||
OAuth2RestTemplate template = getTemplate();
|
||||
OAuth2RestTemplate template = getTemplate(
|
||||
this.details == null ? DEFAULT_RESOURCE_DETAILS : this.details);
|
||||
template.getInterceptors().add(new AcceptJsonRequestInterceptor());
|
||||
AuthorizationCodeAccessTokenProvider accessTokenProvider = new AuthorizationCodeAccessTokenProvider();
|
||||
accessTokenProvider.setTokenRequestEnhancer(new AcceptJsonRequestEnhancer());
|
||||
template.setAccessTokenProvider(accessTokenProvider);
|
||||
AnnotationAwareOrderComparator.sort(this.customizers);
|
||||
for (UserInfoRestTemplateCustomizer customizer : this.customizers) {
|
||||
customizer.customize(template);
|
||||
if (!CollectionUtils.isEmpty(this.customizers)) {
|
||||
AnnotationAwareOrderComparator.sort(this.customizers);
|
||||
for (UserInfoRestTemplateCustomizer customizer : this.customizers) {
|
||||
customizer.customize(template);
|
||||
}
|
||||
}
|
||||
return template;
|
||||
}
|
||||
|
||||
private OAuth2RestTemplate getTemplate() {
|
||||
private OAuth2RestTemplate getTemplate(OAuth2ProtectedResourceDetails details) {
|
||||
if (this.oauth2ClientContext == null) {
|
||||
return new OAuth2RestTemplate(this.details);
|
||||
return new OAuth2RestTemplate(details);
|
||||
}
|
||||
return new OAuth2RestTemplate(this.details, this.oauth2ClientContext);
|
||||
return new OAuth2RestTemplate(details, this.oauth2ClientContext);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -164,18 +169,23 @@ public class ResourceServerTokenServicesConfiguration {
|
|||
@Conditional(NotTokenInfoCondition.class)
|
||||
protected static class SocialTokenServicesConfiguration {
|
||||
|
||||
@Autowired
|
||||
private ResourceServerProperties sso;
|
||||
private final ResourceServerProperties sso;
|
||||
|
||||
@Autowired(required = false)
|
||||
private OAuth2ConnectionFactory<?> connectionFactory;
|
||||
private final OAuth2ConnectionFactory<?> connectionFactory;
|
||||
|
||||
@Autowired(required = false)
|
||||
@Qualifier("userInfoRestTemplate")
|
||||
private OAuth2RestOperations restTemplate;
|
||||
private final OAuth2RestOperations restTemplate;
|
||||
|
||||
@Autowired(required = false)
|
||||
private AuthoritiesExtractor authoritiesExtractor;
|
||||
private final AuthoritiesExtractor authoritiesExtractor;
|
||||
|
||||
public SocialTokenServicesConfiguration(ResourceServerProperties sso,
|
||||
ObjectProvider<OAuth2ConnectionFactory<?>> connectionFactoryProvider,
|
||||
@Qualifier("userInfoRestTemplate") ObjectProvider<OAuth2RestOperations> restTemplateProvider,
|
||||
ObjectProvider<AuthoritiesExtractor> authoritiesExtractorProvider) {
|
||||
this.sso = sso;
|
||||
this.connectionFactory = connectionFactoryProvider.getIfAvailable();
|
||||
this.restTemplate = restTemplateProvider.getIfAvailable();
|
||||
this.authoritiesExtractor = authoritiesExtractorProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(ConnectionFactoryLocator.class)
|
||||
|
@ -206,15 +216,19 @@ public class ResourceServerTokenServicesConfiguration {
|
|||
@Conditional(NotTokenInfoCondition.class)
|
||||
protected static class UserInfoTokenServicesConfiguration {
|
||||
|
||||
@Autowired
|
||||
private ResourceServerProperties sso;
|
||||
private final ResourceServerProperties sso;
|
||||
|
||||
@Autowired(required = false)
|
||||
@Qualifier("userInfoRestTemplate")
|
||||
private OAuth2RestOperations restTemplate;
|
||||
private final OAuth2RestOperations restTemplate;
|
||||
|
||||
@Autowired(required = false)
|
||||
private AuthoritiesExtractor authoritiesExtractor;
|
||||
private final AuthoritiesExtractor authoritiesExtractor;
|
||||
|
||||
public UserInfoTokenServicesConfiguration(ResourceServerProperties sso,
|
||||
@Qualifier("userInfoRestTemplate") ObjectProvider<OAuth2RestOperations> restTemplateProvider,
|
||||
ObjectProvider<AuthoritiesExtractor> authoritiesExtractorProvider) {
|
||||
this.sso = sso;
|
||||
this.restTemplate = restTemplateProvider.getIfAvailable();
|
||||
this.authoritiesExtractor = authoritiesExtractorProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ResourceServerTokenServices.class)
|
||||
|
@ -239,12 +253,15 @@ public class ResourceServerTokenServicesConfiguration {
|
|||
|
||||
private RestTemplate keyUriRestTemplate = new RestTemplate();
|
||||
|
||||
@Autowired
|
||||
private ResourceServerProperties resource;
|
||||
private final ResourceServerProperties resource;
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<JwtAccessTokenConverterConfigurer> configurers = Collections
|
||||
.emptyList();
|
||||
private final List<JwtAccessTokenConverterConfigurer> configurers;
|
||||
|
||||
public JwtTokenServicesConfiguration(ResourceServerProperties resource,
|
||||
ObjectProvider<List<JwtAccessTokenConverterConfigurer>> configurersProvider) {
|
||||
this.resource = resource;
|
||||
this.configurers = configurersProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ResourceServerTokenServices.class)
|
||||
|
@ -278,9 +295,11 @@ public class ResourceServerTokenServicesConfiguration {
|
|||
if (keyValue != null) {
|
||||
converter.setVerifierKey(keyValue);
|
||||
}
|
||||
AnnotationAwareOrderComparator.sort(this.configurers);
|
||||
for (JwtAccessTokenConverterConfigurer configurer : this.configurers) {
|
||||
configurer.configure(converter);
|
||||
if (!CollectionUtils.isEmpty(this.configurers)) {
|
||||
AnnotationAwareOrderComparator.sort(this.configurers);
|
||||
for (JwtAccessTokenConverterConfigurer configurer : this.configurers) {
|
||||
configurer.configure(converter);
|
||||
}
|
||||
}
|
||||
return converter;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 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,7 +20,7 @@ import java.util.List;
|
|||
|
||||
import org.thymeleaf.spring4.SpringTemplateEngine;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
|
@ -75,14 +75,20 @@ public class SocialWebAutoConfiguration {
|
|||
protected static class SocialAutoConfigurationAdapter
|
||||
extends SocialConfigurerAdapter {
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<ConnectInterceptor<?>> connectInterceptors;
|
||||
private final List<ConnectInterceptor<?>> connectInterceptors;
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<DisconnectInterceptor<?>> disconnectInterceptors;
|
||||
private final List<DisconnectInterceptor<?>> disconnectInterceptors;
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<ProviderSignInInterceptor<?>> signInInterceptors;
|
||||
private final List<ProviderSignInInterceptor<?>> signInInterceptors;
|
||||
|
||||
public SocialAutoConfigurationAdapter(
|
||||
ObjectProvider<List<ConnectInterceptor<?>>> connectInterceptorsProvider,
|
||||
ObjectProvider<List<DisconnectInterceptor<?>>> disconnectInterceptorsProvider,
|
||||
ObjectProvider<List<ProviderSignInInterceptor<?>>> signInInterceptorsProvider) {
|
||||
this.connectInterceptors = connectInterceptorsProvider.getIfAvailable();
|
||||
this.disconnectInterceptors = disconnectInterceptorsProvider.getIfAvailable();
|
||||
this.signInInterceptors = signInInterceptorsProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ConnectController.class)
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.springframework.boot.autoconfigure.thymeleaf;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
@ -37,7 +36,7 @@ import org.thymeleaf.spring4.view.ThymeleafViewResolver;
|
|||
import org.thymeleaf.templateresolver.ITemplateResolver;
|
||||
import org.thymeleaf.templateresolver.TemplateResolver;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
|
@ -54,6 +53,7 @@ import org.springframework.context.ApplicationContext;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.MimeType;
|
||||
import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter;
|
||||
|
||||
|
@ -79,11 +79,15 @@ public class ThymeleafAutoConfiguration {
|
|||
@ConditionalOnMissingBean(name = "defaultTemplateResolver")
|
||||
public static class DefaultTemplateResolverConfiguration {
|
||||
|
||||
@Autowired
|
||||
private ThymeleafProperties properties;
|
||||
private final ThymeleafProperties properties;
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
public DefaultTemplateResolverConfiguration(ThymeleafProperties properties,
|
||||
ApplicationContext applicationContext) {
|
||||
this.properties = properties;
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void checkTemplateLocationExists() {
|
||||
|
@ -127,12 +131,16 @@ public class ThymeleafAutoConfiguration {
|
|||
@ConditionalOnMissingBean(SpringTemplateEngine.class)
|
||||
protected static class ThymeleafDefaultConfiguration {
|
||||
|
||||
@Autowired
|
||||
private final Collection<ITemplateResolver> templateResolvers = Collections
|
||||
.emptySet();
|
||||
private final Collection<ITemplateResolver> templateResolvers;
|
||||
|
||||
@Autowired(required = false)
|
||||
private final Collection<IDialect> dialects = Collections.emptySet();
|
||||
private final Collection<IDialect> dialects;
|
||||
|
||||
public ThymeleafDefaultConfiguration(
|
||||
Collection<ITemplateResolver> templateResolvers,
|
||||
ObjectProvider<Collection<IDialect>> dialectsProvider) {
|
||||
this.templateResolvers = templateResolvers;
|
||||
this.dialects = dialectsProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SpringTemplateEngine templateEngine() {
|
||||
|
@ -140,8 +148,10 @@ public class ThymeleafAutoConfiguration {
|
|||
for (ITemplateResolver templateResolver : this.templateResolvers) {
|
||||
engine.addTemplateResolver(templateResolver);
|
||||
}
|
||||
for (IDialect dialect : this.dialects) {
|
||||
engine.addDialect(dialect);
|
||||
if (!CollectionUtils.isEmpty(this.dialects)) {
|
||||
for (IDialect dialect : this.dialects) {
|
||||
engine.addDialect(dialect);
|
||||
}
|
||||
}
|
||||
return engine;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 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.
|
||||
|
@ -22,7 +22,7 @@ import java.util.List;
|
|||
import javax.servlet.MultipartConfigElement;
|
||||
import javax.servlet.ServletRegistration;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
|
||||
|
@ -79,14 +79,19 @@ public class DispatcherServletAutoConfiguration {
|
|||
@EnableConfigurationProperties(WebMvcProperties.class)
|
||||
protected static class DispatcherServletConfiguration {
|
||||
|
||||
@Autowired
|
||||
private ServerProperties server;
|
||||
private final ServerProperties server;
|
||||
|
||||
@Autowired
|
||||
private WebMvcProperties webMvcProperties;
|
||||
private final WebMvcProperties webMvcProperties;
|
||||
|
||||
@Autowired(required = false)
|
||||
private MultipartConfigElement multipartConfig;
|
||||
private final MultipartConfigElement multipartConfig;
|
||||
|
||||
public DispatcherServletConfiguration(ServerProperties server,
|
||||
WebMvcProperties webMvcProperties,
|
||||
ObjectProvider<MultipartConfigElement> multipartConfigProvider) {
|
||||
this.server = server;
|
||||
this.webMvcProperties = webMvcProperties;
|
||||
this.multipartConfig = multipartConfigProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean(name = DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)
|
||||
public DispatcherServlet dispatcherServlet() {
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure.web;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
|
@ -54,13 +54,18 @@ public class HttpMessageConvertersAutoConfiguration {
|
|||
|
||||
static final String PREFERRED_MAPPER_PROPERTY = "spring.http.converters.preferred-json-mapper";
|
||||
|
||||
@Autowired(required = false)
|
||||
private final List<HttpMessageConverter<?>> converters = Collections.emptyList();
|
||||
private final List<HttpMessageConverter<?>> converters;
|
||||
|
||||
public HttpMessageConvertersAutoConfiguration(
|
||||
ObjectProvider<List<HttpMessageConverter<?>>> convertersProvider) {
|
||||
this.converters = convertersProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public HttpMessageConverters messageConverters() {
|
||||
return new HttpMessageConverters(this.converters);
|
||||
return new HttpMessageConverters(this.converters == null
|
||||
? Collections.<HttpMessageConverter<?>>emptyList() : this.converters);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.logging.LogFactory;
|
|||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
|
||||
|
@ -137,20 +138,27 @@ public class WebMvcAutoConfiguration {
|
|||
private static final Log logger = LogFactory
|
||||
.getLog(WebMvcConfigurerAdapter.class);
|
||||
|
||||
@Autowired
|
||||
private ResourceProperties resourceProperties = new ResourceProperties();
|
||||
private final ResourceProperties resourceProperties;
|
||||
|
||||
@Autowired
|
||||
private WebMvcProperties mvcProperties = new WebMvcProperties();
|
||||
private final WebMvcProperties mvcProperties;
|
||||
|
||||
@Autowired
|
||||
private ListableBeanFactory beanFactory;
|
||||
private final ListableBeanFactory beanFactory;
|
||||
|
||||
@Autowired
|
||||
private HttpMessageConverters messageConverters;
|
||||
private final HttpMessageConverters messageConverters;
|
||||
|
||||
@Autowired(required = false)
|
||||
ResourceHandlerRegistrationCustomizer resourceHandlerRegistrationCustomizer;
|
||||
final ResourceHandlerRegistrationCustomizer resourceHandlerRegistrationCustomizer;
|
||||
|
||||
public WebMvcAutoConfigurationAdapter(ResourceProperties resourceProperties,
|
||||
WebMvcProperties mvcProperties, ListableBeanFactory beanFactory,
|
||||
HttpMessageConverters messageConverters,
|
||||
ObjectProvider<ResourceHandlerRegistrationCustomizer> resourceHandlerRegistrationCustomizerProvider) {
|
||||
this.resourceProperties = resourceProperties;
|
||||
this.mvcProperties = mvcProperties;
|
||||
this.beanFactory = beanFactory;
|
||||
this.messageConverters = messageConverters;
|
||||
this.resourceHandlerRegistrationCustomizer = resourceHandlerRegistrationCustomizerProvider
|
||||
.getIfAvailable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
|
@ -329,11 +337,16 @@ public class WebMvcAutoConfiguration {
|
|||
@Configuration
|
||||
public static class EnableWebMvcConfiguration extends DelegatingWebMvcConfiguration {
|
||||
|
||||
@Autowired(required = false)
|
||||
private WebMvcProperties mvcProperties;
|
||||
private final WebMvcProperties mvcProperties;
|
||||
|
||||
@Autowired
|
||||
private ListableBeanFactory beanFactory;
|
||||
private final ListableBeanFactory beanFactory;
|
||||
|
||||
public EnableWebMvcConfiguration(
|
||||
ObjectProvider<WebMvcProperties> mvcPropertiesProvider,
|
||||
ListableBeanFactory beanFactory) {
|
||||
this.mvcProperties = mvcPropertiesProvider.getIfAvailable();
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 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,10 +18,9 @@ package sample.devtools;
|
|||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SampleDevToolsApplication extends WebMvcAutoConfigurationAdapter {
|
||||
public class SampleDevToolsApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SampleDevToolsApplication.class, args);
|
||||
|
|
Loading…
Reference in New Issue