diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerInvoker.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerInvoker.java index 112c4c040b..d302d6e5e1 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerInvoker.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerInvoker.java @@ -29,13 +29,13 @@ import org.springframework.context.ApplicationListener; /** * Bean to handle {@link DataSource} initialization by running {@literal schema-*.sql} on * {@link InitializingBean#afterPropertiesSet()} and {@literal data-*.sql} SQL scripts on - * a {@link DataSourceInitializedEvent}. + * a {@link DataSourceSchemaCreatedEvent}. * * @author Stephane Nicoll * @see DataSourceAutoConfiguration */ class DataSourceInitializerInvoker - implements ApplicationListener, InitializingBean { + implements ApplicationListener, InitializingBean { private static final Log logger = LogFactory.getLog(DataSourceInitializerInvoker.class); @@ -65,7 +65,7 @@ class DataSourceInitializerInvoker if (schemaCreated) { try { this.applicationContext - .publishEvent(new DataSourceInitializedEvent( + .publishEvent(new DataSourceSchemaCreatedEvent( initializer.getDataSource())); // The listener might not be registered yet, so don't rely on it. if (!this.initialized) { @@ -82,7 +82,7 @@ class DataSourceInitializerInvoker } @Override - public void onApplicationEvent(DataSourceInitializedEvent event) { + public void onApplicationEvent(DataSourceSchemaCreatedEvent event) { // NOTE the event can happen more than once and // the event datasource is not used here DataSourceInitializer initializer = getDataSourceInitializer(); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializedEvent.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceSchemaCreatedEvent.java similarity index 63% rename from spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializedEvent.java rename to spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceSchemaCreatedEvent.java index 3b565a833f..a6d94adadd 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializedEvent.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceSchemaCreatedEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2017 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. @@ -21,22 +21,21 @@ import javax.sql.DataSource; import org.springframework.context.ApplicationEvent; /** - * {@link ApplicationEvent} used internally to trigger {@link DataSource} initialization. - * Initialization can occur when {@literal schema-*.sql} files are executed or when - * external libraries (e.g. JPA) initialize the database. + * {@link ApplicationEvent} used internally to indicate that the schema of a new + * {@link DataSource} has been created. This happens when {@literal schema-*.sql} files + * are executed or when Hibernate initializes the database. * * @author Dave Syer - * @see DataSourceInitializer * @since 1.1.0 */ @SuppressWarnings("serial") -public class DataSourceInitializedEvent extends ApplicationEvent { +public class DataSourceSchemaCreatedEvent extends ApplicationEvent { /** - * Create a new {@link DataSourceInitializedEvent}. + * Create a new {@link DataSourceSchemaCreatedEvent}. * @param source the source {@link DataSource}. */ - public DataSourceInitializedEvent(DataSource source) { + public DataSourceSchemaCreatedEvent(DataSource source) { super(source); } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java index ce699ca2d0..845fe59bdb 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java @@ -27,15 +27,15 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.GenericBeanDefinition; -import org.springframework.boot.autoconfigure.jdbc.DataSourceInitializedEvent; +import org.springframework.boot.autoconfigure.jdbc.DataSourceSchemaCreatedEvent; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; import org.springframework.core.type.AnnotationMetadata; /** - * {@link BeanPostProcessor} used to fire {@link DataSourceInitializedEvent}s. Should only - * be registered via the inner {@link Registrar} class. + * {@link BeanPostProcessor} used to fire {@link DataSourceSchemaCreatedEvent}s. Should + * only be registered via the inner {@link Registrar} class. * * @author Dave Syer * @since 1.1.0 @@ -75,7 +75,7 @@ class DataSourceInitializedPublisher implements BeanPostProcessor { DataSource dataSource = findDataSource(entityManagerFactory); if (dataSource != null && isInitializingDatabase(dataSource)) { this.applicationContext - .publishEvent(new DataSourceInitializedEvent(dataSource)); + .publishEvent(new DataSourceSchemaCreatedEvent(dataSource)); } } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerInvokerTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerInvokerTests.java index 5d20b79591..d2486805f9 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerInvokerTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerInvokerTests.java @@ -177,7 +177,7 @@ public class DataSourceInitializerInvokerTests { return context -> { assertThat(context).hasSingleBean(DataSource.class); DataSource dataSource = context.getBean(DataSource.class); - context.publishEvent(new DataSourceInitializedEvent(dataSource)); + context.publishEvent(new DataSourceSchemaCreatedEvent(dataSource)); assertDataSourceNotInitialized(dataSource); }; }