Skip to content

Commit e307dd5

Browse files
committed
Polishing
1 parent c2bd229 commit e307dd5

File tree

8 files changed

+87
-81
lines changed

8 files changed

+87
-81
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-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.
@@ -29,7 +29,7 @@
2929

3030
/**
3131
* Objenesis-based extension of {@link CglibAopProxy} to create proxy instances
32-
* without invoking the constructor of the class.
32+
* without invoking the constructor of the class. Used by default as of Spring 4.
3333
*
3434
* @author Oliver Gierke
3535
* @author Juergen Hoeller
@@ -53,7 +53,6 @@ public ObjenesisCglibAopProxy(AdvisedSupport config) {
5353

5454

5555
@Override
56-
@SuppressWarnings("unchecked")
5756
protected Object createProxyClassAndInstance(Enhancer enhancer, Callback[] callbacks) {
5857
Class<?> proxyClass = enhancer.createClass();
5958
Object proxyInstance = null;

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

Lines changed: 23 additions & 17 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.
@@ -62,12 +62,15 @@ protected AbstractJCacheOperation(CacheMethodDetails<A> methodDetails, CacheReso
6262
this.allParameterDetails = initializeAllParameterDetails(methodDetails.getMethod());
6363
}
6464

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

7275

7376
@Override
@@ -113,12 +116,25 @@ public CacheInvocationParameter[] getAllParameters(Object... values) {
113116
return result.toArray(new CacheInvocationParameter[0]);
114117
}
115118

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

119134
return new ExceptionTypeFilter(Arrays.asList(includes), Arrays.asList(excludes), true);
120135
}
121136

137+
122138
@Override
123139
public String toString() {
124140
return getOperationDescription().append("]").toString();
@@ -137,16 +153,6 @@ protected StringBuilder getOperationDescription() {
137153
}
138154

139155

140-
private static List<CacheParameterDetail> initializeAllParameterDetails(Method method) {
141-
List<CacheParameterDetail> result = new ArrayList<>();
142-
for (int i = 0; i < method.getParameterCount(); i++) {
143-
CacheParameterDetail detail = new CacheParameterDetail(method, i);
144-
result.add(detail);
145-
}
146-
return result;
147-
}
148-
149-
150156
/**
151157
* Details for a single cache parameter.
152158
*/

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

Lines changed: 5 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.
@@ -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

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

Lines changed: 28 additions & 28 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.
@@ -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

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-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.
@@ -49,10 +49,10 @@ public static boolean isUrl(@Nullable String resourceLocation) {
4949
}
5050

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

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

Lines changed: 3 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.
@@ -126,8 +126,8 @@ public boolean isCompilable() {
126126

127127
@Override
128128
public void generateCode(MethodVisitor mv, CodeFlow cf) {
129-
for (int i = 0; i < this.children.length;i++) {
130-
this.children[i].generateCode(mv, cf);
129+
for (SpelNodeImpl child : this.children) {
130+
child.generateCode(mv, cf);
131131
}
132132
cf.pushDescriptor(this.exitTypeDescriptor);
133133
}

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-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.
@@ -21,8 +21,8 @@
2121

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

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

Lines changed: 17 additions & 18 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.
@@ -45,44 +45,43 @@ public class TransactionAttributeEditor extends PropertyEditorSupport {
4545
/**
4646
* Format is PROPAGATION_NAME,ISOLATION_NAME,readOnly,timeout_NNNN,+Exception1,-Exception2.
4747
* Null or the empty string means that the method is non transactional.
48-
* @see java.beans.PropertyEditor#setAsText(java.lang.String)
4948
*/
5049
@Override
5150
public void setAsText(String text) throws IllegalArgumentException {
5251
if (StringUtils.hasLength(text)) {
5352
// tokenize it with ","
5453
String[] tokens = StringUtils.commaDelimitedListToStringArray(text);
5554
RuleBasedTransactionAttribute attr = new RuleBasedTransactionAttribute();
56-
for (int i = 0; i < tokens.length; i++) {
55+
for (String token : tokens) {
5756
// Trim leading and trailing whitespace.
58-
String token = StringUtils.trimWhitespace(tokens[i].trim());
57+
String trimmedToken = StringUtils.trimWhitespace(token.trim());
5958
// Check whether token contains illegal whitespace within text.
60-
if (StringUtils.containsWhitespace(token)) {
59+
if (StringUtils.containsWhitespace(trimmedToken)) {
6160
throw new IllegalArgumentException(
62-
"Transaction attribute token contains illegal whitespace: [" + token + "]");
61+
"Transaction attribute token contains illegal whitespace: [" + trimmedToken + "]");
6362
}
6463
// Check token type.
65-
if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_PROPAGATION)) {
66-
attr.setPropagationBehaviorName(token);
64+
if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_PROPAGATION)) {
65+
attr.setPropagationBehaviorName(trimmedToken);
6766
}
68-
else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_ISOLATION)) {
69-
attr.setIsolationLevelName(token);
67+
else if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_ISOLATION)) {
68+
attr.setIsolationLevelName(trimmedToken);
7069
}
71-
else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_TIMEOUT)) {
72-
String value = token.substring(DefaultTransactionAttribute.PREFIX_TIMEOUT.length());
70+
else if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_TIMEOUT)) {
71+
String value = trimmedToken.substring(DefaultTransactionAttribute.PREFIX_TIMEOUT.length());
7372
attr.setTimeout(Integer.parseInt(value));
7473
}
75-
else if (token.equals(RuleBasedTransactionAttribute.READ_ONLY_MARKER)) {
74+
else if (trimmedToken.equals(RuleBasedTransactionAttribute.READ_ONLY_MARKER)) {
7675
attr.setReadOnly(true);
7776
}
78-
else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_COMMIT_RULE)) {
79-
attr.getRollbackRules().add(new NoRollbackRuleAttribute(token.substring(1)));
77+
else if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_COMMIT_RULE)) {
78+
attr.getRollbackRules().add(new NoRollbackRuleAttribute(trimmedToken.substring(1)));
8079
}
81-
else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_ROLLBACK_RULE)) {
82-
attr.getRollbackRules().add(new RollbackRuleAttribute(token.substring(1)));
80+
else if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_ROLLBACK_RULE)) {
81+
attr.getRollbackRules().add(new RollbackRuleAttribute(trimmedToken.substring(1)));
8382
}
8483
else {
85-
throw new IllegalArgumentException("Invalid transaction attribute token: [" + token + "]");
84+
throw new IllegalArgumentException("Invalid transaction attribute token: [" + trimmedToken + "]");
8685
}
8786
}
8887
setValue(attr);

0 commit comments

Comments
 (0)