Custom resolution of preferred constructors for createBean(Class)

Avoids side effects of traditional AUTOWIRE_CONSTRUCTOR algorithm.

Closes gh-30041
This commit is contained in:
Juergen Hoeller
2023-03-02 12:54:26 +01:00
parent c56c16d7ba
commit f8cb0fa2a0
8 changed files with 110 additions and 13 deletions

View File

@@ -22,6 +22,7 @@ import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.PropertyAccessorFactory;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.lang.Nullable;
@@ -86,8 +87,9 @@ public class SpringBeanJobFactory extends AdaptableJobFactory
@Override
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
Object job = (this.applicationContext != null ?
// to be replaced with createBean(Class) in 6.1
this.applicationContext.getAutowireCapableBeanFactory().createBean(
bundle.getJobDetail().getJobClass()) :
bundle.getJobDetail().getJobClass(), AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false) :
super.createJobInstance(bundle));
if (isEligibleForPropertyPopulation(job)) {