Merge branch '5.1.x'
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -269,7 +269,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
|
||||
|
||||
@@ -188,9 +188,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.
|
||||
*/
|
||||
@Nullable
|
||||
protected Object[] resolveArguments(ApplicationEvent event) {
|
||||
@@ -201,13 +201,15 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
|
||||
if (this.method.getParameterCount() == 0) {
|
||||
return new Object[0];
|
||||
}
|
||||
if (!ApplicationEvent.class.isAssignableFrom(declaredEventType.toClass()) &&
|
||||
Class<?> declaredEventClass = declaredEventType.toClass();
|
||||
if (!ApplicationEvent.class.isAssignableFrom(declaredEventClass) &&
|
||||
event instanceof PayloadApplicationEvent) {
|
||||
return new Object[] {((PayloadApplicationEvent) event).getPayload()};
|
||||
}
|
||||
else {
|
||||
return new Object[] {event};
|
||||
Object payload = ((PayloadApplicationEvent) event).getPayload();
|
||||
if (declaredEventClass.isInstance(payload)) {
|
||||
return new Object[] {payload};
|
||||
}
|
||||
}
|
||||
return new Object[] {event};
|
||||
}
|
||||
|
||||
protected void handleResult(Object result) {
|
||||
|
||||
@@ -36,14 +36,13 @@ import org.springframework.lang.Nullable;
|
||||
* 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!
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user