Switch to JSpecify annotations
This commit updates the whole Spring Framework codebase to use JSpecify annotations instead of Spring null-safety annotations with JSR 305 semantics. JSpecify provides signficant enhancements such as properly defined specifications, a canonical dependency with no split-package issue, better tooling, better Kotlin integration and the capability to specify generic type, array and varargs element null-safety. Generic type null-safety is not defined by this commit yet and will be specified later. A key difference is that Spring null-safety annotations, following JSR 305 semantics, apply to fields, parameters and return values, while JSpecify annotations apply to type usages. That's why this commit moves nullability annotations closer to the type for fields and return values. See gh-28797
This commit is contained in:
parent
fcb8aed03f
commit
bc5d771a06
|
@ -107,7 +107,8 @@ configure([rootProject] + javaProjects) { project ->
|
||||||
// Previously there could be a split-package issue between JSR250 and JSR305 javax.annotation packages,
|
// Previously there could be a split-package issue between JSR250 and JSR305 javax.annotation packages,
|
||||||
// but since 6.0 JSR 250 annotations such as @Resource and @PostConstruct have been replaced by their
|
// but since 6.0 JSR 250 annotations such as @Resource and @PostConstruct have been replaced by their
|
||||||
// JakartaEE equivalents in the jakarta.annotation package.
|
// JakartaEE equivalents in the jakarta.annotation package.
|
||||||
//"https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/3.0.2/"
|
//"https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/3.0.2/",
|
||||||
|
"https://jspecify.dev/docs/api/"
|
||||||
] as String[]
|
] as String[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,7 @@ class CustomCacheConfiguration {
|
||||||
// tag::snippet[]
|
// tag::snippet[]
|
||||||
@Bean
|
@Bean
|
||||||
fun cacheManager(): CacheManager {
|
fun cacheManager(): CacheManager {
|
||||||
return CaffeineCacheManager().apply {
|
return CaffeineCacheManager("default", "books")
|
||||||
cacheNames = listOf("default", "books")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// end::snippet[]
|
// end::snippet[]
|
||||||
}
|
}
|
|
@ -131,6 +131,7 @@ dependencies {
|
||||||
api("org.htmlunit:htmlunit:4.6.0")
|
api("org.htmlunit:htmlunit:4.6.0")
|
||||||
api("org.javamoney:moneta:1.4.4")
|
api("org.javamoney:moneta:1.4.4")
|
||||||
api("org.jruby:jruby:9.4.9.0")
|
api("org.jruby:jruby:9.4.9.0")
|
||||||
|
api("org.jspecify:jspecify:1.0.0")
|
||||||
api("org.junit.support:testng-engine:1.0.5")
|
api("org.junit.support:testng-engine:1.0.5")
|
||||||
api("org.mozilla:rhino:1.7.15")
|
api("org.mozilla:rhino:1.7.15")
|
||||||
api("org.ogce:xpp3:1.1.6")
|
api("org.ogce:xpp3:1.1.6")
|
||||||
|
|
|
@ -13,8 +13,8 @@ dependencies {
|
||||||
jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.37'
|
jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.37'
|
||||||
jmh 'org.openjdk.jmh:jmh-generator-bytecode:1.37'
|
jmh 'org.openjdk.jmh:jmh-generator-bytecode:1.37'
|
||||||
jmh 'net.sf.jopt-simple:jopt-simple'
|
jmh 'net.sf.jopt-simple:jopt-simple'
|
||||||
errorprone 'com.uber.nullaway:nullaway:0.10.26'
|
errorprone 'com.uber.nullaway:nullaway:0.12.2'
|
||||||
errorprone 'com.google.errorprone:error_prone_core:2.9.0'
|
errorprone 'com.google.errorprone:error_prone_core:2.35.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginManager.withPlugin("kotlin") {
|
pluginManager.withPlugin("kotlin") {
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.aop.support.AopUtils;
|
import org.springframework.aop.support.AopUtils;
|
||||||
|
@ -31,7 +32,6 @@ import org.springframework.beans.factory.BeanFactory;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.beans.testfixture.beans.ITestBean;
|
import org.springframework.beans.testfixture.beans.ITestBean;
|
||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.transaction.NoTransactionException;
|
import org.springframework.transaction.NoTransactionException;
|
||||||
import org.springframework.transaction.interceptor.TransactionInterceptor;
|
import org.springframework.transaction.interceptor.TransactionInterceptor;
|
||||||
import org.springframework.transaction.testfixture.CallCountingTransactionManager;
|
import org.springframework.transaction.testfixture.CallCountingTransactionManager;
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.springframework.aop;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* After returning advice is invoked only on normal method return, not if an
|
* After returning advice is invoked only on normal method return, not if an
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.springframework.aop;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Advice invoked before a method is invoked. Such advices cannot
|
* Advice invoked before a method is invoked. Such advices cannot
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
package org.springframework.aop;
|
package org.springframework.aop;
|
||||||
|
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension of the AOP Alliance {@link org.aopalliance.intercept.MethodInvocation}
|
* Extension of the AOP Alliance {@link org.aopalliance.intercept.MethodInvocation}
|
||||||
|
@ -83,7 +82,6 @@ public interface ProxyMethodInvocation extends MethodInvocation {
|
||||||
* @return the value of the attribute, or {@code null} if not set
|
* @return the value of the attribute, or {@code null} if not set
|
||||||
* @see #setUserAttribute
|
* @see #setUserAttribute
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable Object getUserAttribute(String key);
|
||||||
Object getUserAttribute(String key);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package org.springframework.aop;
|
package org.springframework.aop;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minimal interface for exposing the target class behind a proxy.
|
* Minimal interface for exposing the target class behind a proxy.
|
||||||
|
@ -36,7 +36,6 @@ public interface TargetClassAware {
|
||||||
* (typically a proxy configuration or an actual proxy).
|
* (typically a proxy configuration or an actual proxy).
|
||||||
* @return the target Class, or {@code null} if not known
|
* @return the target Class, or {@code null} if not known
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable Class<?> getTargetClass();
|
||||||
Class<?> getTargetClass();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package org.springframework.aop;
|
package org.springframework.aop;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@code TargetSource} is used to obtain the current "target" of
|
* A {@code TargetSource} is used to obtain the current "target" of
|
||||||
|
@ -42,8 +42,7 @@ public interface TargetSource extends TargetClassAware {
|
||||||
* @return the type of targets returned by this {@link TargetSource}
|
* @return the type of targets returned by this {@link TargetSource}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable Class<?> getTargetClass();
|
||||||
Class<?> getTargetClass();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will all calls to {@link #getTarget()} return the same object?
|
* Will all calls to {@link #getTarget()} return the same object?
|
||||||
|
@ -64,8 +63,7 @@ public interface TargetSource extends TargetClassAware {
|
||||||
* or {@code null} if there is no actual target instance
|
* or {@code null} if there is no actual target instance
|
||||||
* @throws Exception if the target object can't be resolved
|
* @throws Exception if the target object can't be resolved
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable Object getTarget() throws Exception;
|
||||||
Object getTarget() throws Exception;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Release the given target object obtained from the
|
* Release the given target object obtained from the
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.aspectj.lang.JoinPoint;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.weaver.tools.JoinPointMatch;
|
import org.aspectj.weaver.tools.JoinPointMatch;
|
||||||
import org.aspectj.weaver.tools.PointcutParameter;
|
import org.aspectj.weaver.tools.PointcutParameter;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.AopInvocationException;
|
import org.springframework.aop.AopInvocationException;
|
||||||
import org.springframework.aop.MethodMatcher;
|
import org.springframework.aop.MethodMatcher;
|
||||||
|
@ -42,7 +43,6 @@ import org.springframework.aop.support.MethodMatchers;
|
||||||
import org.springframework.aop.support.StaticMethodMatcher;
|
import org.springframework.aop.support.StaticMethodMatcher;
|
||||||
import org.springframework.core.DefaultParameterNameDiscoverer;
|
import org.springframework.core.DefaultParameterNameDiscoverer;
|
||||||
import org.springframework.core.ParameterNameDiscoverer;
|
import org.springframework.core.ParameterNameDiscoverer;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
@ -118,16 +118,13 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
* This will be non-null if the creator of this advice object knows the argument names
|
* This will be non-null if the creator of this advice object knows the argument names
|
||||||
* and sets them explicitly.
|
* and sets them explicitly.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
private @Nullable String @Nullable [] argumentNames;
|
||||||
private String[] argumentNames;
|
|
||||||
|
|
||||||
/** Non-null if after throwing advice binds the thrown value. */
|
/** Non-null if after throwing advice binds the thrown value. */
|
||||||
@Nullable
|
private @Nullable String throwingName;
|
||||||
private String throwingName;
|
|
||||||
|
|
||||||
/** Non-null if after returning advice binds the return value. */
|
/** Non-null if after returning advice binds the return value. */
|
||||||
@Nullable
|
private @Nullable String returningName;
|
||||||
private String returningName;
|
|
||||||
|
|
||||||
private Class<?> discoveredReturningType = Object.class;
|
private Class<?> discoveredReturningType = Object.class;
|
||||||
|
|
||||||
|
@ -145,13 +142,11 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
*/
|
*/
|
||||||
private int joinPointStaticPartArgumentIndex = -1;
|
private int joinPointStaticPartArgumentIndex = -1;
|
||||||
|
|
||||||
@Nullable
|
private @Nullable Map<String, Integer> argumentBindings;
|
||||||
private Map<String, Integer> argumentBindings;
|
|
||||||
|
|
||||||
private boolean argumentsIntrospected = false;
|
private boolean argumentsIntrospected = false;
|
||||||
|
|
||||||
@Nullable
|
private @Nullable Type discoveredReturningGenericType;
|
||||||
private Type discoveredReturningGenericType;
|
|
||||||
// Note: Unlike return type, no such generic information is needed for the throwing type,
|
// Note: Unlike return type, no such generic information is needed for the throwing type,
|
||||||
// since Java doesn't allow exception types to be parameterized.
|
// since Java doesn't allow exception types to be parameterized.
|
||||||
|
|
||||||
|
@ -212,8 +207,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
/**
|
/**
|
||||||
* Return the ClassLoader for aspect instances.
|
* Return the ClassLoader for aspect instances.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
public final @Nullable ClassLoader getAspectClassLoader() {
|
||||||
public final ClassLoader getAspectClassLoader() {
|
|
||||||
return this.aspectInstanceFactory.getAspectClassLoader();
|
return this.aspectInstanceFactory.getAspectClassLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,8 +312,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
return this.discoveredReturningType;
|
return this.discoveredReturningType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
protected @Nullable Type getDiscoveredReturningGenericType() {
|
||||||
protected Type getDiscoveredReturningGenericType() {
|
|
||||||
return this.discoveredReturningGenericType;
|
return this.discoveredReturningGenericType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,8 +650,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
/**
|
/**
|
||||||
* Get the current join point match at the join point we are being dispatched on.
|
* Get the current join point match at the join point we are being dispatched on.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
protected @Nullable JoinPointMatch getJoinPointMatch() {
|
||||||
protected JoinPointMatch getJoinPointMatch() {
|
|
||||||
MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation();
|
MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation();
|
||||||
if (!(mi instanceof ProxyMethodInvocation pmi)) {
|
if (!(mi instanceof ProxyMethodInvocation pmi)) {
|
||||||
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
|
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
|
||||||
|
@ -672,8 +664,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
// 'last man wins' which is not what we want at all.
|
// 'last man wins' which is not what we want at all.
|
||||||
// Using the expression is guaranteed to be safe, since 2 identical expressions
|
// Using the expression is guaranteed to be safe, since 2 identical expressions
|
||||||
// are guaranteed to bind in exactly the same way.
|
// are guaranteed to bind in exactly the same way.
|
||||||
@Nullable
|
protected @Nullable JoinPointMatch getJoinPointMatch(ProxyMethodInvocation pmi) {
|
||||||
protected JoinPointMatch getJoinPointMatch(ProxyMethodInvocation pmi) {
|
|
||||||
String expression = this.pointcut.getExpression();
|
String expression = this.pointcut.getExpression();
|
||||||
return (expression != null ? (JoinPointMatch) pmi.getUserAttribute(expression) : null);
|
return (expression != null ? (JoinPointMatch) pmi.getUserAttribute(expression) : null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,9 @@
|
||||||
|
|
||||||
package org.springframework.aop.aspectj;
|
package org.springframework.aop.aspectj;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface implemented to provide an instance of an AspectJ aspect.
|
* Interface implemented to provide an instance of an AspectJ aspect.
|
||||||
|
@ -44,7 +45,6 @@ public interface AspectInstanceFactory extends Ordered {
|
||||||
* @return the aspect class loader (or {@code null} for the bootstrap loader)
|
* @return the aspect class loader (or {@code null} for the bootstrap loader)
|
||||||
* @see org.springframework.util.ClassUtils#getDefaultClassLoader()
|
* @see org.springframework.util.ClassUtils#getDefaultClassLoader()
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable ClassLoader getAspectClassLoader();
|
||||||
ClassLoader getAspectClassLoader();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,9 @@ import org.aspectj.lang.JoinPoint;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.weaver.tools.PointcutParser;
|
import org.aspectj.weaver.tools.PointcutParser;
|
||||||
import org.aspectj.weaver.tools.PointcutPrimitive;
|
import org.aspectj.weaver.tools.PointcutPrimitive;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.core.ParameterNameDiscoverer;
|
import org.springframework.core.ParameterNameDiscoverer;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -157,22 +157,19 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||||
|
|
||||||
|
|
||||||
/** The pointcut expression associated with the advice, as a simple String. */
|
/** The pointcut expression associated with the advice, as a simple String. */
|
||||||
@Nullable
|
private final @Nullable String pointcutExpression;
|
||||||
private final String pointcutExpression;
|
|
||||||
|
|
||||||
private boolean raiseExceptions;
|
private boolean raiseExceptions;
|
||||||
|
|
||||||
/** If the advice is afterReturning, and binds the return value, this is the parameter name used. */
|
/** If the advice is afterReturning, and binds the return value, this is the parameter name used. */
|
||||||
@Nullable
|
private @Nullable String returningName;
|
||||||
private String returningName;
|
|
||||||
|
|
||||||
/** If the advice is afterThrowing, and binds the thrown value, this is the parameter name used. */
|
/** If the advice is afterThrowing, and binds the thrown value, this is the parameter name used. */
|
||||||
@Nullable
|
private @Nullable String throwingName;
|
||||||
private String throwingName;
|
|
||||||
|
|
||||||
private Class<?>[] argumentTypes = new Class<?>[0];
|
private Class<?>[] argumentTypes = new Class<?>[0];
|
||||||
|
|
||||||
private String[] parameterNameBindings = new String[0];
|
private @Nullable String[] parameterNameBindings = new String[0];
|
||||||
|
|
||||||
private int numberOfRemainingUnboundArguments;
|
private int numberOfRemainingUnboundArguments;
|
||||||
|
|
||||||
|
@ -221,8 +218,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||||
* @return the parameter names
|
* @return the parameter names
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable String @Nullable [] getParameterNames(Method method) {
|
||||||
public String[] getParameterNames(Method method) {
|
|
||||||
this.argumentTypes = method.getParameterTypes();
|
this.argumentTypes = method.getParameterTypes();
|
||||||
this.numberOfRemainingUnboundArguments = this.argumentTypes.length;
|
this.numberOfRemainingUnboundArguments = this.argumentTypes.length;
|
||||||
this.parameterNameBindings = new String[this.numberOfRemainingUnboundArguments];
|
this.parameterNameBindings = new String[this.numberOfRemainingUnboundArguments];
|
||||||
|
@ -289,8 +285,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||||
* {@link #setRaiseExceptions(boolean) raiseExceptions} has been set to {@code true}
|
* {@link #setRaiseExceptions(boolean) raiseExceptions} has been set to {@code true}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public String @Nullable [] getParameterNames(Constructor<?> ctor) {
|
||||||
public String[] getParameterNames(Constructor<?> ctor) {
|
|
||||||
if (this.raiseExceptions) {
|
if (this.raiseExceptions) {
|
||||||
throw new UnsupportedOperationException("An advice method can never be a constructor");
|
throw new UnsupportedOperationException("An advice method can never be a constructor");
|
||||||
}
|
}
|
||||||
|
@ -453,8 +448,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||||
/**
|
/**
|
||||||
* If the token starts meets Java identifier conventions, it's in.
|
* If the token starts meets Java identifier conventions, it's in.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
private @Nullable String maybeExtractVariableName(@Nullable String candidateToken) {
|
||||||
private String maybeExtractVariableName(@Nullable String candidateToken) {
|
|
||||||
if (AspectJProxyUtils.isVariableName(candidateToken)) {
|
if (AspectJProxyUtils.isVariableName(candidateToken)) {
|
||||||
return candidateToken;
|
return candidateToken;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,9 @@ import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.aopalliance.intercept.MethodInterceptor;
|
import org.aopalliance.intercept.MethodInterceptor;
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.AfterAdvice;
|
import org.springframework.aop.AfterAdvice;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring AOP advice wrapping an AspectJ after advice method.
|
* Spring AOP advice wrapping an AspectJ after advice method.
|
||||||
|
@ -43,8 +43,7 @@ public class AspectJAfterAdvice extends AbstractAspectJAdvice
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
|
||||||
try {
|
try {
|
||||||
return mi.proceed();
|
return mi.proceed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,10 @@ import java.io.Serializable;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.AfterAdvice;
|
import org.springframework.aop.AfterAdvice;
|
||||||
import org.springframework.aop.AfterReturningAdvice;
|
import org.springframework.aop.AfterReturningAdvice;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.TypeUtils;
|
import org.springframework.util.TypeUtils;
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,9 @@ import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.aopalliance.intercept.MethodInterceptor;
|
import org.aopalliance.intercept.MethodInterceptor;
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.AfterAdvice;
|
import org.springframework.aop.AfterAdvice;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring AOP advice wrapping an AspectJ after-throwing advice method.
|
* Spring AOP advice wrapping an AspectJ after-throwing advice method.
|
||||||
|
@ -58,8 +58,7 @@ public class AspectJAfterThrowingAdvice extends AbstractAspectJAdvice
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
|
||||||
try {
|
try {
|
||||||
return mi.proceed();
|
return mi.proceed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
package org.springframework.aop.aspectj;
|
package org.springframework.aop.aspectj;
|
||||||
|
|
||||||
import org.aopalliance.aop.Advice;
|
import org.aopalliance.aop.Advice;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Advisor;
|
import org.springframework.aop.Advisor;
|
||||||
import org.springframework.aop.AfterAdvice;
|
import org.springframework.aop.AfterAdvice;
|
||||||
import org.springframework.aop.BeforeAdvice;
|
import org.springframework.aop.BeforeAdvice;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility methods for dealing with AspectJ advisors.
|
* Utility methods for dealing with AspectJ advisors.
|
||||||
|
@ -59,8 +59,7 @@ public abstract class AspectJAopUtils {
|
||||||
* If neither the advisor nor the advice have precedence information, this method
|
* If neither the advisor nor the advice have precedence information, this method
|
||||||
* will return {@code null}.
|
* will return {@code null}.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
public static @Nullable AspectJPrecedenceInformation getAspectJPrecedenceInformationFor(Advisor anAdvisor) {
|
||||||
public static AspectJPrecedenceInformation getAspectJPrecedenceInformationFor(Advisor anAdvisor) {
|
|
||||||
if (anAdvisor instanceof AspectJPrecedenceInformation ajpi) {
|
if (anAdvisor instanceof AspectJPrecedenceInformation ajpi) {
|
||||||
return ajpi;
|
return ajpi;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,9 @@ import org.aopalliance.intercept.MethodInterceptor;
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.weaver.tools.JoinPointMatch;
|
import org.aspectj.weaver.tools.JoinPointMatch;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.ProxyMethodInvocation;
|
import org.springframework.aop.ProxyMethodInvocation;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring AOP around advice (MethodInterceptor) that wraps
|
* Spring AOP around advice (MethodInterceptor) that wraps
|
||||||
|
@ -61,8 +61,7 @@ public class AspectJAroundAdvice extends AbstractAspectJAdvice implements Method
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
|
||||||
if (!(mi instanceof ProxyMethodInvocation pmi)) {
|
if (!(mi instanceof ProxyMethodInvocation pmi)) {
|
||||||
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
|
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.aspectj.weaver.tools.PointcutParser;
|
||||||
import org.aspectj.weaver.tools.PointcutPrimitive;
|
import org.aspectj.weaver.tools.PointcutPrimitive;
|
||||||
import org.aspectj.weaver.tools.ShadowMatch;
|
import org.aspectj.weaver.tools.ShadowMatch;
|
||||||
import org.aspectj.weaver.tools.UnsupportedPointcutPrimitiveException;
|
import org.aspectj.weaver.tools.UnsupportedPointcutPrimitiveException;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.ClassFilter;
|
import org.springframework.aop.ClassFilter;
|
||||||
import org.springframework.aop.IntroductionAwareMethodMatcher;
|
import org.springframework.aop.IntroductionAwareMethodMatcher;
|
||||||
|
@ -54,7 +55,6 @@ import org.springframework.beans.factory.BeanFactoryUtils;
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils;
|
import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
@ -99,8 +99,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
|
|
||||||
private static final Log logger = LogFactory.getLog(AspectJExpressionPointcut.class);
|
private static final Log logger = LogFactory.getLog(AspectJExpressionPointcut.class);
|
||||||
|
|
||||||
@Nullable
|
private @Nullable Class<?> pointcutDeclarationScope;
|
||||||
private Class<?> pointcutDeclarationScope;
|
|
||||||
|
|
||||||
private boolean aspectCompiledByAjc;
|
private boolean aspectCompiledByAjc;
|
||||||
|
|
||||||
|
@ -108,14 +107,11 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
|
|
||||||
private Class<?>[] pointcutParameterTypes = new Class<?>[0];
|
private Class<?>[] pointcutParameterTypes = new Class<?>[0];
|
||||||
|
|
||||||
@Nullable
|
private @Nullable BeanFactory beanFactory;
|
||||||
private BeanFactory beanFactory;
|
|
||||||
|
|
||||||
@Nullable
|
private transient @Nullable ClassLoader pointcutClassLoader;
|
||||||
private transient ClassLoader pointcutClassLoader;
|
|
||||||
|
|
||||||
@Nullable
|
private transient @Nullable PointcutExpression pointcutExpression;
|
||||||
private transient PointcutExpression pointcutExpression;
|
|
||||||
|
|
||||||
private transient boolean pointcutParsingFailed = false;
|
private transient boolean pointcutParsingFailed = false;
|
||||||
|
|
||||||
|
@ -207,8 +203,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
/**
|
/**
|
||||||
* Determine the ClassLoader to use for pointcut evaluation.
|
* Determine the ClassLoader to use for pointcut evaluation.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
private @Nullable ClassLoader determinePointcutClassLoader() {
|
||||||
private ClassLoader determinePointcutClassLoader() {
|
|
||||||
if (this.beanFactory instanceof ConfigurableBeanFactory cbf) {
|
if (this.beanFactory instanceof ConfigurableBeanFactory cbf) {
|
||||||
return cbf.getBeanClassLoader();
|
return cbf.getBeanClassLoader();
|
||||||
}
|
}
|
||||||
|
@ -403,8 +398,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
protected @Nullable String getCurrentProxiedBeanName() {
|
||||||
protected String getCurrentProxiedBeanName() {
|
|
||||||
return ProxyCreationContext.getCurrentProxiedBeanName();
|
return ProxyCreationContext.getCurrentProxiedBeanName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,8 +406,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
/**
|
/**
|
||||||
* Get a new pointcut expression based on a target class's loader rather than the default.
|
* Get a new pointcut expression based on a target class's loader rather than the default.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
private @Nullable PointcutExpression getFallbackPointcutExpression(Class<?> targetClass) {
|
||||||
private PointcutExpression getFallbackPointcutExpression(Class<?> targetClass) {
|
|
||||||
try {
|
try {
|
||||||
ClassLoader classLoader = targetClass.getClassLoader();
|
ClassLoader classLoader = targetClass.getClassLoader();
|
||||||
if (classLoader != null && classLoader != this.pointcutClassLoader) {
|
if (classLoader != null && classLoader != this.pointcutClassLoader) {
|
||||||
|
|
|
@ -16,11 +16,12 @@
|
||||||
|
|
||||||
package org.springframework.aop.aspectj;
|
package org.springframework.aop.aspectj;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Pointcut;
|
import org.springframework.aop.Pointcut;
|
||||||
import org.springframework.aop.support.AbstractGenericPointcutAdvisor;
|
import org.springframework.aop.support.AbstractGenericPointcutAdvisor;
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
import org.springframework.beans.factory.BeanFactoryAware;
|
import org.springframework.beans.factory.BeanFactoryAware;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring AOP Advisor that can be used for any AspectJ pointcut expression.
|
* Spring AOP Advisor that can be used for any AspectJ pointcut expression.
|
||||||
|
@ -38,8 +39,7 @@ public class AspectJExpressionPointcutAdvisor extends AbstractGenericPointcutAdv
|
||||||
this.pointcut.setExpression(expression);
|
this.pointcut.setExpression(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public @Nullable String getExpression() {
|
||||||
public String getExpression() {
|
|
||||||
return this.pointcut.getExpression();
|
return this.pointcut.getExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,8 +47,7 @@ public class AspectJExpressionPointcutAdvisor extends AbstractGenericPointcutAdv
|
||||||
this.pointcut.setLocation(location);
|
this.pointcut.setLocation(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public @Nullable String getLocation() {
|
||||||
public String getLocation() {
|
|
||||||
return this.pointcut.getLocation();
|
return this.pointcut.getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,9 @@ package org.springframework.aop.aspectj;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.MethodBeforeAdvice;
|
import org.springframework.aop.MethodBeforeAdvice;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring AOP advice that wraps an AspectJ before method.
|
* Spring AOP advice that wraps an AspectJ before method.
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
package org.springframework.aop.aspectj;
|
package org.springframework.aop.aspectj;
|
||||||
|
|
||||||
import org.aopalliance.aop.Advice;
|
import org.aopalliance.aop.Advice;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Pointcut;
|
import org.springframework.aop.Pointcut;
|
||||||
import org.springframework.aop.PointcutAdvisor;
|
import org.springframework.aop.PointcutAdvisor;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,8 +38,7 @@ public class AspectJPointcutAdvisor implements PointcutAdvisor, Ordered {
|
||||||
|
|
||||||
private final Pointcut pointcut;
|
private final Pointcut pointcut;
|
||||||
|
|
||||||
@Nullable
|
private @Nullable Integer order;
|
||||||
private Integer order;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,10 +18,11 @@ package org.springframework.aop.aspectj;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Advisor;
|
import org.springframework.aop.Advisor;
|
||||||
import org.springframework.aop.PointcutAdvisor;
|
import org.springframework.aop.PointcutAdvisor;
|
||||||
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
|
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,11 +25,11 @@ import org.aspectj.lang.Signature;
|
||||||
import org.aspectj.lang.reflect.MethodSignature;
|
import org.aspectj.lang.reflect.MethodSignature;
|
||||||
import org.aspectj.lang.reflect.SourceLocation;
|
import org.aspectj.lang.reflect.SourceLocation;
|
||||||
import org.aspectj.runtime.internal.AroundClosure;
|
import org.aspectj.runtime.internal.AroundClosure;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.ProxyMethodInvocation;
|
import org.springframework.aop.ProxyMethodInvocation;
|
||||||
import org.springframework.core.DefaultParameterNameDiscoverer;
|
import org.springframework.core.DefaultParameterNameDiscoverer;
|
||||||
import org.springframework.core.ParameterNameDiscoverer;
|
import org.springframework.core.ParameterNameDiscoverer;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,16 +55,13 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
|
|
||||||
private final ProxyMethodInvocation methodInvocation;
|
private final ProxyMethodInvocation methodInvocation;
|
||||||
|
|
||||||
@Nullable
|
private Object @Nullable [] args;
|
||||||
private Object[] args;
|
|
||||||
|
|
||||||
/** Lazily initialized signature object. */
|
/** Lazily initialized signature object. */
|
||||||
@Nullable
|
private @Nullable Signature signature;
|
||||||
private Signature signature;
|
|
||||||
|
|
||||||
/** Lazily initialized source location object. */
|
/** Lazily initialized source location object. */
|
||||||
@Nullable
|
private @Nullable SourceLocation sourceLocation;
|
||||||
private SourceLocation sourceLocation;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,14 +81,12 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object proceed() throws Throwable {
|
||||||
public Object proceed() throws Throwable {
|
|
||||||
return this.methodInvocation.invocableClone().proceed();
|
return this.methodInvocation.invocableClone().proceed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object proceed(Object[] arguments) throws Throwable {
|
||||||
public Object proceed(Object[] arguments) throws Throwable {
|
|
||||||
Assert.notNull(arguments, "Argument array passed to proceed cannot be null");
|
Assert.notNull(arguments, "Argument array passed to proceed cannot be null");
|
||||||
if (arguments.length != this.methodInvocation.getArguments().length) {
|
if (arguments.length != this.methodInvocation.getArguments().length) {
|
||||||
throw new IllegalArgumentException("Expecting " +
|
throw new IllegalArgumentException("Expecting " +
|
||||||
|
@ -114,8 +109,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
* Returns the Spring AOP target. May be {@code null} if there is no target.
|
* Returns the Spring AOP target. May be {@code null} if there is no target.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object getTarget() {
|
||||||
public Object getTarget() {
|
|
||||||
return this.methodInvocation.getThis();
|
return this.methodInvocation.getThis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,8 +174,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
*/
|
*/
|
||||||
private class MethodSignatureImpl implements MethodSignature {
|
private class MethodSignatureImpl implements MethodSignature {
|
||||||
|
|
||||||
@Nullable
|
private volatile String @Nullable [] parameterNames;
|
||||||
private volatile String[] parameterNames;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -219,8 +212,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public String @Nullable [] getParameterNames() {
|
||||||
public String[] getParameterNames() {
|
|
||||||
String[] parameterNames = this.parameterNames;
|
String[] parameterNames = this.parameterNames;
|
||||||
if (parameterNames == null) {
|
if (parameterNames == null) {
|
||||||
parameterNames = parameterNameDiscoverer.getParameterNames(getMethod());
|
parameterNames = parameterNameDiscoverer.getParameterNames(getMethod());
|
||||||
|
|
|
@ -36,8 +36,8 @@ import org.aspectj.weaver.reflect.ReflectionBasedReferenceTypeDelegate;
|
||||||
import org.aspectj.weaver.reflect.ReflectionVar;
|
import org.aspectj.weaver.reflect.ReflectionVar;
|
||||||
import org.aspectj.weaver.reflect.ShadowMatchImpl;
|
import org.aspectj.weaver.reflect.ShadowMatchImpl;
|
||||||
import org.aspectj.weaver.tools.ShadowMatch;
|
import org.aspectj.weaver.tools.ShadowMatch;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
|
@ -79,8 +79,7 @@ class RuntimeTestWalker {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
private final @Nullable Test runtimeTest;
|
||||||
private final Test runtimeTest;
|
|
||||||
|
|
||||||
|
|
||||||
public RuntimeTestWalker(ShadowMatch shadowMatch) {
|
public RuntimeTestWalker(ShadowMatch shadowMatch) {
|
||||||
|
|
|
@ -21,9 +21,9 @@ import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.aspectj.weaver.tools.ShadowMatch;
|
import org.aspectj.weaver.tools.ShadowMatch;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.support.ExpressionPointcut;
|
import org.springframework.aop.support.ExpressionPointcut;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal {@link ShadowMatch} utilities.
|
* Internal {@link ShadowMatch} utilities.
|
||||||
|
@ -49,8 +49,7 @@ public abstract class ShadowMatchUtils {
|
||||||
* @param method the method
|
* @param method the method
|
||||||
* @return the {@code ShadowMatch} to use for the specified expression and method
|
* @return the {@code ShadowMatch} to use for the specified expression and method
|
||||||
*/
|
*/
|
||||||
@Nullable
|
static @Nullable ShadowMatch getShadowMatch(ExpressionPointcut expression, Method method) {
|
||||||
static ShadowMatch getShadowMatch(ExpressionPointcut expression, Method method) {
|
|
||||||
return shadowMatchCache.get(new Key(expression, method));
|
return shadowMatchCache.get(new Key(expression, method));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,10 @@ package org.springframework.aop.aspectj;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.framework.AopConfigException;
|
import org.springframework.aop.framework.AopConfigException;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
|
@ -77,8 +78,7 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable ClassLoader getAspectClassLoader() {
|
||||||
public ClassLoader getAspectClassLoader() {
|
|
||||||
return this.aspectClass.getClassLoader();
|
return this.aspectClass.getClassLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,9 @@ package org.springframework.aop.aspectj;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,8 +55,7 @@ public class SingletonAspectInstanceFactory implements AspectInstanceFactory, Se
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable ClassLoader getAspectClassLoader() {
|
||||||
public ClassLoader getAspectClassLoader() {
|
|
||||||
return this.aspectInstance.getClass().getClassLoader();
|
return this.aspectInstance.getClass().getClassLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,9 @@ import java.util.Objects;
|
||||||
|
|
||||||
import org.aspectj.weaver.tools.PointcutParser;
|
import org.aspectj.weaver.tools.PointcutParser;
|
||||||
import org.aspectj.weaver.tools.TypePatternMatcher;
|
import org.aspectj.weaver.tools.TypePatternMatcher;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.ClassFilter;
|
import org.springframework.aop.ClassFilter;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
@ -39,8 +39,7 @@ public class TypePatternClassFilter implements ClassFilter {
|
||||||
|
|
||||||
private String typePattern = "";
|
private String typePattern = "";
|
||||||
|
|
||||||
@Nullable
|
private @Nullable TypePatternMatcher aspectJTypePatternMatcher;
|
||||||
private TypePatternMatcher aspectJTypePatternMatcher;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,12 +35,12 @@ import org.aspectj.lang.annotation.Pointcut;
|
||||||
import org.aspectj.lang.reflect.AjType;
|
import org.aspectj.lang.reflect.AjType;
|
||||||
import org.aspectj.lang.reflect.AjTypeSystem;
|
import org.aspectj.lang.reflect.AjTypeSystem;
|
||||||
import org.aspectj.lang.reflect.PerClauseKind;
|
import org.aspectj.lang.reflect.PerClauseKind;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.framework.AopConfigException;
|
import org.springframework.aop.framework.AopConfigException;
|
||||||
import org.springframework.core.ParameterNameDiscoverer;
|
import org.springframework.core.ParameterNameDiscoverer;
|
||||||
import org.springframework.core.SpringProperties;
|
import org.springframework.core.SpringProperties;
|
||||||
import org.springframework.core.annotation.AnnotationUtils;
|
import org.springframework.core.annotation.AnnotationUtils;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract base class for factories that can create Spring AOP Advisors
|
* Abstract base class for factories that can create Spring AOP Advisors
|
||||||
|
@ -112,8 +112,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
* (there <i>should</i> only be one anyway...).
|
* (there <i>should</i> only be one anyway...).
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Nullable
|
protected static @Nullable AspectJAnnotation findAspectJAnnotationOnMethod(Method method) {
|
||||||
protected static AspectJAnnotation findAspectJAnnotationOnMethod(Method method) {
|
|
||||||
for (Class<?> annotationType : ASPECTJ_ANNOTATION_CLASSES) {
|
for (Class<?> annotationType : ASPECTJ_ANNOTATION_CLASSES) {
|
||||||
AspectJAnnotation annotation = findAnnotation(method, (Class<Annotation>) annotationType);
|
AspectJAnnotation annotation = findAnnotation(method, (Class<Annotation>) annotationType);
|
||||||
if (annotation != null) {
|
if (annotation != null) {
|
||||||
|
@ -123,8 +122,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
private static @Nullable AspectJAnnotation findAnnotation(Method method, Class<? extends Annotation> annotationType) {
|
||||||
private static AspectJAnnotation findAnnotation(Method method, Class<? extends Annotation> annotationType) {
|
|
||||||
Annotation annotation = AnnotationUtils.findAnnotation(method, annotationType);
|
Annotation annotation = AnnotationUtils.findAnnotation(method, annotationType);
|
||||||
if (annotation != null) {
|
if (annotation != null) {
|
||||||
return new AspectJAnnotation(annotation);
|
return new AspectJAnnotation(annotation);
|
||||||
|
@ -242,8 +240,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
private static final String[] EMPTY_ARRAY = new String[0];
|
private static final String[] EMPTY_ARRAY = new String[0];
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public String @Nullable [] getParameterNames(Method method) {
|
||||||
public String[] getParameterNames(Method method) {
|
|
||||||
if (method.getParameterCount() == 0) {
|
if (method.getParameterCount() == 0) {
|
||||||
return EMPTY_ARRAY;
|
return EMPTY_ARRAY;
|
||||||
}
|
}
|
||||||
|
@ -266,8 +263,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable String @Nullable [] getParameterNames(Constructor<?> ctor) {
|
||||||
public String[] getParameterNames(Constructor<?> ctor) {
|
|
||||||
throw new UnsupportedOperationException("Spring AOP cannot handle constructor advice");
|
throw new UnsupportedOperationException("Spring AOP cannot handle constructor advice");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,12 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Advisor;
|
import org.springframework.aop.Advisor;
|
||||||
import org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator;
|
import org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator;
|
||||||
import org.springframework.beans.factory.ListableBeanFactory;
|
import org.springframework.beans.factory.ListableBeanFactory;
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,14 +50,11 @@ import org.springframework.util.Assert;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class AnnotationAwareAspectJAutoProxyCreator extends AspectJAwareAdvisorAutoProxyCreator {
|
public class AnnotationAwareAspectJAutoProxyCreator extends AspectJAwareAdvisorAutoProxyCreator {
|
||||||
|
|
||||||
@Nullable
|
private @Nullable List<Pattern> includePatterns;
|
||||||
private List<Pattern> includePatterns;
|
|
||||||
|
|
||||||
@Nullable
|
private @Nullable AspectJAdvisorFactory aspectJAdvisorFactory;
|
||||||
private AspectJAdvisorFactory aspectJAdvisorFactory;
|
|
||||||
|
|
||||||
@Nullable
|
private @Nullable BeanFactoryAspectJAdvisorsBuilder aspectJAdvisorsBuilder;
|
||||||
private BeanFactoryAspectJAdvisorsBuilder aspectJAdvisorsBuilder;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,13 +18,14 @@ package org.springframework.aop.aspectj.annotation;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aot.generate.GenerationContext;
|
import org.springframework.aot.generate.GenerationContext;
|
||||||
import org.springframework.aot.hint.MemberCategory;
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
import org.springframework.beans.factory.aot.BeanRegistrationAotContribution;
|
import org.springframework.beans.factory.aot.BeanRegistrationAotContribution;
|
||||||
import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor;
|
import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor;
|
||||||
import org.springframework.beans.factory.aot.BeanRegistrationCode;
|
import org.springframework.beans.factory.aot.BeanRegistrationCode;
|
||||||
import org.springframework.beans.factory.support.RegisteredBean;
|
import org.springframework.beans.factory.support.RegisteredBean;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,8 +44,7 @@ class AspectJAdvisorBeanRegistrationAotProcessor implements BeanRegistrationAotP
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
|
||||||
public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
|
|
||||||
if (aspectjPresent) {
|
if (aspectjPresent) {
|
||||||
Class<?> beanClass = registeredBean.getBeanClass();
|
Class<?> beanClass = registeredBean.getBeanClass();
|
||||||
if (compiledByAjc(beanClass)) {
|
if (compiledByAjc(beanClass)) {
|
||||||
|
|
|
@ -20,11 +20,11 @@ import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.aopalliance.aop.Advice;
|
import org.aopalliance.aop.Advice;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Advisor;
|
import org.springframework.aop.Advisor;
|
||||||
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
|
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
|
||||||
import org.springframework.aop.framework.AopConfigException;
|
import org.springframework.aop.framework.AopConfigException;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for factories that can create Spring AOP Advisors from classes
|
* Interface for factories that can create Spring AOP Advisors from classes
|
||||||
|
@ -80,8 +80,7 @@ public interface AspectJAdvisorFactory {
|
||||||
* or if it is a pointcut that will be used by other advice but will not
|
* or if it is a pointcut that will be used by other advice but will not
|
||||||
* create a Spring advice in its own right
|
* create a Spring advice in its own right
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aspectInstanceFactory,
|
||||||
Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aspectInstanceFactory,
|
|
||||||
int declarationOrder, String aspectName);
|
int declarationOrder, String aspectName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,8 +99,7 @@ public interface AspectJAdvisorFactory {
|
||||||
* @see org.springframework.aop.aspectj.AspectJAfterReturningAdvice
|
* @see org.springframework.aop.aspectj.AspectJAfterReturningAdvice
|
||||||
* @see org.springframework.aop.aspectj.AspectJAfterThrowingAdvice
|
* @see org.springframework.aop.aspectj.AspectJAfterThrowingAdvice
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut expressionPointcut,
|
||||||
Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut expressionPointcut,
|
|
||||||
MetadataAwareAspectInstanceFactory aspectInstanceFactory, int declarationOrder, String aspectName);
|
MetadataAwareAspectInstanceFactory aspectInstanceFactory, int declarationOrder, String aspectName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ package org.springframework.aop.aspectj.annotation;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Advisor;
|
import org.springframework.aop.Advisor;
|
||||||
import org.springframework.aop.aspectj.AbstractAspectJAdvice;
|
import org.springframework.aop.aspectj.AbstractAspectJAdvice;
|
||||||
import org.springframework.aot.generate.GenerationContext;
|
import org.springframework.aot.generate.GenerationContext;
|
||||||
|
@ -27,7 +29,6 @@ import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContrib
|
||||||
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor;
|
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor;
|
||||||
import org.springframework.beans.factory.aot.BeanFactoryInitializationCode;
|
import org.springframework.beans.factory.aot.BeanFactoryInitializationCode;
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,8 +46,7 @@ class AspectJBeanFactoryInitializationAotProcessor implements BeanFactoryInitial
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable BeanFactoryInitializationAotContribution processAheadOfTime(ConfigurableListableBeanFactory beanFactory) {
|
||||||
public BeanFactoryInitializationAotContribution processAheadOfTime(ConfigurableListableBeanFactory beanFactory) {
|
|
||||||
if (aspectJPresent) {
|
if (aspectJPresent) {
|
||||||
return AspectDelegate.processAheadOfTime(beanFactory);
|
return AspectDelegate.processAheadOfTime(beanFactory);
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,7 @@ class AspectJBeanFactoryInitializationAotProcessor implements BeanFactoryInitial
|
||||||
*/
|
*/
|
||||||
private static class AspectDelegate {
|
private static class AspectDelegate {
|
||||||
|
|
||||||
@Nullable
|
private static @Nullable AspectContribution processAheadOfTime(ConfigurableListableBeanFactory beanFactory) {
|
||||||
private static AspectContribution processAheadOfTime(ConfigurableListableBeanFactory beanFactory) {
|
|
||||||
BeanFactoryAspectJAdvisorsBuilder builder = new BeanFactoryAspectJAdvisorsBuilder(beanFactory);
|
BeanFactoryAspectJAdvisorsBuilder builder = new BeanFactoryAspectJAdvisorsBuilder(beanFactory);
|
||||||
List<Advisor> advisors = builder.buildAspectJAdvisors();
|
List<Advisor> advisors = builder.buildAspectJAdvisors();
|
||||||
return (advisors.isEmpty() ? null : new AspectContribution(advisors));
|
return (advisors.isEmpty() ? null : new AspectContribution(advisors));
|
||||||
|
|
|
@ -18,11 +18,12 @@ package org.springframework.aop.aspectj.annotation;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.core.annotation.OrderUtils;
|
import org.springframework.core.annotation.OrderUtils;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
|
@ -91,8 +92,7 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable ClassLoader getAspectClassLoader() {
|
||||||
public ClassLoader getAspectClassLoader() {
|
|
||||||
return (this.beanFactory instanceof ConfigurableBeanFactory cbf ?
|
return (this.beanFactory instanceof ConfigurableBeanFactory cbf ?
|
||||||
cbf.getBeanClassLoader() : ClassUtils.getDefaultClassLoader());
|
cbf.getBeanClassLoader() : ClassUtils.getDefaultClassLoader());
|
||||||
}
|
}
|
||||||
|
@ -103,8 +103,7 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object getAspectCreationMutex() {
|
||||||
public Object getAspectCreationMutex() {
|
|
||||||
if (this.beanFactory.isSingleton(this.name)) {
|
if (this.beanFactory.isSingleton(this.name)) {
|
||||||
// Rely on singleton semantics provided by the factory -> no local lock.
|
// Rely on singleton semantics provided by the factory -> no local lock.
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -25,12 +25,12 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.aspectj.lang.reflect.PerClauseKind;
|
import org.aspectj.lang.reflect.PerClauseKind;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Advisor;
|
import org.springframework.aop.Advisor;
|
||||||
import org.springframework.aop.framework.AopConfigException;
|
import org.springframework.aop.framework.AopConfigException;
|
||||||
import org.springframework.beans.factory.BeanFactoryUtils;
|
import org.springframework.beans.factory.BeanFactoryUtils;
|
||||||
import org.springframework.beans.factory.ListableBeanFactory;
|
import org.springframework.beans.factory.ListableBeanFactory;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,8 +49,7 @@ public class BeanFactoryAspectJAdvisorsBuilder {
|
||||||
|
|
||||||
private final AspectJAdvisorFactory advisorFactory;
|
private final AspectJAdvisorFactory advisorFactory;
|
||||||
|
|
||||||
@Nullable
|
private volatile @Nullable List<String> aspectBeanNames;
|
||||||
private volatile List<String> aspectBeanNames;
|
|
||||||
|
|
||||||
private final Map<String, List<Advisor>> advisorsCache = new ConcurrentHashMap<>();
|
private final Map<String, List<Advisor>> advisorsCache = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.aopalliance.aop.Advice;
|
import org.aopalliance.aop.Advice;
|
||||||
import org.aspectj.lang.reflect.PerClauseKind;
|
import org.aspectj.lang.reflect.PerClauseKind;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Pointcut;
|
import org.springframework.aop.Pointcut;
|
||||||
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
|
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
|
||||||
|
@ -31,7 +32,6 @@ import org.springframework.aop.aspectj.InstantiationModelAwarePointcutAdvisor;
|
||||||
import org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.AspectJAnnotation;
|
import org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.AspectJAnnotation;
|
||||||
import org.springframework.aop.support.DynamicMethodMatcherPointcut;
|
import org.springframework.aop.support.DynamicMethodMatcherPointcut;
|
||||||
import org.springframework.aop.support.Pointcuts;
|
import org.springframework.aop.support.Pointcuts;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,14 +73,11 @@ final class InstantiationModelAwarePointcutAdvisorImpl
|
||||||
|
|
||||||
private final boolean lazy;
|
private final boolean lazy;
|
||||||
|
|
||||||
@Nullable
|
private @Nullable Advice instantiatedAdvice;
|
||||||
private Advice instantiatedAdvice;
|
|
||||||
|
|
||||||
@Nullable
|
private @Nullable Boolean isBeforeAdvice;
|
||||||
private Boolean isBeforeAdvice;
|
|
||||||
|
|
||||||
@Nullable
|
private @Nullable Boolean isAfterAdvice;
|
||||||
private Boolean isAfterAdvice;
|
|
||||||
|
|
||||||
|
|
||||||
public InstantiationModelAwarePointcutAdvisorImpl(AspectJExpressionPointcut declaredPointcut,
|
public InstantiationModelAwarePointcutAdvisorImpl(AspectJExpressionPointcut declaredPointcut,
|
||||||
|
@ -271,8 +268,7 @@ final class InstantiationModelAwarePointcutAdvisorImpl
|
||||||
|
|
||||||
private final Pointcut preInstantiationPointcut;
|
private final Pointcut preInstantiationPointcut;
|
||||||
|
|
||||||
@Nullable
|
private @Nullable LazySingletonAspectInstanceFactoryDecorator aspectInstanceFactory;
|
||||||
private LazySingletonAspectInstanceFactoryDecorator aspectInstanceFactory;
|
|
||||||
|
|
||||||
public PerTargetInstantiationModelPointcut(AspectJExpressionPointcut declaredPointcut,
|
public PerTargetInstantiationModelPointcut(AspectJExpressionPointcut declaredPointcut,
|
||||||
Pointcut preInstantiationPointcut, MetadataAwareAspectInstanceFactory aspectInstanceFactory) {
|
Pointcut preInstantiationPointcut, MetadataAwareAspectInstanceFactory aspectInstanceFactory) {
|
||||||
|
|
|
@ -18,7 +18,8 @@ package org.springframework.aop.aspectj.annotation;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,8 +34,7 @@ public class LazySingletonAspectInstanceFactoryDecorator implements MetadataAwar
|
||||||
|
|
||||||
private final MetadataAwareAspectInstanceFactory maaif;
|
private final MetadataAwareAspectInstanceFactory maaif;
|
||||||
|
|
||||||
@Nullable
|
private volatile @Nullable Object materialized;
|
||||||
private volatile Object materialized;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,8 +74,7 @@ public class LazySingletonAspectInstanceFactoryDecorator implements MetadataAwar
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable ClassLoader getAspectClassLoader() {
|
||||||
public ClassLoader getAspectClassLoader() {
|
|
||||||
return this.maaif.getAspectClassLoader();
|
return this.maaif.getAspectClassLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,8 +84,7 @@ public class LazySingletonAspectInstanceFactoryDecorator implements MetadataAwar
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object getAspectCreationMutex() {
|
||||||
public Object getAspectCreationMutex() {
|
|
||||||
return this.maaif.getAspectCreationMutex();
|
return this.maaif.getAspectCreationMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,9 @@
|
||||||
|
|
||||||
package org.springframework.aop.aspectj.annotation;
|
package org.springframework.aop.aspectj.annotation;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.aspectj.AspectInstanceFactory;
|
import org.springframework.aop.aspectj.AspectInstanceFactory;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subinterface of {@link org.springframework.aop.aspectj.AspectInstanceFactory}
|
* Subinterface of {@link org.springframework.aop.aspectj.AspectInstanceFactory}
|
||||||
|
@ -41,7 +42,6 @@ public interface MetadataAwareAspectInstanceFactory extends AspectInstanceFactor
|
||||||
* @return the mutex object (may be {@code null} for no mutex to use)
|
* @return the mutex object (may be {@code null} for no mutex to use)
|
||||||
* @since 4.3
|
* @since 4.3
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable Object getAspectCreationMutex();
|
||||||
Object getAspectCreationMutex();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.aspectj.lang.annotation.Around;
|
||||||
import org.aspectj.lang.annotation.Before;
|
import org.aspectj.lang.annotation.Before;
|
||||||
import org.aspectj.lang.annotation.DeclareParents;
|
import org.aspectj.lang.annotation.DeclareParents;
|
||||||
import org.aspectj.lang.annotation.Pointcut;
|
import org.aspectj.lang.annotation.Pointcut;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Advisor;
|
import org.springframework.aop.Advisor;
|
||||||
import org.springframework.aop.MethodBeforeAdvice;
|
import org.springframework.aop.MethodBeforeAdvice;
|
||||||
|
@ -49,7 +50,6 @@ import org.springframework.beans.factory.BeanFactory;
|
||||||
import org.springframework.core.annotation.AnnotationUtils;
|
import org.springframework.core.annotation.AnnotationUtils;
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
import org.springframework.core.convert.converter.ConvertingComparator;
|
import org.springframework.core.convert.converter.ConvertingComparator;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
import org.springframework.util.ReflectionUtils.MethodFilter;
|
import org.springframework.util.ReflectionUtils.MethodFilter;
|
||||||
|
@ -96,8 +96,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
private final @Nullable BeanFactory beanFactory;
|
||||||
private final BeanFactory beanFactory;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,8 +182,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||||
* @param introductionField the field to introspect
|
* @param introductionField the field to introspect
|
||||||
* @return the Advisor instance, or {@code null} if not an Advisor
|
* @return the Advisor instance, or {@code null} if not an Advisor
|
||||||
*/
|
*/
|
||||||
@Nullable
|
private @Nullable Advisor getDeclareParentsAdvisor(Field introductionField) {
|
||||||
private Advisor getDeclareParentsAdvisor(Field introductionField) {
|
|
||||||
DeclareParents declareParents = introductionField.getAnnotation(DeclareParents.class);
|
DeclareParents declareParents = introductionField.getAnnotation(DeclareParents.class);
|
||||||
if (declareParents == null) {
|
if (declareParents == null) {
|
||||||
// Not an introduction field
|
// Not an introduction field
|
||||||
|
@ -201,8 +199,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aspectInstanceFactory,
|
||||||
public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aspectInstanceFactory,
|
|
||||||
int declarationOrderInAspect, String aspectName) {
|
int declarationOrderInAspect, String aspectName) {
|
||||||
|
|
||||||
validate(aspectInstanceFactory.getAspectMetadata().getAspectClass());
|
validate(aspectInstanceFactory.getAspectMetadata().getAspectClass());
|
||||||
|
@ -225,8 +222,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
private @Nullable AspectJExpressionPointcut getPointcut(Method candidateAdviceMethod, Class<?> candidateAspectClass) {
|
||||||
private AspectJExpressionPointcut getPointcut(Method candidateAdviceMethod, Class<?> candidateAspectClass) {
|
|
||||||
AspectJAnnotation aspectJAnnotation =
|
AspectJAnnotation aspectJAnnotation =
|
||||||
AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(candidateAdviceMethod);
|
AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(candidateAdviceMethod);
|
||||||
if (aspectJAnnotation == null) {
|
if (aspectJAnnotation == null) {
|
||||||
|
@ -244,8 +240,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut expressionPointcut,
|
||||||
public Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut expressionPointcut,
|
|
||||||
MetadataAwareAspectInstanceFactory aspectInstanceFactory, int declarationOrder, String aspectName) {
|
MetadataAwareAspectInstanceFactory aspectInstanceFactory, int declarationOrder, String aspectName) {
|
||||||
|
|
||||||
Class<?> candidateAspectClass = aspectInstanceFactory.getAspectMetadata().getAspectClass();
|
Class<?> candidateAspectClass = aspectInstanceFactory.getAspectMetadata().getAspectClass();
|
||||||
|
|
|
@ -3,9 +3,7 @@
|
||||||
*
|
*
|
||||||
* <p>Normally to be used through an AspectJAutoProxyCreator rather than directly.
|
* <p>Normally to be used through an AspectJAutoProxyCreator rather than directly.
|
||||||
*/
|
*/
|
||||||
@NonNullApi
|
@NullMarked
|
||||||
@NonNullFields
|
|
||||||
package org.springframework.aop.aspectj.annotation;
|
package org.springframework.aop.aspectj.annotation;
|
||||||
|
|
||||||
import org.springframework.lang.NonNullApi;
|
import org.jspecify.annotations.NullMarked;
|
||||||
import org.springframework.lang.NonNullFields;
|
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
* Base classes enabling auto-proxying based on AspectJ.
|
* Base classes enabling auto-proxying based on AspectJ.
|
||||||
* Support for AspectJ annotation aspects resides in the "aspectj.annotation" package.
|
* Support for AspectJ annotation aspects resides in the "aspectj.annotation" package.
|
||||||
*/
|
*/
|
||||||
@NonNullApi
|
@NullMarked
|
||||||
@NonNullFields
|
|
||||||
package org.springframework.aop.aspectj.autoproxy;
|
package org.springframework.aop.aspectj.autoproxy;
|
||||||
|
|
||||||
import org.springframework.lang.NonNullApi;
|
import org.jspecify.annotations.NullMarked;
|
||||||
import org.springframework.lang.NonNullFields;
|
|
||||||
|
|
|
@ -8,9 +8,7 @@
|
||||||
* or AspectJ load-time weaver. It is intended to enable the use of a valuable subset of AspectJ
|
* or AspectJ load-time weaver. It is intended to enable the use of a valuable subset of AspectJ
|
||||||
* functionality, with consistent semantics, with the proxy-based Spring AOP framework.
|
* functionality, with consistent semantics, with the proxy-based Spring AOP framework.
|
||||||
*/
|
*/
|
||||||
@NonNullApi
|
@NullMarked
|
||||||
@NonNullFields
|
|
||||||
package org.springframework.aop.aspectj;
|
package org.springframework.aop.aspectj;
|
||||||
|
|
||||||
import org.springframework.lang.NonNullApi;
|
import org.jspecify.annotations.NullMarked;
|
||||||
import org.springframework.lang.NonNullFields;
|
|
||||||
|
|
|
@ -16,11 +16,12 @@
|
||||||
|
|
||||||
package org.springframework.aop.config;
|
package org.springframework.aop.config;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.beans.MutablePropertyValues;
|
import org.springframework.beans.MutablePropertyValues;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.beans.factory.config.BeanReference;
|
import org.springframework.beans.factory.config.BeanReference;
|
||||||
import org.springframework.beans.factory.parsing.AbstractComponentDefinition;
|
import org.springframework.beans.factory.parsing.AbstractComponentDefinition;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,8 +111,7 @@ public class AdvisorComponentDefinition extends AbstractComponentDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object getSource() {
|
||||||
public Object getSource() {
|
|
||||||
return this.advisorDefinition.getSource();
|
return this.advisorDefinition.getSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ package org.springframework.aop.config;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator;
|
import org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator;
|
||||||
import org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator;
|
import org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator;
|
||||||
import org.springframework.aop.framework.autoproxy.InfrastructureAdvisorAutoProxyCreator;
|
import org.springframework.aop.framework.autoproxy.InfrastructureAdvisorAutoProxyCreator;
|
||||||
|
@ -26,7 +28,6 @@ import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,37 +65,31 @@ public abstract class AopConfigUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
public static @Nullable BeanDefinition registerAutoProxyCreatorIfNecessary(BeanDefinitionRegistry registry) {
|
||||||
public static BeanDefinition registerAutoProxyCreatorIfNecessary(BeanDefinitionRegistry registry) {
|
|
||||||
return registerAutoProxyCreatorIfNecessary(registry, null);
|
return registerAutoProxyCreatorIfNecessary(registry, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public static @Nullable BeanDefinition registerAutoProxyCreatorIfNecessary(
|
||||||
public static BeanDefinition registerAutoProxyCreatorIfNecessary(
|
|
||||||
BeanDefinitionRegistry registry, @Nullable Object source) {
|
BeanDefinitionRegistry registry, @Nullable Object source) {
|
||||||
|
|
||||||
return registerOrEscalateApcAsRequired(InfrastructureAdvisorAutoProxyCreator.class, registry, source);
|
return registerOrEscalateApcAsRequired(InfrastructureAdvisorAutoProxyCreator.class, registry, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public static @Nullable BeanDefinition registerAspectJAutoProxyCreatorIfNecessary(BeanDefinitionRegistry registry) {
|
||||||
public static BeanDefinition registerAspectJAutoProxyCreatorIfNecessary(BeanDefinitionRegistry registry) {
|
|
||||||
return registerAspectJAutoProxyCreatorIfNecessary(registry, null);
|
return registerAspectJAutoProxyCreatorIfNecessary(registry, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public static @Nullable BeanDefinition registerAspectJAutoProxyCreatorIfNecessary(
|
||||||
public static BeanDefinition registerAspectJAutoProxyCreatorIfNecessary(
|
|
||||||
BeanDefinitionRegistry registry, @Nullable Object source) {
|
BeanDefinitionRegistry registry, @Nullable Object source) {
|
||||||
|
|
||||||
return registerOrEscalateApcAsRequired(AspectJAwareAdvisorAutoProxyCreator.class, registry, source);
|
return registerOrEscalateApcAsRequired(AspectJAwareAdvisorAutoProxyCreator.class, registry, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public static @Nullable BeanDefinition registerAspectJAnnotationAutoProxyCreatorIfNecessary(BeanDefinitionRegistry registry) {
|
||||||
public static BeanDefinition registerAspectJAnnotationAutoProxyCreatorIfNecessary(BeanDefinitionRegistry registry) {
|
|
||||||
return registerAspectJAnnotationAutoProxyCreatorIfNecessary(registry, null);
|
return registerAspectJAnnotationAutoProxyCreatorIfNecessary(registry, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public static @Nullable BeanDefinition registerAspectJAnnotationAutoProxyCreatorIfNecessary(
|
||||||
public static BeanDefinition registerAspectJAnnotationAutoProxyCreatorIfNecessary(
|
|
||||||
BeanDefinitionRegistry registry, @Nullable Object source) {
|
BeanDefinitionRegistry registry, @Nullable Object source) {
|
||||||
|
|
||||||
return registerOrEscalateApcAsRequired(AnnotationAwareAspectJAutoProxyCreator.class, registry, source);
|
return registerOrEscalateApcAsRequired(AnnotationAwareAspectJAutoProxyCreator.class, registry, source);
|
||||||
|
@ -114,8 +109,7 @@ public abstract class AopConfigUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
private static @Nullable BeanDefinition registerOrEscalateApcAsRequired(
|
||||||
private static BeanDefinition registerOrEscalateApcAsRequired(
|
|
||||||
Class<?> cls, BeanDefinitionRegistry registry, @Nullable Object source) {
|
Class<?> cls, BeanDefinitionRegistry registry, @Nullable Object source) {
|
||||||
|
|
||||||
Assert.notNull(registry, "BeanDefinitionRegistry must not be null");
|
Assert.notNull(registry, "BeanDefinitionRegistry must not be null");
|
||||||
|
|
|
@ -16,13 +16,13 @@
|
||||||
|
|
||||||
package org.springframework.aop.config;
|
package org.springframework.aop.config;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
|
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
|
||||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||||
import org.springframework.beans.factory.xml.ParserContext;
|
import org.springframework.beans.factory.xml.ParserContext;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class for handling registration of auto-proxy creators used internally
|
* Utility class for handling registration of auto-proxy creators used internally
|
||||||
|
|
|
@ -16,10 +16,11 @@
|
||||||
|
|
||||||
package org.springframework.aop.config;
|
package org.springframework.aop.config;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.beans.factory.config.BeanReference;
|
import org.springframework.beans.factory.config.BeanReference;
|
||||||
import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
|
import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link org.springframework.beans.factory.parsing.ComponentDefinition}
|
* {@link org.springframework.beans.factory.parsing.ComponentDefinition}
|
||||||
|
@ -38,8 +39,8 @@ public class AspectComponentDefinition extends CompositeComponentDefinition {
|
||||||
private final BeanReference[] beanReferences;
|
private final BeanReference[] beanReferences;
|
||||||
|
|
||||||
|
|
||||||
public AspectComponentDefinition(String aspectName, @Nullable BeanDefinition[] beanDefinitions,
|
public AspectComponentDefinition(String aspectName, BeanDefinition @Nullable [] beanDefinitions,
|
||||||
@Nullable BeanReference[] beanReferences, @Nullable Object source) {
|
BeanReference @Nullable [] beanReferences, @Nullable Object source) {
|
||||||
|
|
||||||
super(aspectName, source);
|
super(aspectName, source);
|
||||||
this.beanDefinitions = (beanDefinitions != null ? beanDefinitions : new BeanDefinition[0]);
|
this.beanDefinitions = (beanDefinitions != null ? beanDefinitions : new BeanDefinition[0]);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package org.springframework.aop.config;
|
package org.springframework.aop.config;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
@ -25,7 +26,6 @@ import org.springframework.beans.factory.config.TypedStringValue;
|
||||||
import org.springframework.beans.factory.support.ManagedList;
|
import org.springframework.beans.factory.support.ManagedList;
|
||||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||||
import org.springframework.beans.factory.xml.ParserContext;
|
import org.springframework.beans.factory.xml.ParserContext;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link BeanDefinitionParser} for the {@code aspectj-autoproxy} tag,
|
* {@link BeanDefinitionParser} for the {@code aspectj-autoproxy} tag,
|
||||||
|
@ -39,8 +39,7 @@ import org.springframework.lang.Nullable;
|
||||||
class AspectJAutoProxyBeanDefinitionParser implements BeanDefinitionParser {
|
class AspectJAutoProxyBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
|
||||||
AopNamespaceUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext, element);
|
AopNamespaceUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext, element);
|
||||||
extendBeanDefinition(element, parserContext);
|
extendBeanDefinition(element, parserContext);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.springframework.aop.config;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
@ -45,7 +46,6 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||||
import org.springframework.beans.factory.xml.ParserContext;
|
import org.springframework.beans.factory.xml.ParserContext;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.util.xml.DomUtils;
|
import org.springframework.util.xml.DomUtils;
|
||||||
|
|
||||||
|
@ -97,8 +97,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
|
||||||
CompositeComponentDefinition compositeDef =
|
CompositeComponentDefinition compositeDef =
|
||||||
new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element));
|
new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element));
|
||||||
parserContext.pushContainingComponent(compositeDef);
|
parserContext.pushContainingComponent(compositeDef);
|
||||||
|
@ -453,8 +452,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
* {@link org.springframework.beans.factory.config.BeanDefinition} for the pointcut if necessary
|
* {@link org.springframework.beans.factory.config.BeanDefinition} for the pointcut if necessary
|
||||||
* and returns its bean name, otherwise returns the bean name of the referred pointcut.
|
* and returns its bean name, otherwise returns the bean name of the referred pointcut.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
private @Nullable Object parsePointcutProperty(Element element, ParserContext parserContext) {
|
||||||
private Object parsePointcutProperty(Element element, ParserContext parserContext) {
|
|
||||||
if (element.hasAttribute(POINTCUT) && element.hasAttribute(POINTCUT_REF)) {
|
if (element.hasAttribute(POINTCUT) && element.hasAttribute(POINTCUT_REF)) {
|
||||||
parserContext.getReaderContext().error(
|
parserContext.getReaderContext().error(
|
||||||
"Cannot define both 'pointcut' and 'pointcut-ref' on <advisor> tag.",
|
"Cannot define both 'pointcut' and 'pointcut-ref' on <advisor> tag.",
|
||||||
|
|
|
@ -18,11 +18,12 @@ package org.springframework.aop.config;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
import org.springframework.beans.factory.BeanFactoryAware;
|
import org.springframework.beans.factory.BeanFactoryAware;
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,14 +34,11 @@ import org.springframework.util.StringUtils;
|
||||||
*/
|
*/
|
||||||
public class MethodLocatingFactoryBean implements FactoryBean<Method>, BeanFactoryAware {
|
public class MethodLocatingFactoryBean implements FactoryBean<Method>, BeanFactoryAware {
|
||||||
|
|
||||||
@Nullable
|
private @Nullable String targetBeanName;
|
||||||
private String targetBeanName;
|
|
||||||
|
|
||||||
@Nullable
|
private @Nullable String methodName;
|
||||||
private String methodName;
|
|
||||||
|
|
||||||
@Nullable
|
private @Nullable Method method;
|
||||||
private Method method;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,8 +82,7 @@ public class MethodLocatingFactoryBean implements FactoryBean<Method>, BeanFacto
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Method getObject() throws Exception {
|
||||||
public Method getObject() throws Exception {
|
|
||||||
return this.method;
|
return this.method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,10 @@
|
||||||
|
|
||||||
package org.springframework.aop.config;
|
package org.springframework.aop.config;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.beans.factory.parsing.AbstractComponentDefinition;
|
import org.springframework.beans.factory.parsing.AbstractComponentDefinition;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,8 +64,7 @@ public class PointcutComponentDefinition extends AbstractComponentDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object getSource() {
|
||||||
public Object getSource() {
|
|
||||||
return this.pointcutDefinition.getSource();
|
return this.pointcutDefinition.getSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,13 @@
|
||||||
|
|
||||||
package org.springframework.aop.config;
|
package org.springframework.aop.config;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.aspectj.AspectInstanceFactory;
|
import org.springframework.aop.aspectj.AspectInstanceFactory;
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
import org.springframework.beans.factory.BeanFactoryAware;
|
import org.springframework.beans.factory.BeanFactoryAware;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
|
@ -35,11 +36,9 @@ import org.springframework.util.ClassUtils;
|
||||||
*/
|
*/
|
||||||
public class SimpleBeanFactoryAwareAspectInstanceFactory implements AspectInstanceFactory, BeanFactoryAware {
|
public class SimpleBeanFactoryAwareAspectInstanceFactory implements AspectInstanceFactory, BeanFactoryAware {
|
||||||
|
|
||||||
@Nullable
|
private @Nullable String aspectBeanName;
|
||||||
private String aspectBeanName;
|
|
||||||
|
|
||||||
@Nullable
|
private @Nullable BeanFactory beanFactory;
|
||||||
private BeanFactory beanFactory;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,8 +68,7 @@ public class SimpleBeanFactoryAwareAspectInstanceFactory implements AspectInstan
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable ClassLoader getAspectClassLoader() {
|
||||||
public ClassLoader getAspectClassLoader() {
|
|
||||||
if (this.beanFactory instanceof ConfigurableBeanFactory cbf) {
|
if (this.beanFactory instanceof ConfigurableBeanFactory cbf) {
|
||||||
return cbf.getBeanClassLoader();
|
return cbf.getBeanClassLoader();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package org.springframework.aop.config;
|
package org.springframework.aop.config;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
|
@ -23,7 +24,6 @@ import org.springframework.beans.factory.parsing.BeanComponentDefinition;
|
||||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||||
import org.springframework.beans.factory.xml.ParserContext;
|
import org.springframework.beans.factory.xml.ParserContext;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link BeanDefinitionParser} responsible for parsing the
|
* {@link BeanDefinitionParser} responsible for parsing the
|
||||||
|
@ -52,8 +52,7 @@ class SpringConfiguredBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
|
||||||
if (!parserContext.getRegistry().containsBeanDefinition(BEAN_CONFIGURER_ASPECT_BEAN_NAME)) {
|
if (!parserContext.getRegistry().containsBeanDefinition(BEAN_CONFIGURER_ASPECT_BEAN_NAME)) {
|
||||||
RootBeanDefinition def = new RootBeanDefinition();
|
RootBeanDefinition def = new RootBeanDefinition();
|
||||||
def.setBeanClassName(BEAN_CONFIGURER_ASPECT_CLASS_NAME);
|
def.setBeanClassName(BEAN_CONFIGURER_ASPECT_CLASS_NAME);
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
* Support package for declarative AOP configuration,
|
* Support package for declarative AOP configuration,
|
||||||
* with XML schema being the primary configuration format.
|
* with XML schema being the primary configuration format.
|
||||||
*/
|
*/
|
||||||
@NonNullApi
|
@NullMarked
|
||||||
@NonNullFields
|
|
||||||
package org.springframework.aop.config;
|
package org.springframework.aop.config;
|
||||||
|
|
||||||
import org.springframework.lang.NonNullApi;
|
import org.jspecify.annotations.NullMarked;
|
||||||
import org.springframework.lang.NonNullFields;
|
|
||||||
|
|
|
@ -19,12 +19,13 @@ package org.springframework.aop.framework;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Advisor;
|
import org.springframework.aop.Advisor;
|
||||||
import org.springframework.aop.support.AopUtils;
|
import org.springframework.aop.support.AopUtils;
|
||||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||||
import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor;
|
import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor;
|
||||||
import org.springframework.core.SmartClassLoader;
|
import org.springframework.core.SmartClassLoader;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for {@link BeanPostProcessor} implementations that apply a
|
* Base class for {@link BeanPostProcessor} implementations that apply a
|
||||||
|
@ -37,8 +38,7 @@ import org.springframework.lang.Nullable;
|
||||||
public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSupport
|
public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSupport
|
||||||
implements SmartInstantiationAwareBeanPostProcessor {
|
implements SmartInstantiationAwareBeanPostProcessor {
|
||||||
|
|
||||||
@Nullable
|
protected @Nullable Advisor advisor;
|
||||||
protected Advisor advisor;
|
|
||||||
|
|
||||||
protected boolean beforeExistingAdvisors = false;
|
protected boolean beforeExistingAdvisors = false;
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package org.springframework.aop.framework;
|
package org.springframework.aop.framework;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.TargetSource;
|
import org.springframework.aop.TargetSource;
|
||||||
import org.springframework.aop.framework.adapter.AdvisorAdapterRegistry;
|
import org.springframework.aop.framework.adapter.AdvisorAdapterRegistry;
|
||||||
import org.springframework.aop.framework.adapter.GlobalAdvisorAdapterRegistry;
|
import org.springframework.aop.framework.adapter.GlobalAdvisorAdapterRegistry;
|
||||||
|
@ -24,7 +26,6 @@ import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
import org.springframework.beans.factory.FactoryBeanNotInitializedException;
|
import org.springframework.beans.factory.FactoryBeanNotInitializedException;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,26 +43,20 @@ import org.springframework.util.ClassUtils;
|
||||||
public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
|
public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
|
||||||
implements FactoryBean<Object>, BeanClassLoaderAware, InitializingBean {
|
implements FactoryBean<Object>, BeanClassLoaderAware, InitializingBean {
|
||||||
|
|
||||||
@Nullable
|
private @Nullable Object target;
|
||||||
private Object target;
|
|
||||||
|
|
||||||
@Nullable
|
private Class<?> @Nullable [] proxyInterfaces;
|
||||||
private Class<?>[] proxyInterfaces;
|
|
||||||
|
|
||||||
@Nullable
|
private Object @Nullable [] preInterceptors;
|
||||||
private Object[] preInterceptors;
|
|
||||||
|
|
||||||
@Nullable
|
private Object @Nullable [] postInterceptors;
|
||||||
private Object[] postInterceptors;
|
|
||||||
|
|
||||||
/** Default is global AdvisorAdapterRegistry. */
|
/** Default is global AdvisorAdapterRegistry. */
|
||||||
private AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
|
private AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
|
||||||
|
|
||||||
@Nullable
|
private transient @Nullable ClassLoader proxyClassLoader;
|
||||||
private transient ClassLoader proxyClassLoader;
|
|
||||||
|
|
||||||
@Nullable
|
private @Nullable Object proxy;
|
||||||
private Object proxy;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -221,8 +216,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Class<?> getObjectType() {
|
||||||
public Class<?> getObjectType() {
|
|
||||||
if (this.proxy != null) {
|
if (this.proxy != null) {
|
||||||
return this.proxy.getClass();
|
return this.proxy.getClass();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.aopalliance.aop.Advice;
|
import org.aopalliance.aop.Advice;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Advisor;
|
import org.springframework.aop.Advisor;
|
||||||
import org.springframework.aop.DynamicIntroductionAdvice;
|
import org.springframework.aop.DynamicIntroductionAdvice;
|
||||||
|
@ -40,7 +41,6 @@ import org.springframework.aop.support.DefaultIntroductionAdvisor;
|
||||||
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
||||||
import org.springframework.aop.target.EmptyTargetSource;
|
import org.springframework.aop.target.EmptyTargetSource;
|
||||||
import org.springframework.aop.target.SingletonTargetSource;
|
import org.springframework.aop.target.SingletonTargetSource;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
@ -108,12 +108,10 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
private List<Advisor> advisorKey = this.advisors;
|
private List<Advisor> advisorKey = this.advisors;
|
||||||
|
|
||||||
/** Cache with Method as key and advisor chain List as value. */
|
/** Cache with Method as key and advisor chain List as value. */
|
||||||
@Nullable
|
private transient @Nullable Map<MethodCacheKey, List<Object>> methodCache;
|
||||||
private transient Map<MethodCacheKey, List<Object>> methodCache;
|
|
||||||
|
|
||||||
/** Cache with shared interceptors which are not method-specific. */
|
/** Cache with shared interceptors which are not method-specific. */
|
||||||
@Nullable
|
private transient volatile @Nullable List<Object> cachedInterceptors;
|
||||||
private transient volatile List<Object> cachedInterceptors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional field for {@link AopProxy} implementations to store metadata in.
|
* Optional field for {@link AopProxy} implementations to store metadata in.
|
||||||
|
@ -121,8 +119,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
* @since 6.1.3
|
* @since 6.1.3
|
||||||
* @see JdkDynamicAopProxy#JdkDynamicAopProxy(AdvisedSupport)
|
* @see JdkDynamicAopProxy#JdkDynamicAopProxy(AdvisedSupport)
|
||||||
*/
|
*/
|
||||||
@Nullable
|
transient volatile @Nullable Object proxyMetadataCache;
|
||||||
transient volatile Object proxyMetadataCache;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -178,8 +175,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Class<?> getTargetClass() {
|
||||||
public Class<?> getTargetClass() {
|
|
||||||
return this.targetSource.getTargetClass();
|
return this.targetSource.getTargetClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -705,11 +701,9 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
|
|
||||||
private final Class<?> adviceType;
|
private final Class<?> adviceType;
|
||||||
|
|
||||||
@Nullable
|
private final @Nullable String classFilterKey;
|
||||||
private final String classFilterKey;
|
|
||||||
|
|
||||||
@Nullable
|
private final @Nullable String methodMatcherKey;
|
||||||
private final String methodMatcherKey;
|
|
||||||
|
|
||||||
public AdvisorKeyEntry(Advisor advisor) {
|
public AdvisorKeyEntry(Advisor advisor) {
|
||||||
this.adviceType = advisor.getAdvice().getClass();
|
this.adviceType = advisor.getAdvice().getClass();
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.springframework.aop.framework;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory interface for advisor chains.
|
* Factory interface for advisor chains.
|
||||||
|
|
|
@ -16,8 +16,9 @@
|
||||||
|
|
||||||
package org.springframework.aop.framework;
|
package org.springframework.aop.framework;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.core.NamedThreadLocal;
|
import org.springframework.core.NamedThreadLocal;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class containing static methods used to obtain information about the current AOP invocation.
|
* Class containing static methods used to obtain information about the current AOP invocation.
|
||||||
|
@ -80,8 +81,7 @@ public final class AopContext {
|
||||||
* @return the old proxy, which may be {@code null} if none was bound
|
* @return the old proxy, which may be {@code null} if none was bound
|
||||||
* @see #currentProxy()
|
* @see #currentProxy()
|
||||||
*/
|
*/
|
||||||
@Nullable
|
static @Nullable Object setCurrentProxy(@Nullable Object proxy) {
|
||||||
static Object setCurrentProxy(@Nullable Object proxy) {
|
|
||||||
Object old = currentProxy.get();
|
Object old = currentProxy.get();
|
||||||
if (proxy != null) {
|
if (proxy != null) {
|
||||||
currentProxy.set(proxy);
|
currentProxy.set(proxy);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package org.springframework.aop.framework;
|
package org.springframework.aop.framework;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delegate interface for a configured AOP proxy, allowing for the creation
|
* Delegate interface for a configured AOP proxy, allowing for the creation
|
||||||
|
|
|
@ -23,13 +23,14 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.SpringProxy;
|
import org.springframework.aop.SpringProxy;
|
||||||
import org.springframework.aop.TargetClassAware;
|
import org.springframework.aop.TargetClassAware;
|
||||||
import org.springframework.aop.TargetSource;
|
import org.springframework.aop.TargetSource;
|
||||||
import org.springframework.aop.support.AopUtils;
|
import org.springframework.aop.support.AopUtils;
|
||||||
import org.springframework.aop.target.SingletonTargetSource;
|
import org.springframework.aop.target.SingletonTargetSource;
|
||||||
import org.springframework.core.DecoratingProxy;
|
import org.springframework.core.DecoratingProxy;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
@ -58,8 +59,7 @@ public abstract class AopProxyUtils {
|
||||||
* @see Advised#getTargetSource()
|
* @see Advised#getTargetSource()
|
||||||
* @see SingletonTargetSource#getTarget()
|
* @see SingletonTargetSource#getTarget()
|
||||||
*/
|
*/
|
||||||
@Nullable
|
public static @Nullable Object getSingletonTarget(Object candidate) {
|
||||||
public static Object getSingletonTarget(Object candidate) {
|
|
||||||
if (candidate instanceof Advised advised) {
|
if (candidate instanceof Advised advised) {
|
||||||
TargetSource targetSource = advised.getTargetSource();
|
TargetSource targetSource = advised.getTargetSource();
|
||||||
if (targetSource instanceof SingletonTargetSource singleTargetSource) {
|
if (targetSource instanceof SingletonTargetSource singleTargetSource) {
|
||||||
|
@ -253,7 +253,7 @@ public abstract class AopProxyUtils {
|
||||||
* @return a cloned argument array, or the original if no adaptation is needed
|
* @return a cloned argument array, or the original if no adaptation is needed
|
||||||
* @since 4.2.3
|
* @since 4.2.3
|
||||||
*/
|
*/
|
||||||
static Object[] adaptArgumentsIfNecessary(Method method, @Nullable Object[] arguments) {
|
static Object[] adaptArgumentsIfNecessary(Method method, Object @Nullable [] arguments) {
|
||||||
if (ObjectUtils.isEmpty(arguments)) {
|
if (ObjectUtils.isEmpty(arguments)) {
|
||||||
return new Object[0];
|
return new Object[0];
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import java.util.WeakHashMap;
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.AopInvocationException;
|
import org.springframework.aop.AopInvocationException;
|
||||||
import org.springframework.aop.RawTargetAccess;
|
import org.springframework.aop.RawTargetAccess;
|
||||||
|
@ -51,7 +52,6 @@ import org.springframework.cglib.transform.impl.UndeclaredThrowableStrategy;
|
||||||
import org.springframework.core.KotlinDetector;
|
import org.springframework.core.KotlinDetector;
|
||||||
import org.springframework.core.MethodParameter;
|
import org.springframework.core.MethodParameter;
|
||||||
import org.springframework.core.SmartClassLoader;
|
import org.springframework.core.SmartClassLoader;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
@ -113,11 +113,9 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||||
/** The configuration used to configure this proxy. */
|
/** The configuration used to configure this proxy. */
|
||||||
protected final AdvisedSupport advised;
|
protected final AdvisedSupport advised;
|
||||||
|
|
||||||
@Nullable
|
protected Object @Nullable [] constructorArgs;
|
||||||
protected Object[] constructorArgs;
|
|
||||||
|
|
||||||
@Nullable
|
protected Class<?> @Nullable [] constructorArgTypes;
|
||||||
protected Class<?>[] constructorArgTypes;
|
|
||||||
|
|
||||||
/** Dispatcher used for methods on Advised. */
|
/** Dispatcher used for methods on Advised. */
|
||||||
private final transient AdvisedDispatcher advisedDispatcher;
|
private final transient AdvisedDispatcher advisedDispatcher;
|
||||||
|
@ -144,7 +142,7 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||||
* @param constructorArgs the constructor argument values
|
* @param constructorArgs the constructor argument values
|
||||||
* @param constructorArgTypes the constructor argument types
|
* @param constructorArgTypes the constructor argument types
|
||||||
*/
|
*/
|
||||||
public void setConstructorArguments(@Nullable Object[] constructorArgs, @Nullable Class<?>[] constructorArgTypes) {
|
public void setConstructorArguments(Object @Nullable [] constructorArgs, Class<?> @Nullable [] constructorArgTypes) {
|
||||||
if (constructorArgs == null || constructorArgTypes == null) {
|
if (constructorArgs == null || constructorArgTypes == null) {
|
||||||
throw new IllegalArgumentException("Both 'constructorArgs' and 'constructorArgTypes' need to be specified");
|
throw new IllegalArgumentException("Both 'constructorArgs' and 'constructorArgTypes' need to be specified");
|
||||||
}
|
}
|
||||||
|
@ -415,8 +413,7 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||||
* {@code proxy} and also verifies that {@code null} is not returned as a primitive.
|
* {@code proxy} and also verifies that {@code null} is not returned as a primitive.
|
||||||
* Also takes care of the conversion from {@code Mono} to Kotlin Coroutines if needed.
|
* Also takes care of the conversion from {@code Mono} to Kotlin Coroutines if needed.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
private static @Nullable Object processReturnType(
|
||||||
private static Object processReturnType(
|
|
||||||
Object proxy, @Nullable Object target, Method method, Object[] arguments, @Nullable Object returnValue) {
|
Object proxy, @Nullable Object target, Method method, Object[] arguments, @Nullable Object returnValue) {
|
||||||
|
|
||||||
// Massage return value if necessary
|
// Massage return value if necessary
|
||||||
|
@ -455,16 +452,14 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||||
*/
|
*/
|
||||||
private static class StaticUnadvisedInterceptor implements MethodInterceptor, Serializable {
|
private static class StaticUnadvisedInterceptor implements MethodInterceptor, Serializable {
|
||||||
|
|
||||||
@Nullable
|
private final @Nullable Object target;
|
||||||
private final Object target;
|
|
||||||
|
|
||||||
public StaticUnadvisedInterceptor(@Nullable Object target) {
|
public StaticUnadvisedInterceptor(@Nullable Object target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
||||||
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
|
||||||
Object retVal = AopUtils.invokeJoinpointUsingReflection(this.target, method, args);
|
Object retVal = AopUtils.invokeJoinpointUsingReflection(this.target, method, args);
|
||||||
return processReturnType(proxy, this.target, method, args, retVal);
|
return processReturnType(proxy, this.target, method, args, retVal);
|
||||||
}
|
}
|
||||||
|
@ -477,16 +472,14 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||||
*/
|
*/
|
||||||
private static class StaticUnadvisedExposedInterceptor implements MethodInterceptor, Serializable {
|
private static class StaticUnadvisedExposedInterceptor implements MethodInterceptor, Serializable {
|
||||||
|
|
||||||
@Nullable
|
private final @Nullable Object target;
|
||||||
private final Object target;
|
|
||||||
|
|
||||||
public StaticUnadvisedExposedInterceptor(@Nullable Object target) {
|
public StaticUnadvisedExposedInterceptor(@Nullable Object target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
||||||
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
|
||||||
Object oldProxy = null;
|
Object oldProxy = null;
|
||||||
try {
|
try {
|
||||||
oldProxy = AopContext.setCurrentProxy(proxy);
|
oldProxy = AopContext.setCurrentProxy(proxy);
|
||||||
|
@ -514,8 +507,7 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
||||||
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
|
||||||
Object target = this.targetSource.getTarget();
|
Object target = this.targetSource.getTarget();
|
||||||
try {
|
try {
|
||||||
Object retVal = AopUtils.invokeJoinpointUsingReflection(target, method, args);
|
Object retVal = AopUtils.invokeJoinpointUsingReflection(target, method, args);
|
||||||
|
@ -542,8 +534,7 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
||||||
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
|
||||||
Object oldProxy = null;
|
Object oldProxy = null;
|
||||||
Object target = this.targetSource.getTarget();
|
Object target = this.targetSource.getTarget();
|
||||||
try {
|
try {
|
||||||
|
@ -568,16 +559,14 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||||
*/
|
*/
|
||||||
private static class StaticDispatcher implements Dispatcher, Serializable {
|
private static class StaticDispatcher implements Dispatcher, Serializable {
|
||||||
|
|
||||||
@Nullable
|
private final @Nullable Object target;
|
||||||
private final Object target;
|
|
||||||
|
|
||||||
public StaticDispatcher(@Nullable Object target) {
|
public StaticDispatcher(@Nullable Object target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object loadObject() {
|
||||||
public Object loadObject() {
|
|
||||||
return this.target;
|
return this.target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -655,11 +644,9 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||||
|
|
||||||
private final List<Object> adviceChain;
|
private final List<Object> adviceChain;
|
||||||
|
|
||||||
@Nullable
|
private final @Nullable Object target;
|
||||||
private final Object target;
|
|
||||||
|
|
||||||
@Nullable
|
private final @Nullable Class<?> targetClass;
|
||||||
private final Class<?> targetClass;
|
|
||||||
|
|
||||||
public FixedChainStaticTargetInterceptor(
|
public FixedChainStaticTargetInterceptor(
|
||||||
List<Object> adviceChain, @Nullable Object target, @Nullable Class<?> targetClass) {
|
List<Object> adviceChain, @Nullable Object target, @Nullable Class<?> targetClass) {
|
||||||
|
@ -670,8 +657,7 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
||||||
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
|
||||||
MethodInvocation invocation = new ReflectiveMethodInvocation(
|
MethodInvocation invocation = new ReflectiveMethodInvocation(
|
||||||
proxy, this.target, method, args, this.targetClass, this.adviceChain);
|
proxy, this.target, method, args, this.targetClass, this.adviceChain);
|
||||||
// If we get here, we need to create a MethodInvocation.
|
// If we get here, we need to create a MethodInvocation.
|
||||||
|
@ -695,8 +681,7 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
||||||
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
|
||||||
Object oldProxy = null;
|
Object oldProxy = null;
|
||||||
boolean setProxyContext = false;
|
boolean setProxyContext = false;
|
||||||
Object target = null;
|
Object target = null;
|
||||||
|
|
|
@ -19,10 +19,10 @@ package org.springframework.aop.framework;
|
||||||
import kotlin.coroutines.Continuation;
|
import kotlin.coroutines.Continuation;
|
||||||
import kotlinx.coroutines.reactive.ReactiveFlowKt;
|
import kotlinx.coroutines.reactive.ReactiveFlowKt;
|
||||||
import kotlinx.coroutines.reactor.MonoKt;
|
import kotlinx.coroutines.reactor.MonoKt;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
import org.reactivestreams.Publisher;
|
import org.reactivestreams.Publisher;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Package-visible class designed to avoid a hard dependency on Kotlin and Coroutines dependency at runtime.
|
* Package-visible class designed to avoid a hard dependency on Kotlin and Coroutines dependency at runtime.
|
||||||
|
@ -41,9 +41,8 @@ abstract class CoroutinesUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
static Object awaitSingleOrNull(@Nullable Object value, Object continuation) {
|
static @Nullable Object awaitSingleOrNull(@Nullable Object value, Object continuation) {
|
||||||
return MonoKt.awaitSingleOrNull(value instanceof Mono mono ? mono : Mono.justOrEmpty(value),
|
return MonoKt.awaitSingleOrNull(value instanceof Mono mono ? mono : Mono.justOrEmpty(value),
|
||||||
(Continuation<Object>) continuation);
|
(Continuation<Object>) continuation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.aopalliance.intercept.Interceptor;
|
import org.aopalliance.intercept.Interceptor;
|
||||||
import org.aopalliance.intercept.MethodInterceptor;
|
import org.aopalliance.intercept.MethodInterceptor;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Advisor;
|
import org.springframework.aop.Advisor;
|
||||||
import org.springframework.aop.IntroductionAdvisor;
|
import org.springframework.aop.IntroductionAdvisor;
|
||||||
|
@ -32,7 +33,6 @@ import org.springframework.aop.MethodMatcher;
|
||||||
import org.springframework.aop.PointcutAdvisor;
|
import org.springframework.aop.PointcutAdvisor;
|
||||||
import org.springframework.aop.framework.adapter.AdvisorAdapterRegistry;
|
import org.springframework.aop.framework.adapter.AdvisorAdapterRegistry;
|
||||||
import org.springframework.aop.framework.adapter.GlobalAdvisorAdapterRegistry;
|
import org.springframework.aop.framework.adapter.GlobalAdvisorAdapterRegistry;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple but definitive way of working out an advice chain for a Method,
|
* A simple but definitive way of working out an advice chain for a Method,
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.List;
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.AopInvocationException;
|
import org.springframework.aop.AopInvocationException;
|
||||||
import org.springframework.aop.RawTargetAccess;
|
import org.springframework.aop.RawTargetAccess;
|
||||||
|
@ -35,7 +36,6 @@ import org.springframework.aop.support.AopUtils;
|
||||||
import org.springframework.core.DecoratingProxy;
|
import org.springframework.core.DecoratingProxy;
|
||||||
import org.springframework.core.KotlinDetector;
|
import org.springframework.core.KotlinDetector;
|
||||||
import org.springframework.core.MethodParameter;
|
import org.springframework.core.MethodParameter;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
|
@ -163,8 +163,7 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
|
||||||
* unless a hook method throws an exception.
|
* unless a hook method throws an exception.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
|
||||||
Object oldProxy = null;
|
Object oldProxy = null;
|
||||||
boolean setProxyContext = false;
|
boolean setProxyContext = false;
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
package org.springframework.aop.framework;
|
package org.springframework.aop.framework;
|
||||||
|
|
||||||
import org.aopalliance.intercept.Interceptor;
|
import org.aopalliance.intercept.Interceptor;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.TargetSource;
|
import org.springframework.aop.TargetSource;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.aopalliance.aop.Advice;
|
||||||
import org.aopalliance.intercept.Interceptor;
|
import org.aopalliance.intercept.Interceptor;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Advisor;
|
import org.springframework.aop.Advisor;
|
||||||
import org.springframework.aop.TargetSource;
|
import org.springframework.aop.TargetSource;
|
||||||
|
@ -43,7 +44,6 @@ import org.springframework.beans.factory.FactoryBean;
|
||||||
import org.springframework.beans.factory.FactoryBeanNotInitializedException;
|
import org.springframework.beans.factory.FactoryBeanNotInitializedException;
|
||||||
import org.springframework.beans.factory.ListableBeanFactory;
|
import org.springframework.beans.factory.ListableBeanFactory;
|
||||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
@ -101,11 +101,9 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
|
|
||||||
private static final Log logger = LogFactory.getLog(ProxyFactoryBean.class);
|
private static final Log logger = LogFactory.getLog(ProxyFactoryBean.class);
|
||||||
|
|
||||||
@Nullable
|
private String @Nullable [] interceptorNames;
|
||||||
private String[] interceptorNames;
|
|
||||||
|
|
||||||
@Nullable
|
private @Nullable String targetName;
|
||||||
private String targetName;
|
|
||||||
|
|
||||||
private boolean autodetectInterfaces = true;
|
private boolean autodetectInterfaces = true;
|
||||||
|
|
||||||
|
@ -115,20 +113,17 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
|
|
||||||
private boolean freezeProxy = false;
|
private boolean freezeProxy = false;
|
||||||
|
|
||||||
@Nullable
|
private transient @Nullable ClassLoader proxyClassLoader = ClassUtils.getDefaultClassLoader();
|
||||||
private transient ClassLoader proxyClassLoader = ClassUtils.getDefaultClassLoader();
|
|
||||||
|
|
||||||
private transient boolean classLoaderConfigured = false;
|
private transient boolean classLoaderConfigured = false;
|
||||||
|
|
||||||
@Nullable
|
private transient @Nullable BeanFactory beanFactory;
|
||||||
private transient BeanFactory beanFactory;
|
|
||||||
|
|
||||||
/** Whether the advisor chain has already been initialized. */
|
/** Whether the advisor chain has already been initialized. */
|
||||||
private boolean advisorChainInitialized = false;
|
private boolean advisorChainInitialized = false;
|
||||||
|
|
||||||
/** If this is a singleton, the cached singleton proxy instance. */
|
/** If this is a singleton, the cached singleton proxy instance. */
|
||||||
@Nullable
|
private @Nullable Object singletonInstance;
|
||||||
private Object singletonInstance;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -246,8 +241,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
* @return a fresh AOP proxy reflecting the current state of this factory
|
* @return a fresh AOP proxy reflecting the current state of this factory
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object getObject() throws BeansException {
|
||||||
public Object getObject() throws BeansException {
|
|
||||||
initializeAdvisorChain();
|
initializeAdvisorChain();
|
||||||
if (isSingleton()) {
|
if (isSingleton()) {
|
||||||
return getSingletonInstance();
|
return getSingletonInstance();
|
||||||
|
@ -268,8 +262,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
* @see org.springframework.aop.framework.AopProxy#getProxyClass
|
* @see org.springframework.aop.framework.AopProxy#getProxyClass
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Class<?> getObjectType() {
|
||||||
public Class<?> getObjectType() {
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (this.singletonInstance != null) {
|
if (this.singletonInstance != null) {
|
||||||
return this.singletonInstance.getClass();
|
return this.singletonInstance.getClass();
|
||||||
|
|
|
@ -18,12 +18,13 @@ package org.springframework.aop.framework;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.beans.factory.Aware;
|
import org.springframework.beans.factory.Aware;
|
||||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||||
import org.springframework.beans.factory.DisposableBean;
|
import org.springframework.beans.factory.DisposableBean;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
|
@ -45,8 +46,7 @@ public class ProxyProcessorSupport extends ProxyConfig implements Ordered, BeanC
|
||||||
*/
|
*/
|
||||||
private int order = Ordered.LOWEST_PRECEDENCE;
|
private int order = Ordered.LOWEST_PRECEDENCE;
|
||||||
|
|
||||||
@Nullable
|
private @Nullable ClassLoader proxyClassLoader = ClassUtils.getDefaultClassLoader();
|
||||||
private ClassLoader proxyClassLoader = ClassUtils.getDefaultClassLoader();
|
|
||||||
|
|
||||||
private boolean classLoaderConfigured = false;
|
private boolean classLoaderConfigured = false;
|
||||||
|
|
||||||
|
@ -80,8 +80,7 @@ public class ProxyProcessorSupport extends ProxyConfig implements Ordered, BeanC
|
||||||
/**
|
/**
|
||||||
* Return the configured proxy ClassLoader for this processor.
|
* Return the configured proxy ClassLoader for this processor.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
protected @Nullable ClassLoader getProxyClassLoader() {
|
||||||
protected ClassLoader getProxyClassLoader() {
|
|
||||||
return this.proxyClassLoader;
|
return this.proxyClassLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,11 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.aopalliance.intercept.MethodInterceptor;
|
import org.aopalliance.intercept.MethodInterceptor;
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.ProxyMethodInvocation;
|
import org.springframework.aop.ProxyMethodInvocation;
|
||||||
import org.springframework.aop.support.AopUtils;
|
import org.springframework.aop.support.AopUtils;
|
||||||
import org.springframework.core.BridgeMethodResolver;
|
import org.springframework.core.BridgeMethodResolver;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring's implementation of the AOP Alliance
|
* Spring's implementation of the AOP Alliance
|
||||||
|
@ -63,21 +63,18 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||||
|
|
||||||
protected final Object proxy;
|
protected final Object proxy;
|
||||||
|
|
||||||
@Nullable
|
protected final @Nullable Object target;
|
||||||
protected final Object target;
|
|
||||||
|
|
||||||
protected final Method method;
|
protected final Method method;
|
||||||
|
|
||||||
protected Object[] arguments;
|
protected Object[] arguments;
|
||||||
|
|
||||||
@Nullable
|
private final @Nullable Class<?> targetClass;
|
||||||
private final Class<?> targetClass;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lazily initialized map of user-specific attributes for this invocation.
|
* Lazily initialized map of user-specific attributes for this invocation.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
private @Nullable Map<String, Object> userAttributes;
|
||||||
private Map<String, Object> userAttributes;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of MethodInterceptor and InterceptorAndDynamicMethodMatcher
|
* List of MethodInterceptor and InterceptorAndDynamicMethodMatcher
|
||||||
|
@ -106,7 +103,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||||
* but would complicate the code. And it would work only for static pointcuts.
|
* but would complicate the code. And it would work only for static pointcuts.
|
||||||
*/
|
*/
|
||||||
protected ReflectiveMethodInvocation(
|
protected ReflectiveMethodInvocation(
|
||||||
Object proxy, @Nullable Object target, Method method, @Nullable Object[] arguments,
|
Object proxy, @Nullable Object target, Method method, Object @Nullable [] arguments,
|
||||||
@Nullable Class<?> targetClass, List<Object> interceptorsAndDynamicMethodMatchers) {
|
@Nullable Class<?> targetClass, List<Object> interceptorsAndDynamicMethodMatchers) {
|
||||||
|
|
||||||
this.proxy = proxy;
|
this.proxy = proxy;
|
||||||
|
@ -124,8 +121,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public final @Nullable Object getThis() {
|
||||||
public final Object getThis() {
|
|
||||||
return this.target;
|
return this.target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,8 +152,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object proceed() throws Throwable {
|
||||||
public Object proceed() throws Throwable {
|
|
||||||
// We start with an index of -1 and increment early.
|
// We start with an index of -1 and increment early.
|
||||||
if (this.currentInterceptorIndex == this.interceptorsAndDynamicMethodMatchers.size() - 1) {
|
if (this.currentInterceptorIndex == this.interceptorsAndDynamicMethodMatchers.size() - 1) {
|
||||||
return invokeJoinpoint();
|
return invokeJoinpoint();
|
||||||
|
@ -191,8 +186,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||||
* @return the return value of the joinpoint
|
* @return the return value of the joinpoint
|
||||||
* @throws Throwable if invoking the joinpoint resulted in an exception
|
* @throws Throwable if invoking the joinpoint resulted in an exception
|
||||||
*/
|
*/
|
||||||
@Nullable
|
protected @Nullable Object invokeJoinpoint() throws Throwable {
|
||||||
protected Object invokeJoinpoint() throws Throwable {
|
|
||||||
return AopUtils.invokeJoinpointUsingReflection(this.target, this.method, this.arguments);
|
return AopUtils.invokeJoinpointUsingReflection(this.target, this.method, this.arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,8 +254,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object getUserAttribute(String key) {
|
||||||
public Object getUserAttribute(String key) {
|
|
||||||
return (this.userAttributes != null ? this.userAttributes.get(key) : null);
|
return (this.userAttributes != null ? this.userAttributes.get(key) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,10 @@ import java.io.Serializable;
|
||||||
|
|
||||||
import org.aopalliance.intercept.MethodInterceptor;
|
import org.aopalliance.intercept.MethodInterceptor;
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.AfterAdvice;
|
import org.springframework.aop.AfterAdvice;
|
||||||
import org.springframework.aop.AfterReturningAdvice;
|
import org.springframework.aop.AfterReturningAdvice;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,8 +52,7 @@ public class AfterReturningAdviceInterceptor implements MethodInterceptor, After
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
|
||||||
Object retVal = mi.proceed();
|
Object retVal = mi.proceed();
|
||||||
this.advice.afterReturning(retVal, mi.getMethod(), mi.getArguments(), mi.getThis());
|
this.advice.afterReturning(retVal, mi.getMethod(), mi.getArguments(), mi.getThis());
|
||||||
return retVal;
|
return retVal;
|
||||||
|
|
|
@ -20,10 +20,10 @@ import java.io.Serializable;
|
||||||
|
|
||||||
import org.aopalliance.intercept.MethodInterceptor;
|
import org.aopalliance.intercept.MethodInterceptor;
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.BeforeAdvice;
|
import org.springframework.aop.BeforeAdvice;
|
||||||
import org.springframework.aop.MethodBeforeAdvice;
|
import org.springframework.aop.MethodBeforeAdvice;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,8 +52,7 @@ public class MethodBeforeAdviceInterceptor implements MethodInterceptor, BeforeA
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
|
||||||
this.advice.before(mi.getMethod(), mi.getArguments(), mi.getThis());
|
this.advice.before(mi.getMethod(), mi.getArguments(), mi.getThis());
|
||||||
return mi.proceed();
|
return mi.proceed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,10 @@ import org.aopalliance.intercept.MethodInterceptor;
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.AfterAdvice;
|
import org.springframework.aop.AfterAdvice;
|
||||||
import org.springframework.aop.framework.AopConfigException;
|
import org.springframework.aop.framework.AopConfigException;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,8 +131,7 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
|
||||||
try {
|
try {
|
||||||
return mi.proceed();
|
return mi.proceed();
|
||||||
}
|
}
|
||||||
|
@ -150,8 +149,7 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice {
|
||||||
* @param exception the exception thrown
|
* @param exception the exception thrown
|
||||||
* @return a handler for the given exception type, or {@code null} if none found
|
* @return a handler for the given exception type, or {@code null} if none found
|
||||||
*/
|
*/
|
||||||
@Nullable
|
private @Nullable Method getExceptionHandler(Throwable exception) {
|
||||||
private Method getExceptionHandler(Throwable exception) {
|
|
||||||
Class<?> exceptionClass = exception.getClass();
|
Class<?> exceptionClass = exception.getClass();
|
||||||
if (logger.isTraceEnabled()) {
|
if (logger.isTraceEnabled()) {
|
||||||
logger.trace("Trying to find handler for exception of type [" + exceptionClass.getName() + "]");
|
logger.trace("Trying to find handler for exception of type [" + exceptionClass.getName() + "]");
|
||||||
|
|
|
@ -9,9 +9,7 @@
|
||||||
*
|
*
|
||||||
* <p>These adapters do not depend on any other Spring framework classes to allow such usage.
|
* <p>These adapters do not depend on any other Spring framework classes to allow such usage.
|
||||||
*/
|
*/
|
||||||
@NonNullApi
|
@NullMarked
|
||||||
@NonNullFields
|
|
||||||
package org.springframework.aop.framework.adapter;
|
package org.springframework.aop.framework.adapter;
|
||||||
|
|
||||||
import org.springframework.lang.NonNullApi;
|
import org.jspecify.annotations.NullMarked;
|
||||||
import org.springframework.lang.NonNullFields;
|
|
||||||
|
|
|
@ -18,6 +18,8 @@ package org.springframework.aop.framework.autoproxy;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Advisor;
|
import org.springframework.aop.Advisor;
|
||||||
import org.springframework.aop.TargetSource;
|
import org.springframework.aop.TargetSource;
|
||||||
import org.springframework.aop.framework.AopConfigException;
|
import org.springframework.aop.framework.AopConfigException;
|
||||||
|
@ -26,7 +28,6 @@ import org.springframework.beans.factory.BeanCreationException;
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,8 +54,7 @@ import org.springframework.util.Assert;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public abstract class AbstractAdvisorAutoProxyCreator extends AbstractAutoProxyCreator {
|
public abstract class AbstractAdvisorAutoProxyCreator extends AbstractAutoProxyCreator {
|
||||||
|
|
||||||
@Nullable
|
private @Nullable BeanFactoryAdvisorRetrievalHelper advisorRetrievalHelper;
|
||||||
private BeanFactoryAdvisorRetrievalHelper advisorRetrievalHelper;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,8 +73,7 @@ public abstract class AbstractAdvisorAutoProxyCreator extends AbstractAutoProxyC
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
protected Object @Nullable [] getAdvicesAndAdvisorsForBean(
|
||||||
protected Object[] getAdvicesAndAdvisorsForBean(
|
|
||||||
Class<?> beanClass, String beanName, @Nullable TargetSource targetSource) {
|
Class<?> beanClass, String beanName, @Nullable TargetSource targetSource) {
|
||||||
|
|
||||||
List<Advisor> advisors = findEligibleAdvisors(beanClass, beanName);
|
List<Advisor> advisors = findEligibleAdvisors(beanClass, beanName);
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
import org.aopalliance.aop.Advice;
|
import org.aopalliance.aop.Advice;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Advisor;
|
import org.springframework.aop.Advisor;
|
||||||
import org.springframework.aop.Pointcut;
|
import org.springframework.aop.Pointcut;
|
||||||
|
@ -48,7 +49,6 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor;
|
import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor;
|
||||||
import org.springframework.core.SmartClassLoader;
|
import org.springframework.core.SmartClassLoader;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
@ -101,8 +101,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
|
||||||
* Convenience constant for subclasses: Return value for "do not proxy".
|
* Convenience constant for subclasses: Return value for "do not proxy".
|
||||||
* @see #getAdvicesAndAdvisorsForBean
|
* @see #getAdvicesAndAdvisorsForBean
|
||||||
*/
|
*/
|
||||||
@Nullable
|
protected static final Object @Nullable [] DO_NOT_PROXY = null;
|
||||||
protected static final Object[] DO_NOT_PROXY = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience constant for subclasses: Return value for
|
* Convenience constant for subclasses: Return value for
|
||||||
|
@ -129,11 +128,9 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
|
||||||
|
|
||||||
private boolean applyCommonInterceptorsFirst = true;
|
private boolean applyCommonInterceptorsFirst = true;
|
||||||
|
|
||||||
@Nullable
|
private TargetSourceCreator @Nullable [] customTargetSourceCreators;
|
||||||
private TargetSourceCreator[] customTargetSourceCreators;
|
|
||||||
|
|
||||||
@Nullable
|
private @Nullable BeanFactory beanFactory;
|
||||||
private BeanFactory beanFactory;
|
|
||||||
|
|
||||||
private final Set<String> targetSourcedBeans = ConcurrentHashMap.newKeySet(16);
|
private final Set<String> targetSourcedBeans = ConcurrentHashMap.newKeySet(16);
|
||||||
|
|
||||||
|
@ -215,15 +212,13 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
|
||||||
* Return the owning {@link BeanFactory}.
|
* Return the owning {@link BeanFactory}.
|
||||||
* May be {@code null}, as this post-processor doesn't need to belong to a bean factory.
|
* May be {@code null}, as this post-processor doesn't need to belong to a bean factory.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
protected @Nullable BeanFactory getBeanFactory() {
|
||||||
protected BeanFactory getBeanFactory() {
|
|
||||||
return this.beanFactory;
|
return this.beanFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Class<?> predictBeanType(Class<?> beanClass, String beanName) {
|
||||||
public Class<?> predictBeanType(Class<?> beanClass, String beanName) {
|
|
||||||
if (this.proxyTypes.isEmpty()) {
|
if (this.proxyTypes.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -256,8 +251,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public Constructor<?> @Nullable [] determineCandidateConstructors(Class<?> beanClass, String beanName) {
|
||||||
public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,8 +263,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) {
|
||||||
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) {
|
|
||||||
Object cacheKey = getCacheKey(beanClass, beanName);
|
Object cacheKey = getCacheKey(beanClass, beanName);
|
||||||
|
|
||||||
if (!StringUtils.hasLength(beanName) || !this.targetSourcedBeans.contains(beanName)) {
|
if (!StringUtils.hasLength(beanName) || !this.targetSourcedBeans.contains(beanName)) {
|
||||||
|
@ -311,8 +304,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
|
||||||
* @see #getAdvicesAndAdvisorsForBean
|
* @see #getAdvicesAndAdvisorsForBean
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object postProcessAfterInitialization(@Nullable Object bean, String beanName) {
|
||||||
public Object postProcessAfterInitialization(@Nullable Object bean, String beanName) {
|
|
||||||
if (bean != null) {
|
if (bean != null) {
|
||||||
Object cacheKey = getCacheKey(bean.getClass(), beanName);
|
Object cacheKey = getCacheKey(bean.getClass(), beanName);
|
||||||
if (this.earlyBeanReferences.remove(cacheKey) != bean) {
|
if (this.earlyBeanReferences.remove(cacheKey) != bean) {
|
||||||
|
@ -426,8 +418,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
|
||||||
* @return a TargetSource for this bean
|
* @return a TargetSource for this bean
|
||||||
* @see #setCustomTargetSourceCreators
|
* @see #setCustomTargetSourceCreators
|
||||||
*/
|
*/
|
||||||
@Nullable
|
protected @Nullable TargetSource getCustomTargetSource(Class<?> beanClass, String beanName) {
|
||||||
protected TargetSource getCustomTargetSource(Class<?> beanClass, String beanName) {
|
|
||||||
// We can't create fancy target sources for directly registered singletons.
|
// We can't create fancy target sources for directly registered singletons.
|
||||||
if (this.customTargetSourceCreators != null &&
|
if (this.customTargetSourceCreators != null &&
|
||||||
this.beanFactory != null && this.beanFactory.containsBean(beanName)) {
|
this.beanFactory != null && this.beanFactory.containsBean(beanName)) {
|
||||||
|
@ -460,19 +451,19 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
|
||||||
* @see #buildAdvisors
|
* @see #buildAdvisors
|
||||||
*/
|
*/
|
||||||
protected Object createProxy(Class<?> beanClass, @Nullable String beanName,
|
protected Object createProxy(Class<?> beanClass, @Nullable String beanName,
|
||||||
@Nullable Object[] specificInterceptors, TargetSource targetSource) {
|
Object @Nullable [] specificInterceptors, TargetSource targetSource) {
|
||||||
|
|
||||||
return buildProxy(beanClass, beanName, specificInterceptors, targetSource, false);
|
return buildProxy(beanClass, beanName, specificInterceptors, targetSource, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Class<?> createProxyClass(Class<?> beanClass, @Nullable String beanName,
|
private Class<?> createProxyClass(Class<?> beanClass, @Nullable String beanName,
|
||||||
@Nullable Object[] specificInterceptors, TargetSource targetSource) {
|
Object @Nullable [] specificInterceptors, TargetSource targetSource) {
|
||||||
|
|
||||||
return (Class<?>) buildProxy(beanClass, beanName, specificInterceptors, targetSource, true);
|
return (Class<?>) buildProxy(beanClass, beanName, specificInterceptors, targetSource, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object buildProxy(Class<?> beanClass, @Nullable String beanName,
|
private Object buildProxy(Class<?> beanClass, @Nullable String beanName,
|
||||||
@Nullable Object[] specificInterceptors, TargetSource targetSource, boolean classOnly) {
|
Object @Nullable [] specificInterceptors, TargetSource targetSource, boolean classOnly) {
|
||||||
|
|
||||||
if (this.beanFactory instanceof ConfigurableListableBeanFactory clbf) {
|
if (this.beanFactory instanceof ConfigurableListableBeanFactory clbf) {
|
||||||
AutoProxyUtils.exposeTargetClass(clbf, beanName, beanClass);
|
AutoProxyUtils.exposeTargetClass(clbf, beanName, beanClass);
|
||||||
|
@ -554,7 +545,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
|
||||||
* specific to this bean (may be empty, but not null)
|
* specific to this bean (may be empty, but not null)
|
||||||
* @return the list of Advisors for the given bean
|
* @return the list of Advisors for the given bean
|
||||||
*/
|
*/
|
||||||
protected Advisor[] buildAdvisors(@Nullable String beanName, @Nullable Object[] specificInterceptors) {
|
protected Advisor[] buildAdvisors(@Nullable String beanName, Object @Nullable [] specificInterceptors) {
|
||||||
// Handle prototypes correctly...
|
// Handle prototypes correctly...
|
||||||
Advisor[] commonInterceptors = resolveInterceptorNames();
|
Advisor[] commonInterceptors = resolveInterceptorNames();
|
||||||
|
|
||||||
|
@ -633,8 +624,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
|
||||||
* @see #DO_NOT_PROXY
|
* @see #DO_NOT_PROXY
|
||||||
* @see #PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS
|
* @see #PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS
|
||||||
*/
|
*/
|
||||||
@Nullable
|
protected abstract Object @Nullable [] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String beanName,
|
||||||
protected abstract Object[] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String beanName,
|
|
||||||
@Nullable TargetSource customTargetSource) throws BeansException;
|
@Nullable TargetSource customTargetSource) throws BeansException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,13 @@
|
||||||
|
|
||||||
package org.springframework.aop.framework.autoproxy;
|
package org.springframework.aop.framework.autoproxy;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor;
|
import org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor;
|
||||||
import org.springframework.aop.framework.ProxyFactory;
|
import org.springframework.aop.framework.ProxyFactory;
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
import org.springframework.beans.factory.BeanFactoryAware;
|
import org.springframework.beans.factory.BeanFactoryAware;
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension of {@link AbstractAutoProxyCreator} which implements {@link BeanFactoryAware},
|
* Extension of {@link AbstractAutoProxyCreator} which implements {@link BeanFactoryAware},
|
||||||
|
@ -40,8 +41,7 @@ import org.springframework.lang.Nullable;
|
||||||
public abstract class AbstractBeanFactoryAwareAdvisingPostProcessor extends AbstractAdvisingBeanPostProcessor
|
public abstract class AbstractBeanFactoryAwareAdvisingPostProcessor extends AbstractAdvisingBeanPostProcessor
|
||||||
implements BeanFactoryAware {
|
implements BeanFactoryAware {
|
||||||
|
|
||||||
@Nullable
|
private @Nullable ConfigurableListableBeanFactory beanFactory;
|
||||||
private ConfigurableListableBeanFactory beanFactory;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,11 +16,12 @@
|
||||||
|
|
||||||
package org.springframework.aop.framework.autoproxy;
|
package org.springframework.aop.framework.autoproxy;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.core.Conventions;
|
import org.springframework.core.Conventions;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,8 +85,7 @@ public abstract class AutoProxyUtils {
|
||||||
* @since 4.2.3
|
* @since 4.2.3
|
||||||
* @see org.springframework.beans.factory.BeanFactory#getType(String)
|
* @see org.springframework.beans.factory.BeanFactory#getType(String)
|
||||||
*/
|
*/
|
||||||
@Nullable
|
public static @Nullable Class<?> determineTargetClass(
|
||||||
public static Class<?> determineTargetClass(
|
|
||||||
ConfigurableListableBeanFactory beanFactory, @Nullable String beanName) {
|
ConfigurableListableBeanFactory beanFactory, @Nullable String beanName) {
|
||||||
|
|
||||||
if (beanName == null) {
|
if (beanName == null) {
|
||||||
|
|
|
@ -21,13 +21,13 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Advisor;
|
import org.springframework.aop.Advisor;
|
||||||
import org.springframework.beans.factory.BeanCreationException;
|
import org.springframework.beans.factory.BeanCreationException;
|
||||||
import org.springframework.beans.factory.BeanCurrentlyInCreationException;
|
import org.springframework.beans.factory.BeanCurrentlyInCreationException;
|
||||||
import org.springframework.beans.factory.BeanFactoryUtils;
|
import org.springframework.beans.factory.BeanFactoryUtils;
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,8 +44,7 @@ public class BeanFactoryAdvisorRetrievalHelper {
|
||||||
|
|
||||||
private final ConfigurableListableBeanFactory beanFactory;
|
private final ConfigurableListableBeanFactory beanFactory;
|
||||||
|
|
||||||
@Nullable
|
private volatile String @Nullable [] cachedAdvisorBeanNames;
|
||||||
private volatile String[] cachedAdvisorBeanNames;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,10 +19,11 @@ package org.springframework.aop.framework.autoproxy;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.TargetSource;
|
import org.springframework.aop.TargetSource;
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.PatternMatchUtils;
|
import org.springframework.util.PatternMatchUtils;
|
||||||
|
|
||||||
|
@ -48,8 +49,7 @@ public class BeanNameAutoProxyCreator extends AbstractAutoProxyCreator {
|
||||||
|
|
||||||
private static final String[] NO_ALIASES = new String[0];
|
private static final String[] NO_ALIASES = new String[0];
|
||||||
|
|
||||||
@Nullable
|
private @Nullable List<String> beanNames;
|
||||||
private List<String> beanNames;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,8 +81,7 @@ public class BeanNameAutoProxyCreator extends AbstractAutoProxyCreator {
|
||||||
* @see #setBeanNames(String...)
|
* @see #setBeanNames(String...)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
protected @Nullable TargetSource getCustomTargetSource(Class<?> beanClass, String beanName) {
|
||||||
protected TargetSource getCustomTargetSource(Class<?> beanClass, String beanName) {
|
|
||||||
return (isSupportedBeanName(beanClass, beanName) ?
|
return (isSupportedBeanName(beanClass, beanName) ?
|
||||||
super.getCustomTargetSource(beanClass, beanName) : null);
|
super.getCustomTargetSource(beanClass, beanName) : null);
|
||||||
}
|
}
|
||||||
|
@ -93,8 +92,7 @@ public class BeanNameAutoProxyCreator extends AbstractAutoProxyCreator {
|
||||||
* @see #setBeanNames(String...)
|
* @see #setBeanNames(String...)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
protected Object @Nullable [] getAdvicesAndAdvisorsForBean(
|
||||||
protected Object[] getAdvicesAndAdvisorsForBean(
|
|
||||||
Class<?> beanClass, String beanName, @Nullable TargetSource targetSource) {
|
Class<?> beanClass, String beanName, @Nullable TargetSource targetSource) {
|
||||||
|
|
||||||
return (isSupportedBeanName(beanClass, beanName) ?
|
return (isSupportedBeanName(beanClass, beanName) ?
|
||||||
|
|
|
@ -16,8 +16,9 @@
|
||||||
|
|
||||||
package org.springframework.aop.framework.autoproxy;
|
package org.springframework.aop.framework.autoproxy;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.beans.factory.BeanNameAware;
|
import org.springframework.beans.factory.BeanNameAware;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code BeanPostProcessor} implementation that creates AOP proxies based on all
|
* {@code BeanPostProcessor} implementation that creates AOP proxies based on all
|
||||||
|
@ -44,8 +45,7 @@ public class DefaultAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCrea
|
||||||
|
|
||||||
private boolean usePrefix = false;
|
private boolean usePrefix = false;
|
||||||
|
|
||||||
@Nullable
|
private @Nullable String advisorBeanNamePrefix;
|
||||||
private String advisorBeanNamePrefix;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,8 +78,7 @@ public class DefaultAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCrea
|
||||||
* Return the prefix for bean names that will cause them to be included
|
* Return the prefix for bean names that will cause them to be included
|
||||||
* for auto-proxying by this object.
|
* for auto-proxying by this object.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
public @Nullable String getAdvisorBeanNamePrefix() {
|
||||||
public String getAdvisorBeanNamePrefix() {
|
|
||||||
return this.advisorBeanNamePrefix;
|
return this.advisorBeanNamePrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,10 @@
|
||||||
|
|
||||||
package org.springframework.aop.framework.autoproxy;
|
package org.springframework.aop.framework.autoproxy;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auto-proxy creator that considers infrastructure Advisor beans only,
|
* Auto-proxy creator that considers infrastructure Advisor beans only,
|
||||||
|
@ -30,8 +31,7 @@ import org.springframework.lang.Nullable;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class InfrastructureAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCreator {
|
public class InfrastructureAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCreator {
|
||||||
|
|
||||||
@Nullable
|
private @Nullable ConfigurableListableBeanFactory beanFactory;
|
||||||
private ConfigurableListableBeanFactory beanFactory;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,8 +16,9 @@
|
||||||
|
|
||||||
package org.springframework.aop.framework.autoproxy;
|
package org.springframework.aop.framework.autoproxy;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.core.NamedThreadLocal;
|
import org.springframework.core.NamedThreadLocal;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holder for the current proxy creation context, as exposed by auto-proxy creators
|
* Holder for the current proxy creation context, as exposed by auto-proxy creators
|
||||||
|
@ -42,8 +43,7 @@ public final class ProxyCreationContext {
|
||||||
* Return the name of the currently proxied bean instance.
|
* Return the name of the currently proxied bean instance.
|
||||||
* @return the name of the bean, or {@code null} if none available
|
* @return the name of the bean, or {@code null} if none available
|
||||||
*/
|
*/
|
||||||
@Nullable
|
public static @Nullable String getCurrentProxiedBeanName() {
|
||||||
public static String getCurrentProxiedBeanName() {
|
|
||||||
return currentProxiedBeanName.get();
|
return currentProxiedBeanName.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,9 @@
|
||||||
|
|
||||||
package org.springframework.aop.framework.autoproxy;
|
package org.springframework.aop.framework.autoproxy;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.TargetSource;
|
import org.springframework.aop.TargetSource;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementations can create special target sources, such as pooling target
|
* Implementations can create special target sources, such as pooling target
|
||||||
|
@ -40,7 +41,6 @@ public interface TargetSourceCreator {
|
||||||
* @return a special TargetSource or {@code null} if this TargetSourceCreator isn't
|
* @return a special TargetSource or {@code null} if this TargetSourceCreator isn't
|
||||||
* interested in the particular bean
|
* interested in the particular bean
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable TargetSource getTargetSource(Class<?> beanClass, String beanName);
|
||||||
TargetSource getTargetSource(Class<?> beanClass, String beanName);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,7 @@
|
||||||
* as post-processors beans are only automatically detected in application contexts.
|
* as post-processors beans are only automatically detected in application contexts.
|
||||||
* Post-processors can be explicitly registered on a ConfigurableBeanFactory instead.
|
* Post-processors can be explicitly registered on a ConfigurableBeanFactory instead.
|
||||||
*/
|
*/
|
||||||
@NonNullApi
|
@NullMarked
|
||||||
@NonNullFields
|
|
||||||
package org.springframework.aop.framework.autoproxy;
|
package org.springframework.aop.framework.autoproxy;
|
||||||
|
|
||||||
import org.springframework.lang.NonNullApi;
|
import org.jspecify.annotations.NullMarked;
|
||||||
import org.springframework.lang.NonNullFields;
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.TargetSource;
|
import org.springframework.aop.TargetSource;
|
||||||
import org.springframework.aop.framework.AopInfrastructureBean;
|
import org.springframework.aop.framework.AopInfrastructureBean;
|
||||||
|
@ -33,7 +34,6 @@ import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||||
import org.springframework.beans.factory.support.GenericBeanDefinition;
|
import org.springframework.beans.factory.support.GenericBeanDefinition;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,8 +59,7 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator
|
||||||
|
|
||||||
protected final Log logger = LogFactory.getLog(getClass());
|
protected final Log logger = LogFactory.getLog(getClass());
|
||||||
|
|
||||||
@Nullable
|
private @Nullable ConfigurableBeanFactory beanFactory;
|
||||||
private ConfigurableBeanFactory beanFactory;
|
|
||||||
|
|
||||||
/** Internally used DefaultListableBeanFactory instances, keyed by bean name. */
|
/** Internally used DefaultListableBeanFactory instances, keyed by bean name. */
|
||||||
private final Map<String, DefaultListableBeanFactory> internalBeanFactories = new HashMap<>();
|
private final Map<String, DefaultListableBeanFactory> internalBeanFactories = new HashMap<>();
|
||||||
|
@ -78,8 +77,7 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator
|
||||||
/**
|
/**
|
||||||
* Return the BeanFactory that this TargetSourceCreators runs in.
|
* Return the BeanFactory that this TargetSourceCreators runs in.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
protected final @Nullable BeanFactory getBeanFactory() {
|
||||||
protected final BeanFactory getBeanFactory() {
|
|
||||||
return this.beanFactory;
|
return this.beanFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,8 +92,7 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public final @Nullable TargetSource getTargetSource(Class<?> beanClass, String beanName) {
|
||||||
public final TargetSource getTargetSource(Class<?> beanClass, String beanName) {
|
|
||||||
AbstractBeanFactoryBasedTargetSource targetSource =
|
AbstractBeanFactoryBasedTargetSource targetSource =
|
||||||
createBeanFactoryBasedTargetSource(beanClass, beanName);
|
createBeanFactoryBasedTargetSource(beanClass, beanName);
|
||||||
if (targetSource == null) {
|
if (targetSource == null) {
|
||||||
|
@ -195,8 +192,7 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator
|
||||||
* @param beanName the name of the bean
|
* @param beanName the name of the bean
|
||||||
* @return the AbstractPrototypeBasedTargetSource, or {@code null} if we don't match this
|
* @return the AbstractPrototypeBasedTargetSource, or {@code null} if we don't match this
|
||||||
*/
|
*/
|
||||||
@Nullable
|
protected abstract @Nullable AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
|
||||||
protected abstract AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
|
|
||||||
Class<?> beanClass, String beanName);
|
Class<?> beanClass, String beanName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,12 @@
|
||||||
|
|
||||||
package org.springframework.aop.framework.autoproxy.target;
|
package org.springframework.aop.framework.autoproxy.target;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource;
|
import org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource;
|
||||||
import org.springframework.aop.target.LazyInitTargetSource;
|
import org.springframework.aop.target.LazyInitTargetSource;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code TargetSourceCreator} that enforces a {@link LazyInitTargetSource} for
|
* {@code TargetSourceCreator} that enforces a {@link LazyInitTargetSource} for
|
||||||
|
@ -62,8 +63,7 @@ public class LazyInitTargetSourceCreator extends AbstractBeanFactoryBasedTargetS
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
protected @Nullable AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
|
||||||
protected AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
|
|
||||||
Class<?> beanClass, String beanName) {
|
Class<?> beanClass, String beanName) {
|
||||||
|
|
||||||
if (getBeanFactory() instanceof ConfigurableListableBeanFactory clbf) {
|
if (getBeanFactory() instanceof ConfigurableListableBeanFactory clbf) {
|
||||||
|
|
|
@ -16,11 +16,12 @@
|
||||||
|
|
||||||
package org.springframework.aop.framework.autoproxy.target;
|
package org.springframework.aop.framework.autoproxy.target;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource;
|
import org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource;
|
||||||
import org.springframework.aop.target.CommonsPool2TargetSource;
|
import org.springframework.aop.target.CommonsPool2TargetSource;
|
||||||
import org.springframework.aop.target.PrototypeTargetSource;
|
import org.springframework.aop.target.PrototypeTargetSource;
|
||||||
import org.springframework.aop.target.ThreadLocalTargetSource;
|
import org.springframework.aop.target.ThreadLocalTargetSource;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenient TargetSourceCreator using bean name prefixes to create one of three
|
* Convenient TargetSourceCreator using bean name prefixes to create one of three
|
||||||
|
@ -55,8 +56,7 @@ public class QuickTargetSourceCreator extends AbstractBeanFactoryBasedTargetSour
|
||||||
public static final String PREFIX_PROTOTYPE = "!";
|
public static final String PREFIX_PROTOTYPE = "!";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
protected final @Nullable AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
|
||||||
protected final AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
|
|
||||||
Class<?> beanClass, String beanName) {
|
Class<?> beanClass, String beanName) {
|
||||||
|
|
||||||
if (beanName.startsWith(PREFIX_COMMONS_POOL)) {
|
if (beanName.startsWith(PREFIX_COMMONS_POOL)) {
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
* Various {@link org.springframework.aop.framework.autoproxy.TargetSourceCreator}
|
* Various {@link org.springframework.aop.framework.autoproxy.TargetSourceCreator}
|
||||||
* implementations for use with Spring's AOP auto-proxying support.
|
* implementations for use with Spring's AOP auto-proxying support.
|
||||||
*/
|
*/
|
||||||
@NonNullApi
|
@NullMarked
|
||||||
@NonNullFields
|
|
||||||
package org.springframework.aop.framework.autoproxy.target;
|
package org.springframework.aop.framework.autoproxy.target;
|
||||||
|
|
||||||
import org.springframework.lang.NonNullApi;
|
import org.jspecify.annotations.NullMarked;
|
||||||
import org.springframework.lang.NonNullFields;
|
|
||||||
|
|
|
@ -12,9 +12,7 @@
|
||||||
* or ApplicationContext. However, proxies can be created programmatically using the
|
* or ApplicationContext. However, proxies can be created programmatically using the
|
||||||
* ProxyFactory class.
|
* ProxyFactory class.
|
||||||
*/
|
*/
|
||||||
@NonNullApi
|
@NullMarked
|
||||||
@NonNullFields
|
|
||||||
package org.springframework.aop.framework;
|
package org.springframework.aop.framework;
|
||||||
|
|
||||||
import org.springframework.lang.NonNullApi;
|
import org.jspecify.annotations.NullMarked;
|
||||||
import org.springframework.lang.NonNullFields;
|
|
||||||
|
|
|
@ -19,8 +19,7 @@ package org.springframework.aop.interceptor;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for monitoring interceptors, such as performance monitors.
|
* Base class for monitoring interceptors, such as performance monitors.
|
||||||
|
|
|
@ -22,9 +22,9 @@ import org.aopalliance.intercept.MethodInterceptor;
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.support.AopUtils;
|
import org.springframework.aop.support.AopUtils;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,8 +52,7 @@ public abstract class AbstractTraceInterceptor implements MethodInterceptor, Ser
|
||||||
* The default {@code Log} instance used to write trace messages.
|
* The default {@code Log} instance used to write trace messages.
|
||||||
* This instance is mapped to the implementing {@code Class}.
|
* This instance is mapped to the implementing {@code Class}.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
protected transient @Nullable Log defaultLogger = LogFactory.getLog(getClass());
|
||||||
protected transient Log defaultLogger = LogFactory.getLog(getClass());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether proxy class names should be hidden when using dynamic loggers.
|
* Indicates whether proxy class names should be hidden when using dynamic loggers.
|
||||||
|
@ -125,8 +124,7 @@ public abstract class AbstractTraceInterceptor implements MethodInterceptor, Ser
|
||||||
* @see #invokeUnderTrace(org.aopalliance.intercept.MethodInvocation, org.apache.commons.logging.Log)
|
* @see #invokeUnderTrace(org.aopalliance.intercept.MethodInvocation, org.apache.commons.logging.Log)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object invoke(MethodInvocation invocation) throws Throwable {
|
||||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
|
||||||
Log logger = getLoggerForInvocation(invocation);
|
Log logger = getLoggerForInvocation(invocation);
|
||||||
if (isInterceptorEnabled(invocation, logger)) {
|
if (isInterceptorEnabled(invocation, logger)) {
|
||||||
return invokeUnderTrace(invocation, logger);
|
return invokeUnderTrace(invocation, logger);
|
||||||
|
@ -245,7 +243,6 @@ public abstract class AbstractTraceInterceptor implements MethodInterceptor, Ser
|
||||||
* @see #writeToLog(Log, String)
|
* @see #writeToLog(Log, String)
|
||||||
* @see #writeToLog(Log, String, Throwable)
|
* @see #writeToLog(Log, String, Throwable)
|
||||||
*/
|
*/
|
||||||
@Nullable
|
protected abstract @Nullable Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable;
|
||||||
protected abstract Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.function.Supplier;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
import org.springframework.beans.factory.BeanFactoryAware;
|
import org.springframework.beans.factory.BeanFactoryAware;
|
||||||
|
@ -38,7 +39,6 @@ import org.springframework.beans.factory.config.EmbeddedValueResolver;
|
||||||
import org.springframework.core.task.AsyncTaskExecutor;
|
import org.springframework.core.task.AsyncTaskExecutor;
|
||||||
import org.springframework.core.task.TaskExecutor;
|
import org.springframework.core.task.TaskExecutor;
|
||||||
import org.springframework.core.task.support.TaskExecutorAdapter;
|
import org.springframework.core.task.support.TaskExecutorAdapter;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.util.StringValueResolver;
|
import org.springframework.util.StringValueResolver;
|
||||||
|
@ -78,11 +78,9 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
|
||||||
|
|
||||||
private SingletonSupplier<AsyncUncaughtExceptionHandler> exceptionHandler;
|
private SingletonSupplier<AsyncUncaughtExceptionHandler> exceptionHandler;
|
||||||
|
|
||||||
@Nullable
|
private @Nullable BeanFactory beanFactory;
|
||||||
private BeanFactory beanFactory;
|
|
||||||
|
|
||||||
@Nullable
|
private @Nullable StringValueResolver embeddedValueResolver;
|
||||||
private StringValueResolver embeddedValueResolver;
|
|
||||||
|
|
||||||
private final Map<Method, AsyncTaskExecutor> executors = new ConcurrentHashMap<>(16);
|
private final Map<Method, AsyncTaskExecutor> executors = new ConcurrentHashMap<>(16);
|
||||||
|
|
||||||
|
@ -167,8 +165,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
|
||||||
* Determine the specific executor to use when executing the given method.
|
* Determine the specific executor to use when executing the given method.
|
||||||
* @return the executor to use (or {@code null}, but just if no default executor is available)
|
* @return the executor to use (or {@code null}, but just if no default executor is available)
|
||||||
*/
|
*/
|
||||||
@Nullable
|
protected @Nullable AsyncTaskExecutor determineAsyncExecutor(Method method) {
|
||||||
protected AsyncTaskExecutor determineAsyncExecutor(Method method) {
|
|
||||||
AsyncTaskExecutor executor = this.executors.get(method);
|
AsyncTaskExecutor executor = this.executors.get(method);
|
||||||
if (executor == null) {
|
if (executor == null) {
|
||||||
Executor targetExecutor;
|
Executor targetExecutor;
|
||||||
|
@ -203,8 +200,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
|
||||||
* @see #determineAsyncExecutor(Method)
|
* @see #determineAsyncExecutor(Method)
|
||||||
* @see #findQualifiedExecutor(BeanFactory, String)
|
* @see #findQualifiedExecutor(BeanFactory, String)
|
||||||
*/
|
*/
|
||||||
@Nullable
|
protected abstract @Nullable String getExecutorQualifier(Method method);
|
||||||
protected abstract String getExecutorQualifier(Method method);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a target executor for the given qualifier.
|
* Retrieve a target executor for the given qualifier.
|
||||||
|
@ -213,8 +209,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
|
||||||
* @since 4.2.6
|
* @since 4.2.6
|
||||||
* @see #getExecutorQualifier(Method)
|
* @see #getExecutorQualifier(Method)
|
||||||
*/
|
*/
|
||||||
@Nullable
|
protected @Nullable Executor findQualifiedExecutor(@Nullable BeanFactory beanFactory, String qualifier) {
|
||||||
protected Executor findQualifiedExecutor(@Nullable BeanFactory beanFactory, String qualifier) {
|
|
||||||
if (beanFactory == null) {
|
if (beanFactory == null) {
|
||||||
throw new IllegalStateException("BeanFactory must be set on " + getClass().getSimpleName() +
|
throw new IllegalStateException("BeanFactory must be set on " + getClass().getSimpleName() +
|
||||||
" to access qualified executor '" + qualifier + "'");
|
" to access qualified executor '" + qualifier + "'");
|
||||||
|
@ -234,8 +229,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
|
||||||
* @see #findQualifiedExecutor(BeanFactory, String)
|
* @see #findQualifiedExecutor(BeanFactory, String)
|
||||||
* @see #DEFAULT_TASK_EXECUTOR_BEAN_NAME
|
* @see #DEFAULT_TASK_EXECUTOR_BEAN_NAME
|
||||||
*/
|
*/
|
||||||
@Nullable
|
protected @Nullable Executor getDefaultExecutor(@Nullable BeanFactory beanFactory) {
|
||||||
protected Executor getDefaultExecutor(@Nullable BeanFactory beanFactory) {
|
|
||||||
if (beanFactory != null) {
|
if (beanFactory != null) {
|
||||||
try {
|
try {
|
||||||
// Search for TaskExecutor bean... not plain Executor since that would
|
// Search for TaskExecutor bean... not plain Executor since that would
|
||||||
|
@ -281,8 +275,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
|
||||||
* @param returnType the declared return type (potentially a {@link Future} variant)
|
* @param returnType the declared return type (potentially a {@link Future} variant)
|
||||||
* @return the execution result (potentially a corresponding {@link Future} handle)
|
* @return the execution result (potentially a corresponding {@link Future} handle)
|
||||||
*/
|
*/
|
||||||
@Nullable
|
protected @Nullable Object doSubmit(Callable<Object> task, AsyncTaskExecutor executor, Class<?> returnType) {
|
||||||
protected Object doSubmit(Callable<Object> task, AsyncTaskExecutor executor, Class<?> returnType) {
|
|
||||||
if (CompletableFuture.class.isAssignableFrom(returnType)) {
|
if (CompletableFuture.class.isAssignableFrom(returnType)) {
|
||||||
return executor.submitCompletable(task);
|
return executor.submitCompletable(task);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.aopalliance.intercept.MethodInterceptor;
|
import org.aopalliance.intercept.MethodInterceptor;
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.support.AopUtils;
|
import org.springframework.aop.support.AopUtils;
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
|
@ -31,7 +32,6 @@ import org.springframework.core.BridgeMethodResolver;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.core.task.AsyncTaskExecutor;
|
import org.springframework.core.task.AsyncTaskExecutor;
|
||||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AOP Alliance {@code MethodInterceptor} that processes method invocations
|
* AOP Alliance {@code MethodInterceptor} that processes method invocations
|
||||||
|
@ -97,9 +97,8 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport imple
|
||||||
* otherwise.
|
* otherwise.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
|
||||||
@SuppressWarnings("NullAway")
|
@SuppressWarnings("NullAway")
|
||||||
public Object invoke(final MethodInvocation invocation) throws Throwable {
|
public @Nullable Object invoke(final MethodInvocation invocation) throws Throwable {
|
||||||
Class<?> targetClass = (invocation.getThis() != null ? AopUtils.getTargetClass(invocation.getThis()) : null);
|
Class<?> targetClass = (invocation.getThis() != null ? AopUtils.getTargetClass(invocation.getThis()) : null);
|
||||||
final Method userMethod = BridgeMethodResolver.getMostSpecificMethod(invocation.getMethod(), targetClass);
|
final Method userMethod = BridgeMethodResolver.getMostSpecificMethod(invocation.getMethod(), targetClass);
|
||||||
|
|
||||||
|
@ -140,8 +139,7 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport imple
|
||||||
* @see #determineAsyncExecutor(Method)
|
* @see #determineAsyncExecutor(Method)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
protected @Nullable String getExecutorQualifier(Method method) {
|
||||||
protected String getExecutorQualifier(Method method) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,8 +152,7 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport imple
|
||||||
* @see #DEFAULT_TASK_EXECUTOR_BEAN_NAME
|
* @see #DEFAULT_TASK_EXECUTOR_BEAN_NAME
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
protected @Nullable Executor getDefaultExecutor(@Nullable BeanFactory beanFactory) {
|
||||||
protected Executor getDefaultExecutor(@Nullable BeanFactory beanFactory) {
|
|
||||||
Executor defaultExecutor = super.getDefaultExecutor(beanFactory);
|
Executor defaultExecutor = super.getDefaultExecutor(beanFactory);
|
||||||
return (defaultExecutor != null ? defaultExecutor : new SimpleAsyncTaskExecutor());
|
return (defaultExecutor != null ? defaultExecutor : new SimpleAsyncTaskExecutor());
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ import java.io.Serializable;
|
||||||
|
|
||||||
import org.aopalliance.intercept.MethodInterceptor;
|
import org.aopalliance.intercept.MethodInterceptor;
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.ConcurrencyThrottleSupport;
|
import org.springframework.util.ConcurrencyThrottleSupport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,8 +49,7 @@ public class ConcurrencyThrottleInterceptor extends ConcurrencyThrottleSupport
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object invoke(MethodInvocation methodInvocation) throws Throwable {
|
||||||
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
|
|
||||||
beforeAccess();
|
beforeAccess();
|
||||||
try {
|
try {
|
||||||
return methodInvocation.proceed();
|
return methodInvocation.proceed();
|
||||||
|
|
|
@ -22,8 +22,8 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.StopWatch;
|
import org.springframework.util.StopWatch;
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
package org.springframework.aop.interceptor;
|
package org.springframework.aop.interceptor;
|
||||||
|
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AOP Alliance {@code MethodInterceptor} that can be introduced in a chain
|
* AOP Alliance {@code MethodInterceptor} that can be introduced in a chain
|
||||||
|
@ -58,8 +57,7 @@ public class DebugInterceptor extends SimpleTraceInterceptor {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object invoke(MethodInvocation invocation) throws Throwable {
|
||||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
this.count++;
|
this.count++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.springframework.aop.interceptor;
|
||||||
|
|
||||||
import org.aopalliance.intercept.MethodInterceptor;
|
import org.aopalliance.intercept.MethodInterceptor;
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Advisor;
|
import org.springframework.aop.Advisor;
|
||||||
import org.springframework.aop.ProxyMethodInvocation;
|
import org.springframework.aop.ProxyMethodInvocation;
|
||||||
|
@ -25,7 +26,6 @@ import org.springframework.aop.support.DefaultIntroductionAdvisor;
|
||||||
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
||||||
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
|
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
|
||||||
import org.springframework.beans.factory.NamedBean;
|
import org.springframework.beans.factory.NamedBean;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenient methods for creating advisors that may be used when autoproxying beans
|
* Convenient methods for creating advisors that may be used when autoproxying beans
|
||||||
|
@ -110,8 +110,7 @@ public abstract class ExposeBeanNameAdvisors {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
|
||||||
if (!(mi instanceof ProxyMethodInvocation pmi)) {
|
if (!(mi instanceof ProxyMethodInvocation pmi)) {
|
||||||
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
|
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
|
||||||
}
|
}
|
||||||
|
@ -134,8 +133,7 @@ public abstract class ExposeBeanNameAdvisors {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
|
||||||
if (!(mi instanceof ProxyMethodInvocation pmi)) {
|
if (!(mi instanceof ProxyMethodInvocation pmi)) {
|
||||||
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
|
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,12 @@ import java.io.Serializable;
|
||||||
|
|
||||||
import org.aopalliance.intercept.MethodInterceptor;
|
import org.aopalliance.intercept.MethodInterceptor;
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.Advisor;
|
import org.springframework.aop.Advisor;
|
||||||
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
||||||
import org.springframework.core.NamedThreadLocal;
|
import org.springframework.core.NamedThreadLocal;
|
||||||
import org.springframework.core.PriorityOrdered;
|
import org.springframework.core.PriorityOrdered;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interceptor that exposes the current {@link org.aopalliance.intercept.MethodInvocation}
|
* Interceptor that exposes the current {@link org.aopalliance.intercept.MethodInvocation}
|
||||||
|
@ -89,8 +89,7 @@ public final class ExposeInvocationInterceptor implements MethodInterceptor, Pri
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
|
||||||
MethodInvocation oldInvocation = invocation.get();
|
MethodInvocation oldInvocation = invocation.get();
|
||||||
invocation.set(mi);
|
invocation.set(mi);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -3,9 +3,7 @@
|
||||||
* More specific interceptors can be found in corresponding
|
* More specific interceptors can be found in corresponding
|
||||||
* functionality packages, like "transaction" and "orm".
|
* functionality packages, like "transaction" and "orm".
|
||||||
*/
|
*/
|
||||||
@NonNullApi
|
@NullMarked
|
||||||
@NonNullFields
|
|
||||||
package org.springframework.aop.interceptor;
|
package org.springframework.aop.interceptor;
|
||||||
|
|
||||||
import org.springframework.lang.NonNullApi;
|
import org.jspecify.annotations.NullMarked;
|
||||||
import org.springframework.lang.NonNullFields;
|
|
||||||
|
|
|
@ -17,9 +17,7 @@
|
||||||
* <p>Spring AOP can be used programmatically or (preferably)
|
* <p>Spring AOP can be used programmatically or (preferably)
|
||||||
* integrated with the Spring IoC container.
|
* integrated with the Spring IoC container.
|
||||||
*/
|
*/
|
||||||
@NonNullApi
|
@NullMarked
|
||||||
@NonNullFields
|
|
||||||
package org.springframework.aop;
|
package org.springframework.aop;
|
||||||
|
|
||||||
import org.springframework.lang.NonNullApi;
|
import org.jspecify.annotations.NullMarked;
|
||||||
import org.springframework.lang.NonNullFields;
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue