Skip to content

Commit 3ec8080

Browse files
committed
Polishing
1 parent 581b567 commit 3ec8080

File tree

8 files changed

+104
-92
lines changed

8 files changed

+104
-92
lines changed

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

Lines changed: 2 additions & 3 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.
@@ -26,7 +26,7 @@
2626

2727
/**
2828
* Objenesis-based extension of {@link CglibAopProxy} to create proxy instances
29-
* without invoking the constructor of the class.
29+
* without invoking the constructor of the class. Used by default as of Spring 4.
3030
*
3131
* @author Oliver Gierke
3232
* @author Juergen Hoeller
@@ -50,7 +50,6 @@ public ObjenesisCglibAopProxy(AdvisedSupport config) {
5050

5151

5252
@Override
53-
@SuppressWarnings("unchecked")
5453
protected Object createProxyClassAndInstance(Enhancer enhancer, Callback[] callbacks) {
5554
Class<?> proxyClass = enhancer.createClass();
5655
Object proxyInstance = null;

spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractJCacheOperation.java

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 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.
@@ -19,6 +19,7 @@
1919
import java.lang.annotation.Annotation;
2020
import java.lang.reflect.Method;
2121
import java.util.ArrayList;
22+
import java.util.Arrays;
2223
import java.util.Collections;
2324
import java.util.LinkedHashSet;
2425
import java.util.List;
@@ -32,8 +33,6 @@
3233
import org.springframework.util.Assert;
3334
import org.springframework.util.ExceptionTypeFilter;
3435

35-
import static java.util.Arrays.*;
36-
3736
/**
3837
* A base {@link JCacheOperation} implementation.
3938
*
@@ -50,24 +49,27 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
5049

5150

5251
/**
53-
* Create a new instance.
52+
* Construct a new {@code AbstractJCacheOperation}.
5453
* @param methodDetails the {@link CacheMethodDetails} related to the cached method
5554
* @param cacheResolver the cache resolver to resolve regular caches
5655
*/
5756
protected AbstractJCacheOperation(CacheMethodDetails<A> methodDetails, CacheResolver cacheResolver) {
58-
Assert.notNull(methodDetails, "method details must not be null.");
59-
Assert.notNull(cacheResolver, "cache resolver must not be null.");
57+
Assert.notNull(methodDetails, "CacheMethodDetails must not be null");
58+
Assert.notNull(cacheResolver, "CacheResolver must not be null");
6059
this.methodDetails = methodDetails;
6160
this.cacheResolver = cacheResolver;
6261
this.allParameterDetails = initializeAllParameterDetails(methodDetails.getMethod());
6362
}
6463

65-
66-
/**
67-
* Return the {@link ExceptionTypeFilter} to use to filter exceptions thrown while
68-
* invoking the method.
69-
*/
70-
public abstract ExceptionTypeFilter getExceptionTypeFilter();
64+
private static List<CacheParameterDetail> initializeAllParameterDetails(Method method) {
65+
int parameterCount = method.getParameterTypes().length;
66+
List<CacheParameterDetail> result = new ArrayList<CacheParameterDetail>(parameterCount);
67+
for (int i = 0; i < parameterCount; i++) {
68+
CacheParameterDetail detail = new CacheParameterDetail(method, i);
69+
result.add(detail);
70+
}
71+
return result;
72+
}
7173

7274

7375
@Override
@@ -113,12 +115,25 @@ public CacheInvocationParameter[] getAllParameters(Object... values) {
113115
return result.toArray(new CacheInvocationParameter[result.size()]);
114116
}
115117

118+
119+
/**
120+
* Return the {@link ExceptionTypeFilter} to use to filter exceptions thrown while
121+
* invoking the method.
122+
* @see #createExceptionTypeFilter
123+
*/
124+
public abstract ExceptionTypeFilter getExceptionTypeFilter();
125+
126+
/**
127+
* Convenience method for subclasses to create a specific {@code ExceptionTypeFilter}.
128+
* @see #getExceptionTypeFilter()
129+
*/
116130
protected ExceptionTypeFilter createExceptionTypeFilter(
117131
Class<? extends Throwable>[] includes, Class<? extends Throwable>[] excludes) {
118132

119-
return new ExceptionTypeFilter(asList(includes), asList(excludes), true);
133+
return new ExceptionTypeFilter(Arrays.asList(includes), Arrays.asList(excludes), true);
120134
}
121135

136+
122137
@Override
123138
public String toString() {
124139
return getOperationDescription().append("]").toString();
@@ -137,16 +152,9 @@ protected StringBuilder getOperationDescription() {
137152
}
138153

139154

140-
private static List<CacheParameterDetail> initializeAllParameterDetails(Method method) {
141-
List<CacheParameterDetail> result = new ArrayList<CacheParameterDetail>();
142-
for (int i = 0; i < method.getParameterTypes().length; i++) {
143-
CacheParameterDetail detail = new CacheParameterDetail(method, i);
144-
result.add(detail);
145-
}
146-
return result;
147-
}
148-
149-
155+
/**
156+
* Details for a single cache parameter.
157+
*/
150158
protected static class CacheParameterDetail {
151159

152160
private final Class<?> rawType;
@@ -196,6 +204,9 @@ public CacheInvocationParameter toCacheInvocationParameter(Object value) {
196204
}
197205

198206

207+
/**
208+
* A single cache invocation parameter.
209+
*/
199210
protected static class CacheInvocationParameterImpl implements CacheInvocationParameter {
200211

201212
private final CacheParameterDetail detail;

spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheOperation.java

Lines changed: 6 additions & 5 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.
@@ -24,9 +24,10 @@
2424
import org.springframework.cache.interceptor.CacheResolver;
2525

2626
/**
27-
* Model the base of JSR-107 cache operation.
28-
* <p>A cache operation can be statically cached as it does not contain
29-
* any runtime operation of a specific cache invocation.
27+
* Model the base of JSR-107 cache operation through an interface contract.
28+
*
29+
* <p>A cache operation can be statically cached as it does not contain any
30+
* runtime operation of a specific cache invocation.
3031
*
3132
* @author Stephane Nicoll
3233
* @since 4.1
@@ -48,4 +49,4 @@ public interface JCacheOperation<A extends Annotation> extends BasicOperation, C
4849
*/
4950
CacheInvocationParameter[] getAllParameters(Object... values);
5051

51-
}
52+
}

spring-context/src/main/java/org/springframework/context/ResourceLoaderAware.java

Lines changed: 29 additions & 29 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-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.
@@ -20,44 +20,44 @@
2020
import org.springframework.core.io.ResourceLoader;
2121

2222
/**
23-
* Interface to be implemented by any object that wishes to be notified of
24-
* the <b>ResourceLoader</b> (typically the ApplicationContext) that it runs in.
25-
* This is an alternative to a full ApplicationContext dependency via the
26-
* ApplicationContextAware interface.
23+
* Interface to be implemented by any object that wishes to be notified of the
24+
* {@link ResourceLoader} (typically the ApplicationContext) that it runs in.
25+
* This is an alternative to a full {@link ApplicationContext} dependency via
26+
* the {@link org.springframework.context.ApplicationContextAware} interface.
2727
*
28-
* <p>Note that Resource dependencies can also be exposed as bean properties
29-
* of type Resource, populated via Strings with automatic type conversion by
30-
* the bean factory. This removes the need for implementing any callback
31-
* interface just for the purpose of accessing a specific file resource.
28+
* <p>Note that {@link org.springframework.core.io.Resource} dependencies can also
29+
* be exposed as bean properties of type {@code Resource}, populated via Strings
30+
* with automatic type conversion by the bean factory. This removes the need for
31+
* implementing any callback interface just for the purpose of accessing a
32+
* specific file resource.
3233
*
33-
* <p>You typically need a ResourceLoader when your application object has
34-
* to access a variety of file resources whose names are calculated. A good
35-
* strategy is to make the object use a DefaultResourceLoader but still
36-
* implement ResourceLoaderAware to allow for overriding when running in an
37-
* ApplicationContext. See ReloadableResourceBundleMessageSource for an example.
34+
* <p>You typically need a {@link ResourceLoader} when your application object has to
35+
* access a variety of file resources whose names are calculated. A good strategy is
36+
* to make the object use a {@link org.springframework.core.io.DefaultResourceLoader}
37+
* but still implement {@code ResourceLoaderAware} to allow for overriding when
38+
* running in an {@code ApplicationContext}. See
39+
* {@link org.springframework.context.support.ReloadableResourceBundleMessageSource}
40+
* for an example.
3841
*
39-
* <p>A passed-in ResourceLoader can also be checked for the
40-
* <b>ResourcePatternResolver</b> interface and cast accordingly, to be able
41-
* to resolve resource patterns into arrays of Resource objects. This will always
42-
* work when running in an ApplicationContext (the context interface extends
43-
* ResourcePatternResolver). Use a PathMatchingResourcePatternResolver as default.
44-
* See also the {@code ResourcePatternUtils.getResourcePatternResolver} method.
42+
* <p>A passed-in {@code ResourceLoader} can also be checked for the
43+
* {@link org.springframework.core.io.support.ResourcePatternResolver} interface
44+
* and cast accordingly, in order to resolve resource patterns into arrays of
45+
* {@code Resource} objects. This will always work when running in an ApplicationContext
46+
* (since the context interface extends the ResourcePatternResolver interface). Use a
47+
* {@link org.springframework.core.io.support.PathMatchingResourcePatternResolver} as
48+
* default; see also the {@code ResourcePatternUtils.getResourcePatternResolver} method.
4549
*
46-
* <p>As alternative to a ResourcePatternResolver dependency, consider exposing
47-
* bean properties of type Resource array, populated via pattern Strings with
48-
* automatic type conversion by the bean factory.
50+
* <p>As an alternative to a {@code ResourcePatternResolver} dependency, consider
51+
* exposing bean properties of type {@code Resource} array, populated via pattern
52+
* Strings with automatic type conversion by the bean factory at binding time.
4953
*
5054
* @author Juergen Hoeller
5155
* @author Chris Beams
5256
* @since 10.03.2004
5357
* @see ApplicationContextAware
54-
* @see org.springframework.beans.factory.InitializingBean
5558
* @see org.springframework.core.io.Resource
59+
* @see org.springframework.core.io.ResourceLoader
5660
* @see org.springframework.core.io.support.ResourcePatternResolver
57-
* @see org.springframework.core.io.support.ResourcePatternUtils#getResourcePatternResolver
58-
* @see org.springframework.core.io.DefaultResourceLoader
59-
* @see org.springframework.core.io.support.PathMatchingResourcePatternResolver
60-
* @see org.springframework.context.support.ReloadableResourceBundleMessageSource
6161
*/
6262
public interface ResourceLoaderAware extends Aware {
6363

@@ -69,7 +69,7 @@ public interface ResourceLoaderAware extends Aware {
6969
* <p>Invoked after population of normal bean properties but before an init callback
7070
* like InitializingBean's {@code afterPropertiesSet} or a custom init-method.
7171
* Invoked before ApplicationContextAware's {@code setApplicationContext}.
72-
* @param resourceLoader ResourceLoader object to be used by this object
72+
* @param resourceLoader the ResourceLoader object to be used by this object
7373
* @see org.springframework.core.io.support.ResourcePatternResolver
7474
* @see org.springframework.core.io.support.ResourcePatternUtils#getResourcePatternResolver
7575
*/

spring-core/src/main/java/org/springframework/core/io/support/ResourcePatternUtils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 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.
@@ -48,10 +48,10 @@ public static boolean isUrl(String resourceLocation) {
4848
}
4949

5050
/**
51-
* Return a default ResourcePatternResolver for the given ResourceLoader.
52-
* <p>This might be the ResourceLoader itself, if it implements the
53-
* ResourcePatternResolver extension, or a PathMatchingResourcePatternResolver
54-
* built on the given ResourceLoader.
51+
* Return a default {@link ResourcePatternResolver} for the given {@link ResourceLoader}.
52+
* <p>This might be the {@code ResourceLoader} itself, if it implements the
53+
* {@code ResourcePatternResolver} extension, or a default
54+
* {@link PathMatchingResourcePatternResolver} built on the given {@code ResourceLoader}.
5555
* @param resourceLoader the ResourceLoader to build a pattern resolver for
5656
* (may be {@code null} to indicate a default ResourceLoader)
5757
* @return the ResourcePatternResolver

spring-expression/src/main/java/org/springframework/expression/spel/ast/CompoundExpression.java

Lines changed: 7 additions & 6 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,7 +24,8 @@
2424
import org.springframework.expression.spel.SpelEvaluationException;
2525

2626
/**
27-
* Represents a DOT separated expression sequence, such as 'property1.property2.methodOne()'
27+
* Represents a DOT separated expression sequence, such as
28+
* {@code 'property1.property2.methodOne()'}.
2829
*
2930
* @author Andy Clement
3031
* @since 3.0
@@ -111,7 +112,7 @@ public String toStringAST() {
111112
}
112113
return sb.toString();
113114
}
114-
115+
115116
@Override
116117
public boolean isCompilable() {
117118
for (SpelNodeImpl child: this.children) {
@@ -121,11 +122,11 @@ public boolean isCompilable() {
121122
}
122123
return true;
123124
}
124-
125+
125126
@Override
126127
public void generateCode(MethodVisitor mv, CodeFlow cf) {
127-
for (int i = 0; i < this.children.length;i++) {
128-
this.children[i].generateCode(mv, cf);
128+
for (SpelNodeImpl child : this.children) {
129+
child.generateCode(mv, cf);
129130
}
130131
cf.pushDescriptor(this.exitTypeDescriptor);
131132
}

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

Lines changed: 4 additions & 3 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-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.
@@ -20,8 +20,8 @@
2020

2121
/**
2222
* This interface adds a {@code rollbackOn} specification to {@link TransactionDefinition}.
23-
* As custom {@code rollbackOn} is only possible with AOP, this class resides
24-
* in the AOP transaction package.
23+
* As custom {@code rollbackOn} is only possible with AOP, it resides in the AOP-related
24+
* transaction subpackage.
2525
*
2626
* @author Rod Johnson
2727
* @author Juergen Hoeller
@@ -35,6 +35,7 @@ public interface TransactionAttribute extends TransactionDefinition {
3535
* Return a qualifier value associated with this transaction attribute.
3636
* <p>This may be used for choosing a corresponding transaction manager
3737
* to process this specific transaction.
38+
* @since 3.0
3839
*/
3940
String getQualifier();
4041

0 commit comments

Comments
 (0)