diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java index d515e31778..61031f3dd6 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java @@ -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. * *

Can be configured:
* Call {@link #setDatabaseName(String)} to change the name of the database.
@@ -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. + *

After calling, {@link #getDataSource()} returns {@code null}. + * Does nothing if no embedded database has been initialized. */ protected void shutdownDatabase() { if (this.dataSource != null) { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactoryBean.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactoryBean.java index f41180ca85..1b28b871f8 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactoryBean.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactoryBean.java @@ -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. * - *

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. + *

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. * - *

Implements DisposableBean to shutdown the embedded database when the managing Spring container is shutdown. + *

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(); + } + }