|
|
|
@ -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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|