summaryrefslogtreecommitdiff
path: root/spring-context
diff options
context:
space:
mode:
Diffstat (limited to 'spring-context')
-rw-r--r--spring-context/src/main/java/org/springframework/context/ResourceLoaderAware.java58
-rw-r--r--spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java12
-rw-r--r--spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java4
-rw-r--r--spring-context/src/main/java/org/springframework/context/annotation/ImportBeanDefinitionRegistrar.java5
-rw-r--r--spring-context/src/main/java/org/springframework/context/annotation/ImportSelector.java16
-rw-r--r--spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java4
-rw-r--r--spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java22
-rw-r--r--spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java24
-rw-r--r--spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java4
-rw-r--r--spring-context/src/main/java/org/springframework/context/support/SimpleThreadScope.java15
-rw-r--r--spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java82
-rw-r--r--spring-context/src/test/java/org/springframework/context/config/ContextNamespaceHandlerTests.java20
-rw-r--r--spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java12
-rw-r--r--spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java69
-rw-r--r--spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-resource.xml2
-rw-r--r--spring-context/src/test/resources/org/springframework/context/config/contextNamespaceHandlerTests-simple.xml4
16 files changed, 212 insertions, 141 deletions
diff --git a/spring-context/src/main/java/org/springframework/context/ResourceLoaderAware.java b/spring-context/src/main/java/org/springframework/context/ResourceLoaderAware.java
index cf9edd71..672a2b37 100644
--- a/spring-context/src/main/java/org/springframework/context/ResourceLoaderAware.java
+++ b/spring-context/src/main/java/org/springframework/context/ResourceLoaderAware.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 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.
@@ -20,44 +20,44 @@ import org.springframework.beans.factory.Aware;
import org.springframework.core.io.ResourceLoader;
/**
- * Interface to be implemented by any object that wishes to be notified of
- * the <b>ResourceLoader</b> (typically the ApplicationContext) that it runs in.
- * This is an alternative to a full ApplicationContext dependency via the
- * ApplicationContextAware interface.
+ * Interface to be implemented by any object that wishes to be notified of the
+ * {@link ResourceLoader} (typically the ApplicationContext) that it runs in.
+ * This is an alternative to a full {@link ApplicationContext} dependency via
+ * the {@link org.springframework.context.ApplicationContextAware} interface.
*
- * <p>Note that Resource dependencies can also be exposed as bean properties
- * of type Resource, populated via Strings with automatic type conversion by
- * the bean factory. This removes the need for implementing any callback
- * interface just for the purpose of accessing a specific file resource.
+ * <p>Note that {@link org.springframework.core.io.Resource} dependencies can also
+ * be exposed as bean properties of type {@code Resource}, populated via Strings
+ * with automatic type conversion by the bean factory. This removes the need for
+ * implementing any callback interface just for the purpose of accessing a
+ * specific file resource.
*
- * <p>You typically need a ResourceLoader when your application object has
- * to access a variety of file resources whose names are calculated. A good
- * strategy is to make the object use a DefaultResourceLoader but still
- * implement ResourceLoaderAware to allow for overriding when running in an
- * ApplicationContext. See ReloadableResourceBundleMessageSource for an example.
+ * <p>You typically need a {@link ResourceLoader} when your application object has to
+ * access a variety of file resources whose names are calculated. A good strategy is
+ * to make the object use a {@link org.springframework.core.io.DefaultResourceLoader}
+ * but still implement {@code ResourceLoaderAware} to allow for overriding when
+ * running in an {@code ApplicationContext}. See
+ * {@link org.springframework.context.support.ReloadableResourceBundleMessageSource}
+ * for an example.
*
- * <p>A passed-in ResourceLoader can also be checked for the
- * <b>ResourcePatternResolver</b> interface and cast accordingly, to be able
- * to resolve resource patterns into arrays of Resource objects. This will always
- * work when running in an ApplicationContext (the context interface extends
- * ResourcePatternResolver). Use a PathMatchingResourcePatternResolver as default.
- * See also the {@code ResourcePatternUtils.getResourcePatternResolver} method.
+ * <p>A passed-in {@code ResourceLoader} can also be checked for the
+ * {@link org.springframework.core.io.support.ResourcePatternResolver} interface
+ * and cast accordingly, in order to resolve resource patterns into arrays of
+ * {@code Resource} objects. This will always work when running in an ApplicationContext
+ * (since the context interface extends the ResourcePatternResolver interface). Use a
+ * {@link org.springframework.core.io.support.PathMatchingResourcePatternResolver} as
+ * default; see also the {@code ResourcePatternUtils.getResourcePatternResolver} method.
*
- * <p>As alternative to a ResourcePatternResolver dependency, consider exposing
- * bean properties of type Resource array, populated via pattern Strings with
- * automatic type conversion by the bean factory.
+ * <p>As an alternative to a {@code ResourcePatternResolver} dependency, consider
+ * exposing bean properties of type {@code Resource} array, populated via pattern
+ * Strings with automatic type conversion by the bean factory at binding time.
*
* @author Juergen Hoeller
* @author Chris Beams
* @since 10.03.2004
* @see ApplicationContextAware
- * @see org.springframework.beans.factory.InitializingBean
* @see org.springframework.core.io.Resource
+ * @see org.springframework.core.io.ResourceLoader
* @see org.springframework.core.io.support.ResourcePatternResolver
- * @see org.springframework.core.io.support.ResourcePatternUtils#getResourcePatternResolver
- * @see org.springframework.core.io.DefaultResourceLoader
- * @see org.springframework.core.io.support.PathMatchingResourcePatternResolver
- * @see org.springframework.context.support.ReloadableResourceBundleMessageSource
*/
public interface ResourceLoaderAware extends Aware {
@@ -69,7 +69,7 @@ public interface ResourceLoaderAware extends Aware {
* <p>Invoked after population of normal bean properties but before an init callback
* like InitializingBean's {@code afterPropertiesSet} or a custom init-method.
* Invoked before ApplicationContextAware's {@code setApplicationContext}.
- * @param resourceLoader ResourceLoader object to be used by this object
+ * @param resourceLoader the ResourceLoader object to be used by this object
* @see org.springframework.core.io.support.ResourcePatternResolver
* @see org.springframework.core.io.support.ResourcePatternUtils#getResourcePatternResolver
*/
diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java
index bf2b838f..98b3d601 100644
--- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java
+++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.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.
@@ -85,9 +85,9 @@ import org.springframework.util.StringUtils;
* another using the {@link Import} annotation).
*
* <p>This class helps separate the concern of parsing the structure of a Configuration
- * class from the concern of registering BeanDefinition objects based on the
- * content of that model (with the exception of {@code @ComponentScan} annotations which
- * need to be registered immediately).
+ * class from the concern of registering BeanDefinition objects based on the content of
+ * that model (with the exception of {@code @ComponentScan} annotations which need to be
+ * registered immediately).
*
* <p>This ASM-based implementation avoids reflection and eager class loading in order to
* interoperate effectively with lazy class loading in a Spring ApplicationContext.
@@ -814,7 +814,7 @@ class ConfigurationClassParser {
return new AssignableTypeFilter(clazz).match((MetadataReader) this.source, metadataReaderFactory);
}
- public ConfigurationClass asConfigClass(ConfigurationClass importedBy) throws IOException {
+ public ConfigurationClass asConfigClass(ConfigurationClass importedBy) {
if (this.source instanceof Class) {
return new ConfigurationClass((Class<?>) this.source, importedBy);
}
@@ -882,7 +882,7 @@ class ConfigurationClassParser {
return result;
}
- public Set<SourceClass> getAnnotations() throws IOException {
+ public Set<SourceClass> getAnnotations() {
Set<SourceClass> result = new LinkedHashSet<SourceClass>();
for (String className : this.metadata.getAnnotationTypes()) {
try {
diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java
index 5ec6846a..abcb5978 100644
--- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java
+++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.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.
@@ -428,7 +428,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
}
@Override
- public Object postProcessBeforeInitialization(Object bean, String beanName) {
+ public Object postProcessBeforeInitialization(Object bean, String beanName) {
if (bean instanceof ImportAware) {
ImportRegistry ir = this.beanFactory.getBean(IMPORT_REGISTRY_BEAN_NAME, ImportRegistry.class);
AnnotationMetadata importingClass = ir.getImportingClassFor(bean.getClass().getSuperclass().getName());
diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ImportBeanDefinitionRegistrar.java b/spring-context/src/main/java/org/springframework/context/annotation/ImportBeanDefinitionRegistrar.java
index 1dce3d41..49af978b 100644
--- a/spring-context/src/main/java/org/springframework/context/annotation/ImportBeanDefinitionRegistrar.java
+++ b/spring-context/src/main/java/org/springframework/context/annotation/ImportBeanDefinitionRegistrar.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 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.
@@ -58,7 +58,6 @@ public interface ImportBeanDefinitionRegistrar {
* @param importingClassMetadata annotation metadata of the importing class
* @param registry current bean definition registry
*/
- public void registerBeanDefinitions(
- AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry);
+ void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry);
}
diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ImportSelector.java b/spring-context/src/main/java/org/springframework/context/annotation/ImportSelector.java
index c684426f..973fca6f 100644
--- a/spring-context/src/main/java/org/springframework/context/annotation/ImportSelector.java
+++ b/spring-context/src/main/java/org/springframework/context/annotation/ImportSelector.java
@@ -20,12 +20,12 @@ import org.springframework.core.type.AnnotationMetadata;
/**
* Interface to be implemented by types that determine which @{@link Configuration}
- * class(es) should be imported based on a given selection criteria, usually one or more
- * annotation attributes.
+ * class(es) should be imported based on a given selection criteria, usually one or
+ * more annotation attributes.
*
* <p>An {@link ImportSelector} may implement any of the following
- * {@link org.springframework.beans.factory.Aware Aware} interfaces, and their respective
- * methods will be called prior to {@link #selectImports}:
+ * {@link org.springframework.beans.factory.Aware Aware} interfaces,
+ * and their respective methods will be called prior to {@link #selectImports}:
* <ul>
* <li>{@link org.springframework.context.EnvironmentAware EnvironmentAware}</li>
* <li>{@link org.springframework.beans.factory.BeanFactoryAware BeanFactoryAware}</li>
@@ -33,10 +33,10 @@ import org.springframework.core.type.AnnotationMetadata;
* <li>{@link org.springframework.context.ResourceLoaderAware ResourceLoaderAware}</li>
* </ul>
*
- * <p>ImportSelectors are usually processed in the same way as regular {@code @Import}
- * annotations, however, it is also possible to defer selection of imports until all
- * {@code @Configuration} classes have been processed (see {@link DeferredImportSelector}
- * for details).
+ * <p>{@code ImportSelector} implementations are usually processed in the same way
+ * as regular {@code @Import} annotations, however, it is also possible to defer
+ * selection of imports until all {@code @Configuration} classes have been processed
+ * (see {@link DeferredImportSelector} for details).
*
* @author Chris Beams
* @since 3.1
diff --git a/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java b/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java
index ef92882d..19d3dedf 100644
--- a/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java
+++ b/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.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.
@@ -257,7 +257,7 @@ public abstract class AbstractApplicationEventMulticaster
* type before trying to instantiate it.
* <p>If this method returns {@code true} for a given listener as a first pass,
* the listener instance will get retrieved and fully evaluated through a
- * {@link #supportsEvent(ApplicationListener,ResolvableType, Class)} call afterwards.
+ * {@link #supportsEvent(ApplicationListener, ResolvableType, Class)} call afterwards.
* @param listenerType the listener's type as determined by the BeanFactory
* @param eventType the event type to check
* @return whether the given listener should be included in the candidates
diff --git a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java
index 9a58e921..1e12aec7 100644
--- a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java
+++ b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.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.
@@ -93,7 +93,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
this.declaredEventTypes = resolveDeclaredEventTypes(method, ann);
this.condition = (ann != null ? ann.condition() : null);
- this.order = resolveOrder(method);
+ this.order = resolveOrder(targetMethod);
this.methodKey = new AnnotatedElementKey(method, targetClass);
}
@@ -186,9 +186,9 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
/**
* Resolve the method arguments to use for the specified {@link ApplicationEvent}.
- * <p>These arguments will be used to invoke the method handled by this instance. Can
- * return {@code null} to indicate that no suitable arguments could be resolved and
- * therefore the method should not be invoked at all for the specified event.
+ * <p>These arguments will be used to invoke the method handled by this instance.
+ * Can return {@code null} to indicate that no suitable arguments could be resolved
+ * and therefore the method should not be invoked at all for the specified event.
*/
protected Object[] resolveArguments(ApplicationEvent event) {
ResolvableType declaredEventType = getResolvableType(event);
@@ -198,13 +198,15 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
if (this.method.getParameterTypes().length == 0) {
return new Object[0];
}
- if (!ApplicationEvent.class.isAssignableFrom(declaredEventType.getRawClass()) &&
+ Class<?> eventClass = declaredEventType.getRawClass();
+ if ((eventClass == null || !ApplicationEvent.class.isAssignableFrom(eventClass)) &&
event instanceof PayloadApplicationEvent) {
- return new Object[] {((PayloadApplicationEvent) event).getPayload()};
- }
- else {
- return new Object[] {event};
+ Object payload = ((PayloadApplicationEvent) event).getPayload();
+ if (eventClass == null || eventClass.isInstance(payload)) {
+ return new Object[] {payload};
+ }
}
+ return new Object[] {event};
}
protected void handleResult(Object result) {
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!
*
diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java
index 6543e365..25c3ab13 100644
--- a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java
+++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.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.
@@ -129,16 +129,16 @@ public class XmlBeanFactoryTests {
return new ClassPathResource(CLASSNAME + suffix, CLASS);
}
- /* SPR-2368 */
- @Test
- public void testCollectionsReferredToAsRefLocals() throws Exception {
+
+ @Test // SPR-2368
+ public void testCollectionsReferredToAsRefLocals() {
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(COLLECTIONS_XSD_CONTEXT);
factory.preInstantiateSingletons();
}
@Test
- public void testRefToSeparatePrototypeInstances() throws Exception {
+ public void testRefToSeparatePrototypeInstances() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
@@ -157,7 +157,7 @@ public class XmlBeanFactoryTests {
}
@Test
- public void testRefToSingleton() throws Exception {
+ public void testRefToSingleton() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
@@ -313,7 +313,7 @@ public class XmlBeanFactoryTests {
}
@Test
- public void testInheritanceFromParentFactoryPrototype() throws Exception {
+ public void testInheritanceFromParentFactoryPrototype() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@@ -329,7 +329,7 @@ public class XmlBeanFactoryTests {
}
@Test
- public void testInheritanceWithDifferentClass() throws Exception {
+ public void testInheritanceWithDifferentClass() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@@ -344,7 +344,7 @@ public class XmlBeanFactoryTests {
}
@Test
- public void testInheritanceWithClass() throws Exception {
+ public void testInheritanceWithClass() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@@ -359,7 +359,7 @@ public class XmlBeanFactoryTests {
}
@Test
- public void testPrototypeInheritanceFromParentFactoryPrototype() throws Exception {
+ public void testPrototypeInheritanceFromParentFactoryPrototype() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@@ -379,7 +379,7 @@ public class XmlBeanFactoryTests {
}
@Test
- public void testPrototypeInheritanceFromParentFactorySingleton() throws Exception {
+ public void testPrototypeInheritanceFromParentFactorySingleton() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@@ -439,7 +439,7 @@ public class XmlBeanFactoryTests {
}
@Test
- public void testDependenciesMaterializeThis() throws Exception {
+ public void testDependenciesMaterializeThis() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(DEP_MATERIALIZE_CONTEXT);
@@ -458,7 +458,7 @@ public class XmlBeanFactoryTests {
}
@Test
- public void testChildOverridesParentBean() throws Exception {
+ public void testChildOverridesParentBean() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@@ -477,7 +477,7 @@ public class XmlBeanFactoryTests {
* If a singleton does this the factory will fail to load.
*/
@Test
- public void testBogusParentageFromParentFactory() throws Exception {
+ public void testBogusParentageFromParentFactory() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@@ -488,7 +488,7 @@ public class XmlBeanFactoryTests {
}
catch (BeanDefinitionStoreException ex) {
// check exception message contains the name
- assertTrue(ex.getMessage().indexOf("bogusParent") != -1);
+ assertTrue(ex.getMessage().contains("bogusParent"));
assertTrue(ex.getCause() instanceof NoSuchBeanDefinitionException);
}
}
@@ -499,7 +499,7 @@ public class XmlBeanFactoryTests {
* instances even if derived from a prototype
*/
@Test
- public void testSingletonInheritsFromParentFactoryPrototype() throws Exception {
+ public void testSingletonInheritsFromParentFactoryPrototype() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@@ -664,7 +664,7 @@ public class XmlBeanFactoryTests {
}
@Test
- public void testInitMethodIsInvoked() throws Exception {
+ public void testInitMethodIsInvoked() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
DoubleInitializer in = (DoubleInitializer) xbf.getBean("init-method1");
@@ -684,14 +684,14 @@ public class XmlBeanFactoryTests {
fail();
}
catch (BeanCreationException ex) {
- assertTrue(ex.getResourceDescription().indexOf("initializers.xml") != -1);
+ assertTrue(ex.getResourceDescription().contains("initializers.xml"));
assertEquals("init-method2", ex.getBeanName());
assertTrue(ex.getCause() instanceof IOException);
}
}
@Test
- public void testNoSuchInitMethod() throws Exception {
+ public void testNoSuchInitMethod() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
try {
@@ -700,9 +700,9 @@ public class XmlBeanFactoryTests {
}
catch (FatalBeanException ex) {
// check message is helpful
- assertTrue(ex.getMessage().indexOf("initializers.xml") != -1);
- assertTrue(ex.getMessage().indexOf("init-method3") != -1);
- assertTrue(ex.getMessage().indexOf("init") != -1);
+ assertTrue(ex.getMessage().contains("initializers.xml"));
+ assertTrue(ex.getMessage().contains("init-method3"));
+ assertTrue(ex.getMessage().contains("init"));
}
}
@@ -710,7 +710,7 @@ public class XmlBeanFactoryTests {
* Check that InitializingBean method is called first.
*/
@Test
- public void testInitializingBeanAndInitMethod() throws Exception {
+ public void testInitializingBeanAndInitMethod() {
InitAndIB.constructed = false;
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
@@ -731,7 +731,7 @@ public class XmlBeanFactoryTests {
* Check that InitializingBean method is not called twice.
*/
@Test
- public void testInitializingBeanAndSameInitMethod() throws Exception {
+ public void testInitializingBeanAndSameInitMethod() {
InitAndIB.constructed = false;
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
@@ -749,7 +749,7 @@ public class XmlBeanFactoryTests {
}
@Test
- public void testDefaultLazyInit() throws Exception {
+ public void testDefaultLazyInit() {
InitAndIB.constructed = false;
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(DEFAULT_LAZY_CONTEXT);
@@ -765,13 +765,13 @@ public class XmlBeanFactoryTests {
}
@Test(expected = BeanDefinitionStoreException.class)
- public void noSuchXmlFile() throws Exception {
+ public void noSuchXmlFile() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(MISSING_CONTEXT);
}
@Test(expected = BeanDefinitionStoreException.class)
- public void invalidXmlFile() throws Exception {
+ public void invalidXmlFile() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INVALID_CONTEXT);
}
@@ -825,7 +825,7 @@ public class XmlBeanFactoryTests {
}
@Test
- public void testAutowire() throws Exception {
+ public void testAutowire() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(AUTOWIRE_CONTEXT);
TestBean spouse = new TestBean("kerry", 0);
@@ -834,7 +834,7 @@ public class XmlBeanFactoryTests {
}
@Test
- public void testAutowireWithParent() throws Exception {
+ public void testAutowireWithParent() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(AUTOWIRE_CONTEXT);
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
@@ -847,7 +847,7 @@ public class XmlBeanFactoryTests {
doTestAutowire(xbf);
}
- private void doTestAutowire(DefaultListableBeanFactory xbf) throws Exception {
+ private void doTestAutowire(DefaultListableBeanFactory xbf) {
DependenciesBean rod1 = (DependenciesBean) xbf.getBean("rod1");
TestBean kerry = (TestBean) xbf.getBean("spouse");
// should have been autowired
@@ -896,7 +896,7 @@ public class XmlBeanFactoryTests {
}
@Test
- public void testAutowireWithDefault() throws Exception {
+ public void testAutowireWithDefault() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(DEFAULT_AUTOWIRE_CONTEXT);
@@ -919,7 +919,7 @@ public class XmlBeanFactoryTests {
}
@Test
- public void testAutowireByConstructor() throws Exception {
+ public void testAutowireByConstructor() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
ConstructorDependenciesBean rod1 = (ConstructorDependenciesBean) xbf.getBean("rod1");
@@ -957,7 +957,7 @@ public class XmlBeanFactoryTests {
}
@Test
- public void testAutowireByConstructorWithSimpleValues() throws Exception {
+ public void testAutowireByConstructorWithSimpleValues() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
@@ -995,7 +995,7 @@ public class XmlBeanFactoryTests {
xbf.getBean("rod2Accessor");
}
catch (BeanCreationException ex) {
- assertTrue(ex.toString().indexOf("touchy") != -1);
+ assertTrue(ex.toString().contains("touchy"));
ex.printStackTrace();
assertNull(ex.getRelatedCauses());
}
@@ -1075,14 +1075,14 @@ public class XmlBeanFactoryTests {
}
@Test(expected = BeanCreationException.class)
- public void throwsExceptionOnTooManyArguments() throws Exception {
+ public void throwsExceptionOnTooManyArguments() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
xbf.getBean("rod7", ConstructorDependenciesBean.class);
}
@Test(expected = UnsatisfiedDependencyException.class)
- public void throwsExceptionOnAmbiguousResolution() throws Exception {
+ public void throwsExceptionOnAmbiguousResolution() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
xbf.getBean("rod8", ConstructorDependenciesBean.class);
@@ -1176,7 +1176,7 @@ public class XmlBeanFactoryTests {
fail("Must have thrown a CannotLoadBeanClassException");
}
catch (CannotLoadBeanClassException ex) {
- assertTrue(ex.getResourceDescription().indexOf("classNotFound.xml") != -1);
+ assertTrue(ex.getResourceDescription().contains("classNotFound.xml"));
assertTrue(ex.getCause() instanceof ClassNotFoundException);
}
}
@@ -1428,12 +1428,12 @@ public class XmlBeanFactoryTests {
}
catch (BeanDefinitionStoreException ex) {
// Check that the bogus method name was included in the error message
- assertTrue("Bogus method name correctly reported", ex.getMessage().indexOf("bogusMethod") != -1);
+ assertTrue("Bogus method name correctly reported", ex.getMessage().contains("bogusMethod"));
}
}
@Test
- public void serializableMethodReplacerAndSuperclass() throws Exception {
+ public void serializableMethodReplacerAndSuperclass() throws IOException {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(DELEGATION_OVERRIDES_CONTEXT);
@@ -1632,7 +1632,7 @@ public class XmlBeanFactoryTests {
}
@Test
- public void testWithDuplicateName() throws Exception {
+ public void testWithDuplicateName() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
try {
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(TEST_WITH_DUP_NAMES_CONTEXT);
@@ -1644,7 +1644,7 @@ public class XmlBeanFactoryTests {
}
@Test
- public void testWithDuplicateNameInAlias() throws Exception {
+ public void testWithDuplicateNameInAlias() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
try {
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(TEST_WITH_DUP_NAME_IN_ALIAS_CONTEXT);
diff --git a/spring-context/src/test/java/org/springframework/context/config/ContextNamespaceHandlerTests.java b/spring-context/src/test/java/org/springframework/context/config/ContextNamespaceHandlerTests.java
index bf106be7..abfb143f 100644
--- a/spring-context/src/test/java/org/springframework/context/config/ContextNamespaceHandlerTests.java
+++ b/spring-context/src/test/java/org/springframework/context/config/ContextNamespaceHandlerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 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.
@@ -48,7 +48,7 @@ public class ContextNamespaceHandlerTests {
@Test
- public void propertyPlaceholder() throws Exception {
+ public void propertyPlaceholder() {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
"contextNamespaceHandlerTests-replace.xml", getClass());
assertEquals("bar", applicationContext.getBean("string"));
@@ -56,7 +56,7 @@ public class ContextNamespaceHandlerTests {
}
@Test
- public void propertyPlaceholderSystemProperties() throws Exception {
+ public void propertyPlaceholderSystemProperties() {
String value = System.setProperty("foo", "spam");
try {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
@@ -72,7 +72,7 @@ public class ContextNamespaceHandlerTests {
}
@Test
- public void propertyPlaceholderEnvironmentProperties() throws Exception {
+ public void propertyPlaceholderEnvironmentProperties() {
MockEnvironment env = new MockEnvironment().withProperty("foo", "spam");
GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext();
applicationContext.setEnvironment(env);
@@ -83,7 +83,7 @@ public class ContextNamespaceHandlerTests {
}
@Test
- public void propertyPlaceholderLocation() throws Exception {
+ public void propertyPlaceholderLocation() {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
"contextNamespaceHandlerTests-location.xml", getClass());
assertEquals("bar", applicationContext.getBean("foo"));
@@ -92,7 +92,7 @@ public class ContextNamespaceHandlerTests {
}
@Test
- public void propertyPlaceholderLocationWithSystemPropertyForOneLocation() throws Exception {
+ public void propertyPlaceholderLocationWithSystemPropertyForOneLocation() {
System.setProperty("properties",
"classpath*:/org/springframework/context/config/test-*.properties");
try {
@@ -108,7 +108,7 @@ public class ContextNamespaceHandlerTests {
}
@Test
- public void propertyPlaceholderLocationWithSystemPropertyForMultipleLocations() throws Exception {
+ public void propertyPlaceholderLocationWithSystemPropertyForMultipleLocations() {
System.setProperty("properties",
"classpath*:/org/springframework/context/config/test-*.properties," +
"classpath*:/org/springframework/context/config/empty-*.properties," +
@@ -126,7 +126,7 @@ public class ContextNamespaceHandlerTests {
}
@Test
- public void propertyPlaceholderLocationWithSystemPropertyMissing() throws Exception {
+ public void propertyPlaceholderLocationWithSystemPropertyMissing() {
try {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
"contextNamespaceHandlerTests-location-placeholder.xml", getClass());
@@ -140,7 +140,7 @@ public class ContextNamespaceHandlerTests {
}
@Test
- public void propertyPlaceholderIgnored() throws Exception {
+ public void propertyPlaceholderIgnored() {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
"contextNamespaceHandlerTests-replace-ignore.xml", getClass());
assertEquals("${bar}", applicationContext.getBean("string"));
@@ -148,7 +148,7 @@ public class ContextNamespaceHandlerTests {
}
@Test
- public void propertyOverride() throws Exception {
+ public void propertyOverride() {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
"contextNamespaceHandlerTests-override.xml", getClass());
Date date = (Date) applicationContext.getBean("date");
diff --git a/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java b/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java
index 6437ac57..dc298c22 100644
--- a/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java
+++ b/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 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.
@@ -49,14 +49,14 @@ public class EventPublicationInterceptorTests {
this.publisher = mock(ApplicationEventPublisher.class);
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testWithNoApplicationEventClassSupplied() throws Exception {
EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
interceptor.setApplicationEventPublisher(this.publisher);
interceptor.afterPropertiesSet();
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testWithNonApplicationEventClassSupplied() throws Exception {
EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
interceptor.setApplicationEventPublisher(this.publisher);
@@ -64,7 +64,7 @@ public class EventPublicationInterceptorTests {
interceptor.afterPropertiesSet();
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testWithAbstractStraightApplicationEventClassSupplied() throws Exception {
EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
interceptor.setApplicationEventPublisher(this.publisher);
@@ -72,7 +72,7 @@ public class EventPublicationInterceptorTests {
interceptor.afterPropertiesSet();
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testWithApplicationEventClassThatDoesntExposeAValidCtor() throws Exception {
EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
interceptor.setApplicationEventPublisher(this.publisher);
@@ -129,7 +129,7 @@ public class EventPublicationInterceptorTests {
public static class FactoryBeanTestListener extends TestListener implements FactoryBean<Object> {
@Override
- public Object getObject() throws Exception {
+ public Object getObject() {
return "test";
}
diff --git a/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java b/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java
new file mode 100644
index 00000000..1b1100ba
--- /dev/null
+++ b/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.context.event;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.PayloadApplicationEvent;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.stereotype.Component;
+
+import static org.junit.Assert.*;
+
+/**
+ * @author Juergen Hoeller
+ */
+public class PayloadApplicationEventTests {
+
+ @Test
+ public void testEventClassWithInterface() {
+ ApplicationContext ac = new AnnotationConfigApplicationContext(AuditableListener.class);
+ AuditablePayloadEvent event = new AuditablePayloadEvent<>(this, "xyz");
+ ac.publishEvent(event);
+ assertTrue(ac.getBean(AuditableListener.class).events.contains(event));
+ }
+
+
+ public interface Auditable {
+ }
+
+
+ @SuppressWarnings("serial")
+ public static class AuditablePayloadEvent<T> extends PayloadApplicationEvent<T> implements Auditable {
+
+ public AuditablePayloadEvent(Object source, T payload) {
+ super(source, payload);
+ }
+ }
+
+
+ @Component
+ public static class AuditableListener {
+
+ public final List<Auditable> events = new ArrayList<>();
+
+ @EventListener
+ public void onEvent(Auditable event) {
+ events.add(event);
+ }
+ }
+
+}
diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-resource.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-resource.xml
index a48a3267..d03cdec6 100644
--- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-resource.xml
+++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-resource.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "https://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
diff --git a/spring-context/src/test/resources/org/springframework/context/config/contextNamespaceHandlerTests-simple.xml b/spring-context/src/test/resources/org/springframework/context/config/contextNamespaceHandlerTests-simple.xml
index 42bd4335..b8f2aa88 100644
--- a/spring-context/src/test/resources/org/springframework/context/config/contextNamespaceHandlerTests-simple.xml
+++ b/spring-context/src/test/resources/org/springframework/context/config/contextNamespaceHandlerTests-simple.xml
@@ -2,8 +2,8 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
+ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:property-placeholder/>