Merge branch '6.0.x'
This commit is contained in:
@@ -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.
|
||||
@@ -191,14 +191,9 @@ public class AnnotationTransactionAttributeSource extends AbstractFallbackTransa
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof AnnotationTransactionAttributeSource otherTas)) {
|
||||
return false;
|
||||
}
|
||||
return (this.annotationParsers.equals(otherTas.annotationParsers) &&
|
||||
this.publicMethodsOnly == otherTas.publicMethodsOnly);
|
||||
return (this == other || (other instanceof AnnotationTransactionAttributeSource otherTas &&
|
||||
this.annotationParsers.equals(otherTas.annotationParsers) &&
|
||||
this.publicMethodsOnly == otherTas.publicMethodsOnly));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -19,7 +19,6 @@ package org.springframework.transaction.interceptor;
|
||||
import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.aop.Pointcut;
|
||||
import org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Advisor driven by a {@link TransactionAttributeSource}, used to include
|
||||
@@ -34,16 +33,7 @@ import org.springframework.lang.Nullable;
|
||||
@SuppressWarnings("serial")
|
||||
public class BeanFactoryTransactionAttributeSourceAdvisor extends AbstractBeanFactoryPointcutAdvisor {
|
||||
|
||||
@Nullable
|
||||
private TransactionAttributeSource transactionAttributeSource;
|
||||
|
||||
private final TransactionAttributeSourcePointcut pointcut = new TransactionAttributeSourcePointcut() {
|
||||
@Override
|
||||
@Nullable
|
||||
protected TransactionAttributeSource getTransactionAttributeSource() {
|
||||
return transactionAttributeSource;
|
||||
}
|
||||
};
|
||||
private final TransactionAttributeSourcePointcut pointcut = new TransactionAttributeSourcePointcut();
|
||||
|
||||
|
||||
/**
|
||||
@@ -53,7 +43,7 @@ public class BeanFactoryTransactionAttributeSourceAdvisor extends AbstractBeanFa
|
||||
* @see TransactionInterceptor#setTransactionAttributeSource
|
||||
*/
|
||||
public void setTransactionAttributeSource(TransactionAttributeSource transactionAttributeSource) {
|
||||
this.transactionAttributeSource = transactionAttributeSource;
|
||||
this.pointcut.setTransactionAttributeSource(transactionAttributeSource);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
@@ -239,13 +239,8 @@ public class MethodMapTransactionAttributeSource
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof MethodMapTransactionAttributeSource otherTas)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(this.methodMap, otherTas.methodMap);
|
||||
return (this == other || (other instanceof MethodMapTransactionAttributeSource otherTas &&
|
||||
ObjectUtils.nullSafeEquals(this.methodMap, otherTas.methodMap)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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.
|
||||
@@ -164,13 +164,8 @@ public class NameMatchTransactionAttributeSource
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof NameMatchTransactionAttributeSource otherTas)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(this.nameMap, otherTas.nameMap);
|
||||
return (this == other || (other instanceof NameMatchTransactionAttributeSource otherTas &&
|
||||
ObjectUtils.nullSafeEquals(this.nameMap, otherTas.nameMap)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -43,13 +43,7 @@ public class TransactionAttributeSourceAdvisor extends AbstractPointcutAdvisor {
|
||||
@Nullable
|
||||
private TransactionInterceptor transactionInterceptor;
|
||||
|
||||
private final TransactionAttributeSourcePointcut pointcut = new TransactionAttributeSourcePointcut() {
|
||||
@Override
|
||||
@Nullable
|
||||
protected TransactionAttributeSource getTransactionAttributeSource() {
|
||||
return (transactionInterceptor != null ? transactionInterceptor.getTransactionAttributeSource() : null);
|
||||
}
|
||||
};
|
||||
private final TransactionAttributeSourcePointcut pointcut = new TransactionAttributeSourcePointcut();
|
||||
|
||||
|
||||
/**
|
||||
@@ -71,7 +65,9 @@ public class TransactionAttributeSourceAdvisor extends AbstractPointcutAdvisor {
|
||||
* Set the transaction interceptor to use for this advisor.
|
||||
*/
|
||||
public void setTransactionInterceptor(TransactionInterceptor interceptor) {
|
||||
Assert.notNull(interceptor, "TransactionInterceptor must not be null");
|
||||
this.transactionInterceptor = interceptor;
|
||||
this.pointcut.setTransactionAttributeSource(interceptor.getTransactionAttributeSource());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,28 +34,31 @@ import org.springframework.util.ObjectUtils;
|
||||
* @since 2.5.5
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
abstract class TransactionAttributeSourcePointcut extends StaticMethodMatcherPointcut implements Serializable {
|
||||
class TransactionAttributeSourcePointcut extends StaticMethodMatcherPointcut implements Serializable {
|
||||
|
||||
protected TransactionAttributeSourcePointcut() {
|
||||
@Nullable
|
||||
private TransactionAttributeSource transactionAttributeSource;
|
||||
|
||||
|
||||
public TransactionAttributeSourcePointcut() {
|
||||
setClassFilter(new TransactionAttributeSourceClassFilter());
|
||||
}
|
||||
|
||||
|
||||
public void setTransactionAttributeSource(@Nullable TransactionAttributeSource transactionAttributeSource) {
|
||||
this.transactionAttributeSource = transactionAttributeSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Method method, Class<?> targetClass) {
|
||||
TransactionAttributeSource tas = getTransactionAttributeSource();
|
||||
return (tas == null || tas.getTransactionAttribute(method, targetClass) != null);
|
||||
return (this.transactionAttributeSource == null ||
|
||||
this.transactionAttributeSource.getTransactionAttribute(method, targetClass) != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof TransactionAttributeSourcePointcut otherPc)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(getTransactionAttributeSource(), otherPc.getTransactionAttributeSource());
|
||||
return (this == other || (other instanceof TransactionAttributeSourcePointcut otherPc &&
|
||||
ObjectUtils.nullSafeEquals(this.transactionAttributeSource, otherPc.transactionAttributeSource)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,18 +68,10 @@ abstract class TransactionAttributeSourcePointcut extends StaticMethodMatcherPoi
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + ": " + getTransactionAttributeSource();
|
||||
return getClass().getName() + ": " + this.transactionAttributeSource;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtain the underlying TransactionAttributeSource (may be {@code null}).
|
||||
* To be implemented by subclasses.
|
||||
*/
|
||||
@Nullable
|
||||
protected abstract TransactionAttributeSource getTransactionAttributeSource();
|
||||
|
||||
|
||||
/**
|
||||
* {@link ClassFilter} that delegates to {@link TransactionAttributeSource#isCandidateClass}
|
||||
* for filtering classes whose methods are not worth searching to begin with.
|
||||
@@ -90,8 +85,7 @@ abstract class TransactionAttributeSourcePointcut extends StaticMethodMatcherPoi
|
||||
PersistenceExceptionTranslator.class.isAssignableFrom(clazz)) {
|
||||
return false;
|
||||
}
|
||||
TransactionAttributeSource tas = getTransactionAttributeSource();
|
||||
return (tas == null || tas.isCandidateClass(clazz));
|
||||
return (transactionAttributeSource == null || transactionAttributeSource.isCandidateClass(clazz));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user