001/*
002 * Copyright 2002-2014 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.interceptor;
018
019import org.springframework.aop.ClassFilter;
020import org.springframework.aop.Pointcut;
021import org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor;
022
023/**
024 * Advisor driven by a {@link JCacheOperationSource}, used to include a
025 * cache advice bean for methods that are cacheable.
026 *
027 * @author Stephane Nicoll
028 * @since 4.1
029 */
030@SuppressWarnings("serial")
031public class BeanFactoryJCacheOperationSourceAdvisor extends AbstractBeanFactoryPointcutAdvisor {
032
033        private JCacheOperationSource cacheOperationSource;
034
035        private final JCacheOperationSourcePointcut pointcut = new JCacheOperationSourcePointcut() {
036                @Override
037                protected JCacheOperationSource getCacheOperationSource() {
038                        return cacheOperationSource;
039                }
040        };
041
042        /**
043         * Set the cache operation attribute source which is used to find cache
044         * attributes. This should usually be identical to the source reference
045         * set on the cache interceptor itself.
046         */
047        public void setCacheOperationSource(JCacheOperationSource cacheOperationSource) {
048                this.cacheOperationSource = cacheOperationSource;
049        }
050
051        /**
052         * Set the {@link org.springframework.aop.ClassFilter} to use for this pointcut.
053         * Default is {@link org.springframework.aop.ClassFilter#TRUE}.
054         */
055        public void setClassFilter(ClassFilter classFilter) {
056                this.pointcut.setClassFilter(classFilter);
057        }
058
059        @Override
060        public Pointcut getPointcut() {
061                return this.pointcut;
062        }
063
064}