since 3.0
This commit is contained in:
@@ -27,6 +27,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
/**
|
||||
* Base class for {@link EmbeddedDatabaseConfigurer} implementations providing common shutdown behaviour.
|
||||
* @author Oliver Gierke
|
||||
* @since 3.0
|
||||
*/
|
||||
abstract class AbstractEmbeddedDatabaseConfigurer implements EmbeddedDatabaseConfigurer {
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ import org.springframework.core.io.support.EncodedResource;
|
||||
/**
|
||||
* Thrown by {@link ResourceDatabasePopulator} if one of its SQL scripts could
|
||||
* not be read during population.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class CannotReadScriptException extends RuntimeException {
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.jdbc.datasource.embedded;
|
||||
* DataSourceFactory helper that allows essential JDBC connection properties to be configured consistently,
|
||||
* independent of the actual DataSource implementation.
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
* @see DataSourceFactory
|
||||
*/
|
||||
public interface ConnectionProperties {
|
||||
|
||||
@@ -22,7 +22,8 @@ import org.springframework.jdbc.datasource.SimpleDriverDataSource;
|
||||
/**
|
||||
* Encapsulates the creation of a particular DataSource implementation, such as a {@link SimpleDriverDataSource} or connection pool such as Apache DBCP or c3p0.
|
||||
* Call {@link #getConnectionProperties()} to configure normalized DataSource properties before calling {@link #getDataSource()} to actually get the configured DataSource instance.
|
||||
* @author Keith Donald
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
*/
|
||||
public interface DataSourceFactory {
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.sql.SQLException;
|
||||
/**
|
||||
* Strategy used to populate an embedded database during initialization.
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
* @see ResourceDatabasePopulator
|
||||
*/
|
||||
public interface DatabasePopulator {
|
||||
|
||||
@@ -32,8 +32,8 @@ import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* {@link EmbeddedDatabaseConfigurer} for the Apache Derby database.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @since 3.0
|
||||
*/
|
||||
final class DerbyEmbeddedDatabaseConfigurer implements EmbeddedDatabaseConfigurer {
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import javax.sql.DataSource;
|
||||
* Is a {@link DataSource}.
|
||||
* Adds a shutdown operation so the embedded database instance can be shutdown.
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
*/
|
||||
public interface EmbeddedDatabase extends DataSource {
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.core.io.ResourceLoader;
|
||||
* db.shutdown();
|
||||
* </pre>
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
*/
|
||||
public class EmbeddedDatabaseBuilder {
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import javax.sql.DataSource;
|
||||
* Encapsulates the configuration required to create, connect to, and shutdown a specific type of embedded database such as HSQL or H2.
|
||||
* Create a implementation for each database type you wish to support; for example HSQL, H2, or some other type.
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
*/
|
||||
public interface EmbeddedDatabaseConfigurer {
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.util.Assert;
|
||||
* strategies.
|
||||
* @author Keith Donald
|
||||
* @author Oliver Gierke
|
||||
* @since 3.0
|
||||
*/
|
||||
final class EmbeddedDatabaseConfigurerFactory {
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ import org.springframework.util.Assert;
|
||||
* Call {@link #setDatabasePopulator(DatabasePopulator)} to change the algorithm used to populate the database.<br>
|
||||
* Call {@link #setDataSourceFactory(DataSourceFactory)} to change the type of DataSource used to connect to the database.<br>
|
||||
* Call {@link #getDatabase()} to get the {@link EmbeddedDatabase} instance.<br>
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
*/
|
||||
public class EmbeddedDatabaseFactory {
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
* 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.
|
||||
* Implements DisposableBean to shutdown the embedded database when the managing Spring container is shutdown.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
*/
|
||||
public class EmbeddedDatabaseFactoryBean extends EmbeddedDatabaseFactory implements FactoryBean<DataSource>, InitializingBean, DisposableBean {
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.jdbc.datasource.embedded;
|
||||
* A supported embedded database type.
|
||||
* @author Keith Donald
|
||||
* @author Oliver Gierke
|
||||
* @since 3.0
|
||||
*/
|
||||
public enum EmbeddedDatabaseType {
|
||||
HSQL, H2, DERBY;
|
||||
|
||||
@@ -20,8 +20,8 @@ import org.springframework.util.ClassUtils;
|
||||
/**
|
||||
* Initializes an H2 embedded database instance.
|
||||
* Call {@link #getInstance()} to get the singleton instance of this class.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @since 3.0
|
||||
*/
|
||||
final class H2EmbeddedDatabaseConfigurer extends AbstractEmbeddedDatabaseConfigurer {
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ import org.springframework.util.ClassUtils;
|
||||
/**
|
||||
* Initializes an HSQL embedded database instance.
|
||||
* Call {@link #getInstance()} to get the singleton instance of this class.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @author Oliver Gierke
|
||||
* @since 3.0
|
||||
*/
|
||||
final class HsqlEmbeddedDatabaseConfigurer extends AbstractEmbeddedDatabaseConfigurer {
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.springframework.jdbc.CannotGetJdbcConnectionException;
|
||||
* Note there is some duplication here with JdbcUtils in jdbc.support package.
|
||||
* We may want to consider simply using that at some point.
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
*/
|
||||
final class JdbcUtils {
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ import org.springframework.util.StringUtils;
|
||||
* <p>
|
||||
* Call {@link #addScript(Resource)} to add a SQL script location.<br>
|
||||
* Call {@link #setSqlScriptEncoding(String)} to set the encoding for all added scripts.<br>
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
*/
|
||||
public class ResourceDatabasePopulator implements DatabasePopulator {
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.jdbc.datasource.SimpleDriverDataSource;
|
||||
/**
|
||||
* Creates a {@link SimpleDriverDataSource}.
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
*/
|
||||
final class SimpleDriverDataSourceFactory implements DataSourceFactory {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user