Skip to content

Commit d434ef9

Browse files
committed
Polishing
Issue: SPR-11344
1 parent c406c56 commit d434ef9

File tree

4 files changed

+36
-32
lines changed

4 files changed

+36
-32
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 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.
@@ -19,9 +19,9 @@
1919
import java.lang.reflect.Method;
2020

2121
/**
22-
* A specialized type of MethodMatcher that takes into account introductions when
23-
* matching methods. If there are no introductions on the target class, a method
24-
* matcher may be able to optimize matching more effectively for example.
22+
* A specialized type of {@link MethodMatcher} that takes into account introductions
23+
* when matching methods. If there are no introductions on the target class,
24+
* a method matcher may be able to optimize matching more effectively for example.
2525
*
2626
* @author Adrian Colyer
2727
* @since 2.0
@@ -39,6 +39,6 @@ public interface IntroductionAwareMethodMatcher extends MethodMatcher {
3939
* asking is the subject on one or more introductions; {@code false} otherwise
4040
* @return whether or not this method matches statically
4141
*/
42-
boolean matches(Method method, Class targetClass, boolean hasIntroductions);
42+
boolean matches(Method method, Class<?> targetClass, boolean hasIntroductions);
4343

4444
}

spring-aop/src/main/java/org/springframework/aop/support/ClassFilters.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 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.
@@ -23,8 +23,7 @@
2323
import org.springframework.util.ObjectUtils;
2424

