Skip to content

Commit

Permalink
Merge branch '2.3.x'
Browse files Browse the repository at this point in the history
Closes gh-24010
  • Loading branch information
wilkinsona committed Nov 3, 2020
2 parents c93d911 + 2dce4aa commit 699f03d
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 76 deletions.
Expand Up @@ -21,8 +21,6 @@
import java.util.HashSet;
import java.util.List;

import javax.annotation.PostConstruct;

import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.model.Resource;

Expand Down Expand Up @@ -112,10 +110,10 @@ static class JerseyWebEndpointsResourcesRegistrar {
this.mediaTypes = endpointMediaTypes;
this.basePath = basePath;
this.shouldRegisterLinks = shouldRegisterLinks;
register();
}

@PostConstruct
void register() {
private void register() {
// We can't easily use @ConditionalOnBean because @AutoConfigureBefore is
// not an option for management contexts. Instead we manually check if
// the resource config bean exists
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
Expand All @@ -19,8 +19,6 @@
import java.util.Collection;
import java.util.Map;

import javax.annotation.PostConstruct;

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag;

Expand Down Expand Up @@ -56,15 +54,15 @@ class CacheMetricsRegistrarConfiguration {
this.registry = registry;
this.cacheManagers = cacheManagers;
this.cacheMetricsRegistrar = new CacheMetricsRegistrar(this.registry, binderProviders);
bindCachesToRegistry();
}

@Bean
CacheMetricsRegistrar cacheMetricsRegistrar() {
return this.cacheMetricsRegistrar;
}

@PostConstruct
void bindCachesToRegistry() {
private void bindCachesToRegistry() {
this.cacheManagers.forEach(this::bindCacheManagerToRegistry);
}

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
Expand All @@ -16,7 +16,6 @@

package org.springframework.boot.autoconfigure.batch;

import javax.annotation.PostConstruct;
import javax.sql.DataSource;

import org.springframework.batch.core.configuration.annotation.BatchConfigurer;
Expand All @@ -26,6 +25,7 @@
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
Expand All @@ -40,7 +40,7 @@
* @author Stephane Nicoll
* @since 1.0.0
*/
public class BasicBatchConfigurer implements BatchConfigurer {
public class BasicBatchConfigurer implements BatchConfigurer, InitializingBean {

private final BatchProperties properties;

Expand Down Expand Up @@ -90,7 +90,11 @@ public JobExplorer getJobExplorer() throws Exception {
return this.jobExplorer;
}

@PostConstruct
@Override
public void afterPropertiesSet() {
initialize();
}

public void initialize() {
try {
this.transactionManager = buildTransactionManager();
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
Expand All @@ -19,8 +19,6 @@
import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand Down Expand Up @@ -57,9 +55,9 @@ public class FreeMarkerAutoConfiguration {
public FreeMarkerAutoConfiguration(ApplicationContext applicationContext, FreeMarkerProperties properties) {
this.applicationContext = applicationContext;
this.properties = properties;
checkTemplateLocationExists();
}

@PostConstruct
public void checkTemplateLocationExists() {
if (logger.isWarnEnabled() && this.properties.isCheckTemplateLocation()) {
List<TemplateLocation> locations = getLocations();
Expand Down
Expand Up @@ -19,7 +19,6 @@
import java.security.CodeSource;
import java.security.ProtectionDomain;

import javax.annotation.PostConstruct;
import javax.servlet.Servlet;

import groovy.text.markup.MarkupTemplateEngine;
Expand Down Expand Up @@ -77,9 +76,9 @@ public static class GroovyMarkupConfiguration {
public GroovyMarkupConfiguration(ApplicationContext applicationContext, GroovyTemplateProperties properties) {
this.applicationContext = applicationContext;
this.properties = properties;
checkTemplateLocationExists();
}

@PostConstruct
public void checkTemplateLocationExists() {
if (this.properties.isCheckTemplateLocation() && !isUsingGroovyAllJar()) {
TemplateLocation location = new TemplateLocation(this.properties.getResourceLoaderPath());
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
Expand All @@ -20,11 +20,10 @@
import java.util.Collection;
import java.util.List;

import javax.annotation.PostConstruct;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand Down Expand Up @@ -60,12 +59,13 @@ public static HalMessageConverterSupportedMediaTypesCustomizer halMessageConvert
* {@code Jackson2ModuleRegisteringBeanPostProcessor} has registered the converter and
* it is unordered.
*/
private static class HalMessageConverterSupportedMediaTypesCustomizer implements BeanFactoryAware {
private static class HalMessageConverterSupportedMediaTypesCustomizer
implements BeanFactoryAware, InitializingBean {

private volatile BeanFactory beanFactory;

@PostConstruct
void configureHttpMessageConverters() {
@Override
public void afterPropertiesSet() {
if (this.beanFactory instanceof ListableBeanFactory) {
configureHttpMessageConverters(((ListableBeanFactory) this.beanFactory)
.getBeansOfType(RequestMappingHandlerAdapter.class).values());
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
Expand All @@ -18,7 +18,6 @@

import java.sql.SQLException;

import javax.annotation.PostConstruct;
import javax.sql.DataSource;

import com.zaxxer.hikari.HikariDataSource;
Expand Down Expand Up @@ -59,10 +58,10 @@ static class Hikari {
Hikari(DataSource dataSource, ObjectProvider<MBeanExporter> mBeanExporter) {
this.dataSource = dataSource;
this.mBeanExporter = mBeanExporter;
validateMBeans();
}

@PostConstruct
void validateMBeans() {
private void validateMBeans() {
HikariDataSource hikariDataSource = DataSourceUnwrapper.unwrap(this.dataSource, HikariDataSource.class);
if (hikariDataSource != null && hikariDataSource.isRegisterMbeans()) {
this.mBeanExporter.ifUnique((exporter) -> exporter.addExcludedBean("dataSource"));
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
Expand All @@ -19,7 +19,6 @@
import java.util.Collections;
import java.util.EnumSet;

import javax.annotation.PostConstruct;
import javax.servlet.DispatcherType;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
Expand Down Expand Up @@ -95,22 +94,11 @@ public class JerseyAutoConfiguration implements ServletContextAware {

private final ResourceConfig config;

private final ObjectProvider<ResourceConfigCustomizer> customizers;

public JerseyAutoConfiguration(JerseyProperties jersey, ResourceConfig config,
ObjectProvider<ResourceConfigCustomizer> customizers) {
this.jersey = jersey;
this.config = config;
this.customizers = customizers;
}

@PostConstruct
public void path() {
customize();
}

private void customize() {
this.customizers.orderedStream().forEach((customizer) -> customizer.customize(this.config));
customizers.orderedStream().forEach((customizer) -> customizer.customize(this.config));
}

@Bean
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
Expand All @@ -16,7 +16,6 @@

package org.springframework.boot.autoconfigure.mail;

import javax.annotation.PostConstruct;
import javax.mail.MessagingException;

import org.springframework.boot.autoconfigure.AutoConfigureAfter;
Expand Down Expand Up @@ -44,9 +43,9 @@ public class MailSenderValidatorAutoConfiguration {

public MailSenderValidatorAutoConfiguration(JavaMailSenderImpl mailSender) {
this.mailSender = mailSender;
validateConnection();
}

@PostConstruct
public void validateConnection() {
try {
this.mailSender.testConnection();
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
Expand All @@ -16,8 +16,6 @@

package org.springframework.boot.autoconfigure.mustache;

import javax.annotation.PostConstruct;

import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Mustache.Collector;
import com.samskivert.mustache.Mustache.TemplateLoader;
Expand Down Expand Up @@ -57,9 +55,9 @@ public class MustacheAutoConfiguration {
public MustacheAutoConfiguration(MustacheProperties mustache, ApplicationContext applicationContext) {
this.mustache = mustache;
this.applicationContext = applicationContext;
checkTemplateLocationExists();
}

@PostConstruct
public void checkTemplateLocationExists() {
if (this.mustache.isCheckTemplateLocation()) {
TemplateLocation location = new TemplateLocation(this.mustache.getPrefix());
Expand Down
Expand Up @@ -20,8 +20,7 @@
import java.util.Map;
import java.util.Set;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.StringUtils;

Expand All @@ -35,7 +34,7 @@
* @since 2.0.0
*/
@ConfigurationProperties(prefix = "spring.security.oauth2.client")
public class OAuth2ClientProperties {
public class OAuth2ClientProperties implements InitializingBean {

/**
* OAuth provider details.
Expand All @@ -55,7 +54,11 @@ public Map<String, Registration> getRegistration() {
return this.registration;
}

@PostConstruct
@Override
public void afterPropertiesSet() {
validate();
}

public void validate() {
getRegistration().values().forEach(this::validateRegistration);
}
Expand Down
Expand Up @@ -21,8 +21,7 @@
import java.util.List;
import java.util.Locale;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
Expand Down Expand Up @@ -223,10 +222,10 @@ abstract static class AbstractSessionRepositoryImplementationValidator {
this.classLoader = applicationContext.getClassLoader();
this.sessionProperties = sessionProperties;
this.candidates = candidates;
checkAvailableImplementations();
}

@PostConstruct
void checkAvailableImplementations() {
private void checkAvailableImplementations() {
List<Class<?>> availableCandidates = new ArrayList<>();
for (String candidate : this.candidates) {
addCandidateIfAvailable(availableCandidates, candidate);
Expand Down Expand Up @@ -288,7 +287,7 @@ static class ReactiveSessionRepositoryImplementationValidator
/**
* Base class for validating that a (reactive) session repository bean exists.
*/
abstract static class AbstractSessionRepositoryValidator {
abstract static class AbstractSessionRepositoryValidator implements InitializingBean {

private final SessionProperties sessionProperties;

Expand All @@ -300,8 +299,8 @@ protected AbstractSessionRepositoryValidator(SessionProperties sessionProperties
this.sessionRepositoryProvider = sessionRepositoryProvider;
}

@PostConstruct
void checkSessionRepository() {
@Override
public void afterPropertiesSet() {
StoreType storeType = this.sessionProperties.getStoreType();
if (storeType != StoreType.NONE && this.sessionRepositoryProvider.getIfAvailable() == null
&& storeType != null) {
Expand Down

0 comments on commit 699f03d

Please sign in to comment.