|
|
|
@ -25,6 +25,7 @@ import org.apache.commons.logging.LogFactory;
@@ -25,6 +25,7 @@ import org.apache.commons.logging.LogFactory;
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter; |
|
|
|
|
import org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration; |
|
|
|
|
import org.springframework.boot.autoconfigure.condition.AllNestedConditions; |
|
|
|
|
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; |
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
|
|
|
@ -43,9 +44,9 @@ import org.springframework.context.annotation.Conditional;
@@ -43,9 +44,9 @@ import org.springframework.context.annotation.Conditional;
|
|
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* An AutoConfiguration that automatically enables caching when when Spring Boot, and |
|
|
|
|
* Spring Framework Cache support are present. If Caffeine is present in the classpath, it |
|
|
|
|
* will be used for loadbalancer caching. If not, a default cache will be used. |
|
|
|
|
* An AutoConfiguration that automatically enables caching when Spring Boot, and Spring |
|
|
|
|
* Framework Cache support are present. If Caffeine is present in the classpath, it will |
|
|
|
|
* be used for loadbalancer caching. If not, a default cache will be used. |
|
|
|
|
* |
|
|
|
|
* @author Olga Maciaszek-Sharma |
|
|
|
|
* @since 2.2.0 |
|
|
|
@ -57,8 +58,8 @@ import org.springframework.context.annotation.Configuration;
@@ -57,8 +58,8 @@ import org.springframework.context.annotation.Configuration;
|
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
|
@ConditionalOnClass({ CacheManager.class, CacheAutoConfiguration.class }) |
|
|
|
|
@AutoConfigureAfter(CacheAutoConfiguration.class) |
|
|
|
|
@ConditionalOnProperty(value = "spring.cloud.loadbalancer.cache.enabled", matchIfMissing = true) |
|
|
|
|
@EnableConfigurationProperties(LoadBalancerCacheProperties.class) |
|
|
|
|
@Conditional(LoadBalancerCacheAutoConfiguration.OnLoadBalancerCachingEnabledCondition.class) |
|
|
|
|
public class LoadBalancerCacheAutoConfiguration { |
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
@ -130,4 +131,22 @@ public class LoadBalancerCacheAutoConfiguration {
@@ -130,4 +131,22 @@ public class LoadBalancerCacheAutoConfiguration {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static final class OnLoadBalancerCachingEnabledCondition extends AllNestedConditions { |
|
|
|
|
|
|
|
|
|
OnLoadBalancerCachingEnabledCondition() { |
|
|
|
|
super(ConfigurationPhase.REGISTER_BEAN); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ConditionalOnProperty(value = "spring.cloud.loadbalancer.enabled", havingValue = "true", matchIfMissing = true) |
|
|
|
|
static class LoadBalancerEnabled { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ConditionalOnProperty(value = "spring.cloud.loadbalancer.cache.enabled", matchIfMissing = true) |
|
|
|
|
static class LoadBalancerCacheEnabled { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|