提交 0756a6ab 编写于 作者: C Chris Beams

Polish PropertySource and Environment Javadoc

上级 37d955b3
...@@ -98,7 +98,8 @@ import org.springframework.stereotype.Component; ...@@ -98,7 +98,8 @@ import org.springframework.stereotype.Component;
* <h3>Using the {@code Environment} API</h3> * <h3>Using the {@code Environment} API</h3>
* Externalized values may be looked up by injecting the Spring * Externalized values may be looked up by injecting the Spring
* {@link org.springframework.core.env.Environment Environment} into a * {@link org.springframework.core.env.Environment Environment} into a
* {@code @Configuration} class: * {@code @Configuration} class using the {@code @Autowired} or the {@code @Inject}
* annotation:
* <pre class="code"> * <pre class="code">
* &#064;Configuration * &#064;Configuration
* public class AppConfig { * public class AppConfig {
......
...@@ -49,10 +49,10 @@ import java.lang.annotation.Target; ...@@ -49,10 +49,10 @@ import java.lang.annotation.Target;
* } * }
* }</pre> * }</pre>
* *
* Notice that the {@code Environment} object is @{@link Autowired} into the * Notice that the {@code Environment} object is @{@link
* configuration class and then used when populating the {@code TestBean} * org.springframework.beans.factory.annotation.Autowired Autowired} into the
* object. Given the configuration above, a call to {@code testBean.getName()} will * configuration class and then used when populating the {@code TestBean} object. Given
* return "myTestBean". * the configuration above, a call to {@code testBean.getName()} will return "myTestBean".
* *
* <h3>A note on property overriding with @PropertySource</h3> * <h3>A note on property overriding with @PropertySource</h3>
* In cases where a given property key exists in more than one {@code .properties} * In cases where a given property key exists in more than one {@code .properties}
...@@ -91,13 +91,16 @@ import java.lang.annotation.Target; ...@@ -91,13 +91,16 @@ import java.lang.annotation.Target;
* if the {@code @Configuration} classes above were registered via component-scanning, * if the {@code @Configuration} classes above were registered via component-scanning,
* the ordering is difficult to predict. In such cases - and if overriding is important - * the ordering is difficult to predict. In such cases - and if overriding is important -
* it is recommended that the user fall back to using the programmatic PropertySource API. * it is recommended that the user fall back to using the programmatic PropertySource API.
* See {@link org.springframework.core.env.ConfigurableEnvironment ConfigurableEnvironment} and * See {@link org.springframework.core.env.ConfigurableEnvironment ConfigurableEnvironment}
* {@link org.springframework.core.env.MutablePropertySources MutablePropertySources} Javadoc * and * {@link org.springframework.core.env.MutablePropertySources MutablePropertySources}
* for details. * Javadoc for details.
* *
* @author Chris Beams * @author Chris Beams
* @since 3.1 * @since 3.1
* @see Configuration
* @see org.springframework.core.env.PropertySource
* @see org.springframework.core.env.ConfigurableEnvironment#getPropertySources()
* @see org.springframework.core.env.MutablePropertySources
*/ */
@Target(ElementType.TYPE) @Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
...@@ -105,7 +108,7 @@ import java.lang.annotation.Target; ...@@ -105,7 +108,7 @@ import java.lang.annotation.Target;
public @interface PropertySource { public @interface PropertySource {
/** /**
* Indicate the name of this PropertySource. If omitted, a name * Indicate the name of this property source. If omitted, a name
* will be generated based on the description of the underlying * will be generated based on the description of the underlying
* resource. * resource.
* @see org.springframework.core.env.PropertySource#getName() * @see org.springframework.core.env.PropertySource#getName()
......
...@@ -24,19 +24,26 @@ import org.springframework.util.Assert; ...@@ -24,19 +24,26 @@ import org.springframework.util.Assert;
* Abstract base class representing a source of key/value property pairs. The underlying * Abstract base class representing a source of key/value property pairs. The underlying
* {@linkplain #getSource() source object} may be of any type {@code T} that encapsulates * {@linkplain #getSource() source object} may be of any type {@code T} that encapsulates
* properties. Examples include {@link java.util.Properties} objects, {@link java.util.Map} * properties. Examples include {@link java.util.Properties} objects, {@link java.util.Map}
* objects, {@code ServletContext} and {@code ServletConfig} objects (for access to init parameters). * objects, {@code ServletContext} and {@code ServletConfig} objects (for access to init
* Explore the {@code PropertySource} type hierarchy to see provided implementations. * parameters). Explore the {@code PropertySource} type hierarchy to see provided
* implementations.
* *
* <p>{@code PropertySource} objects are not typically used in isolation, but rather through a * <p>{@code PropertySource} objects are not typically used in isolation, but rather
* {@link PropertySources} object, which aggregates property sources and in conjunction with * through a {@link PropertySources} object, which aggregates property sources and in
* a {@link PropertyResolver} implementation that can perform precedence-based searches across * conjunction with a {@link PropertyResolver} implementation that can perform
* the set of {@code PropertySources}. * precedence-based searches across the set of {@code PropertySources}.
* *
* <p>{@code PropertySource} identity is determined not based on the content of encapsulated * <p>{@code PropertySource} identity is determined not based on the content of
* properties, but rather based on the {@link #getName() name} of the {@code PropertySource} * encapsulated properties, but rather based on the {@link #getName() name} of the
* alone. This is useful for manipulating {@code PropertySource} objects when in collection * {@code PropertySource} alone. This is useful for manipulating {@code PropertySource}
* contexts. See operations in {@link MutablePropertySources} as well as the * objects when in collection contexts. See operations in {@link MutablePropertySources}
* {@link #named(String)} and {@link #toString()} methods for details. * as well as the {@link #named(String)} and {@link #toString()} methods for details.
*
* <p>Note that when working with @{@link
* org.springframework.context.annotation.Configuration Configuration} classes that
* the @{@link org.springframework.context.annotation.PropertySource PropertySource}
* annotation provides a convenient and declarative way of adding property sources to the
* enclosing {@code Environment}.
* *
* @author Chris Beams * @author Chris Beams
* @since 3.1 * @since 3.1
...@@ -44,6 +51,7 @@ import org.springframework.util.Assert; ...@@ -44,6 +51,7 @@ import org.springframework.util.Assert;
* @see PropertyResolver * @see PropertyResolver
* @see PropertySourcesPropertyResolver * @see PropertySourcesPropertyResolver
* @see MutablePropertySources * @see MutablePropertySources
* @see org.springframework.context.annotation.PropertySource
*/ */
public abstract class PropertySource<T> { public abstract class PropertySource<T> {
......
...@@ -67,7 +67,7 @@ package org.springframework.core.env; ...@@ -67,7 +67,7 @@ package org.springframework.core.env;
* {@link org.springframework.context.support.AbstractApplicationContext#refresh() * {@link org.springframework.context.support.AbstractApplicationContext#refresh()
* refresh()} method is called. This ensures that all PropertySources are available during * refresh()} method is called. This ensures that all PropertySources are available during
* the container bootstrap process, including use by * the container bootstrap process, including use by
* {@link org.springframework.context.support.PropertySourcesPlaceholderConfigurer * {@linkplain org.springframework.context.support.PropertySourcesPlaceholderConfigurer
* property placeholder configurers}. * property placeholder configurers}.
* *
* @author Chris Beams * @author Chris Beams
...@@ -93,6 +93,7 @@ public class StandardEnvironment extends AbstractEnvironment { ...@@ -93,6 +93,7 @@ public class StandardEnvironment extends AbstractEnvironment {
* </ul> * </ul>
* <p>Properties present in {@value #SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME} will * <p>Properties present in {@value #SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME} will
* take precedence over those in {@value #SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME}. * take precedence over those in {@value #SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME}.
* @see AbstractEnvironment#customizePropertySources(MutablePropertySources)
* @see #getSystemProperties() * @see #getSystemProperties()
* @see #getSystemEnvironment() * @see #getSystemEnvironment()
*/ */
......
...@@ -68,6 +68,7 @@ public class StandardPortletEnvironment extends StandardEnvironment { ...@@ -68,6 +68,7 @@ public class StandardPortletEnvironment extends StandardEnvironment {
* initialized} once the actual {@link PortletConfig}, {@link PortletContext}, and * initialized} once the actual {@link PortletConfig}, {@link PortletContext}, and
* {@link ServletContext} objects are available. * {@link ServletContext} objects are available.
* @see StandardEnvironment#customizePropertySources * @see StandardEnvironment#customizePropertySources
* @see org.springframework.core.env.AbstractEnvironment#customizePropertySources
* @see PortletConfigPropertySource * @see PortletConfigPropertySource
* @see PortletContextPropertySource * @see PortletContextPropertySource
* @see AbstractRefreshablePortletApplicationContext#initPropertySources * @see AbstractRefreshablePortletApplicationContext#initPropertySources
......
...@@ -77,6 +77,7 @@ public class StandardServletEnvironment extends StandardEnvironment { ...@@ -77,6 +77,7 @@ public class StandardServletEnvironment extends StandardEnvironment {
* servlet property sources, but higher than system properties and environment * servlet property sources, but higher than system properties and environment
* variables. * variables.
* @see StandardEnvironment#customizePropertySources * @see StandardEnvironment#customizePropertySources
* @see org.springframework.core.env.AbstractEnvironment#customizePropertySources
* @see ServletConfigPropertySource * @see ServletConfigPropertySource
* @see ServletContextPropertySource * @see ServletContextPropertySource
* @see org.springframework.jndi.JndiPropertySource * @see org.springframework.jndi.JndiPropertySource
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册