Skip to content

Commit

Permalink
Migrate auto-configurations to @autoConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
rainboyan committed Apr 21, 2023
1 parent ea66545 commit 356f623
Show file tree
Hide file tree
Showing 29 changed files with 46 additions and 99 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2022 the original author or authors.
* Copyright 2015-2023 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,8 +18,8 @@
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;
Expand All @@ -34,7 +34,7 @@
* @see org.springframework.context.annotation.Configuration
* @see GrailsApplicationPostProcessor
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
@AutoConfigureOrder(10000)
@Import(GrailsAutoConfiguration.GrailsRegistrar.class)
public class GrailsAutoConfiguration {
Expand Down
4 changes: 0 additions & 4 deletions grails-boot/src/main/resources/META-INF/spring.factories
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Auto Configure
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
grails.boot.config.GrailsAutoConfiguration

# Application Context Initializers
org.springframework.context.ApplicationContextInitializer=\
org.grails.boot.context.GrailsConfigurationWarningsApplicationContextInitializer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2022 the original author or authors.
* Copyright 2021-2023 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,14 +16,14 @@
package org.grails.plugins.config;

import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Role;

import org.grails.plugins.support.GrailsDynamicPluginRegistryPostProcessor;

@Configuration(proxyBeanMethods = false)
@AutoConfiguration
@AutoConfigureOrder
public class GrailsDynamicModuleConfiguration {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2022 the original author or authors.
* Copyright 2021-2023 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,8 @@
package org.grails.plugins.config;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import grails.plugins.GrailsPluginManager;

Expand All @@ -29,7 +29,7 @@
* @author Michael Yan
* @since 2022.0.0
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
public class GrailsPluginManagerConfiguration {

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Application Context Initializers
org.springframework.context.ApplicationContextInitializer=\
org.grails.plugins.support.GrailsPluginsInfoApplicationContextInitializer

# Auto Configure
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.grails.plugins.config.GrailsDynamicModuleConfiguration,\
org.grails.plugins.config.GrailsPluginManagerConfiguration
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2022 the original author or authors.
* Copyright 2004-2023 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,9 +16,9 @@
package org.grails.plugins.codecs;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import grails.core.GrailsApplication;
Expand All @@ -32,7 +32,7 @@
* @author Michael Yan
* @since 2022.0.0
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
public class CodecsPluginConfiguration {

@Bean
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 the original author or authors.
* Copyright 2022-2023 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 @@ -23,7 +23,7 @@
import javax.servlet.Servlet;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand All @@ -35,7 +35,6 @@
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.filter.OrderedFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ClassUtils;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
Expand All @@ -60,10 +59,9 @@
* @author Michael Yan
* @since 2022.0.0
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration(before = { WebMvcAutoConfiguration.class, DispatcherServletAutoConfiguration.class })
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
@ConditionalOnClass({ Servlet.class })
@AutoConfigureBefore({ WebMvcAutoConfiguration.class, DispatcherServletAutoConfiguration.class })
public class ControllersPluginConfiguration {

@Bean
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
package org.grails.plugins.core;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import grails.config.ConfigProperties;
Expand All @@ -32,7 +32,7 @@
* @author Michael Yan
* @since 4.0
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
@AutoConfigureOrder
public class CoreConfiguration {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2022 the original author or authors.
* Copyright 2021-2023 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,14 +16,13 @@
package org.grails.plugins.core;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import grails.config.Config;
Expand All @@ -40,9 +39,8 @@
* @author Michael Yan
* @since 2022.0.0
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration(before = PropertyPlaceholderAutoConfiguration.class)
@AutoConfigureOrder(10010)
@AutoConfigureBefore(PropertyPlaceholderAutoConfiguration.class)
public class PropertyPlaceholderConfiguration {

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,3 @@
org.springframework.boot.env.PropertySourceLoader=\
org.grails.spring.boot.env.GroovyConfigPropertySourceLoader,\
org.grails.spring.boot.env.YamlPropertySourceLoader

# Auto Configure
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.grails.plugins.core.CoreConfiguration,\
org.grails.plugins.core.PropertyPlaceholderConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.math.BigInteger;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;

import grails.databinding.TypedStructuredBindingEditor;
Expand All @@ -34,7 +34,7 @@
/**
* Default converters configuration.
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
public class DefaultConvertersConfiguration {

private final DataBindingConfigurationProperties configurationProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
package org.grails.plugins.databinding;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;

import grails.core.GrailsApplication;
Expand Down Expand Up @@ -49,7 +49,7 @@
*
* @since 2022.0.0
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
@AutoConfigureOrder
@EnableConfigurationProperties(DataBindingConfigurationProperties.class)
@ImportAutoConfiguration(DefaultConvertersConfiguration.class)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2022 the original author or authors.
* Copyright 2004-2023 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 @@ -15,13 +15,13 @@
*/
package org.grails.plugins.i18n;

import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.LocaleResolver;
Expand All @@ -39,7 +39,7 @@
* @author Michael Yan
* @since 2022.0.0
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE + 8)
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
@ConditionalOnClass(ParamsAwareLocaleChangeInterceptor.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2022 the original author or authors.
* Copyright 2004-2023 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,15 +16,14 @@
package org.grails.plugins.i18n;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.context.MessageSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.AbstractApplicationContext;

import grails.config.Config;
Expand All @@ -40,8 +39,7 @@
* @author Michael Yan
* @since 2022.0.0
*/
@Configuration(proxyBeanMethods = false)
@AutoConfigureBefore(MessageSourceAutoConfiguration.class)
@AutoConfiguration(before = MessageSourceAutoConfiguration.class)
public class GrailsMessageSourceConfiguration {

@Bean
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2022 the original author or authors.
* Copyright 2021-2023 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,10 +16,10 @@
package org.grails.plugins.web.interceptors;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.handler.MappedInterceptor;

import grails.artefact.Interceptor;
Expand All @@ -30,7 +30,7 @@
* @author Michael Yan
* @since 2022.0.0
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
public class InterceptorsPluginConfiguration {

Expand Down

This file was deleted.

Loading

0 comments on commit 356f623

Please sign in to comment.