|
|
@ -36,6 +36,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
|
|
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceSchemaCreatedEvent;
|
|
|
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceSchemaCreatedEvent;
|
|
|
|
import org.springframework.boot.jdbc.EmbeddedDatabaseConnection;
|
|
|
|
import org.springframework.boot.jdbc.EmbeddedDatabaseConnection;
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
|
|
|
|
import org.springframework.context.ApplicationContextAware;
|
|
|
|
import org.springframework.context.ApplicationListener;
|
|
|
|
import org.springframework.context.ApplicationListener;
|
|
|
|
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
|
|
|
|
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
|
|
|
|
import org.springframework.context.event.ContextRefreshedEvent;
|
|
|
|
import org.springframework.context.event.ContextRefreshedEvent;
|
|
|
@ -136,12 +137,17 @@ class DataSourceInitializedPublisher implements BeanPostProcessor {
|
|
|
|
* blocks until any asynchronous DataSource initialization has completed.
|
|
|
|
* blocks until any asynchronous DataSource initialization has completed.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static class DataSourceInitializationCompletionListener
|
|
|
|
static class DataSourceInitializationCompletionListener
|
|
|
|
implements ApplicationListener<ContextRefreshedEvent>, Ordered {
|
|
|
|
implements ApplicationListener<ContextRefreshedEvent>, Ordered, ApplicationContextAware {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private volatile ApplicationContext applicationContext;
|
|
|
|
|
|
|
|
|
|
|
|
private volatile Future<?> dataSourceInitialization;
|
|
|
|
private volatile Future<?> dataSourceInitialization;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onApplicationEvent(ContextRefreshedEvent event) {
|
|
|
|
public void onApplicationEvent(ContextRefreshedEvent event) {
|
|
|
|
|
|
|
|
if (!event.getApplicationContext().equals(this.applicationContext)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
Future<?> dataSourceInitialization = this.dataSourceInitialization;
|
|
|
|
Future<?> dataSourceInitialization = this.dataSourceInitialization;
|
|
|
|
if (dataSourceInitialization != null) {
|
|
|
|
if (dataSourceInitialization != null) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -158,6 +164,11 @@ class DataSourceInitializedPublisher implements BeanPostProcessor {
|
|
|
|
return Ordered.HIGHEST_PRECEDENCE;
|
|
|
|
return Ordered.HIGHEST_PRECEDENCE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void setApplicationContext(ApplicationContext applicationContext) {
|
|
|
|
|
|
|
|
this.applicationContext = applicationContext;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|