Commit 9e3a2bbd authored by Andy Wilkinson's avatar Andy Wilkinson

Implement BeanFactoryAware to inject BeanFactory

Closes gh-23543
parent 9ff946ba
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -20,7 +20,7 @@ import javax.sql.DataSource; ...@@ -20,7 +20,7 @@ import javax.sql.DataSource;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory; 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.beans.factory.config.BeanPostProcessor;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
...@@ -30,14 +30,13 @@ import org.springframework.core.Ordered; ...@@ -30,14 +30,13 @@ import org.springframework.core.Ordered;
* *
* @author Dave Syer * @author Dave Syer
*/ */
class DataSourceInitializerPostProcessor implements BeanPostProcessor, Ordered { class DataSourceInitializerPostProcessor implements BeanPostProcessor, Ordered, BeanFactoryAware {
@Override @Override
public int getOrder() { public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE + 1; return Ordered.HIGHEST_PRECEDENCE + 1;
} }
@Autowired
private BeanFactory beanFactory; private BeanFactory beanFactory;
@Override @Override
...@@ -54,4 +53,9 @@ class DataSourceInitializerPostProcessor implements BeanPostProcessor, Ordered { ...@@ -54,4 +53,9 @@ class DataSourceInitializerPostProcessor implements BeanPostProcessor, Ordered {
return bean; return bean;
} }
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment