diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java b/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java index d0dddf1fe2..730f166484 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java @@ -26,9 +26,9 @@ import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; /** - * Selects which implementation of {@link AbstractCachingConfiguration} should be used - * based on the value of {@link EnableCaching#mode} on the importing {@code @Configuration} - * class. + * Selects which implementation of {@link AbstractCachingConfiguration} should + * be used based on the value of {@link EnableCaching#mode} on the importing + * {@code @Configuration} class. * *

Detects the presence of JSR-107 and enables JCache support accordingly. * @@ -58,9 +58,9 @@ public class CachingConfigurationSelector extends AdviceModeImportSelectorTake care of adding the necessary JSR-107 import if it is available. */ private String[] getProxyImports() { - List result = new ArrayList(); + List result = new ArrayList(3); result.add(AutoProxyRegistrar.class.getName()); result.add(ProxyCachingConfiguration.class.getName()); if (jsr107Present && jcacheImplPresent) { @@ -93,7 +93,7 @@ public class CachingConfigurationSelector extends AdviceModeImportSelectorTake care of adding the necessary JSR-107 import if it is available. */ private String[] getAspectJImports() { - List result = new ArrayList(); + List result = new ArrayList(2); result.add(CACHE_ASPECT_CONFIGURATION_CLASS_NAME); if (jsr107Present && jcacheImplPresent) { result.add(JCACHE_ASPECT_CONFIGURATION_CLASS_NAME); diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AdviceMode.java b/spring-context/src/main/java/org/springframework/context/annotation/AdviceMode.java index 5b741d6069..5f088533fb 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AdviceMode.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AdviceMode.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,8 +17,8 @@ package org.springframework.context.annotation; /** - * Enumeration used to determine whether JDK proxy-based or AspectJ weaving-based advice - * should be applied. + * Enumeration used to determine whether JDK proxy-based or + * AspectJ weaving-based advice should be applied. * * @author Chris Beams * @since 3.1 @@ -27,6 +27,15 @@ package org.springframework.context.annotation; * @see org.springframework.transaction.annotation.EnableTransactionManagement#mode() */ public enum AdviceMode { + + /** + * JDK proxy-based advice. + */ PROXY, + + /** + * AspectJ weaving-based advice. + */ ASPECTJ + } diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AdviceModeImportSelector.java b/spring-context/src/main/java/org/springframework/context/annotation/AdviceModeImportSelector.java index 14f9f1bfa2..67daeb5932 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AdviceModeImportSelector.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AdviceModeImportSelector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.springframework.core.GenericTypeResolver; import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.type.AnnotationMetadata; - /** +/** * Convenient base class for {@link ImportSelector} implementations that select imports * based on an {@link AdviceMode} value from an annotation (such as the {@code @Enable*} * annotations). @@ -33,6 +33,9 @@ import org.springframework.core.type.AnnotationMetadata; */ public abstract class AdviceModeImportSelector implements ImportSelector { + /** + * The default advice mode attribute name. + */ public static final String DEFAULT_ADVICE_MODE_ATTRIBUTE_NAME = "mode"; @@ -59,31 +62,31 @@ public abstract class AdviceModeImportSelector implements */ @Override public final String[] selectImports(AnnotationMetadata importingClassMetadata) { - Class annoType = GenericTypeResolver.resolveTypeArgument(getClass(), AdviceModeImportSelector.class); - AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(importingClassMetadata, annoType); + Class annType = GenericTypeResolver.resolveTypeArgument(getClass(), AdviceModeImportSelector.class); + AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(importingClassMetadata, annType); if (attributes == null) { throw new IllegalArgumentException(String.format( - "@%s is not present on importing class '%s' as expected", - annoType.getSimpleName(), importingClassMetadata.getClassName())); + "@%s is not present on importing class '%s' as expected", + annType.getSimpleName(), importingClassMetadata.getClassName())); } - AdviceMode adviceMode = attributes.getEnum(this.getAdviceModeAttributeName()); + AdviceMode adviceMode = attributes.getEnum(getAdviceModeAttributeName()); String[] imports = selectImports(adviceMode); if (imports == null) { - throw new IllegalArgumentException(String.format("Unknown AdviceMode: '%s'", adviceMode)); + throw new IllegalArgumentException("Unknown AdviceMode: " + adviceMode); } return imports; } /** * Determine which classes should be imported based on the given {@code AdviceMode}. - *

Returning {@code null} from this method indicates that the {@code AdviceMode} could - * not be handled or was unknown and that an {@code IllegalArgumentException} should - * be thrown. + *

Returning {@code null} from this method indicates that the {@code AdviceMode} + * could not be handled or was unknown and that an {@code IllegalArgumentException} + * should be thrown. * @param adviceMode the value of the {@linkplain #getAdviceModeAttributeName() * advice mode attribute} for the annotation specified via generics. - * @return array containing classes to import; empty array if none, {@code null} if - * the given {@code AdviceMode} is unknown. + * @return array containing classes to import (empty array if none; + * {@code null} if the given {@code AdviceMode} is unknown) */ protected abstract String[] selectImports(AdviceMode adviceMode); diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigApplicationContext.java b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigApplicationContext.java index c4a0657884..25b54b969b 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigApplicationContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,8 +37,8 @@ import org.springframework.util.Assert; * *

See @{@link Configuration}'s javadoc for usage examples. * - * @author Chris Beams * @author Juergen Hoeller + * @author Chris Beams * @since 3.0 * @see #register * @see #scan @@ -97,9 +97,8 @@ public class AnnotationConfigApplicationContext extends GenericApplicationContex /** - * {@inheritDoc} - *

Delegates given environment to underlying {@link AnnotatedBeanDefinitionReader} - * and {@link ClassPathBeanDefinitionScanner} members. + * Propagates the given custom {@code Environment} to the underlying + * {@link AnnotatedBeanDefinitionReader} and {@link ClassPathBeanDefinitionScanner}. */ @Override public void setEnvironment(ConfigurableEnvironment environment) { diff --git a/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java b/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java index bc72d8de9a..12fb98e73f 100644 --- a/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java +++ b/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java @@ -40,10 +40,10 @@ import org.springframework.util.StringValueResolver; * Spring {@link Environment} and its set of {@link PropertySources}. * *

This class is designed as a general replacement for {@code PropertyPlaceholderConfigurer} - * in Spring 3.1 applications. It is used by default to support the {@code property-placeholder} - * element in working against the spring-context-3.1 XSD, whereas spring-context versions - * <= 3.0 default to {@code PropertyPlaceholderConfigurer} to ensure backward compatibility. - * See the spring-context XSD documentation for complete details. + * introduced in Spring 3.1. It is used by default to support the {@code property-placeholder} + * element in working against the spring-context-3.1 or higher XSD, whereas spring-context + * versions <= 3.0 default to {@code PropertyPlaceholderConfigurer} to ensure backward + * compatibility. See the spring-context XSD documentation for complete details. * *

Any local properties (e.g. those added via {@link #setProperties}, {@link #setLocations} * et al.) are added as a {@code PropertySource}. Search precedence of local properties is @@ -51,10 +51,11 @@ import org.springframework.util.StringValueResolver; * default {@code false} meaning that local properties are to be searched last, after all * environment property sources. * - *

See {@link org.springframework.core.env.ConfigurableEnvironment ConfigurableEnvironment} - * and related javadocs for details on manipulating environment property sources. + *

See {@link org.springframework.core.env.ConfigurableEnvironment} and related javadocs + * for details on manipulating environment property sources. * * @author Chris Beams + * @author Juergen Hoeller * @since 3.1 * @see org.springframework.core.env.ConfigurableEnvironment * @see org.springframework.beans.factory.config.PlaceholderConfigurerSupport @@ -84,8 +85,8 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS /** * Customize the set of {@link PropertySources} to be used by this configurer. - * Setting this property indicates that environment property sources and local - * properties should be ignored. + *

Setting this property indicates that environment property sources and + * local properties should be ignored. * @see #postProcessBeanFactory */ public void setPropertySources(PropertySources propertySources) { @@ -93,8 +94,8 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS } /** - * {@inheritDoc} - *

{@code PropertySources} from this environment will be searched when replacing ${...} placeholders. + * {@code PropertySources} from the given {@link Environment} + * will be searched when replacing ${...} placeholders. * @see #setPropertySources * @see #postProcessBeanFactory */ @@ -105,8 +106,7 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS /** - * {@inheritDoc} - *

Processing occurs by replacing ${...} placeholders in bean definitions by resolving each + * Processing occurs by replacing ${...} placeholders in bean definitions by resolving each * against this configurer's set of {@link PropertySources}, which includes: *