Implement BeanFactoryAware to inject BeanFactory

Closes gh-23543
This commit is contained in:
Andy Wilkinson 2020-09-30 19:38:06 +01:00
parent 9ff946bafa
commit 9e3a2bbdeb
1 changed files with 8 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
@ -20,7 +20,7 @@ import javax.sql.DataSource;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.Ordered;
@ -30,14 +30,13 @@ import org.springframework.core.Ordered;
*
* @author Dave Syer
*/
class DataSourceInitializerPostProcessor implements BeanPostProcessor, Ordered {
class DataSourceInitializerPostProcessor implements BeanPostProcessor, Ordered, BeanFactoryAware {
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE + 1;
}
@Autowired
private BeanFactory beanFactory;
@Override
@ -54,4 +53,9 @@ class DataSourceInitializerPostProcessor implements BeanPostProcessor, Ordered {
return bean;
}
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
}
}