Skip to content

Commit edd1e91

Browse files
committed
Polishing
1 parent fef3cf8 commit edd1e91

File tree

7 files changed

+101
-96
lines changed

7 files changed

+101
-96
lines changed

spring-aop/src/main/java/org/springframework/aop/ClassFilter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,11 +17,11 @@
1717
package org.springframework.aop;
1818

1919
/**
20-
* Filter that restricts matching of a pointcut or introduction to
21-
* a given set of target classes.
20+
* Filter that restricts matching of a pointcut or introduction to a given set
21+
* of target classes.
2222
*
23-
* <p>Can be used as part of a {@link Pointcut} or for the entire
24-
* targeting of an {@link IntroductionAdvisor}.
23+
* <p>Can be used as part of a {@link Pointcut} or for the entire targeting of
24+
* an {@link IntroductionAdvisor}.
2525
*
2626
* <p>Concrete implementations of this interface typically should provide proper
2727
* implementations of {@link Object#equals(Object)} and {@link Object#hashCode()}
@@ -44,7 +44,7 @@ public interface ClassFilter {
4444

4545

4646
/**
47-
* Canonical instance of a ClassFilter that matches all classes.
47+
* Canonical instance of a {@code ClassFilter} that matches all classes.
4848
*/
4949
ClassFilter TRUE = TrueClassFilter.INSTANCE;
5050

spring-aop/src/main/java/org/springframework/aop/MethodMatcher.java

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,24 +21,25 @@
2121
/**
2222
* Part of a {@link Pointcut}: Checks whether the target method is eligible for advice.
2323
*
24-
* <p>A MethodMatcher may be evaluated <b>statically</b> or at <b>runtime</b> (dynamically).
25-
* Static matching involves method and (possibly) method attributes. Dynamic matching
26-
* also makes arguments for a particular call available, and any effects of running
27-
* previous advice applying to the joinpoint.
24+
* <p>A {@code MethodMatcher} may be evaluated <b>statically</b> or at <b>runtime</b>
25+
* (dynamically). Static matching involves a method and (possibly) method attributes.
26+
* Dynamic matching also makes arguments for a particular call available, and any
27+
* effects of running previous advice applying to the joinpoint.
2828
*
2929
* <p>If an implementation returns {@code false} from its {@link #isRuntime()}
3030
* method, evaluation can be performed statically, and the result will be the same
3131
* for all invocations of this method, whatever their arguments. This means that
3232
* if the {@link #isRuntime()} method returns {@code false}, the 3-arg
33-
* {@link #matches(java.lang.reflect.Method, Class, Object[])} method will never be invoked.
33+
* {@link #matches(Method, Class, Object[])} method will never be invoked.
3434
*
3535
* <p>If an implementation returns {@code true} from its 2-arg
36-
* {@link #matches(java.lang.reflect.Method, Class)} method and its {@link #isRuntime()} method
37-
* returns {@code true}, the 3-arg {@link #matches(java.lang.reflect.Method, Class, Object[])}
38-
* method will be invoked <i>immediately before each potential execution of the related advice</i>,
39-
* to decide whether the advice should run. All previous advice, such as earlier interceptors
40-
* in an interceptor chain, will have run, so any state changes they have produced in
41-
* parameters or ThreadLocal state will be available at the time of evaluation.
36+
* {@link #matches(Method, Class)} method and its {@link #isRuntime()} method
37+
* returns {@code true}, the 3-arg {@link #matches(Method, Class, Object[])}
38+
* method will be invoked <i>immediately before each potential execution of the
39+
* related advice</i> to decide whether the advice should run. All previous advice,
40+
* such as earlier interceptors in an interceptor chain, will have run, so any
41+
* state changes they have produced in parameters or {@code ThreadLocal} state will
42+
* be available at the time of evaluation.
4243
*
4344
* <p>Concrete implementations of this interface typically should provide proper
4445
* implementations of {@link Object#equals(Object)} and {@link Object#hashCode()}
@@ -53,48 +54,46 @@
5354
public interface MethodMatcher {
5455

5556
/**
56-
* Perform static checking whether the given method matches.
57-
* <p>If this returns {@code false} or if the {@link #isRuntime()}
58-
* method returns {@code false}, no runtime check (i.e. no
59-
* {@link #matches(java.lang.reflect.Method, Class, Object[])} call)
60-
* will be made.
57+
* Perform static checking to determine whether the given method matches.
58+
* <p>If this method returns {@code false} or if {@link #isRuntime()}
59+
* returns {@code false}, no runtime check (i.e. no
60+
* {@link #matches(Method, Class, Object[])} call) will be made.
6161
* @param method the candidate method
6262
* @param targetClass the target class
6363
* @return whether this method matches statically
6464
*/
6565
boolean matches(Method method, Class<?> targetClass);
6666

