Fix binary compatibility for SmartApplicationListener
Making sure that `GenericApplicationListenerAdapter` implements `SmartApplicationListener` again as older code may try to cast an instance to `SmartApplicationListener`. Issue: SPR-8201
This commit is contained in:
parent
5d67219a4e
commit
b8f10f69a9
|
@ -32,7 +32,7 @@ import org.springframework.util.Assert;
|
|||
* @since 3.0
|
||||
* @see org.springframework.context.ApplicationListener#onApplicationEvent
|
||||
*/
|
||||
public class GenericApplicationListenerAdapter implements GenericApplicationListener {
|
||||
public class GenericApplicationListenerAdapter implements GenericApplicationListener, SmartApplicationListener {
|
||||
|
||||
private final ApplicationListener<ApplicationEvent> delegate;
|
||||
|
||||
|
@ -67,6 +67,11 @@ public class GenericApplicationListenerAdapter implements GenericApplicationList
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
|
||||
return supportsEventType(ResolvableType.forType(eventType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsSourceType(Class<?> sourceType) {
|
||||
if (this.delegate instanceof SmartApplicationListener) {
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.springframework.core.ResolvableType;
|
|||
* @author Stephane Nicoll
|
||||
* @since 2.0.5
|
||||
*/
|
||||
public class SourceFilteringListener implements GenericApplicationListener {
|
||||
public class SourceFilteringListener implements GenericApplicationListener, SmartApplicationListener {
|
||||
|
||||
private final Object source;
|
||||
|
||||
|
@ -77,6 +77,11 @@ public class SourceFilteringListener implements GenericApplicationListener {
|
|||
return (this.delegate == null || this.delegate.supportsEventType(eventType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
|
||||
return supportsEventType(ResolvableType.forType(eventType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsSourceType(Class<?> sourceType) {
|
||||
return (sourceType != null && sourceType.isInstance(this.source));
|
||||
|
|
Loading…
Reference in New Issue