Polishing
Issue: SPR-11372
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -30,8 +30,8 @@ import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Creates a {@link EmbeddedDatabase} instance. Callers are guaranteed that the returned database has been fully
|
||||
* initialized and populated.
|
||||
* Creates a {@link EmbeddedDatabase} instance. Callers are guaranteed that
|
||||
* the returned database has been fully initialized and populated.
|
||||
*
|
||||
* <p>Can be configured:<br>
|
||||
* Call {@link #setDatabaseName(String)} to change the name of the database.<br>
|
||||
@@ -145,7 +145,8 @@ public class EmbeddedDatabaseFactory {
|
||||
|
||||
/**
|
||||
* Hook to shutdown the embedded database. Subclasses may call to force shutdown.
|
||||
* After calling, {@link #getDataSource()} returns null. Does nothing if no embedded database has been initialized.
|
||||
* <p>After calling, {@link #getDataSource()} returns {@code null}.
|
||||
* Does nothing if no embedded database has been initialized.
|
||||
*/
|
||||
protected void shutdownDatabase() {
|
||||
if (this.dataSource != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -25,13 +25,16 @@ import org.springframework.jdbc.datasource.init.DatabasePopulator;
|
||||
import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils;
|
||||
|
||||
/**
|
||||
* A subclass of {@link EmbeddedDatabaseFactory} that implements {@link FactoryBean} for registration as a Spring bean.
|
||||
* Returns the actual {@link DataSource} that provides connectivity to the embedded database to Spring.
|
||||
* A subclass of {@link EmbeddedDatabaseFactory} that implements {@link FactoryBean}
|
||||
* for registration as a Spring bean. Returns the actual {@link DataSource} that
|
||||
* provides connectivity to the embedded database to Spring.
|
||||
*
|
||||
* <p>The target DataSource is returned instead of a {@link EmbeddedDatabase} proxy since the FactoryBean
|
||||
* will manage the initialization and destruction lifecycle of the database instance.
|
||||
* <p>The target {@link DataSource} is returned instead of an {@link EmbeddedDatabase}
|
||||
* proxy since the {@link FactoryBean} will manage the initialization and destruction
|
||||
* lifecycle of the embedded database instance.
|
||||
*
|
||||
* <p>Implements DisposableBean to shutdown the embedded database when the managing Spring container is shutdown.
|
||||
* <p>Implements {@link DisposableBean} to shutdown the embedded database when the
|
||||
* managing Spring container is being closed.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @author Juergen Hoeller
|
||||
@@ -59,14 +62,6 @@ public class EmbeddedDatabaseFactoryBean extends EmbeddedDatabaseFactory
|
||||
initDatabase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (this.databaseCleaner != null) {
|
||||
DatabasePopulatorUtils.execute(this.databaseCleaner, getDataSource());
|
||||
}
|
||||
shutdownDatabase();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DataSource getObject() {
|
||||
@@ -83,4 +78,13 @@ public class EmbeddedDatabaseFactoryBean extends EmbeddedDatabaseFactory
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (this.databaseCleaner != null) {
|
||||
DatabasePopulatorUtils.execute(this.databaseCleaner, getDataSource());
|
||||
}
|
||||
shutdownDatabase();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user