git://wamblee.org
/
utils
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
javadoc updates
[utils]
/
test
/
enterprise
/
src
/
main
/
java
/
org
/
wamblee
/
support
/
persistence
/
AbstractDatabase.java
diff --git
a/test/enterprise/src/main/java/org/wamblee/support/persistence/AbstractDatabase.java
b/test/enterprise/src/main/java/org/wamblee/support/persistence/AbstractDatabase.java
index 6eaba50b880f9a218e35ed54a0a3d22aea8168e4..12c82c41177b7fe9f66d239d1d642d4218c0a1b9 100644
(file)
--- a/
test/enterprise/src/main/java/org/wamblee/support/persistence/AbstractDatabase.java
+++ b/
test/enterprise/src/main/java/org/wamblee/support/persistence/AbstractDatabase.java
@@
-28,6
+28,14
@@
import org.apache.commons.dbcp.PoolableConnectionFactory;
import org.apache.commons.dbcp.PoolingDataSource;
import org.apache.commons.pool.impl.GenericObjectPool;
import org.apache.commons.dbcp.PoolingDataSource;
import org.apache.commons.pool.impl.GenericObjectPool;
+/**
+ * Abstract database class providing the creation of the datasource,
+ * preventing duplicate starts of the same database, and checking
+ * for connection leaks when the database is stopped.
+ *
+ * @author Erik Brakkee
+ *
+ */
public abstract class AbstractDatabase implements Database {
/**
public abstract class AbstractDatabase implements Database {
/**
@@
-47,12
+55,21
@@
public abstract class AbstractDatabase implements Database {
private boolean started;
private boolean started;
+ /**
+ * Constructs the database.
+ */
protected AbstractDatabase() {
started = false;
}
protected AbstractDatabase() {
started = false;
}
+ /**
+ * To be implemented by subclasses to start the database.
+ */
protected abstract void doStart();
protected abstract void doStart();
+ /**
+ * To be implemented by subclasses to stop the database.
+ */
protected abstract void doStop();
/**
protected abstract void doStop();
/**
@@
-83,6
+100,9
@@
public abstract class AbstractDatabase implements Database {
// / BELOW THIS LINE IS NOT OF INTEREST TO SUBCLASSES.
// / BELOW THIS LINE IS NOT OF INTEREST TO SUBCLASSES.
+ /**
+ * Starts the database.
+ */
public final DataSource start() {
if (started) {
throw new RuntimeException("Database already started");
public final DataSource start() {
if (started) {
throw new RuntimeException("Database already started");
@@
-92,6
+112,11
@@
public abstract class AbstractDatabase implements Database {
return getDatasource();
}
return getDatasource();
}
+ /**
+ * Stops the database and tests for connection leaks.
+ * In cast the system property with the name given by {@link #IGNORE_CONNECTION_LEAK_PROPERTY}
+ * is set then the connection leaks are not checked.
+ */
public final void stop() {
if (!started) {
return; // nothing to do.
public final void stop() {
if (!started) {
return; // nothing to do.