Skip to content

Commit 64afc91

Browse files
committed
Polishing
1 parent 6f45a1a commit 64afc91

File tree

11 files changed

+47
-63
lines changed

11 files changed

+47
-63
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -327,10 +327,11 @@ private Callback[] getCallbacks(Class<?> rootClass) throws Exception {
327327

328328
// TODO: small memory optimization here (can skip creation for methods with no advice)
329329
for (int x = 0; x < methods.length; x++) {
330-
List<Object> chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(methods[x], rootClass);
330+
Method method = methods[x];
331+
List<Object> chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(method, rootClass);
331332
fixedCallbacks[x] = new FixedChainStaticTargetInterceptor(
332333
chain, this.advised.getTargetSource().getTarget(), this.advised.getTargetClass());
333-
this.fixedInterceptorMap.put(methods[x].toString(), x);
334+
this.fixedInterceptorMap.put(methods.toString(), x);
334335
}
335336

336337
// Now copy both the callbacks from mainCallbacks
@@ -633,8 +634,8 @@ public FixedChainStaticTargetInterceptor(
633634
@Override
634635
@Nullable
635636
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
636-
MethodInvocation invocation = new CglibMethodInvocation(proxy, this.target, method, args,
637-
this.targetClass, this.adviceChain, methodProxy);
637+
MethodInvocation invocation = new CglibMethodInvocation(
638+
proxy, this.target, method, args, this.targetClass, this.adviceChain, methodProxy);
638639
// If we get here, we need to create a MethodInvocation.
639640
Object retVal = invocation.proceed();
640641
retVal = processReturnType(proxy, this.target, method, retVal);
@@ -795,7 +796,7 @@ public ProxyCallbackFilter(
795796
* <dt>For advised methods:</dt>
796797
* <dd>If the target is static and the advice chain is frozen then a
797798
* FixedChainStaticTargetInterceptor specific to the method is used to
798-
* invoke the advice chain. Otherwise a DyanmicAdvisedInterceptor is
799+
* invoke the advice chain. Otherwise a DynamicAdvisedInterceptor is
799800
* used.</dd>
800801
* <dt>For non-advised methods:</dt>
801802
* <dd>Where it can be determined that the method will not return {@code this}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -68,7 +68,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
6868

6969
protected final Method method;
7070

71-
protected Object[] arguments = new Object[0];
71+
protected Object[] arguments;
7272

7373
@Nullable
7474
private final Class<?> targetClass;
@@ -158,7 +158,7 @@ public void setArguments(Object... arguments) {
158158
@Override
159159
@Nullable
160160
public Object proceed() throws Throwable {
161-
// We start with an index of -1 and increment early.
161+
// We start with an index of -1 and increment early.
162162
if (this.currentInterceptorIndex == this.interceptorsAndDynamicMethodMatchers.size() - 1) {
163163
return invokeJoinpoint();
164164
}

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -24,12 +24,15 @@
2424
import org.springframework.util.Assert;
2525

2626
/**
27-
* Convenient class for building up pointcuts. All methods return
28-
* ComposablePointcut, so we can use a concise idiom like:
27+
* Convenient class for building up pointcuts.
2928
*
30-
* {@code
31-
* Pointcut pc = new ComposablePointcut().union(classFilter).intersection(methodMatcher).intersection(pointcut);
32-
* }
29+
* <p>All methods return {@code ComposablePointcut}, so we can use concise idioms
30+
* like in the following example.
31+
*
32+
* <pre class="code">Pointcut pc = new ComposablePointcut()
33+
* .union(classFilter)
34+
* .intersection(methodMatcher)
35+
* .intersection(pointcut);</pre>
3336
*
3437
* @author Rod Johnson
3538
* @author Juergen Hoeller
@@ -199,7 +202,7 @@ public int hashCode() {
199202

200203
@Override
201204
public String toString() {
202-
return "ComposablePointcut: " + this.classFilter + ", " +this.methodMatcher;
205+
return "ComposablePointcut: " + this.classFilter + ", " + this.methodMatcher;
203206
}
204207

205208
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -39,7 +39,7 @@
3939
* @author Juergen Hoeller
4040
* @since 11.11.2003
4141
*/
42-
@SuppressWarnings({"serial" })
42+
@SuppressWarnings("serial")
4343
public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFilter, Ordered, Serializable {
4444

4545
private final Advice advice;
@@ -113,8 +113,8 @@ public void validateInterfaces() throws IllegalArgumentException {
113113
for (Class<?> ifc : this.interfaces) {
114114
if (this.advice instanceof DynamicIntroductionAdvice &&
115115
!((DynamicIntroductionAdvice) this.advice).implementsInterface(ifc)) {
116-
throw new IllegalArgumentException("DynamicIntroductionAdvice [" + this.advice + "] " +
117-
"does not implement interface [" + ifc.getName() + "] specified for introduction");
116+
throw new IllegalArgumentException("DynamicIntroductionAdvice [" + this.advice + "] " +
117+
"does not implement interface [" + ifc.getName() + "] specified for introduction");
118118
}
119119
}
120120
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -26,8 +26,9 @@
2626
import org.springframework.util.PatternMatchUtils;
2727

2828
/**
29-
* Pointcut bean for simple method name matches, as alternative to regexp patterns.
30-
* Does not handle overloaded methods: all methods with a given name will be eligible.
29+
* Pointcut bean for simple method name matches, as an alternative to regexp patterns.
30+
*
31+
* <p>Does not handle overloaded methods: all methods with a given name will be eligible.
3132
*
3233
* @author Juergen Hoeller
3334
* @author Rod Johnson

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -27,7 +27,8 @@
2727
/**
2828
* Pointcut constants for matching getters and setters,
2929
* and static methods useful for manipulating and evaluating pointcuts.
30-
* These methods are particularly useful for composing pointcuts
30+
*
31+
* <p>These methods are particularly useful for composing pointcuts
3132
* using the union and intersection methods.
3233
*
3334
* @author Rod Johnson

spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMatchingPointcut.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -62,7 +62,7 @@ public AnnotationMatchingPointcut(Class<? extends Annotation> classAnnotationTyp
6262
}
6363

6464
/**
65-
* Create a new AnnotationMatchingPointcut for the given annotation type.
65+
* Create a new AnnotationMatchingPointcut for the given annotation types.
6666
* @param classAnnotationType the annotation type to look for at the class level
6767
* (can be {@code null})
6868
* @param methodAnnotationType the annotation type to look for at the method level
@@ -75,7 +75,7 @@ public AnnotationMatchingPointcut(@Nullable Class<? extends Annotation> classAnn
7575
}
7676

7777
/**
78-
* Create a new AnnotationMatchingPointcut for the given annotation type.
78+
* Create a new AnnotationMatchingPointcut for the given annotation types.
7979
* @param classAnnotationType the annotation type to look for at the class level
8080
* (can be {@code null})
8181
* @param methodAnnotationType the annotation type to look for at the method level
@@ -138,7 +138,7 @@ public int hashCode() {
138138

139139
@Override
140140
public String toString() {
141-
return "AnnotationMatchingPointcut: " + this.classFilter + ", " +this.methodMatcher;
141+
return "AnnotationMatchingPointcut: " + this.classFilter + ", " + this.methodMatcher;
142142
}
143143

144144

spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -139,9 +139,10 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
139139

140140

141141
/**
142-
* Create a new AutowiredAnnotationBeanPostProcessor
143-
* for Spring's standard {@link Autowired} annotation.
144-
* <p>Also supports JSR-330's {@link javax.inject.Inject} annotation, if available.
142+
* Create a new {@code AutowiredAnnotationBeanPostProcessor} for Spring's
143+
* standard {@link Autowired @Autowired} annotation.
144+
* <p>Also supports JSR-330's {@link javax.inject.Inject @Inject} annotation,
145+
* if available.
145146
*/
146147
@SuppressWarnings("unchecked")
147148
public AutowiredAnnotationBeanPostProcessor() {
@@ -236,7 +237,7 @@ public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, C
236237
public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, final String beanName)
237238
throws BeanCreationException {
238239

239-
// Let's check for lookup methods here..
240+
// Let's check for lookup methods here...
240241
if (!this.lookupMethodsChecked.contains(beanName)) {
241242
try {
242243
ReflectionUtils.doWithMethods(beanClass, method -> {
@@ -245,7 +246,8 @@ public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, final
245246
Assert.state(this.beanFactory != null, "No BeanFactory available");
246247
LookupOverride override = new LookupOverride(method, lookup.value());
247248
try {
248-
RootBeanDefinition mbd = (RootBeanDefinition) this.beanFactory.getMergedBeanDefinition(beanName);
249+
RootBeanDefinition mbd = (RootBeanDefinition)
250+
this.beanFactory.getMergedBeanDefinition(beanName);
249251
mbd.getMethodOverrides().addOverride(override);
250252
}
251253
catch (NoSuchBeanDefinitionException ex) {

spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public MethodOverrideCallbackFilter(RootBeanDefinition beanDefinition) {
249249
public int accept(Method method) {
250250
MethodOverride methodOverride = getBeanDefinition().getMethodOverrides().getOverride(method);
251251
if (logger.isTraceEnabled()) {
252-
logger.trace("Override for '" + method.getName() + "' is [" + methodOverride + "]");
252+
logger.trace("MethodOverride for " + method + ": " + methodOverride);
253253
}
254254
if (methodOverride == null) {
255255
return PASSTHROUGH;

spring-core/src/main/java/org/springframework/core/annotation/AnnotationAttributes.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -369,26 +369,6 @@ private void assertAttributeType(String attributeName, Object attributeValue, Cl
369369
}
370370
}
371371

372-
/**
373-
* Store the supplied {@code value} in this map under the specified
374-
* {@code key}, unless a value is already stored under the key.
375-
* @param key the key under which to store the value
376-
* @param value the value to store
377-
* @return the current value stored in this map, or {@code null} if no
378-
* value was previously stored in this map
379-
* @see #get
380-
* @see #put
381-
* @since 4.2
382-
*/
383-
@Override
384-
public Object putIfAbsent(String key, Object value) {
385-
Object obj = get(key);
386-
if (obj == null) {
387-
obj = put(key, value);
388-
}
389-
return obj;
390-
}
391-
392372
@Override
393373
public String toString() {
394374
Iterator<Map.Entry<String, Object>> entries = entrySet().iterator();

0 commit comments

Comments
 (0)