Apply "instanceof pattern matching" in spring-tx
This commit also applies additional clean-up tasks such as the following. - final fields This has only been applied to `src/main/java`.
This commit is contained in:
parent
b8fc79543d
commit
e9cf645b86
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -43,7 +43,7 @@ import org.springframework.util.Assert;
|
||||||
public class SimpleBootstrapContext implements BootstrapContext {
|
public class SimpleBootstrapContext implements BootstrapContext {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private WorkManager workManager;
|
private final WorkManager workManager;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private XATerminator xaTerminator;
|
private XATerminator xaTerminator;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -194,10 +194,9 @@ public class AnnotationTransactionAttributeSource extends AbstractFallbackTransa
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(other instanceof AnnotationTransactionAttributeSource)) {
|
if (!(other instanceof AnnotationTransactionAttributeSource otherTas)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
AnnotationTransactionAttributeSource otherTas = (AnnotationTransactionAttributeSource) other;
|
|
||||||
return (this.annotationParsers.equals(otherTas.annotationParsers) &&
|
return (this.annotationParsers.equals(otherTas.annotationParsers) &&
|
||||||
this.publicMethodsOnly == otherTas.publicMethodsOnly);
|
this.publicMethodsOnly == otherTas.publicMethodsOnly);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -128,8 +128,7 @@ public abstract class AbstractFallbackTransactionAttributeSource
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String methodIdentification = ClassUtils.getQualifiedMethodName(method, targetClass);
|
String methodIdentification = ClassUtils.getQualifiedMethodName(method, targetClass);
|
||||||
if (txAttr instanceof DefaultTransactionAttribute) {
|
if (txAttr instanceof DefaultTransactionAttribute dta) {
|
||||||
DefaultTransactionAttribute dta = (DefaultTransactionAttribute) txAttr;
|
|
||||||
dta.setDescriptor(methodIdentification);
|
dta.setDescriptor(methodIdentification);
|
||||||
dta.resolveAttributeStrings(this.embeddedValueResolver);
|
dta.resolveAttributeStrings(this.embeddedValueResolver);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -49,8 +49,8 @@ public class MatchAlwaysTransactionAttributeSource implements TransactionAttribu
|
||||||
* @see org.springframework.transaction.interceptor.TransactionAttributeEditor
|
* @see org.springframework.transaction.interceptor.TransactionAttributeEditor
|
||||||
*/
|
*/
|
||||||
public void setTransactionAttribute(TransactionAttribute transactionAttribute) {
|
public void setTransactionAttribute(TransactionAttribute transactionAttribute) {
|
||||||
if (transactionAttribute instanceof DefaultTransactionAttribute) {
|
if (transactionAttribute instanceof DefaultTransactionAttribute dta) {
|
||||||
((DefaultTransactionAttribute) transactionAttribute).resolveAttributeStrings(null);
|
dta.resolveAttributeStrings(null);
|
||||||
}
|
}
|
||||||
this.transactionAttribute = transactionAttribute;
|
this.transactionAttribute = transactionAttribute;
|
||||||
}
|
}
|
||||||
|
@ -68,10 +68,9 @@ public class MatchAlwaysTransactionAttributeSource implements TransactionAttribu
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(other instanceof MatchAlwaysTransactionAttributeSource)) {
|
if (!(other instanceof MatchAlwaysTransactionAttributeSource otherTas)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MatchAlwaysTransactionAttributeSource otherTas = (MatchAlwaysTransactionAttributeSource) other;
|
|
||||||
return ObjectUtils.nullSafeEquals(this.transactionAttribute, otherTas.transactionAttribute);
|
return ObjectUtils.nullSafeEquals(this.transactionAttribute, otherTas.transactionAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -199,8 +199,8 @@ public class MethodMapTransactionAttributeSource
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Adding transactional method [" + method + "] with attribute [" + attr + "]");
|
logger.debug("Adding transactional method [" + method + "] with attribute [" + attr + "]");
|
||||||
}
|
}
|
||||||
if (this.embeddedValueResolver != null && attr instanceof DefaultTransactionAttribute) {
|
if (this.embeddedValueResolver != null && attr instanceof DefaultTransactionAttribute dta) {
|
||||||
((DefaultTransactionAttribute) attr).resolveAttributeStrings(this.embeddedValueResolver);
|
dta.resolveAttributeStrings(this.embeddedValueResolver);
|
||||||
}
|
}
|
||||||
this.transactionAttributeMap.put(method, attr);
|
this.transactionAttributeMap.put(method, attr);
|
||||||
}
|
}
|
||||||
|
@ -242,10 +242,9 @@ public class MethodMapTransactionAttributeSource
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(other instanceof MethodMapTransactionAttributeSource)) {
|
if (!(other instanceof MethodMapTransactionAttributeSource otherTas)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MethodMapTransactionAttributeSource otherTas = (MethodMapTransactionAttributeSource) other;
|
|
||||||
return ObjectUtils.nullSafeEquals(this.methodMap, otherTas.methodMap);
|
return ObjectUtils.nullSafeEquals(this.methodMap, otherTas.methodMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -101,8 +101,8 @@ public class NameMatchTransactionAttributeSource
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Adding transactional method [" + methodName + "] with attribute [" + attr + "]");
|
logger.debug("Adding transactional method [" + methodName + "] with attribute [" + attr + "]");
|
||||||
}
|
}
|
||||||
if (this.embeddedValueResolver != null && attr instanceof DefaultTransactionAttribute) {
|
if (this.embeddedValueResolver != null && attr instanceof DefaultTransactionAttribute dta) {
|
||||||
((DefaultTransactionAttribute) attr).resolveAttributeStrings(this.embeddedValueResolver);
|
dta.resolveAttributeStrings(this.embeddedValueResolver);
|
||||||
}
|
}
|
||||||
this.nameMap.put(methodName, attr);
|
this.nameMap.put(methodName, attr);
|
||||||
}
|
}
|
||||||
|
@ -115,8 +115,8 @@ public class NameMatchTransactionAttributeSource
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() {
|
public void afterPropertiesSet() {
|
||||||
for (TransactionAttribute attr : this.nameMap.values()) {
|
for (TransactionAttribute attr : this.nameMap.values()) {
|
||||||
if (attr instanceof DefaultTransactionAttribute) {
|
if (attr instanceof DefaultTransactionAttribute dta) {
|
||||||
((DefaultTransactionAttribute) attr).resolveAttributeStrings(this.embeddedValueResolver);
|
dta.resolveAttributeStrings(this.embeddedValueResolver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,10 +167,9 @@ public class NameMatchTransactionAttributeSource
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(other instanceof NameMatchTransactionAttributeSource)) {
|
if (!(other instanceof NameMatchTransactionAttributeSource otherTas)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
NameMatchTransactionAttributeSource otherTas = (NameMatchTransactionAttributeSource) other;
|
|
||||||
return ObjectUtils.nullSafeEquals(this.nameMap, otherTas.nameMap);
|
return ObjectUtils.nullSafeEquals(this.nameMap, otherTas.nameMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -129,10 +129,9 @@ public class RollbackRuleAttribute implements Serializable{
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(other instanceof RollbackRuleAttribute)) {
|
if (!(other instanceof RollbackRuleAttribute rhs)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
RollbackRuleAttribute rhs = (RollbackRuleAttribute) other;
|
|
||||||
return this.exceptionName.equals(rhs.exceptionName);
|
return this.exceptionName.equals(rhs.exceptionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -52,10 +52,9 @@ abstract class TransactionAttributeSourcePointcut extends StaticMethodMatcherPoi
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(other instanceof TransactionAttributeSourcePointcut)) {
|
if (!(other instanceof TransactionAttributeSourcePointcut otherPc)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
TransactionAttributeSourcePointcut otherPc = (TransactionAttributeSourcePointcut) other;
|
|
||||||
return ObjectUtils.nullSafeEquals(getTransactionAttributeSource(), otherPc.getTransactionAttributeSource());
|
return ObjectUtils.nullSafeEquals(getTransactionAttributeSource(), otherPc.getTransactionAttributeSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue