Merge branch '6.0.x'

This commit is contained in:
Juergen Hoeller
2023-06-08 17:46:19 +02:00
32 changed files with 317 additions and 335 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,30 +16,30 @@
package org.springframework.cache.jcache.interceptor;
import java.io.Serializable;
import java.lang.reflect.Method;
import org.springframework.aop.ClassFilter;
import org.springframework.aop.Pointcut;
import org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor;
import org.springframework.aop.support.StaticMethodMatcherPointcut;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
* Advisor driven by a {@link JCacheOperationSource}, used to include a
* cache advice bean for methods that are cacheable.
*
* @author Stephane Nicoll
* @author Juergen Hoeller
* @since 4.1
* @see #setAdviceBeanName
* @see JCacheInterceptor
*/
@SuppressWarnings("serial")
public class BeanFactoryJCacheOperationSourceAdvisor extends AbstractBeanFactoryPointcutAdvisor {
@Nullable
private JCacheOperationSource cacheOperationSource;
private final JCacheOperationSourcePointcut pointcut = new JCacheOperationSourcePointcut() {
@Override
protected JCacheOperationSource getCacheOperationSource() {
return cacheOperationSource;
}
};
private final JCacheOperationSourcePointcut pointcut = new JCacheOperationSourcePointcut();
/**
@@ -48,7 +48,7 @@ public class BeanFactoryJCacheOperationSourceAdvisor extends AbstractBeanFactory
* set on the cache interceptor itself.
*/
public void setCacheOperationSource(JCacheOperationSource cacheOperationSource) {
this.cacheOperationSource = cacheOperationSource;
this.pointcut.setCacheOperationSource(cacheOperationSource);
}
/**
@@ -64,4 +64,37 @@ public class BeanFactoryJCacheOperationSourceAdvisor extends AbstractBeanFactory
return this.pointcut;
}
private static class JCacheOperationSourcePointcut extends StaticMethodMatcherPointcut implements Serializable {
@Nullable
private JCacheOperationSource cacheOperationSource;
public void setCacheOperationSource(@Nullable JCacheOperationSource cacheOperationSource) {
this.cacheOperationSource = cacheOperationSource;
}
@Override
public boolean matches(Method method, Class<?> targetClass) {
return (this.cacheOperationSource == null ||
this.cacheOperationSource.getCacheOperation(method, targetClass) != null);
}
@Override
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof JCacheOperationSourcePointcut otherPc &&
ObjectUtils.nullSafeEquals(this.cacheOperationSource, otherPc.cacheOperationSource)));
}
@Override
public int hashCode() {
return JCacheOperationSourcePointcut.class.hashCode();
}
@Override
public String toString() {
return getClass().getName() + ": " + this.cacheOperationSource;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,9 @@ import org.springframework.util.ObjectUtils;
*
* @author Stephane Nicoll
* @since 4.1
* @deprecated since 6.0.10, as it is not used by the framework anymore
*/
@Deprecated(since = "6.0.10", forRemoval = true)
@SuppressWarnings("serial")
public abstract class JCacheOperationSourcePointcut extends StaticMethodMatcherPointcut implements Serializable {