2525
/**
26-
* Static utility methods for composing
27-
* {@link org.springframework.aop.ClassFilter ClassFilters}.
26+
* Static utility methods for composing {@link ClassFilter ClassFilters}.
2827
*
2928
* @author Rod Johnson
3029
* @author Rob Harrop
@@ -96,9 +95,9 @@ public UnionClassFilter(ClassFilter[] filters) {
9695
this.filters = filters;
9796
}
9897

99-
public boolean matches(Class clazz) {
100-
for (int i = 0; i < this.filters.length; i++) {
101-
if (this.filters[i].matches(clazz)) {
98+
public boolean matches(Class<?> clazz) {
99+
for (ClassFilter filter : this.filters) {
100+
if (filter.matches(clazz)) {
102101
return true;
103102
}
104103
}
@@ -130,9 +129,9 @@ public IntersectionClassFilter(ClassFilter[] filters) {
130129
this.filters = filters;
131130
}
132131

133-
public boolean matches(Class clazz) {
134-
for (int i = 0; i < this.filters.length; i++) {
135-
if (!this.filters[i].matches(clazz)) {
132+
public boolean matches(Class<?> clazz) {
133+
for (ClassFilter filter : this.filters) {
134+
if (!filter.matches(clazz)) {
136135
return false;
137136
}
138137
}

spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@
2525
import org.springframework.util.Assert;
2626

2727
/**
28-
* Static utility methods for composing
29-
* {@link org.springframework.aop.MethodMatcher MethodMatchers}.
28+
* Static utility methods for composing {@link MethodMatcher MethodMatchers}.
3029
*
31-
* <p>A MethodMatcher may be evaluated statically (based on method
32-
* and target class) or need further evaluation dynamically
33-
* (based on arguments at the time of method invocation).
30+
* <p>A MethodMatcher may be evaluated statically (based on method and target
31+
* class) or need further evaluation dynamically (based on arguments at the
32+
* time of method invocation).
3433
*
3534
* @author Rod Johnson
3635
* @author Rob Harrop
@@ -88,7 +87,7 @@ public static MethodMatcher intersection(MethodMatcher mm1, MethodMatcher mm2) {
8887
* asking is the subject on one or more introductions; {@code false} otherwise
8988
* @return whether or not this method matches statically
9089
*/
91-
public static boolean matches(MethodMatcher mm, Method method, Class targetClass, boolean hasIntroductions) {
90+
public static boolean matches(MethodMatcher mm, Method method, Class<?> targetClass, boolean hasIntroductions) {
9291
Assert.notNull(mm, "MethodMatcher must not be null");
9392
return ((mm instanceof IntroductionAwareMethodMatcher &&
9493
((IntroductionAwareMethodMatcher) mm).matches(method, targetClass, hasIntroductions)) ||
@@ -113,29 +112,29 @@ public UnionMethodMatcher(MethodMatcher mm1, MethodMatcher mm2) {
113112
this.mm2 = mm2;
114113
}
115114

116-
public boolean matches(Method method, Class targetClass, boolean hasIntroductions) {
115+
public boolean matches(Method method, Class<?> targetClass, boolean hasIntroductions) {
117116
return (matchesClass1(targetClass) && MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions)) ||
118117
(matchesClass2(targetClass) && MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions));
119118
}
120119

121-
public boolean matches(Method method, Class targetClass) {
120+
public boolean matches(Method method, Class<?> targetClass) {
122121
return (matchesClass1(targetClass) && this.mm1.matches(method, targetClass)) ||
123122
(matchesClass2(targetClass) && this.mm2.matches(method, targetClass));
124123
}
125124

126-
protected boolean matchesClass1(Class targetClass) {
125+
protected boolean matchesClass1(Class<?> targetClass) {
127126
return true;
128127
}
129128

130-
protected boolean matchesClass2(Class targetClass) {
129+
protected boolean matchesClass2(Class<?> targetClass) {
131130
return true;
132131
}
133132

134133
public boolean isRuntime() {
135134
return this.mm1.isRuntime() || this.mm2.isRuntime();
136135
}
137136

138-
public boolean matches(Method method, Class targetClass, Object[] args) {
137+
public boolean matches(Method method, Class<?> targetClass, Object[] args) {
139138
return this.mm1.matches(method, targetClass, args) || this.mm2.matches(method, targetClass, args);
140139
}
141140

@@ -179,12 +178,12 @@ public ClassFilterAwareUnionMethodMatcher(MethodMatcher mm1, ClassFilter cf1, Me
179178
}
180179

181180
@Override
182-
protected boolean matchesClass1(Class targetClass) {
181+
protected boolean matchesClass1(Class<?> targetClass) {
183182
return this.cf1.matches(targetClass);
184183
}
185184

186185
@Override
187-
protected boolean matchesClass2(Class targetClass) {
186+
protected boolean matchesClass2(Class<?> targetClass) {
188187
return this.cf2.matches(targetClass);
189188
}
190189

@@ -225,20 +224,20 @@ public IntersectionMethodMatcher(MethodMatcher mm1, MethodMatcher mm2) {
225224
this.mm2 = mm2;
226225
}
227226

228-
public boolean matches(Method method, Class targetClass, boolean hasIntroductions) {
227+
public boolean matches(Method method, Class<?> targetClass, boolean hasIntroductions) {
229228
return MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions) &&
230229
MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions);
231230
}
232231

233-
public boolean matches(Method method, Class targetClass) {
232+
public boolean matches(Method method, Class<?> targetClass) {
234233
return this.mm1.matches(method, targetClass) && this.mm2.matches(method, targetClass);
235234
}
236235

237236
public boolean isRuntime() {
238237
return this.mm1.isRuntime() || this.mm2.isRuntime();
239238
}
240239

241-
public boolean matches(Method method, Class targetClass, Object[] args) {
240+
public boolean matches(Method method, Class<?> targetClass, Object[] args) {
242241
// Because a dynamic intersection may be composed of a static and dynamic part,
243242
// we must avoid calling the 3-arg matches method on a dynamic matcher, as
244243
// it will probably be an unsupported operation.

spring-context/src/test/java/org/springframework/aop/aspectj/TargetPointcutSelectionTests.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 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.
@@ -34,16 +34,21 @@
3434
public final class TargetPointcutSelectionTests {
3535

3636
public TestInterface testImpl1;
37+
3738
public TestInterface testImpl2;
39+
3840
public TestAspect testAspectForTestImpl1;
41+
3942
public TestAspect testAspectForAbstractTestImpl;
43+
4044
public TestInterceptor testInterceptor;
4145

4246

4347
@Before
4448
public void setUp() {
4549
ClassPathXmlApplicationContext ctx =
46-
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
50+
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
51+
4752
testImpl1 = (TestInterface) ctx.getBean("testImpl1");
4853
testImpl2 = (TestInterface) ctx.getBean("testImpl2");
4954
testAspectForTestImpl1 = (TestAspect) ctx.getBean("testAspectForTestImpl1");
@@ -55,6 +60,7 @@ public void setUp() {
5560
testInterceptor.count = 0;
5661
}
5762

63+
5864
@Test
5965
public void testTargetSelectionForMatchedType() {
6066
testImpl1.interfaceMethod();

0 commit comments

Comments
 (0)