org.opensubsystems.core.persist.db
Class DatabaseDependentClassManager

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

public class DatabaseDependentClassManager
extends java.lang.Object

Class responsible for instantiation of classes whose implementation depends on currently used database. It creates new instance if it wasn't created yet and caches created instances. This of course assumes that the data dependent classes are implemented to be stateless and reentrant.

Version:
$Id: DatabaseDependentClassManager.java,v 1.4 2007/01/07 06:14:18 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
Initial revision

Field Summary
protected  ClassFactory m_classFactory
          Class factory used to instantiate database dependent classes.
 
Constructor Summary
DatabaseDependentClassManager()
          Default constructor.
 
Method Summary
 java.lang.Object getDependentInstance(java.lang.Class dependentClass)
          Method to create actual database dependent instance based on specified class.
static java.lang.Object getInstance(java.lang.Class dependentClass)
          Create database dependent instance for specified class.
static DatabaseDependentClassManager getManagerInstance()
          Get the default instance.
static void setManagerInstance(DatabaseDependentClassManager 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_classFactory

protected ClassFactory m_classFactory
Class factory used to instantiate database dependent classes.

Constructor Detail

DatabaseDependentClassManager

public DatabaseDependentClassManager()
Default constructor.

Method Detail

getInstance

public static java.lang.Object getInstance(java.lang.Class dependentClass)
                                    throws OSSException
Create database dependent instance for specified class.

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

getManagerInstance

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

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

setManagerInstance

public static void setManagerInstance(DatabaseDependentClassManager 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)

getDependentInstance

public java.lang.Object getDependentInstance(java.lang.Class dependentClass)
                                      throws OSSException
Method to create actual database dependent instance 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:
dependentClass - - the database dependent class for which we want applicable instance. This is usually database independent class and we will try to create database dependent class.
Returns:
Object - the database dependent instance to use for given class
Throws:
OSSException - - an error has occured


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