org.wamblee.test.persistence
Class ExternalDatabase

java.lang.Object
  extended by org.wamblee.test.persistence.AbstractDatabase
      extended by org.wamblee.test.persistence.ExternalDatabase
All Implemented Interfaces:
Database

public class ExternalDatabase
extends AbstractDatabase

Database that encapsulates connection to an external database. Database connection details can be configured through system properties and environment variables, see DB_URL_PROP, DB_USER_PROP, and {@link #DB_PASSWORD_PROP|. This class assumes modern database drivers that work together with java.util.ServiceLoader so that explicitly doing a Class.forName() is not necessary to load the database driver.


Field Summary
static java.lang.String DB_PASSWORD_PROP
          System property/environment variable that defines the database password.
static java.lang.String DB_URL_PROP
          System property/environment variable that defines the database URL.
static java.lang.String DB_USER_PROP
          System property/environment variable that defines the database user.
 
Constructor Summary
ExternalDatabase()
           
 
Method Summary
 void doStart()
          To be implemented by subclasses to start the database.
 void doStop()
          To be implemented by subclasses to stop the database.
 java.lang.String getExternalJdbcUrl()
          Gets the external Jdbc URL to connect to this database from other JVMs.
 java.lang.String getJdbcUrl()
          Gets the Jdbc Url to connect to this database.
 java.lang.String getPassword()
          Gets the password to connect to the database.
 java.lang.String getUsername()
          Gets the username to connect to the database.
 
Methods inherited from class org.wamblee.test.persistence.AbstractDatabase
createDataSource, getActiveConnections, getProperty, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DB_URL_PROP

public static final java.lang.String DB_URL_PROP
System property/environment variable that defines the database URL.

See Also:
Constant Field Values

DB_USER_PROP

public static final java.lang.String DB_USER_PROP
System property/environment variable that defines the database user.

See Also:
Constant Field Values

DB_PASSWORD_PROP

public static final java.lang.String DB_PASSWORD_PROP
System property/environment variable that defines the database password.

See Also:
Constant Field Values
Constructor Detail

ExternalDatabase

public ExternalDatabase()
Method Detail

getExternalJdbcUrl

public java.lang.String getExternalJdbcUrl()
Description copied from interface: Database
Gets the external Jdbc URL to connect to this database from other JVMs.


getJdbcUrl

public java.lang.String getJdbcUrl()
Description copied from interface: Database
Gets the Jdbc Url to connect to this database.

Returns:
Jdbc Url.

getPassword

public java.lang.String getPassword()
Description copied from interface: Database
Gets the password to connect to the database.

Returns:
password.

getUsername

public java.lang.String getUsername()
Description copied from interface: Database
Gets the username to connect to the database.

Returns:
username.

doStart

public void doStart()
Description copied from class: AbstractDatabase
To be implemented by subclasses to start the database.

Specified by:
doStart in class AbstractDatabase

doStop

public void doStop()
Description copied from class: AbstractDatabase
To be implemented by subclasses to stop the database.

Specified by:
doStop in class AbstractDatabase


Copyright © 2010. All Rights Reserved.