Declare Advisor#isPerInstance() as default method
Includes INSTANCE constants on default factory classes. Closes gh-30614
This commit is contained in:
parent
2317bef021
commit
e210f08dce
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -62,8 +62,11 @@ public interface Advisor {
|
||||||
* Typical Advisor implementations always return {@code true}.
|
* Typical Advisor implementations always return {@code true}.
|
||||||
* Use singleton/prototype bean definitions or appropriate programmatic
|
* Use singleton/prototype bean definitions or appropriate programmatic
|
||||||
* proxy creation to ensure that Advisors have the correct lifecycle model.
|
* proxy creation to ensure that Advisors have the correct lifecycle model.
|
||||||
|
* <p>As of 6.0.10, the default implementation returns {@code true}.
|
||||||
* @return whether this advice is associated with a particular target instance
|
* @return whether this advice is associated with a particular target instance
|
||||||
*/
|
*/
|
||||||
boolean isPerInstance();
|
default boolean isPerInstance() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -67,11 +67,6 @@ public class AspectJPointcutAdvisor implements PointcutAdvisor, Ordered {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPerInstance() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Advice getAdvice() {
|
public Advice getAdvice() {
|
||||||
return this.advice;
|
return this.advice;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -91,11 +91,6 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPerInstance() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Advice getAdvice() {
|
public Advice getAdvice() {
|
||||||
return this.advice;
|
return this.advice;
|
||||||
|
|
|
@ -47,6 +47,13 @@ import org.springframework.lang.Nullable;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializable {
|
public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Singleton instance of this class.
|
||||||
|
* @since 6.0.10
|
||||||
|
*/
|
||||||
|
public static final DefaultAdvisorChainFactory INSTANCE = new DefaultAdvisorChainFactory();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Object> getInterceptorsAndDynamicInterceptionAdvice(
|
public List<Object> getInterceptorsAndDynamicInterceptionAdvice(
|
||||||
Advised config, Method method, @Nullable Class<?> targetClass) {
|
Advised config, Method method, @Nullable Class<?> targetClass) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -48,6 +48,12 @@ import org.springframework.util.ClassUtils;
|
||||||
*/
|
*/
|
||||||
public class DefaultAopProxyFactory implements AopProxyFactory, Serializable {
|
public class DefaultAopProxyFactory implements AopProxyFactory, Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Singleton instance of this class.
|
||||||
|
* @since 6.0.10
|
||||||
|
*/
|
||||||
|
public static final DefaultAopProxyFactory INSTANCE = new DefaultAopProxyFactory();
|
||||||
|
|
||||||
private static final long serialVersionUID = 7930414337282325166L;
|
private static final long serialVersionUID = 7930414337282325166L;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -44,7 +44,7 @@ public class ProxyCreatorSupport extends AdvisedSupport {
|
||||||
* Create a new ProxyCreatorSupport instance.
|
* Create a new ProxyCreatorSupport instance.
|
||||||
*/
|
*/
|
||||||
public ProxyCreatorSupport() {
|
public ProxyCreatorSupport() {
|
||||||
this.aopProxyFactory = new DefaultAopProxyFactory();
|
this.aopProxyFactory = DefaultAopProxyFactory.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -606,11 +606,6 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
throw new UnsupportedOperationException("Cannot invoke methods: " + this.message);
|
throw new UnsupportedOperationException("Cannot invoke methods: " + this.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPerInstance() {
|
|
||||||
throw new UnsupportedOperationException("Cannot invoke methods: " + this.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.message;
|
return this.message;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -58,22 +58,12 @@ public abstract class AbstractPointcutAdvisor implements PointcutAdvisor, Ordere
|
||||||
return Ordered.LOWEST_PRECEDENCE;
|
return Ordered.LOWEST_PRECEDENCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPerInstance() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object other) {
|
public boolean equals(@Nullable Object other) {
|
||||||
if (this == other) {
|
return (this == other || (other instanceof PointcutAdvisor otherAdvisor &&
|
||||||
return true;
|
ObjectUtils.nullSafeEquals(getAdvice(), otherAdvisor.getAdvice()) &&
|
||||||
}
|
ObjectUtils.nullSafeEquals(getPointcut(), otherAdvisor.getPointcut())));
|
||||||
if (!(other instanceof PointcutAdvisor otherAdvisor)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return (ObjectUtils.nullSafeEquals(getAdvice(), otherAdvisor.getAdvice()) &&
|
|
||||||
ObjectUtils.nullSafeEquals(getPointcut(), otherAdvisor.getPointcut()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -134,11 +134,6 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||||
return this.advice;
|
return this.advice;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPerInstance() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClassFilter getClassFilter() {
|
public ClassFilter getClassFilter() {
|
||||||
return this;
|
return this;
|
||||||
|
@ -152,13 +147,9 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object other) {
|
public boolean equals(@Nullable Object other) {
|
||||||
if (this == other) {
|
return (this == other || (other instanceof DefaultIntroductionAdvisor otherAdvisor &&
|
||||||
return true;
|
this.advice.equals(otherAdvisor.advice) &&
|
||||||
}
|
this.interfaces.equals(otherAdvisor.interfaces)));
|
||||||
if (!(other instanceof DefaultIntroductionAdvisor otherAdvisor)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return (this.advice.equals(otherAdvisor.advice) && this.interfaces.equals(otherAdvisor.interfaces));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -77,11 +77,6 @@ public abstract class StaticMethodMatcherPointcutAdvisor extends StaticMethodMat
|
||||||
return this.advice;
|
return this.advice;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPerInstance() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Pointcut getPointcut() {
|
public Pointcut getPointcut() {
|
||||||
return this;
|
return this;
|
||||||
|
|
Loading…
Reference in New Issue