Skip to content

Commit 4c05020

Browse files
committed
Polishing
1 parent 7ac99c1 commit 4c05020

File tree

7 files changed

+78
-60
lines changed

7 files changed

+78
-60
lines changed

spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
import org.springframework.util.StringUtils;
2727

2828
/**
29-
* Selects which implementation of {@link AbstractCachingConfiguration} should be used
30-
* based on the value of {@link EnableCaching#mode} on the importing {@code @Configuration}
31-
* class.
29+
* Selects which implementation of {@link AbstractCachingConfiguration} should
30+
* be used based on the value of {@link EnableCaching#mode} on the importing
31+
* {@code @Configuration} class.
3232
*
3333
* <p>Detects the presence of JSR-107 and enables JCache support accordingly.
3434
*
@@ -58,9 +58,9 @@ public class CachingConfigurationSelector extends AdviceModeImportSelector<Enabl
5858

5959

6060
/**
61-
* {@inheritDoc}
62-
* @return {@link ProxyCachingConfiguration} or {@code AspectJCacheConfiguration} for
63-
* {@code PROXY} and {@code ASPECTJ} values of {@link EnableCaching#mode()}, respectively
61+
* Returns {@link ProxyCachingConfiguration} or {@code AspectJCachingConfiguration}
62+
* for {@code PROXY} and {@code ASPECTJ} values of {@link EnableCaching#mode()},
63+
* respectively. Potentially includes corresponding JCache configuration as well.
6464
*/
6565
@Override
6666
public String[] selectImports(AdviceMode adviceMode) {
@@ -79,7 +79,7 @@ public String[] selectImports(AdviceMode adviceMode) {
7979
* <p>Take care of adding the necessary JSR-107 import if it is available.
8080
*/
8181
private String[] getProxyImports() {
82-
List<String> result = new ArrayList<String>();
82+
List<String> result = new ArrayList<String>(3);
8383
result.add(AutoProxyRegistrar.class.getName());
8484
result.add(ProxyCachingConfiguration.class.getName());
8585
if (jsr107Present && jcacheImplPresent) {
@@ -93,7 +93,7 @@ private String[] getProxyImports() {
9393
* <p>Take care of adding the necessary JSR-107 import if it is available.
9494
*/
9595
private String[] getAspectJImports() {
96-
List<String> result = new ArrayList<String>();
96+
List<String> result = new ArrayList<String>(2);
9797
result.add(CACHE_ASPECT_CONFIGURATION_CLASS_NAME);
9898
if (jsr107Present && jcacheImplPresent) {
9999
result.add(JCACHE_ASPECT_CONFIGURATION_CLASS_NAME);

spring-context/src/main/java/org/springframework/context/annotation/AdviceMode.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2018 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,8 +17,8 @@
1717
package org.springframework.context.annotation;
1818

1919
/**
20-
* Enumeration used to determine whether JDK proxy-based or AspectJ weaving-based advice
21-
* should be applied.
20+
* Enumeration used to determine whether JDK proxy-based or
21+
* AspectJ weaving-based advice should be applied.
2222
*
2323
* @author Chris Beams
2424
* @since 3.1
@@ -27,6 +27,15 @@
2727
* @see org.springframework.transaction.annotation.EnableTransactionManagement#mode()
2828
*/
2929
public enum AdviceMode {
30+
31+
/**
32+
* JDK proxy-based advice.
33+
*/
3034
PROXY,
35+
36+
/**
37+
* AspectJ weaving-based advice.
38+
*/
3139
ASPECTJ
40+
3241
}

spring-context/src/main/java/org/springframework/context/annotation/AdviceModeImportSelector.java

Lines changed: 16 additions & 13 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-2018 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.
@@ -22,7 +22,7 @@
2222
import org.springframework.core.annotation.AnnotationAttributes;
2323
import org.springframework.core.type.AnnotationMetadata;
2424

25-
/**
25+
/**
2626
* Convenient base class for {@link ImportSelector} implementations that select imports
2727
* based on an {@link AdviceMode} value from an annotation (such as the {@code @Enable*}
2828
* annotations).
@@ -33,6 +33,9 @@
3333
*/
3434
public abstract class AdviceModeImportSelector<A extends Annotation> implements ImportSelector {
3535

36+
/**
37+
* The default advice mode attribute name.
38+
*/
3639
public static final String DEFAULT_ADVICE_MODE_ATTRIBUTE_NAME = "mode";
3740

3841

@@ -59,31 +62,31 @@ protected String getAdviceModeAttributeName() {
5962
*/
6063
@Override
6164
public final String[] selectImports(AnnotationMetadata importingClassMetadata) {
62-
Class<?> annoType = GenericTypeResolver.resolveTypeArgument(getClass(), AdviceModeImportSelector.class);
63-
AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(importingClassMetadata, annoType);
65+
Class<?> annType = GenericTypeResolver.resolveTypeArgument(getClass(), AdviceModeImportSelector.class);
66+
AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(importingClassMetadata, annType);
6467
if (attributes == null) {
6568
throw new IllegalArgumentException(String.format(
66-
"@%s is not present on importing class '%s' as expected",
67-
annoType.getSimpleName(), importingClassMetadata.getClassName()));
69+
"@%s is not present on importing class '%s' as expected",
70+
annType.getSimpleName(), importingClassMetadata.getClassName()));
6871
}
6972

70-
AdviceMode adviceMode = attributes.getEnum(this.getAdviceModeAttributeName());
73+
AdviceMode adviceMode = attributes.getEnum(getAdviceModeAttributeName());
7174
String[] imports = selectImports(adviceMode);
7275
if (imports == null) {
73-
throw new IllegalArgumentException(String.format("Unknown AdviceMode: '%s'", adviceMode));
76+
throw new IllegalArgumentException("Unknown AdviceMode: " + adviceMode);
7477
}
7578
return imports;
7679
}
7780

7881
/**
7982
* Determine which classes should be imported based on the given {@code AdviceMode}.
80-
* <p>Returning {@code null} from this method indicates that the {@code AdviceMode} could
81-
* not be handled or was unknown and that an {@code IllegalArgumentException} should
82-
* be thrown.
83+
* <p>Returning {@code null} from this method indicates that the {@code AdviceMode}
84+
* could not be handled or was unknown and that an {@code IllegalArgumentException}
85+
* should be thrown.
8386
* @param adviceMode the value of the {@linkplain #getAdviceModeAttributeName()
8487
* advice mode attribute} for the annotation specified via generics.
85-
* @return array containing classes to import; empty array if none, {@code null} if
86-
* the given {@code AdviceMode} is unknown.
88+
* @return array containing classes to import (empty array if none;
89+
* {@code null} if the given {@code AdviceMode} is unknown)
8790
*/
8891
protected abstract String[] selectImports(AdviceMode adviceMode);
8992

spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigApplicationContext.java

Lines changed: 4 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-2018 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.
@@ -37,8 +37,8 @@
3737
*
3838
* <p>See @{@link Configuration}'s javadoc for usage examples.
3939
*
40-
* @author Chris Beams
4140
* @author Juergen Hoeller
41+
* @author Chris Beams
4242
* @since 3.0
4343
* @see #register
4444
* @see #scan
@@ -97,9 +97,8 @@ public AnnotationConfigApplicationContext(String... basePackages) {
9797

9898

9999
/**
100-
* {@inheritDoc}
101-
* <p>Delegates given environment to underlying {@link AnnotatedBeanDefinitionReader}
102-
* and {@link ClassPathBeanDefinitionScanner} members.
100+
* Propagates the given custom {@code Environment} to the underlying
101+
* {@link AnnotatedBeanDefinitionReader} and {@link ClassPathBeanDefinitionScanner}.
103102
*/
104103
@Override
105104
public void setEnvironment(ConfigurableEnvironment environment) {

spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,22 @@
4040
* Spring {@link Environment} and its set of {@link PropertySources}.
4141
*
4242
* <p>This class is designed as a general replacement for {@code PropertyPlaceholderConfigurer}
43-
* in Spring 3.1 applications. It is used by default to support the {@code property-placeholder}
44-
* element in working against the spring-context-3.1 XSD, whereas spring-context versions
45-
* &lt;= 3.0 default to {@code PropertyPlaceholderConfigurer} to ensure backward compatibility.
46-
* See the spring-context XSD documentation for complete details.
43+
* introduced in Spring 3.1. It is used by default to support the {@code property-placeholder}
44+
* element in working against the spring-context-3.1 or higher XSD, whereas spring-context
45+
* versions &lt;= 3.0 default to {@code PropertyPlaceholderConfigurer} to ensure backward
46+
* compatibility. See the spring-context XSD documentation for complete details.
4747
*
4848
* <p>Any local properties (e.g. those added via {@link #setProperties}, {@link #setLocations}
4949
* et al.) are added as a {@code PropertySource}. Search precedence of local properties is
5050
* based on the value of the {@link #setLocalOverride localOverride} property, which is by
5151
* default {@code false} meaning that local properties are to be searched last, after all
5252
* environment property sources.
5353
*
54-
* <p>See {@link org.springframework.core.env.ConfigurableEnvironment ConfigurableEnvironment}
55-
* and related javadocs for details on manipulating environment property sources.
54+
* <p>See {@link org.springframework.core.env.ConfigurableEnvironment} and related javadocs
55+
* for details on manipulating environment property sources.
5656
*
5757
* @author Chris Beams
58+
* @author Juergen Hoeller
5859
* @since 3.1
5960
* @see org.springframework.core.env.ConfigurableEnvironment
6061
* @see org.springframework.beans.factory.config.PlaceholderConfigurerSupport
@@ -84,17 +85,17 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS
8485

8586
/**
8687
* Customize the set of {@link PropertySources} to be used by this configurer.
87-
* Setting this property indicates that environment property sources and local
88-
* properties should be ignored.
88+
* <p>Setting this property indicates that environment property sources and
89+
* local properties should be ignored.
8990
* @see #postProcessBeanFactory
9091
*/
9192
public void setPropertySources(PropertySources propertySources) {
9293
this.propertySources = new MutablePropertySources(propertySources);
9394
}
9495

9596
/**
96-
* {@inheritDoc}
97-
* <p>{@code PropertySources} from this environment will be searched when replacing ${...} placeholders.
97+
* {@code PropertySources} from the given {@link Environment}
98+
* will be searched when replacing ${...} placeholders.
9899
* @see #setPropertySources
99100
* @see #postProcessBeanFactory
100101
*/
@@ -105,8 +106,7 @@ public void setEnvironment(Environment environment) {
105106

106107

107108
/**
108-
* {@inheritDoc}
109-
* <p>Processing occurs by replacing ${...} placeholders in bean definitions by resolving each
109+
* Processing occurs by replacing ${...} placeholders in bean definitions by resolving each
110110
* against this configurer's set of {@link PropertySources}, which includes:
111111
* <ul>
112112
* <li>all {@linkplain org.springframework.core.env.ConfigurableEnvironment#getPropertySources
@@ -181,8 +181,10 @@ public String resolveStringValue(String strVal) {
181181
}
182182

183183
/**
184-
* Implemented for compatibility with {@link org.springframework.beans.factory.config.PlaceholderConfigurerSupport}.
185-
* @deprecated in favor of {@link #processProperties(ConfigurableListableBeanFactory, ConfigurablePropertyResolver)}
184+
* Implemented for compatibility with
185+
* {@link org.springframework.beans.factory.config.PlaceholderConfigurerSupport}.
186+
* @deprecated in favor of
187+
* {@link #processProperties(ConfigurableListableBeanFactory, ConfigurablePropertyResolver)}
186188
* @throws UnsupportedOperationException in this implementation
187189
*/
188190
@Override
@@ -193,14 +195,14 @@ protected void processProperties(ConfigurableListableBeanFactory beanFactory, Pr
193195
}
194196

195197
/**
196-
* Returns the property sources that were actually applied during
198+
* Return the property sources that were actually applied during
197199
* {@link #postProcessBeanFactory(ConfigurableListableBeanFactory) post-processing}.
198200
* @return the property sources that were applied
199201
* @throws IllegalStateException if the property sources have not yet been applied
200202
* @since 4.0
201203
*/
202204
public PropertySources getAppliedPropertySources() throws IllegalStateException {
203-
Assert.state(this.appliedPropertySources != null, "PropertySources have not get been applied");
205+
Assert.state(this.appliedPropertySources != null, "PropertySources have not yet been applied");
204206
return this.appliedPropertySources;
205207
}
206208

spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurationSelector.java

Lines changed: 11 additions & 8 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-2018 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,10 +20,12 @@
2020
import org.springframework.context.annotation.AdviceModeImportSelector;
2121

2222
/**
23-
* Selects which implementation of {@link AbstractAsyncConfiguration} should be used based
24-
* on the value of {@link EnableAsync#mode} on the importing {@code @Configuration} class.
23+
* Selects which implementation of {@link AbstractAsyncConfiguration} should
24+
* be used based on the value of {@link EnableAsync#mode} on the importing
25+
* {@code @Configuration} class.
2526
*
2627
* @author Chris Beams
28+
* @author Juergen Hoeller
2729
* @since 3.1
2830
* @see EnableAsync
2931
* @see ProxyAsyncConfiguration
@@ -33,18 +35,19 @@ public class AsyncConfigurationSelector extends AdviceModeImportSelector<EnableA
3335
private static final String ASYNC_EXECUTION_ASPECT_CONFIGURATION_CLASS_NAME =
3436
"org.springframework.scheduling.aspectj.AspectJAsyncConfiguration";
3537

38+
3639
/**
37-
* {@inheritDoc}
38-
* @return {@link ProxyAsyncConfiguration} or {@code AspectJAsyncConfiguration} for
39-
* {@code PROXY} and {@code ASPECTJ} values of {@link EnableAsync#mode()}, respectively
40+
* Returns {@link ProxyAsyncConfiguration} or {@code AspectJAsyncConfiguration}
41+
* for {@code PROXY} and {@code ASPECTJ} values of {@link EnableAsync#mode()},
42+
* respectively.
4043
*/
4144
@Override
4245
public String[] selectImports(AdviceMode adviceMode) {
4346
switch (adviceMode) {
4447
case PROXY:
45-
return new String[] { ProxyAsyncConfiguration.class.getName() };
48+
return new String[] {ProxyAsyncConfiguration.class.getName()};
4649
case ASPECTJ:
47-
return new String[] { ASYNC_EXECUTION_ASPECT_CONFIGURATION_CLASS_NAME };
50+
return new String[] {ASYNC_EXECUTION_ASPECT_CONFIGURATION_CLASS_NAME};
4851
default:
4952
return null;
5053
}

spring-tx/src/main/java/org/springframework/transaction/annotation/TransactionManagementConfigurationSelector.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -35,18 +35,20 @@
3535
public class TransactionManagementConfigurationSelector extends AdviceModeImportSelector<EnableTransactionManagement> {
3636

3737
/**
38-
* {@inheritDoc}
39-
* @return {@link ProxyTransactionManagementConfiguration} or
40-
* {@code AspectJTransactionManagementConfiguration} for {@code PROXY} and
41-
* {@code ASPECTJ} values of {@link EnableTransactionManagement#mode()}, respectively
38+
* Returns {@link ProxyTransactionManagementConfiguration} or
39+
* {@code AspectJTransactionManagementConfiguration} for {@code PROXY}
40+
* and {@code ASPECTJ} values of {@link EnableTransactionManagement#mode()},
41+
* respectively.
4242
*/
4343
@Override
4444
protected String[] selectImports(AdviceMode adviceMode) {
4545
switch (adviceMode) {
4646
case PROXY:
47-
return new String[] {AutoProxyRegistrar.class.getName(), ProxyTransactionManagementConfiguration.class.getName()};
47+
return new String[] {AutoProxyRegistrar.class.getName(),
48+
ProxyTransactionManagementConfiguration.class.getName()};
4849
case ASPECTJ:
49-
return new String[] {TransactionManagementConfigUtils.TRANSACTION_ASPECT_CONFIGURATION_CLASS_NAME};
50+
return new String[] {
51+
TransactionManagementConfigUtils.TRANSACTION_ASPECT_CONFIGURATION_CLASS_NAME};
5052
default:
5153
return null;
5254
}

0 commit comments

Comments
 (0)