ca.spaz.cron.datasource.sql
Class ConnectionManager

java.lang.Object
  extended by ca.spaz.cron.datasource.sql.ConnectionManager

public class ConnectionManager
extends java.lang.Object

Class for JDBC connection management. Provides information about available datasources, and provides Connection objects to calling classes that are guaranteed to be working.

Author:
Chris Rose

Method Summary
 void addConnectionStatusListener(IConnectionStatusObserver observer)
          Add an observer for notification when the database connection is made.
 java.sql.Connection getConnection()
          Get the database connection.
static java.util.List getDatabaseIDs()
          Retrieve a list of available database IDs.
static ConnectionManager getInstance(java.lang.String dbID)
          Get an instance of a ConnectionManager for a particular dbID.
 void removeConnectionStatusListener(IConnectionStatusObserver observer)
          Remove an observer from this ConnectionManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDatabaseIDs

public static java.util.List getDatabaseIDs()
Retrieve a list of available database IDs.

Returns:
a List containing DatabaseID implementations for every available user datasource.

getInstance

public static ConnectionManager getInstance(java.lang.String dbID)
Get an instance of a ConnectionManager for a particular dbID.

Parameters:
dbID - the ID of the connection
Returns:
a ConnectionManager for the ID

addConnectionStatusListener

public void addConnectionStatusListener(IConnectionStatusObserver observer)
Add an observer for notification when the database connection is made. If the database is already connected, fires a notification immediately.

Parameters:
observer - the Observer.

getConnection

public java.sql.Connection getConnection()
Get the database connection. Lazy initializer.

Returns:
the connection to the food database or null if there is no connection possible.

removeConnectionStatusListener

public void removeConnectionStatusListener(IConnectionStatusObserver observer)
Remove an observer from this ConnectionManager

Parameters:
observer - the Observer to remove.


Copyright © 2005 Spaz. All Rights Reserved.