001/* 002 * Copyright 2002-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.cache.annotation; 018 019import java.lang.reflect.Method; 020import java.util.Collection; 021 022import org.springframework.cache.interceptor.CacheOperation; 023 024/** 025 * Strategy interface for parsing known caching annotation types. 026 * {@link AnnotationCacheOperationSource} delegates to such parsers 027 * for supporting specific annotation types such as Spring's own 028 * {@link Cacheable}, {@link CachePut} and{@link CacheEvict}. 029 * 030 * @author Costin Leau 031 * @author Stephane Nicoll 032 * @since 3.1 033 * @see AnnotationCacheOperationSource 034 * @see SpringCacheAnnotationParser 035 */ 036public interface CacheAnnotationParser { 037 038 /** 039 * Parse the cache definition for the given class, 040 * based on an annotation type understood by this parser. 041 * <p>This essentially parses a known cache annotation into Spring's metadata 042 * attribute class. Returns {@code null} if the class is not cacheable. 043 * @param type the annotated class 044 * @return the configured caching operation, or {@code null} if none found 045 * @see AnnotationCacheOperationSource#findCacheOperations(Class) 046 */ 047 Collection<CacheOperation> parseCacheAnnotations(Class<?> type); 048 049 /** 050 * Parse the cache definition for the given method, 051 * based on an annotation type understood by this parser. 052 * <p>This essentially parses a known cache annotation into Spring's metadata 053 * attribute class. Returns {@code null} if the method is not cacheable. 054 * @param method the annotated method 055 * @return the configured caching operation, or {@code null} if none found 056 * @see AnnotationCacheOperationSource#findCacheOperations(Method) 057 */ 058 Collection<CacheOperation> parseCacheAnnotations(Method method); 059 060}