6767
/**
68-
* Is this MethodMatcher dynamic, that is, must a final call be made on the
69-
* {@link #matches(java.lang.reflect.Method, Class, Object[])} method at
70-
* runtime even if the 2-arg matches method returns {@code true}?
68+
* Is this {@code MethodMatcher} dynamic, that is, must a final check be made
69+
* via the {@link #matches(Method, Class, Object[])} method at runtime even
70+
* if {@link #matches(Method, Class)} returns {@code true}?
7171
* <p>Can be invoked when an AOP proxy is created, and need not be invoked
72-
* again before each method invocation,
73-
* @return whether a runtime match via the 3-arg
74-
* {@link #matches(java.lang.reflect.Method, Class, Object[])} method
72+
* again before each method invocation.
73+
* @return whether a runtime match via {@link #matches(Method, Class, Object[])}
7574
* is required if static matching passed
7675
*/
7776
boolean isRuntime();
7877

7978
/**
80-
* Check whether there a runtime (dynamic) match for this method,
81-
* which must have matched statically.
82-
* <p>This method is invoked only if the 2-arg matches method returns
83-
* {@code true} for the given method and target class, and if the
84-
* {@link #isRuntime()} method returns {@code true}. Invoked
85-
* immediately before potential running of the advice, after any
79+
* Check whether there is a runtime (dynamic) match for this method, which
80+
* must have matched statically.
81+
* <p>This method is invoked only if {@link #matches(Method, Class)} returns
82+
* {@code true} for the given method and target class, and if
83+
* {@link #isRuntime()} returns {@code true}.
84+
* <p>Invoked immediately before potential running of the advice, after any
8685
* advice earlier in the advice chain has run.
8786
* @param method the candidate method
8887
* @param targetClass the target class
8988
* @param args arguments to the method
9089
* @return whether there's a runtime match
91-
* @see MethodMatcher#matches(Method, Class)
90+
* @see #matches(Method, Class)
9291
*/
9392
boolean matches(Method method, Class<?> targetClass, Object... args);
9493

9594

9695
/**
97-
* Canonical instance that matches all methods.
96+
* Canonical instance of a {@code MethodMatcher} that matches all methods.
9897
*/
9998
MethodMatcher TRUE = TrueMethodMatcher.INSTANCE;
10099

spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJPointcutAdvisor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.springframework.util.Assert;
2626

