diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/AutowireCapableBeanJobFactory.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/AutowireCapableBeanJobFactory.java deleted file mode 100644 index e114f17a93a..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/AutowireCapableBeanJobFactory.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2012-2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.autoconfigure.quartz; - -import org.quartz.spi.TriggerFiredBundle; - -import org.springframework.beans.factory.config.AutowireCapableBeanFactory; -import org.springframework.scheduling.quartz.SpringBeanJobFactory; -import org.springframework.util.Assert; - -/** - * Subclass of {@link SpringBeanJobFactory} that supports auto-wiring job beans. - * - * @author Vedran Pavic - * @see Inject application - * context dependencies in Quartz job beans - */ -class AutowireCapableBeanJobFactory extends SpringBeanJobFactory { - - private final AutowireCapableBeanFactory beanFactory; - - AutowireCapableBeanJobFactory(AutowireCapableBeanFactory beanFactory) { - Assert.notNull(beanFactory, "Bean factory must not be null"); - this.beanFactory = beanFactory; - } - - @Override - protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { - Object jobInstance = super.createJobInstance(bundle); - this.beanFactory.autowireBean(jobInstance); - this.beanFactory.initializeBean(jobInstance, null); - return jobInstance; - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java index de4e3178236..57925b40d69 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java @@ -42,6 +42,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.Order; import org.springframework.core.io.ResourceLoader; import org.springframework.scheduling.quartz.SchedulerFactoryBean; +import org.springframework.scheduling.quartz.SpringBeanJobFactory; import org.springframework.transaction.PlatformTransactionManager; /** @@ -88,8 +89,9 @@ public class QuartzAutoConfiguration { @ConditionalOnMissingBean public SchedulerFactoryBean quartzScheduler() { SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean(); - schedulerFactoryBean.setJobFactory(new AutowireCapableBeanJobFactory( - this.applicationContext.getAutowireCapableBeanFactory())); + SpringBeanJobFactory jobFactory = new SpringBeanJobFactory(); + jobFactory.setApplicationContext(this.applicationContext); + schedulerFactoryBean.setJobFactory(jobFactory); if (this.properties.getSchedulerName() != null) { schedulerFactoryBean.setSchedulerName(this.properties.getSchedulerName()); }