org.opensubsystems.core.persist
Class DataFactoryManager

java.lang.Object
  extended by org.opensubsystems.core.persist.DataFactoryManager

public class DataFactoryManager
extends java.lang.Object

Class responsible for instantiation of data factories. This class determines what data factory should be used based on currently used persistence mechanism, creates the factory 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: DataFactoryManager.java,v 1.10 2007/01/07 06:15:05 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
1.7 2006/04/05 04:58:26 bastafidli

Field Summary
protected  ClassFactory m_factoryClassFactory
          Class factory used to instantiate data factorys.
 
Constructor Summary
DataFactoryManager()
          Default constructor.
 
Method Summary
 DataFactory getFactoryInstance(java.lang.Class dataFactory)
          Method to create actual factory based on specified class.
static DataFactory getInstance(java.lang.Class dataFactory)
          Create data factory for specified class.
static DataFactoryManager getManagerInstance()
          Get the default instance.
static void setManagerInstance(DataFactoryManager 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_factoryClassFactory

protected ClassFactory m_factoryClassFactory
Class factory used to instantiate data factorys.

Constructor Detail

DataFactoryManager

public DataFactoryManager()
Default constructor.

Method Detail

getInstance

public static DataFactory getInstance(java.lang.Class dataFactory)
                               throws OSSException
Create data factory for specified class.

Parameters:
dataFactory - - the data factory interface for which we want applicable factory. This is usually persistence independent class and we will try to create dependent class, such as one which can persist data in database.
Returns:
DataFactory - the data factory to use for given interface
Throws:
OSSException - - an error has occured

getManagerInstance

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

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

setManagerInstance

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

getFactoryInstance

public DataFactory getFactoryInstance(java.lang.Class dataFactory)
                               throws OSSException
Method to create actual factory 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:
dataFactory - - the data factory interface for which we want applicable factory. This is usually persistence independent class and we will try to create dependent class, such as one which can persist data in database.
Returns:
DataFactory - the data factory to use for given interface
Throws:
OSSException - - an error has occured


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