Browse Source

Deprecate applyBeanPostProcessorsBefore/AfterInitialization

Closes gh-30974
pull/30980/head
Juergen Hoeller 1 year ago
parent
commit
2d50b758c4
  1. 6
      spring-beans/src/main/java/org/springframework/beans/factory/config/AutowireCapableBeanFactory.java
  2. 5
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
  3. 2
      spring-test/src/main/java/org/springframework/test/web/servlet/setup/StubWebApplicationContext.java

6
spring-beans/src/main/java/org/springframework/beans/factory/config/AutowireCapableBeanFactory.java

@ -297,7 +297,10 @@ public interface AutowireCapableBeanFactory extends BeanFactory { @@ -297,7 +297,10 @@ public interface AutowireCapableBeanFactory extends BeanFactory {
* @throws BeansException if any post-processing failed
* @see BeanPostProcessor#postProcessBeforeInitialization
* @see #ORIGINAL_INSTANCE_SUFFIX
* @deprecated as of 6.1, in favor of implicit post-processing through
* {@link #initializeBean(Object, String)}
*/
@Deprecated(since = "6.1")
Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, String beanName)
throws BeansException;
@ -314,7 +317,10 @@ public interface AutowireCapableBeanFactory extends BeanFactory { @@ -314,7 +317,10 @@ public interface AutowireCapableBeanFactory extends BeanFactory {
* @throws BeansException if any post-processing failed
* @see BeanPostProcessor#postProcessAfterInitialization
* @see #ORIGINAL_INSTANCE_SUFFIX
* @deprecated as of 6.1, in favor of implicit post-processing through
* {@link #initializeBean(Object, String)}
*/
@Deprecated(since = "6.1")
Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String beanName)
throws BeansException;

5
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java

@ -411,6 +411,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -411,6 +411,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
return initializeBean(beanName, existingBean, null);
}
@Deprecated(since = "6.1")
@Override
public Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, String beanName)
throws BeansException {
@ -426,6 +427,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -426,6 +427,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
return result;
}
@Deprecated(since = "6.1")
@Override
public Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String beanName)
throws BeansException {
@ -1092,6 +1094,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -1092,6 +1094,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @param mbd the bean definition for the bean
* @return the shortcut-determined bean instance, or {@code null} if none
*/
@SuppressWarnings("deprecation")
@Nullable
protected Object resolveBeforeInstantiation(String beanName, RootBeanDefinition mbd) {
Object bean = null;
@ -1755,6 +1758,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -1755,6 +1758,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @see #invokeInitMethods
* @see #applyBeanPostProcessorsAfterInitialization
*/
@SuppressWarnings("deprecation")
protected Object initializeBean(String beanName, Object bean, @Nullable RootBeanDefinition mbd) {
invokeAwareMethods(beanName, bean);
@ -1886,6 +1890,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -1886,6 +1890,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* object obtained from FactoryBeans (for example, to auto-proxy them).
* @see #applyBeanPostProcessorsAfterInitialization
*/
@SuppressWarnings("deprecation")
@Override
protected Object postProcessObjectFromFactoryBean(Object object, String beanName) {
return applyBeanPostProcessorsAfterInitialization(object, beanName);

2
spring-test/src/main/java/org/springframework/test/web/servlet/setup/StubWebApplicationContext.java

@ -472,11 +472,13 @@ class StubWebApplicationContext implements WebApplicationContext { @@ -472,11 +472,13 @@ class StubWebApplicationContext implements WebApplicationContext {
public void applyBeanPropertyValues(Object existingBean, String beanName) throws BeansException {
}
@SuppressWarnings("deprecation")
@Override
public Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, String beanName) {
return existingBean;
}
@SuppressWarnings("deprecation")
@Override
public Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String beanName) {
return existingBean;

Loading…
Cancel
Save