org.melati.poem
Class PoemDatabaseFactory

Package class diagram package PoemDatabaseFactory
java.lang.Object
  extended by org.melati.poem.PoemDatabaseFactory

public final class PoemDatabaseFactory
extends Object

Since:
2 Feb 2007
Author:
timp

Nested Class Summary
static class PoemDatabaseFactory.PoemShutdownThread
          Shutdown databases cleanly when JVM exits.
 
Method Summary
static void disconnectDatabase(String name)
          Disconnect and disconnect from a known database.
static void disconnectFromDatabases()
          Disconnect from all initialised databases.
static Database getDatabase(String name)
          Retrieve a database by name.
static Database getDatabase(String name, String url, String user, String password, String clazz, String dbmsClass, boolean addConstraints, boolean logSQL, boolean logCommits, int maxTransactions)
          Return a database from the cache or create it.
static Vector<String> getInitialisedDatabaseNames()
          Retrieve the names of the databases which have completed initialisation.
static PoemDatabaseFactory.PoemShutdownThread getPoemShutdownThread()
           
static Vector<Database> initialisedDatabases()
          Retrieve the databases which have completed initialisation.
static void removeDatabase(String name)
          Enable a database to be reinitialised, without incurring the full overhead of restarting hsqldb, used in tests.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

initialisedDatabases

public static Vector<Database> initialisedDatabases()
Retrieve the databases which have completed initialisation.

Returns:
a Vector of the initialised databases

getInitialisedDatabaseNames

public static Vector<String> getInitialisedDatabaseNames()
Retrieve the names of the databases which have completed initialisation. Note that a database which has not been used will not have been initialised.

Returns:
a Vector of the initialised database names

getDatabase

public static Database getDatabase(String name)
                            throws DatabaseInitialisationPoemException
Retrieve a database by name.

Parameters:
name - the name of the database
Returns:
a Database with the name specified
Throws:
DatabaseInitialisationPoemException - if any Exception is trapped

getDatabase

public static Database getDatabase(String name,
                                   String url,
                                   String user,
                                   String password,
                                   String clazz,
                                   String dbmsClass,
                                   boolean addConstraints,
                                   boolean logSQL,
                                   boolean logCommits,
                                   int maxTransactions)
Return a database from the cache or create it. NOTE The first sucessful invocation will determine databases settings.

Parameters:
name - a short name of the db
url - a JDBC url
user - user authorised to access the databse through JDBC
password - password for the user
clazz - the name of the (POEM) database class
dbmsClass - the name of the (POEM) dbms class
addConstraints - whether to add constraints to the databases JDBC meta data
logSQL - whether SQL statements should be logged
logCommits - whether commits should be logged
maxTransactions - the number of transactions (one less than the number of connections)
Returns:
a new or existing database

removeDatabase

public static void removeDatabase(String name)
Enable a database to be reinitialised, without incurring the full overhead of restarting hsqldb, used in tests.

Parameters:
name - name of db to remove

disconnectDatabase

public static void disconnectDatabase(String name)
Disconnect and disconnect from a known database.

Parameters:
name - name of db to remove

disconnectFromDatabases

public static void disconnectFromDatabases()
Disconnect from all initialised databases.


getPoemShutdownThread

public static PoemDatabaseFactory.PoemShutdownThread getPoemShutdownThread()
Returns:
the poemShutdownThread


Copyright © 2000-2010 PanEris. All Rights Reserved.