Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.cache.annotation;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -68,8 +69,7 @@ public class AnnotationCacheOperationSource extends AbstractFallbackCacheOperati
|
||||
*/
|
||||
public AnnotationCacheOperationSource(boolean publicMethodsOnly) {
|
||||
this.publicMethodsOnly = publicMethodsOnly;
|
||||
this.annotationParsers = new LinkedHashSet<>(1);
|
||||
this.annotationParsers.add(new SpringCacheAnnotationParser());
|
||||
this.annotationParsers = Collections.singleton(new SpringCacheAnnotationParser());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,9 +89,7 @@ public class AnnotationCacheOperationSource extends AbstractFallbackCacheOperati
|
||||
public AnnotationCacheOperationSource(CacheAnnotationParser... annotationParsers) {
|
||||
this.publicMethodsOnly = true;
|
||||
Assert.notEmpty(annotationParsers, "At least one CacheAnnotationParser needs to be specified");
|
||||
Set<CacheAnnotationParser> parsers = new LinkedHashSet<>(annotationParsers.length);
|
||||
Collections.addAll(parsers, annotationParsers);
|
||||
this.annotationParsers = parsers;
|
||||
this.annotationParsers = new LinkedHashSet<>(Arrays.asList(annotationParsers));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,23 +105,22 @@ public class AnnotationCacheOperationSource extends AbstractFallbackCacheOperati
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Collection<CacheOperation> findCacheOperations(final Class<?> clazz) {
|
||||
protected Collection<CacheOperation> findCacheOperations(Class<?> clazz) {
|
||||
return determineCacheOperations(parser -> parser.parseCacheAnnotations(clazz));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Collection<CacheOperation> findCacheOperations(final Method method) {
|
||||
protected Collection<CacheOperation> findCacheOperations(Method method) {
|
||||
return determineCacheOperations(parser -> parser.parseCacheAnnotations(method));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the cache operation(s) for the given {@link CacheOperationProvider}.
|
||||
* <p>This implementation delegates to configured
|
||||
* {@link CacheAnnotationParser}s for parsing known annotations into
|
||||
* Spring's metadata attribute class.
|
||||
* <p>Can be overridden to support custom annotations that carry
|
||||
* caching metadata.
|
||||
* {@link CacheAnnotationParser CacheAnnotationParsers}
|
||||
* for parsing known annotations into Spring's metadata attribute class.
|
||||
* <p>Can be overridden to support custom annotations that carry caching metadata.
|
||||
* @param provider the cache operation provider to use
|
||||
* @return the configured caching operations, or {@code null} if none found
|
||||
*/
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.springframework.context.annotation.Role;
|
||||
* to enable proxy-based annotation-driven cache management.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @author Juergen Hoeller
|
||||
* @since 3.1
|
||||
* @see EnableCaching
|
||||
* @see CachingConfigurationSelector
|
||||
@@ -41,8 +42,7 @@ public class ProxyCachingConfiguration extends AbstractCachingConfiguration {
|
||||
@Bean(name = CacheManagementConfigUtils.CACHE_ADVISOR_BEAN_NAME)
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
public BeanFactoryCacheOperationSourceAdvisor cacheAdvisor() {
|
||||
BeanFactoryCacheOperationSourceAdvisor advisor =
|
||||
new BeanFactoryCacheOperationSourceAdvisor();
|
||||
BeanFactoryCacheOperationSourceAdvisor advisor = new BeanFactoryCacheOperationSourceAdvisor();
|
||||
advisor.setCacheOperationSource(cacheOperationSource());
|
||||
advisor.setAdvice(cacheInterceptor());
|
||||
if (this.enableCaching != null) {
|
||||
|
||||
Reference in New Issue
Block a user