Polishing

This commit is contained in:
Sam Brannen
2023-09-18 17:17:56 +02:00
parent fef3cf8e58
commit edd1e9134f
7 changed files with 101 additions and 96 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2023 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.
@@ -17,11 +17,11 @@
package org.springframework.aop; package org.springframework.aop;
/** /**
* Filter that restricts matching of a pointcut or introduction to * Filter that restricts matching of a pointcut or introduction to a given set
* a given set of target classes. * of target classes.
* *
* <p>Can be used as part of a {@link Pointcut} or for the entire * <p>Can be used as part of a {@link Pointcut} or for the entire targeting of
* targeting of an {@link IntroductionAdvisor}. * an {@link IntroductionAdvisor}.
* *
* <p>Concrete implementations of this interface typically should provide proper * <p>Concrete implementations of this interface typically should provide proper
* implementations of {@link Object#equals(Object)} and {@link Object#hashCode()} * implementations of {@link Object#equals(Object)} and {@link Object#hashCode()}
@@ -44,7 +44,7 @@ public interface ClassFilter {
/** /**
* Canonical instance of a ClassFilter that matches all classes. * Canonical instance of a {@code ClassFilter} that matches all classes.
*/ */
ClassFilter TRUE = TrueClassFilter.INSTANCE; ClassFilter TRUE = TrueClassFilter.INSTANCE;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2023 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.
@@ -21,24 +21,25 @@ import java.lang.reflect.Method;
/** /**
* Part of a {@link Pointcut}: Checks whether the target method is eligible for advice. * Part of a {@link Pointcut}: Checks whether the target method is eligible for advice.
* *
* <p>A MethodMatcher may be evaluated <b>statically</b> or at <b>runtime</b> (dynamically). * <p>A {@code MethodMatcher} may be evaluated <b>statically</b> or at <b>runtime</b>
* Static matching involves method and (possibly) method attributes. Dynamic matching * (dynamically). Static matching involves a method and (possibly) method attributes.
* also makes arguments for a particular call available, and any effects of running * Dynamic matching also makes arguments for a particular call available, and any
* previous advice applying to the joinpoint. * effects of running previous advice applying to the joinpoint.
* *
* <p>If an implementation returns {@code false} from its {@link #isRuntime()} * <p>If an implementation returns {@code false} from its {@link #isRuntime()}
* method, evaluation can be performed statically, and the result will be the same * method, evaluation can be performed statically, and the result will be the same
* for all invocations of this method, whatever their arguments. This means that * for all invocations of this method, whatever their arguments. This means that
* if the {@link #isRuntime()} method returns {@code false}, the 3-arg * if the {@link #isRuntime()} method returns {@code false}, the 3-arg
* {@link #matches(java.lang.reflect.Method, Class, Object[])} method will never be invoked. * {@link #matches(Method, Class, Object[])} method will never be invoked.
* *
* <p>If an implementation returns {@code true} from its 2-arg * <p>If an implementation returns {@code true} from its 2-arg
* {@link #matches(java.lang.reflect.Method, Class)} method and its {@link #isRuntime()} method * {@link #matches(Method, Class)} method and its {@link #isRuntime()} method
* returns {@code true}, the 3-arg {@link #matches(java.lang.reflect.Method, Class, Object[])} * returns {@code true}, the 3-arg {@link #matches(Method, Class, Object[])}
* method will be invoked <i>immediately before each potential execution of the related advice</i>, * method will be invoked <i>immediately before each potential execution of the
* to decide whether the advice should run. All previous advice, such as earlier interceptors * related advice</i> to decide whether the advice should run. All previous advice,
* in an interceptor chain, will have run, so any state changes they have produced in * such as earlier interceptors in an interceptor chain, will have run, so any
* parameters or ThreadLocal state will be available at the time of evaluation. * state changes they have produced in parameters or {@code ThreadLocal} state will
* be available at the time of evaluation.
* *
* <p>Concrete implementations of this interface typically should provide proper * <p>Concrete implementations of this interface typically should provide proper
* implementations of {@link Object#equals(Object)} and {@link Object#hashCode()} * implementations of {@link Object#equals(Object)} and {@link Object#hashCode()}
@@ -53,11 +54,10 @@ import java.lang.reflect.Method;
public interface MethodMatcher { public interface MethodMatcher {
/** /**
* Perform static checking whether the given method matches. * Perform static checking to determine whether the given method matches.
* <p>If this returns {@code false} or if the {@link #isRuntime()} * <p>If this method returns {@code false} or if {@link #isRuntime()}
* method returns {@code false}, no runtime check (i.e. no * returns {@code false}, no runtime check (i.e. no
* {@link #matches(java.lang.reflect.Method, Class, Object[])} call) * {@link #matches(Method, Class, Object[])} call) will be made.
* will be made.
* @param method the candidate method * @param method the candidate method
* @param targetClass the target class * @param targetClass the target class
* @return whether this method matches statically * @return whether this method matches statically
@@ -65,36 +65,35 @@ public interface MethodMatcher {
boolean matches(Method method, Class<?> targetClass); boolean matches(Method method, Class<?> targetClass);
/** /**
* Is this MethodMatcher dynamic, that is, must a final call be made on the * Is this {@code MethodMatcher} dynamic, that is, must a final check be made
* {@link #matches(java.lang.reflect.Method, Class, Object[])} method at * via the {@link #matches(Method, Class, Object[])} method at runtime even
* runtime even if the 2-arg matches method returns {@code true}? * if {@link #matches(Method, Class)} returns {@code true}?
* <p>Can be invoked when an AOP proxy is created, and need not be invoked * <p>Can be invoked when an AOP proxy is created, and need not be invoked
* again before each method invocation, * again before each method invocation.
* @return whether a runtime match via the 3-arg * @return whether a runtime match via {@link #matches(Method, Class, Object[])}
* {@link #matches(java.lang.reflect.Method, Class, Object[])} method
* is required if static matching passed * is required if static matching passed
*/ */
boolean isRuntime(); boolean isRuntime();
/** /**
* Check whether there a runtime (dynamic) match for this method, * Check whether there is a runtime (dynamic) match for this method, which
* which must have matched statically. * must have matched statically.
* <p>This method is invoked only if the 2-arg matches method returns * <p>This method is invoked only if {@link #matches(Method, Class)} returns
* {@code true} for the given method and target class, and if the * {@code true} for the given method and target class, and if
* {@link #isRuntime()} method returns {@code true}. Invoked * {@link #isRuntime()} returns {@code true}.
* immediately before potential running of the advice, after any * <p>Invoked immediately before potential running of the advice, after any
* advice earlier in the advice chain has run. * advice earlier in the advice chain has run.
* @param method the candidate method * @param method the candidate method
* @param targetClass the target class * @param targetClass the target class
* @param args arguments to the method * @param args arguments to the method
* @return whether there's a runtime match * @return whether there's a runtime match
* @see MethodMatcher#matches(Method, Class) * @see #matches(Method, Class)
*/ */
boolean matches(Method method, Class<?> targetClass, Object... args); boolean matches(Method method, Class<?> targetClass, Object... args);
/** /**
* Canonical instance that matches all methods. * Canonical instance of a {@code MethodMatcher} that matches all methods.
*/ */
MethodMatcher TRUE = TrueMethodMatcher.INSTANCE; MethodMatcher TRUE = TrueMethodMatcher.INSTANCE;

