diff options
Diffstat (limited to 'spring-context/src/main/java/org/springframework/context/support')
3 files changed, 22 insertions, 21 deletions
diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java index 94f0c801..a40f6632 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 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. @@ -91,24 +91,24 @@ import org.springframework.util.StringValueResolver; * to detect special beans defined in its internal bean factory: * Therefore, this class automatically registers * {@link org.springframework.beans.factory.config.BeanFactoryPostProcessor BeanFactoryPostProcessors}, - * {@link org.springframework.beans.factory.config.BeanPostProcessor BeanPostProcessors} + * {@link org.springframework.beans.factory.config.BeanPostProcessor BeanPostProcessors}, * and {@link org.springframework.context.ApplicationListener ApplicationListeners} * which are defined as beans in the context. * * <p>A {@link org.springframework.context.MessageSource} may also be supplied * as a bean in the context, with the name "messageSource"; otherwise, message * resolution is delegated to the parent context. Furthermore, a multicaster - * for application events can be supplied as "applicationEventMulticaster" bean + * for application events can be supplied as an "applicationEventMulticaster" bean * of type {@link org.springframework.context.event.ApplicationEventMulticaster} * in the context; otherwise, a default multicaster of type * {@link org.springframework.context.event.SimpleApplicationEventMulticaster} will be used. * - * <p>Implements resource loading through extending + * <p>Implements resource loading by extending * {@link org.springframework.core.io.DefaultResourceLoader}. * Consequently treats non-URL resource paths as class path resources * (supporting full class path resource names that include the package path, * e.g. "mypackage/myresource.dat"), unless the {@link #getResourceByPath} - * method is overwritten in a subclass. + * method is overridden in a subclass. * * @author Rod Johnson * @author Juergen Hoeller @@ -381,7 +381,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader else { applicationEvent = new PayloadApplicationEvent<Object>(this, event); if (eventType == null) { - eventType = ((PayloadApplicationEvent) applicationEvent).getResolvableType(); + eventType = ((PayloadApplicationEvent<?>) applicationEvent).getResolvableType(); } } @@ -478,7 +478,6 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader this.beanFactoryPostProcessors.add(postProcessor); } - /** * Return the list of BeanFactoryPostProcessors that will get applied * to the internal BeanFactory. @@ -575,6 +574,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader * active flag as well as performing any initialization of property sources. */ protected void prepareRefresh() { + // Switch to active. this.startupDate = System.currentTimeMillis(); this.closed.set(false); this.active.set(true); @@ -583,10 +583,10 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader logger.info("Refreshing " + this); } - // Initialize any placeholder property sources in the context environment + // Initialize any placeholder property sources in the context environment. initPropertySources(); - // Validate that all properties marked as required are resolvable + // Validate that all properties marked as required are resolvable: // see ConfigurablePropertyResolver#setRequiredProperties getEnvironment().validateRequiredProperties(); @@ -695,7 +695,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader } /** - * Instantiate and invoke all registered BeanPostProcessor beans, + * Instantiate and register all BeanPostProcessor beans, * respecting explicit order if given. * <p>Must be called before any instantiation of application beans. */ @@ -979,6 +979,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader * @see #registerShutdownHook() */ protected void doClose() { + // Check whether an actual close attempt is necessary... if (this.active.get() && this.closed.compareAndSet(false, true)) { if (logger.isInfoEnabled()) { logger.info("Closing " + this); @@ -1013,6 +1014,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader // Let subclasses do some final clean-up if they wish... onClose(); + // Switch to inactive. this.active.set(false); } } @@ -1212,7 +1214,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader @Override public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType) - throws NoSuchBeanDefinitionException{ + throws NoSuchBeanDefinitionException { assertBeanFactoryActive(); return getBeanFactory().findAnnotationOnBean(beanName, annotationType); diff --git a/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java index 48250948..f6710d44 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -292,7 +292,7 @@ public class ResourceBundleMessageSource extends AbstractResourceBasedMessageSou try { return bundle.getString(key); } - catch (MissingResourceException ex){ + catch (MissingResourceException ex) { // Assume key not found for some other reason // -> do NOT throw the exception to allow for checking parent message source. } diff --git a/spring-context/src/main/java/org/springframework/context/support/SimpleThreadScope.java b/spring-context/src/main/java/org/springframework/context/support/SimpleThreadScope.java index 9dbd8a65..e9989a38 100644 --- a/spring-context/src/main/java/org/springframework/context/support/SimpleThreadScope.java +++ b/spring-context/src/main/java/org/springframework/context/support/SimpleThreadScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 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. @@ -35,14 +35,13 @@ import org.springframework.core.NamedThreadLocal; * or through a {@link org.springframework.beans.factory.config.CustomScopeConfigurer} bean. * * <p>{@code SimpleThreadScope} <em>does not clean up any objects</em> associated with it. - * As such, it is typically preferable to use - * {@link org.springframework.web.context.request.RequestScope RequestScope} - * in web environments. + * It is therefore typically preferable to use a request-bound scope implementation such + * as {@code org.springframework.web.context.request.RequestScope} in web environments, + * implementing the full lifecycle for scoped attributes (including reliable destruction). * - * <p>For an implementation of a thread-based {@code Scope} with support for - * destruction callbacks, refer to the - * <a href="http://www.springbyexample.org/examples/custom-thread-scope-module.html"> -* Spring by Example Custom Thread Scope Module</a>. + * <p>For an implementation of a thread-based {@code Scope} with support for destruction + * callbacks, refer to + * <a href="http://www.springbyexample.org/examples/custom-thread-scope-module.html">Spring by Example</a>. * * <p>Thanks to Eugene Kuleshov for submitting the original prototype for a thread scope! * |