提交 c2303854 编写于 作者: J Juergen Hoeller

Polishing

Issue: SPR-11372
上级 5be83011
/*
* 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) {
......
/*
* 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();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册