Polishing

This commit is contained in:
Sam Brannen
2023-03-03 15:31:27 +01:00
parent 3dd0fbfb57
commit 3854861a8a
5 changed files with 43 additions and 61 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 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.
@@ -52,8 +52,8 @@ import org.springframework.util.ObjectUtils;
*
* <p>Implementing ApplicationEventMulticaster's actual {@link #multicastEvent} method
* is left to subclasses. {@link SimpleApplicationEventMulticaster} simply multicasts
* all events to all registered listeners, invoking them in the calling thread.
* Alternative implementations could be more sophisticated in those respects.
* all events to all registered listeners, invoking them in the calling thread by
* default. Alternative implementations could be more sophisticated in those respects.
*
* @author Juergen Hoeller
* @author Stephane Nicoll
@@ -82,10 +82,10 @@ public abstract class AbstractApplicationEventMulticaster
@Override
public void setBeanFactory(BeanFactory beanFactory) {
if (!(beanFactory instanceof ConfigurableBeanFactory)) {
if (!(beanFactory instanceof ConfigurableBeanFactory cbf)) {
throw new IllegalStateException("Not running in a ConfigurableBeanFactory: " + beanFactory);
}
this.beanFactory = (ConfigurableBeanFactory) beanFactory;
this.beanFactory = cbf;
if (this.beanClassLoader == null) {
this.beanClassLoader = this.beanFactory.getBeanClassLoader();
}
@@ -373,8 +373,8 @@ public abstract class AbstractApplicationEventMulticaster
protected boolean supportsEvent(
ApplicationListener<?> listener, ResolvableType eventType, @Nullable Class<?> sourceType) {
GenericApplicationListener smartListener = (listener instanceof GenericApplicationListener ?
(GenericApplicationListener) listener : new GenericApplicationListenerAdapter(listener));
GenericApplicationListener smartListener = (listener instanceof GenericApplicationListener gal ? gal :
new GenericApplicationListenerAdapter(listener));
return (smartListener.supportsEventType(eventType) && smartListener.supportsSourceType(sourceType));
}