Deprecate AutowireCapableBeanFactory.createBean(Class, int, boolean)
Includes consistent usage of createBean(Class) in SpringBeanJobFactory and SpringBeanContainer. Closes gh-30345 See gh-29855 See gh-30041
This commit is contained in:
parent
4d15b58ca4
commit
d39e44c209
|
@ -64,7 +64,6 @@ public interface AutowireCapableBeanFactory extends BeanFactory {
|
|||
/**
|
||||
* Constant that indicates no externally defined autowiring. Note that
|
||||
* BeanFactoryAware etc and annotation-driven injection will still be applied.
|
||||
* @see #createBean
|
||||
* @see #autowire
|
||||
* @see #autowireBeanProperties
|
||||
*/
|
||||
|
@ -73,7 +72,6 @@ public interface AutowireCapableBeanFactory extends BeanFactory {
|
|||
/**
|
||||
* Constant that indicates autowiring bean properties by name
|
||||
* (applying to all bean property setters).
|
||||
* @see #createBean
|
||||
* @see #autowire
|
||||
* @see #autowireBeanProperties
|
||||
*/
|
||||
|
@ -82,7 +80,6 @@ public interface AutowireCapableBeanFactory extends BeanFactory {
|
|||
/**
|
||||
* Constant that indicates autowiring bean properties by type
|
||||
* (applying to all bean property setters).
|
||||
* @see #createBean
|
||||
* @see #autowire
|
||||
* @see #autowireBeanProperties
|
||||
*/
|
||||
|
@ -91,7 +88,6 @@ public interface AutowireCapableBeanFactory extends BeanFactory {
|
|||
/**
|
||||
* Constant that indicates autowiring the greediest constructor that
|
||||
* can be satisfied (involves resolving the appropriate constructor).
|
||||
* @see #createBean
|
||||
* @see #autowire
|
||||
*/
|
||||
int AUTOWIRE_CONSTRUCTOR = 3;
|
||||
|
@ -99,7 +95,6 @@ public interface AutowireCapableBeanFactory extends BeanFactory {
|
|||
/**
|
||||
* Constant that indicates determining an appropriate autowire strategy
|
||||
* through introspection of the bean class.
|
||||
* @see #createBean
|
||||
* @see #autowire
|
||||
* @deprecated as of Spring 3.0: If you are using mixed autowiring strategies,
|
||||
* prefer annotation-based autowiring for clearer demarcation of autowiring needs.
|
||||
|
@ -192,7 +187,9 @@ public interface AutowireCapableBeanFactory extends BeanFactory {
|
|||
* @see #AUTOWIRE_BY_NAME
|
||||
* @see #AUTOWIRE_BY_TYPE
|
||||
* @see #AUTOWIRE_CONSTRUCTOR
|
||||
* @deprecated as of 6.1, in favor of {@link #createBean(Class)}
|
||||
*/
|
||||
@Deprecated(since = "6.1")
|
||||
Object createBean(Class<?> beanClass, int autowireMode, boolean dependencyCheck) throws BeansException;
|
||||
|
||||
/**
|
||||
|
@ -322,7 +319,7 @@ public interface AutowireCapableBeanFactory extends BeanFactory {
|
|||
throws BeansException;
|
||||
|
||||
/**
|
||||
* Destroy the given bean instance (typically coming from {@link #createBean}),
|
||||
* Destroy the given bean instance (typically coming from {@link #createBean(Class)}),
|
||||
* applying the {@link org.springframework.beans.factory.DisposableBean} contract as well as
|
||||
* registered {@link DestructionAwareBeanPostProcessor DestructionAwareBeanPostProcessors}.
|
||||
* <p>Any exception that arises during destruction should be caught
|
||||
|
|
|
@ -357,6 +357,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
|||
// Specialized methods for fine-grained control over the bean lifecycle
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Object createBean(Class<?> beanClass, int autowireMode, boolean dependencyCheck) throws BeansException {
|
||||
// Use non-singleton bean definition, to avoid registering bean as dependent bean.
|
||||
|
|
|
@ -22,7 +22,6 @@ 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;
|
||||
|
@ -87,9 +86,7 @@ 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(), AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false) :
|
||||
this.applicationContext.getAutowireCapableBeanFactory().createBean(bundle.getJobDetail().getJobClass()) :
|
||||
super.createJobInstance(bundle));
|
||||
|
||||
if (isEligibleForPropertyPopulation(job)) {
|
||||
|
|
|
@ -144,7 +144,7 @@ public final class SpringBeanContainer implements BeanContainer {
|
|||
try {
|
||||
if (lifecycleOptions.useJpaCompliantCreation()) {
|
||||
return new SpringContainedBean<>(
|
||||
this.beanFactory.createBean(beanType, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false),
|
||||
this.beanFactory.createBean(beanType),
|
||||
this.beanFactory::destroyBean);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 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.
|
||||
|
@ -421,6 +421,7 @@ class StubWebApplicationContext implements WebApplicationContext {
|
|||
return BeanUtils.instantiateClass(beanClass);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Object createBean(Class<?> beanClass, int autowireMode, boolean dependencyCheck) {
|
||||
return BeanUtils.instantiateClass(beanClass);
|
||||
|
|
|
@ -915,12 +915,12 @@ public class DispatcherServlet extends FrameworkServlet {
|
|||
/**
|
||||
* Create a default strategy.
|
||||
* <p>The default implementation uses
|
||||
* {@link org.springframework.beans.factory.config.AutowireCapableBeanFactory#createBean}.
|
||||
* {@link org.springframework.beans.factory.config.AutowireCapableBeanFactory#createBean(Class)}.
|
||||
* @param context the current WebApplicationContext
|
||||
* @param clazz the strategy implementation class to instantiate
|
||||
* @return the fully configured strategy instance
|
||||
* @see org.springframework.context.ApplicationContext#getAutowireCapableBeanFactory()
|
||||
* @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#createBean
|
||||
* @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#createBean(Class)
|
||||
*/
|
||||
protected Object createDefaultStrategy(ApplicationContext context, Class<?> clazz) {
|
||||
return context.getAutowireCapableBeanFactory().createBean(clazz);
|
||||
|
|
Loading…
Reference in New Issue