2727
/**
28-
* AspectJPointcutAdvisor that adapts an {@link AbstractAspectJAdvice}
28+
* AspectJ {@link PointcutAdvisor} that adapts an {@link AbstractAspectJAdvice}
2929
* to the {@link org.springframework.aop.PointcutAdvisor} interface.
3030
*
3131
* @author Adrian Colyer

spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,17 @@
4848

4949
/**
5050
* Base class for AOP proxy configuration managers.
51-
* These are not themselves AOP proxies, but subclasses of this class are
51+
*
52+
* <p>These are not themselves AOP proxies, but subclasses of this class are
5253
* normally factories from which AOP proxy instances are obtained directly.
5354
*
5455
* <p>This class frees subclasses of the housekeeping of Advices
5556
* and Advisors, but doesn't actually implement proxy creation
5657
* methods, which are provided by subclasses.
5758
*
5859
* <p>This class is serializable; subclasses need not be.
59-
* This class is used to hold snapshots of proxies.
60+
*
61+
* <p>This class is used to hold snapshots of proxies.
6062
*
6163
* @author Rod Johnson
6264
* @author Juergen Hoeller
@@ -111,7 +113,7 @@ public AdvisedSupport() {
111113
}
112114

113115
/**
114-
* Create a AdvisedSupport instance with the given parameters.
116+
* Create an {@code AdvisedSupport} instance with the given parameters.
115117
* @param interfaces the proxied interfaces
116118
*/
117119
public AdvisedSupport(Class<?>... interfaces) {
@@ -131,7 +133,7 @@ private AdvisedSupport(AdvisorChainFactory advisorChainFactory, Map<MethodCacheK
131133

132134
/**
133135
* Set the given object as target.
134-
* Will create a SingletonTargetSource for the object.
136+
* <p>Will create a SingletonTargetSource for the object.
135137
* @see #setTargetSource
136138
* @see org.springframework.aop.target.SingletonTargetSource
137139
*/
@@ -506,9 +508,9 @@ protected void copyConfigurationFrom(AdvisedSupport other) {
506508
}
507509

508510
/**
509-
* Copy the AOP configuration from the given AdvisedSupport object,
510-
* but allow substitution of a fresh TargetSource and a given interceptor chain.
511-
* @param other the AdvisedSupport object to take proxy configuration from
511+
* Copy the AOP configuration from the given {@link AdvisedSupport} object,
512+
* but allow substitution of a fresh {@link TargetSource} and a given interceptor chain.
513+
* @param other the {@code AdvisedSupport} object to take proxy configuration from
512514
* @param targetSource the new TargetSource
513515
* @param advisors the Advisors for the chain
514516
*/
@@ -528,8 +530,8 @@ protected void copyConfigurationFrom(AdvisedSupport other, TargetSource targetSo
528530
}
529531

530532
/**
531-
* Build a configuration-only copy of this AdvisedSupport,
532-
* replacing the TargetSource.
533+
* Build a configuration-only copy of this {@link AdvisedSupport},
534+
* replacing the {@link TargetSource}.
533535
*/
534536
AdvisedSupport getConfigurationOnlyCopy() {
535537
AdvisedSupport copy = new AdvisedSupport(this.advisorChainFactory, this.methodCache);
@@ -604,8 +606,7 @@ public MethodCacheKey(Method method) {
604606

605607
@Override
606608
public boolean equals(@Nullable Object other) {
607-
return (this == other || (other instanceof MethodCacheKey methodCacheKey &&
608-
this.method == methodCacheKey.method));
609+
return (this == other || (other instanceof MethodCacheKey that && this.method == that.method));
609610
}
610611

611612
@Override
@@ -630,7 +631,7 @@ public int compareTo(MethodCacheKey other) {
630631

631632

632633
/**
633-
* Stub for an Advisor instance that is just needed for key purposes,
634+
* Stub for an {@link Advisor} instance that is just needed for key purposes,
634635
* allowing for efficient equals and hashCode comparisons against the
635636
* advice class and the pointcut.
636637
* @since 6.0.10
@@ -642,10 +643,11 @@ private static class AdvisorKeyEntry implements Advisor {
642643
private final Class<?> adviceType;
643644

644645
@Nullable
645-
private String classFilterKey;
646+
private final String classFilterKey;
646647

647648
@Nullable
648-
private String methodMatcherKey;
649+
private final String methodMatcherKey;
650+
649651

650652
public AdvisorKeyEntry(Advisor advisor) {
651653
this.adviceType = advisor.getAdvice().getClass();
@@ -654,6 +656,10 @@ public AdvisorKeyEntry(Advisor advisor) {
654656
this.classFilterKey = ObjectUtils.identityToString(pointcut.getClassFilter());
655657
this.methodMatcherKey = ObjectUtils.identityToString(pointcut.getMethodMatcher());
656658
}
659+
else {
660+
this.classFilterKey = null;
661+
this.methodMatcherKey = null;
662+
}
657663
}
658664

659665
@Override
@@ -663,10 +669,10 @@ public Advice getAdvice() {
663669

664670
@Override
665671
public boolean equals(Object other) {
666-
return (this == other || (other instanceof AdvisorKeyEntry otherEntry &&
667-
this.adviceType == otherEntry.adviceType &&
668-
ObjectUtils.nullSafeEquals(this.classFilterKey, otherEntry.classFilterKey) &&
669-
ObjectUtils.nullSafeEquals(this.methodMatcherKey, otherEntry.methodMatcherKey)));
672+
return (this == other || (other instanceof AdvisorKeyEntry that &&
673+
this.adviceType == that.adviceType &&
674+
ObjectUtils.nullSafeEquals(this.classFilterKey, that.classFilterKey) &&
675+
ObjectUtils.nullSafeEquals(this.methodMatcherKey, that.methodMatcherKey)));
670676
}
671677

672678
@Override

spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationSourcePointcut.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.springframework.util.ObjectUtils;
2828

2929
/**
30-
* A Pointcut that matches if the underlying {@link CacheOperationSource}
30+
* A {@code Pointcut} that matches if the underlying {@link CacheOperationSource}
3131
* has an attribute for a given method.
3232
*
3333
* @author Costin Leau

spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAttributeSourcePointcut.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.springframework.util.ObjectUtils;
2828

2929
/**
30-
* Abstract class that implements a Pointcut that matches if the underlying
30+
* Abstract class that implements a {@code Pointcut} that matches if the underlying
3131
* {@link TransactionAttributeSource} has an attribute for a given method.
3232
*
3333
* @author Juergen Hoeller

0 commit comments

Comments
 (0)