View File

@@ -25,7 +25,7 @@ import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
* AspectJPointcutAdvisor that adapts an {@link AbstractAspectJAdvice} * AspectJ {@link PointcutAdvisor} that adapts an {@link AbstractAspectJAdvice}
* to the {@link org.springframework.aop.PointcutAdvisor} interface. * to the {@link org.springframework.aop.PointcutAdvisor} interface.
* *
* @author Adrian Colyer * @author Adrian Colyer

View File

@@ -48,7 +48,8 @@ import org.springframework.util.ObjectUtils;
/** /**
* Base class for AOP proxy configuration managers. * Base class for AOP proxy configuration managers.
* These are not themselves AOP proxies, but subclasses of this class are *
* <p>These are not themselves AOP proxies, but subclasses of this class are
* normally factories from which AOP proxy instances are obtained directly. * normally factories from which AOP proxy instances are obtained directly.
* *
* <p>This class frees subclasses of the housekeeping of Advices * <p>This class frees subclasses of the housekeeping of Advices
@@ -56,7 +57,8 @@ import org.springframework.util.ObjectUtils;
* methods, which are provided by subclasses. * methods, which are provided by subclasses.
* *
* <p>This class is serializable; subclasses need not be. * <p>This class is serializable; subclasses need not be.
* This class is used to hold snapshots of proxies. *
* <p>This class is used to hold snapshots of proxies.
* *
* @author Rod Johnson * @author Rod Johnson
* @author Juergen Hoeller * @author Juergen Hoeller
@@ -111,7 +113,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
} }
/** /**
* Create a AdvisedSupport instance with the given parameters. * Create an {@code AdvisedSupport} instance with the given parameters.
* @param interfaces the proxied interfaces * @param interfaces the proxied interfaces
*/ */
public AdvisedSupport(Class<?>... interfaces) { public AdvisedSupport(Class<?>... interfaces) {
@@ -131,7 +133,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
/** /**
* Set the given object as target. * Set the given object as target.
* Will create a SingletonTargetSource for the object. * <p>Will create a SingletonTargetSource for the object.
* @see #setTargetSource * @see #setTargetSource
* @see org.springframework.aop.target.SingletonTargetSource * @see org.springframework.aop.target.SingletonTargetSource
*/ */
@@ -506,9 +508,9 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
} }
/** /**
* Copy the AOP configuration from the given AdvisedSupport object, * Copy the AOP configuration from the given {@link AdvisedSupport} object,
* but allow substitution of a fresh TargetSource and a given interceptor chain. * but allow substitution of a fresh {@link TargetSource} and a given interceptor chain.
* @param other the AdvisedSupport object to take proxy configuration from * @param other the {@code AdvisedSupport} object to take proxy configuration from
* @param targetSource the new TargetSource * @param targetSource the new TargetSource
* @param advisors the Advisors for the chain * @param advisors the Advisors for the chain
*/ */
@@ -528,8 +530,8 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
} }
/** /**
* Build a configuration-only copy of this AdvisedSupport, * Build a configuration-only copy of this {@link AdvisedSupport},
* replacing the TargetSource. * replacing the {@link TargetSource}.
*/ */
AdvisedSupport getConfigurationOnlyCopy() { AdvisedSupport getConfigurationOnlyCopy() {
AdvisedSupport copy = new AdvisedSupport(this.advisorChainFactory, this.methodCache); AdvisedSupport copy = new AdvisedSupport(this.advisorChainFactory, this.methodCache);
@@ -604,8 +606,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
@Override @Override
public boolean equals(@Nullable Object other) { public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof MethodCacheKey methodCacheKey && return (this == other || (other instanceof MethodCacheKey that && this.method == that.method));
this.method == methodCacheKey.method));
} }
@Override @Override
@@ -630,7 +631,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
/** /**
* Stub for an Advisor instance that is just needed for key purposes, * Stub for an {@link Advisor} instance that is just needed for key purposes,
* allowing for efficient equals and hashCode comparisons against the * allowing for efficient equals and hashCode comparisons against the
* advice class and the pointcut. * advice class and the pointcut.
* @since 6.0.10 * @since 6.0.10
@@ -642,10 +643,11 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
private final Class<?> adviceType; private final Class<?> adviceType;
@Nullable @Nullable
private String classFilterKey; private final String classFilterKey;
@Nullable @Nullable
private String methodMatcherKey; private final String methodMatcherKey;
public AdvisorKeyEntry(Advisor advisor) { public AdvisorKeyEntry(Advisor advisor) {
this.adviceType = advisor.getAdvice().getClass(); this.adviceType = advisor.getAdvice().getClass();
@@ -654,6 +656,10 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
this.classFilterKey = ObjectUtils.identityToString(pointcut.getClassFilter()); this.classFilterKey = ObjectUtils.identityToString(pointcut.getClassFilter());
this.methodMatcherKey = ObjectUtils.identityToString(pointcut.getMethodMatcher()); this.methodMatcherKey = ObjectUtils.identityToString(pointcut.getMethodMatcher());
} }
else {
this.classFilterKey = null;
this.methodMatcherKey = null;
}
} }
@Override @Override
@@ -663,10 +669,10 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
return (this == other || (other instanceof AdvisorKeyEntry otherEntry && return (this == other || (other instanceof AdvisorKeyEntry that &&
this.adviceType == otherEntry.adviceType && this.adviceType == that.adviceType &&
ObjectUtils.nullSafeEquals(this.classFilterKey, otherEntry.classFilterKey) && ObjectUtils.nullSafeEquals(this.classFilterKey, that.classFilterKey) &&
ObjectUtils.nullSafeEquals(this.methodMatcherKey, otherEntry.methodMatcherKey))); ObjectUtils.nullSafeEquals(this.methodMatcherKey, that.methodMatcherKey)));
} }
@Override @Override

View File

@@ -27,7 +27,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
/** /**
* A Pointcut that matches if the underlying {@link CacheOperationSource} * A {@code Pointcut} that matches if the underlying {@link CacheOperationSource}
* has an attribute for a given method. * has an attribute for a given method.
* *
* @author Costin Leau * @author Costin Leau

View File

@@ -27,7 +27,7 @@ import org.springframework.transaction.TransactionManager;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
/** /**
* Abstract class that implements a Pointcut that matches if the underlying * Abstract class that implements a {@code Pointcut} that matches if the underlying
* {@link TransactionAttributeSource} has an attribute for a given method. * {@link TransactionAttributeSource} has an attribute for a given method.
* *
* @author Juergen Hoeller * @author Juergen Hoeller

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2023 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.
@@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Mark Paluch * @author Mark Paluch
*/ */
public class AnnotationTransactionInterceptorTests { class AnnotationTransactionInterceptorTests {
private final CallCountingTransactionManager ptm = new CallCountingTransactionManager(); private final CallCountingTransactionManager ptm = new CallCountingTransactionManager();
@@ -53,7 +53,7 @@ public class AnnotationTransactionInterceptorTests {
@Test @Test
public void classLevelOnly() { void classLevelOnly() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestClassLevelOnly()); proxyFactory.setTarget(new TestClassLevelOnly());
proxyFactory.addAdvice(this.ti); proxyFactory.addAdvice(this.ti);
@@ -74,7 +74,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withSingleMethodOverride() { void withSingleMethodOverride() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithSingleMethodOverride()); proxyFactory.setTarget(new TestWithSingleMethodOverride());
proxyFactory.addAdvice(this.ti); proxyFactory.addAdvice(this.ti);
@@ -95,7 +95,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withSingleMethodOverrideInverted() { void withSingleMethodOverrideInverted() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithSingleMethodOverrideInverted()); proxyFactory.setTarget(new TestWithSingleMethodOverrideInverted());
proxyFactory.addAdvice(this.ti); proxyFactory.addAdvice(this.ti);
@@ -116,7 +116,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withMultiMethodOverride() { void withMultiMethodOverride() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithMultiMethodOverride()); proxyFactory.setTarget(new TestWithMultiMethodOverride());
proxyFactory.addAdvice(this.ti); proxyFactory.addAdvice(this.ti);
@@ -137,7 +137,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withRollbackOnRuntimeException() { void withRollbackOnRuntimeException() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithExceptions()); proxyFactory.setTarget(new TestWithExceptions());
proxyFactory.addAdvice(this.ti); proxyFactory.addAdvice(this.ti);
@@ -154,7 +154,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withCommitOnCheckedException() { void withCommitOnCheckedException() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithExceptions()); proxyFactory.setTarget(new TestWithExceptions());
proxyFactory.addAdvice(this.ti); proxyFactory.addAdvice(this.ti);
@@ -167,7 +167,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withRollbackOnCheckedExceptionAndRollbackRule() { void withRollbackOnCheckedExceptionAndRollbackRule() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithExceptions()); proxyFactory.setTarget(new TestWithExceptions());
proxyFactory.addAdvice(this.ti); proxyFactory.addAdvice(this.ti);
@@ -180,7 +180,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withMonoSuccess() { void withMonoSuccess() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithReactive()); proxyFactory.setTarget(new TestWithReactive());
proxyFactory.addAdvice(new TransactionInterceptor(rtm, this.source)); proxyFactory.addAdvice(new TransactionInterceptor(rtm, this.source));
@@ -192,7 +192,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withMonoFailure() { void withMonoFailure() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithReactive()); proxyFactory.setTarget(new TestWithReactive());
proxyFactory.addAdvice(new TransactionInterceptor(rtm, this.source)); proxyFactory.addAdvice(new TransactionInterceptor(rtm, this.source));
@@ -204,7 +204,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withMonoRollback() { void withMonoRollback() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithReactive()); proxyFactory.setTarget(new TestWithReactive());
proxyFactory.addAdvice(new TransactionInterceptor(rtm, this.source)); proxyFactory.addAdvice(new TransactionInterceptor(rtm, this.source));
@@ -216,7 +216,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withFluxSuccess() { void withFluxSuccess() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithReactive()); proxyFactory.setTarget(new TestWithReactive());
proxyFactory.addAdvice(new TransactionInterceptor(rtm, this.source)); proxyFactory.addAdvice(new TransactionInterceptor(rtm, this.source));
@@ -228,7 +228,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withFluxFailure() { void withFluxFailure() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithReactive()); proxyFactory.setTarget(new TestWithReactive());
proxyFactory.addAdvice(new TransactionInterceptor(rtm, this.source)); proxyFactory.addAdvice(new TransactionInterceptor(rtm, this.source));
@@ -240,7 +240,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withFluxRollback() { void withFluxRollback() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithReactive()); proxyFactory.setTarget(new TestWithReactive());
proxyFactory.addAdvice(new TransactionInterceptor(rtm, this.source)); proxyFactory.addAdvice(new TransactionInterceptor(rtm, this.source));
@@ -252,7 +252,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withVavrTrySuccess() { void withVavrTrySuccess() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithVavrTry()); proxyFactory.setTarget(new TestWithVavrTry());
proxyFactory.addAdvice(this.ti); proxyFactory.addAdvice(this.ti);
@@ -264,7 +264,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withVavrTryRuntimeException() { void withVavrTryRuntimeException() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithVavrTry()); proxyFactory.setTarget(new TestWithVavrTry());
proxyFactory.addAdvice(this.ti); proxyFactory.addAdvice(this.ti);
@@ -276,7 +276,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withVavrTryCheckedException() { void withVavrTryCheckedException() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithVavrTry()); proxyFactory.setTarget(new TestWithVavrTry());
proxyFactory.addAdvice(this.ti); proxyFactory.addAdvice(this.ti);
@@ -288,7 +288,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withVavrTryCheckedExceptionAndRollbackRule() { void withVavrTryCheckedExceptionAndRollbackRule() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithVavrTry()); proxyFactory.setTarget(new TestWithVavrTry());
proxyFactory.addAdvice(this.ti); proxyFactory.addAdvice(this.ti);
@@ -300,7 +300,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withInterface() { void withInterface() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithInterfaceImpl()); proxyFactory.setTarget(new TestWithInterfaceImpl());
proxyFactory.addInterface(TestWithInterface.class); proxyFactory.addInterface(TestWithInterface.class);
@@ -325,7 +325,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void crossClassInterfaceMethodLevelOnJdkProxy() { void crossClassInterfaceMethodLevelOnJdkProxy() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new SomeServiceImpl()); proxyFactory.setTarget(new SomeServiceImpl());
proxyFactory.addInterface(SomeService.class); proxyFactory.addInterface(SomeService.class);
@@ -344,7 +344,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void crossClassInterfaceOnJdkProxy() { void crossClassInterfaceOnJdkProxy() {
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new OtherServiceImpl()); proxyFactory.setTarget(new OtherServiceImpl());
proxyFactory.addInterface(OtherService.class); proxyFactory.addInterface(OtherService.class);
@@ -357,7 +357,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withInterfaceOnTargetJdkProxy() { void withInterfaceOnTargetJdkProxy() {
ProxyFactory targetFactory = new ProxyFactory(); ProxyFactory targetFactory = new ProxyFactory();
targetFactory.setTarget(new TestWithInterfaceImpl()); targetFactory.setTarget(new TestWithInterfaceImpl());
targetFactory.addInterface(TestWithInterface.class); targetFactory.addInterface(TestWithInterface.class);
@@ -386,7 +386,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Test @Test
public void withInterfaceOnTargetCglibProxy() { void withInterfaceOnTargetCglibProxy() {
ProxyFactory targetFactory = new ProxyFactory(); ProxyFactory targetFactory = new ProxyFactory();
targetFactory.setTarget(new TestWithInterfaceImpl()); targetFactory.setTarget(new TestWithInterfaceImpl());
targetFactory.setProxyTargetClass(true); targetFactory.setProxyTargetClass(true);
@@ -436,7 +436,7 @@ public class AnnotationTransactionInterceptorTests {
@Transactional @Transactional
public static class TestClassLevelOnly { static class TestClassLevelOnly {
public void doSomething() { public void doSomething() {
assertThat(TransactionSynchronizationManager.isActualTransactionActive()).isTrue(); assertThat(TransactionSynchronizationManager.isActualTransactionActive()).isTrue();
@@ -451,7 +451,7 @@ public class AnnotationTransactionInterceptorTests {
@Transactional @Transactional
public static class TestWithSingleMethodOverride { static class TestWithSingleMethodOverride {
public void doSomething() { public void doSomething() {
assertThat(TransactionSynchronizationManager.isActualTransactionActive()).isTrue(); assertThat(TransactionSynchronizationManager.isActualTransactionActive()).isTrue();
@@ -472,7 +472,7 @@ public class AnnotationTransactionInterceptorTests {
@Transactional(readOnly = true) @Transactional(readOnly = true)
public static class TestWithSingleMethodOverrideInverted { static class TestWithSingleMethodOverrideInverted {
@Transactional @Transactional
public void doSomething() { public void doSomething() {
@@ -493,7 +493,7 @@ public class AnnotationTransactionInterceptorTests {
@Transactional @Transactional
public static class TestWithMultiMethodOverride { static class TestWithMultiMethodOverride {
@Transactional(readOnly = true) @Transactional(readOnly = true)
public void doSomething() { public void doSomething() {
@@ -515,7 +515,7 @@ public class AnnotationTransactionInterceptorTests {
@Transactional @Transactional
public static class TestWithExceptions { static class TestWithExceptions {
public void doSomethingErroneous() { public void doSomethingErroneous() {
assertThat(TransactionSynchronizationManager.isActualTransactionActive()).isTrue(); assertThat(TransactionSynchronizationManager.isActualTransactionActive()).isTrue();
@@ -545,7 +545,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Transactional @Transactional
public static class TestWithReactive { static class TestWithReactive {
public Mono<Void> monoSuccess() { public Mono<Void> monoSuccess() {
return Mono.delay(Duration.ofSeconds(10)).then(); return Mono.delay(Duration.ofSeconds(10)).then();
@@ -565,7 +565,7 @@ public class AnnotationTransactionInterceptorTests {
} }
@Transactional @Transactional
public static class TestWithVavrTry { static class TestWithVavrTry {
public Try<String> doSomething() { public Try<String> doSomething() {
assertThat(TransactionSynchronizationManager.isActualTransactionActive()).isTrue(); assertThat(TransactionSynchronizationManager.isActualTransactionActive()).isTrue();
@@ -594,14 +594,14 @@ public class AnnotationTransactionInterceptorTests {
} }
public interface BaseInterface { interface BaseInterface {
void doSomething(); void doSomething();
} }
@Transactional @Transactional
public interface TestWithInterface extends BaseInterface { interface TestWithInterface extends BaseInterface {
@Transactional(readOnly = true) @Transactional(readOnly = true)
void doSomethingElse(); void doSomethingElse();
@@ -613,7 +613,7 @@ public class AnnotationTransactionInterceptorTests {
} }
public static class TestWithInterfaceImpl implements TestWithInterface { static class TestWithInterfaceImpl implements TestWithInterface {
@Override @Override
public void doSomething() { public void doSomething() {
@@ -629,7 +629,7 @@ public class AnnotationTransactionInterceptorTests {
} }
public interface SomeService { interface SomeService {
void foo(); void foo();
@@ -641,7 +641,7 @@ public class AnnotationTransactionInterceptorTests {
} }
public static class SomeServiceImpl implements SomeService { static class SomeServiceImpl implements SomeService {
@Override @Override
public void bar() { public void bar() {
@@ -659,14 +659,14 @@ public class AnnotationTransactionInterceptorTests {
} }
public interface OtherService { interface OtherService {
void foo(); void foo();
} }
@Transactional @Transactional
public static class OtherServiceImpl implements OtherService { static class OtherServiceImpl implements OtherService {
@Override @Override
public void foo() { public void foo() {