org.opensubsystems.core.persist.db
Class DatabaseSchemaManager

java.lang.Object
  extended by org.opensubsystems.core.persist.db.DatabaseSchemaManager

public class DatabaseSchemaManager
extends java.lang.Object

Class responsible for instantiation of database schemas. This class determines what database schema should be used based on currently used database, creates the schema instance if it wasn't created yet and caches created instances. This of course assumes that the data factories are implemented to be stateless and reentrant.

Version:
$Id: DatabaseSchemaManager.java,v 1.8 2007/01/07 06:14:18 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
1.4 2005/03/11 14:48:58 bastafidli

Field Summary
protected  ClassFactory m_schemaClassFactory
          Class factory used to instantiate database schemas.
 
Constructor Summary
DatabaseSchemaManager()
          Default constructor.
 
Method Summary
static DatabaseSchema getInstance(java.lang.Class databaseSchema)
          Create database schema for specified class.
static DatabaseSchema getInstance(java.lang.String databaseSchema)
          Create database schema for specified class.
static DatabaseSchemaManager getManagerInstance()
          Get the default instance.
 DatabaseSchema getSchemaInstance(java.lang.Class databaseSchema)
          Method to create actual schema based on specified class.
 DatabaseSchema getSchemaInstance(java.lang.String databaseSchema)
          Method to create actual schema based on specified class.
static void setManagerInstance(DatabaseSchemaManager defaultInstance)
          Set default instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_schemaClassFactory

protected ClassFactory m_schemaClassFactory
Class factory used to instantiate database schemas.

Constructor Detail

DatabaseSchemaManager

public DatabaseSchemaManager()
Default constructor.

Method Detail

getInstance

public static DatabaseSchema getInstance(java.lang.Class databaseSchema)
                                  throws OSSException
Create database schema for specified class.

Parameters:
databaseSchema - - the database schema class for which we want applicable schema. This is usually database independent class and we will try to create database dependent class.
Returns:
DatabaseSchema - the database schema to use for given class
Throws:
OSSException - - an error has occured

getInstance

public static DatabaseSchema getInstance(java.lang.String databaseSchema)
                                  throws OSSException
Create database schema for specified class.

Parameters:
databaseSchema - - the database schema class name for which we want applicable schema. This is usually database independent class and we will try to create database dependent class.
Returns:
DatabaseSchema - the database schema to use for given class
Throws:
OSSException - - an error has occured

getManagerInstance

public static DatabaseSchemaManager getManagerInstance()
                                                throws OSSException
Get the default instance. This method is here to make the schema manager configurable. Once can specify in configuration file derived class to used instead of this one [DatabaseSchemaManager.class]=new class to use.

Returns:
DatabaseSchemaManager
Throws:
OSSException - - cannot get current database

setManagerInstance

public static void setManagerInstance(DatabaseSchemaManager defaultInstance)
Set default instance. This instance will be returned by getInstance method until it is changed.

Parameters:
defaultInstance - - new default instance
See Also:
getInstance(java.lang.Class)

getSchemaInstance

public DatabaseSchema getSchemaInstance(java.lang.Class databaseSchema)
                                 throws OSSException
Method to create actual schema based on specified class. This method can be overriden and new manager can be setup either through setManagerInstance or through configuration file if different strategy is desired.

Parameters:
databaseSchema - - the database schema class for which we want applicable schema. This is usually database independent class and we will try to create database dependent class.
Returns:
DatabaseSchema - the database schema to use for given class
Throws:
OSSException - - an error has occured

getSchemaInstance

public DatabaseSchema getSchemaInstance(java.lang.String databaseSchema)
                                 throws OSSException
Method to create actual schema based on specified class. This method can be overriden and new manager can be setup either through setManagerInstance or through configuration file if different strategy is desired.

Parameters:
databaseSchema - - the database schema class name for which we want applicable schema. This is usually database independent class and we will try to create database dependent class.
Returns:
DatabaseSchema - the database schema to use for given class
Throws:
OSSException - - an error has occured


Copyright © 2003 - 2006 OpenSubsystems s.r.o.