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.jcache.config;
018
019import org.springframework.cache.annotation.CachingConfigurer;
020import org.springframework.cache.interceptor.CacheResolver;
021import org.springframework.lang.Nullable;
022
023/**
024 * Extension of {@link CachingConfigurer} for the JSR-107 implementation.
025 *
026 * <p>To be implemented by classes annotated with
027 * {@link org.springframework.cache.annotation.EnableCaching} that wish
028 * or need to specify explicitly how exception caches are resolved for
029 * annotation-driven cache management. Consider extending {@link JCacheConfigurerSupport},
030 * which provides a stub implementation of all interface methods.
031 *
032 * <p>See {@link org.springframework.cache.annotation.EnableCaching} for
033 * general examples and context; see {@link #exceptionCacheResolver()} for
034 * detailed instructions.
035 *
036 * @author Stephane Nicoll
037 * @since 4.1
038 * @see CachingConfigurer
039 * @see JCacheConfigurerSupport
040 * @see org.springframework.cache.annotation.EnableCaching
041 */
042public interface JCacheConfigurer extends CachingConfigurer {
043
044        /**
045         * Return the {@link CacheResolver} bean to use to resolve exception caches for
046         * annotation-driven cache management. Implementations must explicitly declare
047         * {@link org.springframework.context.annotation.Bean @Bean}, e.g.
048         * <pre class="code">
049         * &#064;Configuration
050         * &#064;EnableCaching
051         * public class AppConfig extends JCacheConfigurerSupport {
052         *     &#064;Bean // important!
053         *     &#064;Override
054         *     public CacheResolver exceptionCacheResolver() {
055         *         // configure and return CacheResolver instance
056         *     }
057         *     // ...
058         * }
059         * </pre>
060         * See {@link org.springframework.cache.annotation.EnableCaching} for more complete examples.
061         */
062        @Nullable
063        CacheResolver exceptionCacheResolver();
064
065}