Break out of loop once an AspectJ advice has been found
Closes gh-22449
This commit is contained in:
parent
f07014ad37
commit
cb54f201c2
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -27,27 +27,31 @@ import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
|
|||
*
|
||||
* @author Rod Johnson
|
||||
* @author Ramnivas Laddad
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.0
|
||||
*/
|
||||
public abstract class AspectJProxyUtils {
|
||||
|
||||
/**
|
||||
* Add special advisors if necessary to work with a proxy chain that contains AspectJ advisors.
|
||||
* This will expose the current Spring AOP invocation (necessary for some AspectJ pointcut matching)
|
||||
* and make available the current AspectJ JoinPoint. The call will have no effect if there are no
|
||||
* AspectJ advisors in the advisor chain.
|
||||
* Add special advisors if necessary to work with a proxy chain that contains AspectJ advisors:
|
||||
* concretely, {@link ExposeInvocationInterceptor} at the beginning of the list.
|
||||
* <p>This will expose the current Spring AOP invocation (necessary for some AspectJ pointcut
|
||||
* matching) and make available the current AspectJ JoinPoint. The call will have no effect
|
||||
* if there are no AspectJ advisors in the advisor chain.
|
||||
* @param advisors the advisors available
|
||||
* @return {@code true} if any special {@link Advisor Advisors} were added, otherwise {@code false}
|
||||
* @return {@code true} if an {@link ExposeInvocationInterceptor} was added to the list,
|
||||
* otherwise {@code false}
|
||||
*/
|
||||
public static boolean makeAdvisorChainAspectJCapableIfNecessary(List<Advisor> advisors) {
|
||||
// Don't add advisors to an empty list; may indicate that proxying is just not required
|
||||
if (!advisors.isEmpty()) {
|
||||
boolean foundAspectJAdvice = false;
|
||||
for (Advisor advisor : advisors) {
|
||||
// Be careful not to get the Advice without a guard, as
|
||||
// this might eagerly instantiate a non-singleton AspectJ aspect
|
||||
// Be careful not to get the Advice without a guard, as this might eagerly
|
||||
// instantiate a non-singleton AspectJ aspect...
|
||||
if (isAspectJAdvice(advisor)) {
|
||||
foundAspectJAdvice = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundAspectJAdvice && !advisors.contains(ExposeInvocationInterceptor.ADVISOR)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue