org.wamblee.test.persistence
Class AbstractDatabase

java.lang.Object
  extended by org.wamblee.test.persistence.AbstractDatabase
All Implemented Interfaces:
Database
Direct Known Subclasses:
DerbyDatabase, ExternalDatabase

public abstract class AbstractDatabase
extends java.lang.Object
implements Database

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

Constructor Summary
protected AbstractDatabase()
          Constructs the database.
 
Method Summary
protected  void createDataSource()
          This method must be called from the start method.
protected abstract  void doStart()
          To be implemented by subclasses to start the database.
protected abstract  void doStop()
          To be implemented by subclasses to stop the database.
 int getActiveConnections()
          Gets the number of active connections from the pool.
protected  java.lang.String getProperty(java.lang.String aName)
           
 javax.sql.DataSource start()
          Starts the database.
 void stop()
          Stops the database and tests for connection leaks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.wamblee.test.persistence.Database
getExternalJdbcUrl, getJdbcUrl, getPassword, getUsername
 

Constructor Detail

AbstractDatabase

protected AbstractDatabase()
Constructs the database.

Method Detail

doStart

protected abstract void doStart()
To be implemented by subclasses to start the database.


doStop

protected abstract void doStop()
To be implemented by subclasses to stop the database.


createDataSource

protected final void createDataSource()
This method must be called from the start method.


getActiveConnections

public int getActiveConnections()
Description copied from interface: Database
Gets the number of active connections from the pool. This is useful for determining resource leaks.

Specified by:
getActiveConnections in interface Database
Returns:
Active connections.

start

public final javax.sql.DataSource start()
Starts the database.

Specified by:
start in interface Database

stop

public final void stop()
Stops the database and tests for connection leaks. In cast the system property with the name given by IGNORE_CONNECTION_LEAK_PROPERTY is set then the connection leaks are not checked.

Specified by:
stop in interface Database

getProperty

protected java.lang.String getProperty(java.lang.String aName)


Copyright © 2010. All Rights Reserved.