From 6a73d2655f15000214912765ce75059b714b5995 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 19 Feb 2022 14:59:54 +0100 Subject: [PATCH] Polishing --- .../interceptor/AsyncExecutionAspectSupport.java | 6 +++--- .../annotation/BeanFactoryAnnotationUtils.java | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java index 66dbc3042f..45221f3674 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java @@ -156,7 +156,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware { /** * Determine the specific executor to use when executing the given method. - * Should preferably return an {@link AsyncListenableTaskExecutor} implementation. + *

Should preferably return an {@link AsyncListenableTaskExecutor} implementation. * @return the executor to use (or {@code null}, but just if no default executor is available) */ @Nullable @@ -184,7 +184,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware { /** * Return the qualifier or bean name of the executor to be used when executing the * given async method, typically specified in the form of an annotation attribute. - * Returning an empty string or {@code null} indicates that no specific executor has + *

Returning an empty string or {@code null} indicates that no specific executor has * been specified and that the {@linkplain #setExecutor(Executor) default executor} * should be used. * @param method the method to inspect for executor qualifier metadata @@ -213,7 +213,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware { /** * Retrieve or build a default executor for this advice instance. - * An executor returned from here will be cached for further use. + *

An executor returned from here will be cached for further use. *

The default implementation searches for a unique {@link TaskExecutor} bean * in the context, or for an {@link Executor} bean named "taskExecutor" otherwise. * If neither of the two is resolvable, this implementation will return {@code null}. diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/BeanFactoryAnnotationUtils.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/BeanFactoryAnnotationUtils.java index 722995aabe..fd41a5cfe0 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/BeanFactoryAnnotationUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/BeanFactoryAnnotationUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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 @@ import org.springframework.util.Assert; public abstract class BeanFactoryAnnotationUtils { /** - * Retrieve all bean of type {@code T} from the given {@code BeanFactory} declaring a + * Retrieve all beans of type {@code T} from the given {@code BeanFactory} declaring a * qualifier (e.g. via {@code } or {@code @Qualifier}) matching the given * qualifier, or having a bean name matching the given qualifier. * @param beanFactory the factory to get the target beans from (also searching ancestors) @@ -90,9 +90,9 @@ public abstract class BeanFactoryAnnotationUtils { Assert.notNull(beanFactory, "BeanFactory must not be null"); - if (beanFactory instanceof ListableBeanFactory) { + if (beanFactory instanceof ListableBeanFactory lbf) { // Full qualifier matching supported. - return qualifiedBeanOfType((ListableBeanFactory) beanFactory, beanType, qualifier); + return qualifiedBeanOfType(lbf, beanType, qualifier); } else if (beanFactory.containsBean(qualifier)) { // Fallback: target bean at least found by bean name. @@ -163,8 +163,8 @@ public abstract class BeanFactoryAnnotationUtils { } try { Class beanType = beanFactory.getType(beanName); - if (beanFactory instanceof ConfigurableBeanFactory) { - BeanDefinition bd = ((ConfigurableBeanFactory) beanFactory).getMergedBeanDefinition(beanName); + if (beanFactory instanceof ConfigurableBeanFactory cbf) { + BeanDefinition bd = cbf.getMergedBeanDefinition(beanName); // Explicit qualifier metadata on bean definition? (typically in XML definition) if (bd instanceof AbstractBeanDefinition abd) { AutowireCandidateQualifier candidate = abd.getQualifier(Qualifier.class.getName()); @@ -176,8 +176,8 @@ public abstract class BeanFactoryAnnotationUtils { } } // Corresponding qualifier on factory method? (typically in configuration class) - if (bd instanceof RootBeanDefinition) { - Method factoryMethod = ((RootBeanDefinition) bd).getResolvedFactoryMethod(); + if (bd instanceof RootBeanDefinition rbd) { + Method factoryMethod = rbd.getResolvedFactoryMethod(); if (factoryMethod != null) { Qualifier targetAnnotation = AnnotationUtils.getAnnotation(factoryMethod, Qualifier.class); if (targetAnnotation != null) {