001/* 002 * Copyright 2002-2015 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.annotation.Documented; 020import java.lang.annotation.ElementType; 021import java.lang.annotation.Retention; 022import java.lang.annotation.RetentionPolicy; 023import java.lang.annotation.Target; 024 025/** 026 * {@code @CacheConfig} provides a mechanism for sharing common cache-related 027 * settings at the class level. 028 * 029 * <p>When this annotation is present on a given class, it provides a set 030 * of default settings for any cache operation defined in that class. 031 * 032 * @author Stephane Nicoll 033 * @author Sam Brannen 034 * @since 4.1 035 */ 036@Target(ElementType.TYPE) 037@Retention(RetentionPolicy.RUNTIME) 038@Documented 039public @interface CacheConfig { 040 041 /** 042 * Names of the default caches to consider for caching operations defined 043 * in the annotated class. 044 * <p>If none is set at the operation level, these are used instead of the default. 045 * <p>May be used to determine the target cache (or caches), matching the 046 * qualifier value or the bean names of a specific bean definition. 047 */ 048 String[] cacheNames() default {}; 049 050 /** 051 * The bean name of the default {@link org.springframework.cache.interceptor.KeyGenerator} to 052 * use for the class. 053 * <p>If none is set at the operation level, this one is used instead of the default. 054 * <p>The key generator is mutually exclusive with the use of a custom key. When such key is 055 * defined for the operation, the value of this key generator is ignored. 056 */ 057 String keyGenerator() default ""; 058 059 /** 060 * The bean name of the custom {@link org.springframework.cache.CacheManager} to use to 061 * create a default {@link org.springframework.cache.interceptor.CacheResolver} if none 062 * is set already. 063 * <p>If no resolver and no cache manager are set at the operation level, and no cache 064 * resolver is set via {@link #cacheResolver}, this one is used instead of the default. 065 * @see org.springframework.cache.interceptor.SimpleCacheResolver 066 */ 067 String cacheManager() default ""; 068 069 /** 070 * The bean name of the custom {@link org.springframework.cache.interceptor.CacheResolver} to use. 071 * <p>If no resolver and no cache manager are set at the operation level, this one is used 072 * instead of the default. 073 */ 074 String cacheResolver() default ""; 075 076}