Skip to content

Commit

Permalink
Merge pull request #349 from groldan/autoconfigurations
Browse files Browse the repository at this point in the history
Annotate auto-configurations with @autoConfiguration
  • Loading branch information
groldan authored Aug 3, 2023
2 parents 912d1fb + 2a6c81e commit 77954a8
Show file tree
Hide file tree
Showing 48 changed files with 99 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@
import org.geoserver.config.GeoServerInfo;
import org.geoserver.config.GeoServerInfo.WebUIMode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Configuration;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Import;
import org.springframework.core.env.Environment;

import javax.annotation.PostConstruct;

@Configuration
@AutoConfigureAfter({GeoServerWebMvcMainAutoConfiguration.class})
@AutoConfiguration(after = {GeoServerWebMvcMainAutoConfiguration.class})
@Import({ //
WebCoreConfiguration.class, // this one is mandatory
SecurityAutoConfiguration.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
import org.geoserver.cloud.autoconfigure.core.GeoServerWebMvcMainAutoConfiguration;
import org.geoserver.cloud.config.factory.FilteringXmlBeanDefinitionReader;
import org.geoserver.cloud.virtualservice.VirtualServiceVerifier;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

@Configuration(proxyBeanMethods = true)
@AutoConfigureAfter({GeoServerWebMvcMainAutoConfiguration.class})
@AutoConfiguration(after = GeoServerWebMvcMainAutoConfiguration.class)
@ImportResource( //
reader = FilteringXmlBeanDefinitionReader.class, //
locations = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@
import org.geoserver.wms.capabilities.LegendSample;
import org.geoserver.wms.capabilities.LegendSampleImpl;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

@Configuration
// auto-configure before GWC's wms-integration to avoid it precluding to load beans from
// jar:gs-wms-.*
@AutoConfigureBefore(WMSIntegrationAutoConfiguration.class)
@AutoConfiguration(before = WMSIntegrationAutoConfiguration.class)
@ImportResource( //
reader = FilteringXmlBeanDefinitionReader.class, //
locations = { //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
import org.geoserver.cloud.autoconfigure.catalog.backend.core.DefaultUpdateSequenceAutoConfiguration;
import org.geoserver.cloud.config.catalog.backend.catalogservice.CatalogClientBackendConfigurer;
import org.geoserver.cloud.config.catalog.backend.core.GeoServerBackendConfigurer;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
Expand All @@ -22,8 +21,7 @@
*
* @see ConditionalOnCatalogServiceClientEnabled
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration(before = DefaultUpdateSequenceAutoConfiguration.class)
@ConditionalOnCatalogServiceClientEnabled
@Import(CatalogClientBackendConfigurer.class)
@AutoConfigureBefore(DefaultUpdateSequenceAutoConfiguration.class)
public class CatalogClientBackendAutoConfiguration {}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

import org.geoserver.platform.config.DefaultUpdateSequence;
import org.geoserver.platform.config.UpdateSequence;
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;

@AutoConfiguration
@ConditionalOnMissingBean(UpdateSequence.class)
@Configuration
public class DefaultUpdateSequenceAutoConfiguration {
@Bean
UpdateSequence defaultUpdateSequence() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import org.geoserver.cloud.autoconfigure.geotools.GeoToolsHttpClientAutoConfiguration;
import org.geoserver.cloud.config.catalog.backend.core.CoreBackendConfiguration;
import org.geoserver.cloud.config.jndidatasource.JNDIDataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
Expand All @@ -22,10 +22,7 @@
*
* @see CoreBackendConfiguration
*/
@Configuration(proxyBeanMethods = false)
@AutoConfigureAfter({
GeoToolsHttpClientAutoConfiguration.class,
JNDIDataSourceAutoConfiguration.class
})
@AutoConfiguration(
after = {GeoToolsHttpClientAutoConfiguration.class, JNDIDataSourceAutoConfiguration.class})
@Import(CoreBackendConfiguration.class)
public class GeoServerBackendAutoConfiguration {}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
import org.geoserver.cloud.event.info.InfoEvent;
import org.geoserver.cloud.event.remote.resourcepool.RemoteEventResourcePoolProcessor;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* Cleans up cached {@link ResourcePool} entries upon remote Catalog events
*
* @since 1.0
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
@ConditionalOnClass(InfoEvent.class)
@ConditionalOnCatalogEvents
public class RemoteEventResourcePoolCleaupUpAutoConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
import org.geoserver.wms.WMSXStreamLoader;
import org.geoserver.wps.WPSFactoryExtension;
import org.geoserver.wps.WPSXStreamLoader;
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;

/**
* Configuration to make sure all {@link XStreamServiceLoader} extensions are loaded regardless of
* the microservice this starter is used from.
*
* @since 1.0
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
@Slf4j(topic = "org.geoserver.cloud.config.catalog")
public class XstreamServiceLoadersAutoConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import org.geoserver.cloud.autoconfigure.geotools.GeoToolsHttpClientProxyConfigurationProperties.ProxyHostConfig;
import org.geotools.http.HTTPClientFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* {@link EnableAutoConfiguration @EnableAutoConfiguration} auto configuration for a GeoTools {@link
Expand Down Expand Up @@ -66,7 +66,7 @@
* </code>
* </pre>
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
@EnableConfigurationProperties(GeoToolsHttpClientProxyConfigurationProperties.class)
@ConditionalOnProperty(
name = "geotools.httpclient.proxy.enabled",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegistryAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* {@link EnableAutoConfiguration Auto-configuration} for {@link Catalog} and {@link GeoServer}
Expand All @@ -25,8 +24,8 @@
* @see CatalogMetrics
* @since 1.0
*/
@Configuration(proxyBeanMethods = false)
@AutoConfigureAfter({MetricsAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class})
@AutoConfiguration(
after = {MetricsAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class})
@ConditionalOnGeoServerMetricsEnabled
@EnableConfigurationProperties(GeoSeverMetricsConfigProperties.class)
public class CatalogMetricsAutoConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.geoserver.cloud.security.GeoServerSecurityConfiguration;
import org.geoserver.config.util.XStreamPersisterFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
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;
Expand All @@ -20,8 +20,7 @@

import javax.annotation.PostConstruct;

@Configuration
@AutoConfigureAfter(GeoServerBackendAutoConfiguration.class)
@AutoConfiguration(after = GeoServerBackendAutoConfiguration.class)
@Import({
GeoServerSecurityAutoConfiguration.Enabled.class,
GeoServerSecurityAutoConfiguration.Disabled.class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@

import org.geoserver.cloud.autoconfigure.catalog.backend.core.DefaultUpdateSequenceAutoConfiguration;
import org.geoserver.cloud.config.catalog.backend.datadirectory.DataDirectoryBackendConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.context.annotation.Configuration;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Import;

@Configuration(proxyBeanMethods = false)
@AutoConfiguration(before = DefaultUpdateSequenceAutoConfiguration.class)
@ConditionalOnDataDirectoryEnabled
@Import(DataDirectoryBackendConfiguration.class)
@AutoConfigureBefore(DefaultUpdateSequenceAutoConfiguration.class)
public class DataDirectoryAutoConfiguration {}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import org.geoserver.cloud.event.remote.datadir.RemoteEventDataDirectoryProcessor;
import org.geoserver.config.plugin.RepositoryGeoServerFacade;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
@AutoConfiguration
@ConditionalOnDataDirectoryEnabled
@ConditionalOnCatalogEvents
public class RemoteEventDataDirectoryAutoConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@

import org.geoserver.cloud.autoconfigure.catalog.backend.core.DefaultUpdateSequenceAutoConfiguration;
import org.geoserver.cloud.config.catalog.backend.jdbcconfig.JDBCConfigBackendConfigurer;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.context.annotation.Configuration;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Import;

@Configuration(proxyBeanMethods = false)
@AutoConfiguration(before = DefaultUpdateSequenceAutoConfiguration.class)
@ConditionalOnJdbcConfigEnabled
@Import(JDBCConfigBackendConfigurer.class)
@AutoConfigureBefore(DefaultUpdateSequenceAutoConfiguration.class)
public class JDBCConfigAutoConfiguration {}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
package org.geoserver.cloud.autoconfigure.catalog.backend.jdbcconfig;

import org.geoserver.cloud.config.catalog.backend.jdbcconfig.JDBCConfigWebConfiguration;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Import;

/** Auto configuration for the wicket ui components of the jdbcconfig extension */
@AutoConfiguration
@ConditionalOnJdbcConfigWebUIEnabled
@Import({JDBCConfigWebConfiguration.class})
public class JDBCConfigWebAutoConfiguration {}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
package org.geoserver.cloud.autoconfigure.catalog.cache;

import org.geoserver.cloud.catalog.cache.GeoServerBackendCacheConfiguration;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.cache.CacheManager;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
Expand All @@ -19,7 +19,7 @@
*
* @see GeoServerBackendCacheConfiguration
*/
@Configuration
@AutoConfiguration
@ConditionalOnBackendCacheEnabled
@Import(GeoServerBackendCacheConfiguration.class)
public class BackendCacheAutoConfiguration {}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import lombok.extern.slf4j.Slf4j;

import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.cloud.bus.BusAutoConfiguration;
import org.springframework.context.annotation.Configuration;
Expand All @@ -14,7 +15,7 @@
import javax.annotation.PostConstruct;

/** Log a message if spring-cloud-bus is explicitly disables */
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
@Import({
GeoServerBusIntegrationAutoConfiguration.Enabled.class,
GeoServerBusIntegrationAutoConfiguration.Disabled.class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
package org.geoserver.cloud.autoconfigure.catalog.event;

import org.geoserver.cloud.config.catalog.events.CatalogApplicationEventsConfiguration;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
* {@link EnableAutoConfiguration auto-configuration} for {@link
* CatalogApplicationEventsConfiguration}
*/
@Configuration
@AutoConfiguration
@ConditionalOnCatalogEvents
@Import(CatalogApplicationEventsConfiguration.class)
public class LocalCatalogEventsAutoConfiguration {}
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

import org.geoserver.config.GeoServer;
import org.geoserver.platform.config.UpdateSequence;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;

/**
* @since 1.0
*/
@Configuration(proxyBeanMethods = false)
@AutoConfiguration
@ConditionalOnWebApplication
@EnableGlobalMethodSecurity(jsr250Enabled = true)
public class UpdateSequenceControllerAutoConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@

import org.geoserver.jackson.databind.catalog.GeoServerCatalogModule;
import org.geoserver.jackson.databind.config.GeoServerConfigModule;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
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;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* Spring boot {@link EnableAutoConfiguration @EnableAutoConfiguration} to register GeoServer
Expand All @@ -26,8 +25,7 @@
* despite them being register-able through Jackson's SPI; a configuration like this is needed to
* set up the application required ones.
*/
@Configuration
@AutoConfigureAfter(GeoToolsJacksonBindingsAutoConfiguration.class)
@AutoConfiguration(after = GeoToolsJacksonBindingsAutoConfiguration.class)
@ConditionalOnClass(GeoServerCatalogModule.class)
public class GeoServerJacksonBindingsAutoConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

import org.geotools.jackson.databind.filter.GeoToolsFilterModule;
import org.geotools.jackson.databind.geojson.GeoToolsGeoJsonModule;
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;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* Spring boot {@link EnableAutoConfiguration @EnableAutoConfiguration} to register GeoTools and
Expand All @@ -26,7 +26,7 @@
* despite them being register-able through Jackson's SPI; a configuration like this is needed to
* set up the application required ones.
*/
@Configuration
@AutoConfiguration
@ConditionalOnClass(GeoToolsFilterModule.class)
public class GeoToolsJacksonBindingsAutoConfiguration {

Expand Down
Loading

0 comments on commit 77954a8

Please sign in to comment.