Use proxyBeanMethods=false on remaining internal configuration classes

Closes gh-24511
This commit is contained in:
Juergen Hoeller 2020-05-12 22:19:44 +02:00
parent dd0d0d51f6
commit f09093132e
12 changed files with 40 additions and 35 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -34,7 +34,7 @@ import org.springframework.context.annotation.Role;
* @see org.springframework.cache.annotation.EnableCaching * @see org.springframework.cache.annotation.EnableCaching
* @see org.springframework.cache.annotation.CachingConfigurationSelector * @see org.springframework.cache.annotation.CachingConfigurationSelector
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class AspectJCachingConfiguration extends AbstractCachingConfiguration { public class AspectJCachingConfiguration extends AbstractCachingConfiguration {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,6 +19,7 @@ package org.springframework.cache.aspectj;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.cache.config.CacheManagementConfigUtils; import org.springframework.cache.config.CacheManagementConfigUtils;
import org.springframework.cache.jcache.config.AbstractJCacheConfiguration; import org.springframework.cache.jcache.config.AbstractJCacheConfiguration;
import org.springframework.cache.jcache.interceptor.JCacheOperationSource;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Role; import org.springframework.context.annotation.Role;
@ -33,15 +34,15 @@ import org.springframework.context.annotation.Role;
* @see org.springframework.cache.annotation.EnableCaching * @see org.springframework.cache.annotation.EnableCaching
* @see org.springframework.cache.annotation.CachingConfigurationSelector * @see org.springframework.cache.annotation.CachingConfigurationSelector
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class AspectJJCacheConfiguration extends AbstractJCacheConfiguration { public class AspectJJCacheConfiguration extends AbstractJCacheConfiguration {
@Bean(name = CacheManagementConfigUtils.JCACHE_ASPECT_BEAN_NAME) @Bean(name = CacheManagementConfigUtils.JCACHE_ASPECT_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public JCacheCacheAspect cacheAspect() { public JCacheCacheAspect cacheAspect(JCacheOperationSource jCacheOperationSource) {
JCacheCacheAspect cacheAspect = JCacheCacheAspect.aspectOf(); JCacheCacheAspect cacheAspect = JCacheCacheAspect.aspectOf();
cacheAspect.setCacheOperationSource(cacheOperationSource()); cacheAspect.setCacheOperationSource(jCacheOperationSource);
return cacheAspect; return cacheAspect;
} }

View File

@ -36,7 +36,7 @@ import org.springframework.scheduling.config.TaskManagementConfigUtils;
* @see org.springframework.scheduling.annotation.AsyncConfigurationSelector * @see org.springframework.scheduling.annotation.AsyncConfigurationSelector
* @see org.springframework.scheduling.annotation.ProxyAsyncConfiguration * @see org.springframework.scheduling.annotation.ProxyAsyncConfiguration
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class AspectJAsyncConfiguration extends AbstractAsyncConfiguration { public class AspectJAsyncConfiguration extends AbstractAsyncConfiguration {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -38,7 +38,7 @@ import org.springframework.lang.Nullable;
* @since 4.1 * @since 4.1
* @see JCacheConfigurer * @see JCacheConfigurer
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
public class AbstractJCacheConfiguration extends AbstractCachingConfiguration { public class AbstractJCacheConfiguration extends AbstractCachingConfiguration {
@Nullable @Nullable

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,6 +20,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.cache.config.CacheManagementConfigUtils; import org.springframework.cache.config.CacheManagementConfigUtils;
import org.springframework.cache.jcache.interceptor.BeanFactoryJCacheOperationSourceAdvisor; import org.springframework.cache.jcache.interceptor.BeanFactoryJCacheOperationSourceAdvisor;
import org.springframework.cache.jcache.interceptor.JCacheInterceptor; import org.springframework.cache.jcache.interceptor.JCacheInterceptor;
import org.springframework.cache.jcache.interceptor.JCacheOperationSource;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Role; import org.springframework.context.annotation.Role;
@ -36,17 +37,18 @@ import org.springframework.context.annotation.Role;
* @see org.springframework.cache.annotation.EnableCaching * @see org.springframework.cache.annotation.EnableCaching
* @see org.springframework.cache.annotation.CachingConfigurationSelector * @see org.springframework.cache.annotation.CachingConfigurationSelector
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class ProxyJCacheConfiguration extends AbstractJCacheConfiguration { public class ProxyJCacheConfiguration extends AbstractJCacheConfiguration {
@Bean(name = CacheManagementConfigUtils.JCACHE_ADVISOR_BEAN_NAME) @Bean(name = CacheManagementConfigUtils.JCACHE_ADVISOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public BeanFactoryJCacheOperationSourceAdvisor cacheAdvisor() { public BeanFactoryJCacheOperationSourceAdvisor cacheAdvisor(
BeanFactoryJCacheOperationSourceAdvisor advisor = JCacheOperationSource jCacheOperationSource, JCacheInterceptor jCacheInterceptor) {
new BeanFactoryJCacheOperationSourceAdvisor();
advisor.setCacheOperationSource(cacheOperationSource()); BeanFactoryJCacheOperationSourceAdvisor advisor = new BeanFactoryJCacheOperationSourceAdvisor();
advisor.setAdvice(cacheInterceptor()); advisor.setCacheOperationSource(jCacheOperationSource);
advisor.setAdvice(jCacheInterceptor);
if (this.enableCaching != null) { if (this.enableCaching != null) {
advisor.setOrder(this.enableCaching.<Integer>getNumber("order")); advisor.setOrder(this.enableCaching.<Integer>getNumber("order"));
} }
@ -55,9 +57,9 @@ public class ProxyJCacheConfiguration extends AbstractJCacheConfiguration {
@Bean(name = "jCacheInterceptor") @Bean(name = "jCacheInterceptor")
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public JCacheInterceptor cacheInterceptor() { public JCacheInterceptor cacheInterceptor(JCacheOperationSource jCacheOperationSource) {
JCacheInterceptor interceptor = new JCacheInterceptor(this.errorHandler); JCacheInterceptor interceptor = new JCacheInterceptor(this.errorHandler);
interceptor.setCacheOperationSource(cacheOperationSource()); interceptor.setCacheOperationSource(jCacheOperationSource);
return interceptor; return interceptor;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -41,7 +41,7 @@ import org.springframework.util.CollectionUtils;
* @since 3.1 * @since 3.1
* @see EnableCaching * @see EnableCaching
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
public abstract class AbstractCachingConfiguration implements ImportAware { public abstract class AbstractCachingConfiguration implements ImportAware {
@Nullable @Nullable

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -35,16 +35,18 @@ import org.springframework.context.annotation.Role;
* @see EnableCaching * @see EnableCaching
* @see CachingConfigurationSelector * @see CachingConfigurationSelector
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class ProxyCachingConfiguration extends AbstractCachingConfiguration { public class ProxyCachingConfiguration extends AbstractCachingConfiguration {
@Bean(name = CacheManagementConfigUtils.CACHE_ADVISOR_BEAN_NAME) @Bean(name = CacheManagementConfigUtils.CACHE_ADVISOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public BeanFactoryCacheOperationSourceAdvisor cacheAdvisor() { public BeanFactoryCacheOperationSourceAdvisor cacheAdvisor(
CacheOperationSource cacheOperationSource, CacheInterceptor cacheInterceptor) {
BeanFactoryCacheOperationSourceAdvisor advisor = new BeanFactoryCacheOperationSourceAdvisor(); BeanFactoryCacheOperationSourceAdvisor advisor = new BeanFactoryCacheOperationSourceAdvisor();
advisor.setCacheOperationSource(cacheOperationSource()); advisor.setCacheOperationSource(cacheOperationSource);
advisor.setAdvice(cacheInterceptor()); advisor.setAdvice(cacheInterceptor);
if (this.enableCaching != null) { if (this.enableCaching != null) {
advisor.setOrder(this.enableCaching.<Integer>getNumber("order")); advisor.setOrder(this.enableCaching.<Integer>getNumber("order"));
} }
@ -59,10 +61,10 @@ public class ProxyCachingConfiguration extends AbstractCachingConfiguration {
@Bean @Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public CacheInterceptor cacheInterceptor() { public CacheInterceptor cacheInterceptor(CacheOperationSource cacheOperationSource) {
CacheInterceptor interceptor = new CacheInterceptor(); CacheInterceptor interceptor = new CacheInterceptor();
interceptor.configure(this.errorHandler, this.keyGenerator, this.cacheResolver, this.cacheManager); interceptor.configure(this.errorHandler, this.keyGenerator, this.cacheResolver, this.cacheManager);
interceptor.setCacheOperationSource(cacheOperationSource()); interceptor.setCacheOperationSource(cacheOperationSource);
return interceptor; return interceptor;
} }

View File

@ -41,7 +41,7 @@ import org.springframework.util.Assert;
* @see LoadTimeWeavingConfigurer * @see LoadTimeWeavingConfigurer
* @see ConfigurableApplicationContext#LOAD_TIME_WEAVER_BEAN_NAME * @see ConfigurableApplicationContext#LOAD_TIME_WEAVER_BEAN_NAME
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class LoadTimeWeavingConfiguration implements ImportAware, BeanClassLoaderAware { public class LoadTimeWeavingConfiguration implements ImportAware, BeanClassLoaderAware {

View File

@ -49,7 +49,7 @@ import org.springframework.util.StringUtils;
* @since 3.2 * @since 3.2
* @see EnableMBeanExport * @see EnableMBeanExport
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class MBeanExportConfiguration implements ImportAware, EnvironmentAware, BeanFactoryAware { public class MBeanExportConfiguration implements ImportAware, EnvironmentAware, BeanFactoryAware {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -39,7 +39,7 @@ import org.springframework.util.CollectionUtils;
* @since 3.1 * @since 3.1
* @see EnableAsync * @see EnableAsync
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
public abstract class AbstractAsyncConfiguration implements ImportAware { public abstract class AbstractAsyncConfiguration implements ImportAware {
@Nullable @Nullable

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -37,7 +37,7 @@ import org.springframework.util.Assert;
* @see EnableAsync * @see EnableAsync
* @see AsyncConfigurationSelector * @see AsyncConfigurationSelector
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class ProxyAsyncConfiguration extends AbstractAsyncConfiguration { public class ProxyAsyncConfiguration extends AbstractAsyncConfiguration {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -35,7 +35,7 @@ import org.springframework.scheduling.config.TaskManagementConfigUtils;
* @see EnableScheduling * @see EnableScheduling
* @see ScheduledAnnotationBeanPostProcessor * @see ScheduledAnnotationBeanPostProcessor
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class SchedulingConfiguration { public class SchedulingConfiguration {