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