com.onewebsql.dao
Class DefaultDaoManager

java.lang.Object
  extended by com.onewebsql.dao.DefaultDaoManager
All Implemented Interfaces:
DaoManager

public class DefaultDaoManager
extends Object
implements DaoManager

Default implementation of DAO manager.


Field Summary
static String DEFAULT_DS
          Default name of the default data source.
 
Constructor Summary
DefaultDaoManager(DataSource dataSource, DBAdapter dbAdapter)
          Constructor.
DefaultDaoManager(DataSource dataSource, DBAdapter dbAdapter, DaoMonitor daoMonitor)
          Constructor.
DefaultDaoManager(DataSourceManager dataSourceManager, DBAdapterMapper dbAdapterMapper)
          Constructor.
DefaultDaoManager(DataSourceManager dataSourceManager, DBAdapterMapper dbAdapterMapper, DaoMonitor daoMonitor)
          Constructor.
DefaultDaoManager(DataSourceManager dataSourceManager, DBAdapterMapper dbAdapterMapper, String defaultDs)
          Constructor.
DefaultDaoManager(DataSourceManager dataSourceManager, DBAdapterMapper dbAdapterMapper, String defaultDs, DaoMonitor daoMonitor)
          Constructor.
 
Method Summary
<T> T
getDao(Class<T> daoClass)
          Returns a DAO object implementing the specified DAO interface.
<T> T
getDao(Class<T> daoClass, String schemaName)
          Returns a DAO object implementing the specified DAO interface using the specified schema name.
<T> T
getDao(Class<T> daoClass, String dataSourceName, String schemaName)
          Returns a DAO object implementing the specified DAO interface using the data source and the specified schema name.
 DaoMonitor getDaoMonitor()
          Returns the DAO monitor
 DataSourceManager getDataSourceManager()
          Returns the data source manager of this DaoManager.
 DBAdapterMapper getDbAdapterMapper()
          Returns the database adapter mapper of this DaoManager.
 String getDefaultDs()
          Returns the name of the default data source.
 void setDaoMonitor(DaoMonitor daoMonitor)
          Sets the DAO monitor.
 void setDataSourceManager(DataSourceManager dataSourceManager)
          Set the data source manager
 void setDbAdapterMapper(DBAdapterMapper dbAdapterMapper)
          Sets the database adapter mapper.
 void setDefaultDaoMonitor()
          Sets the default DAO monitor as this manager's DAO monitor
 void setDefaultDs(String defaultDs)
          Sets the name of the default data source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DS

public static final String DEFAULT_DS
Default name of the default data source.

See Also:
Constant Field Values
Constructor Detail

DefaultDaoManager

public DefaultDaoManager(DataSource dataSource,
                         DBAdapter dbAdapter)
Constructor.

Parameters:
dataSource - default data source
dbAdapter - default database adapter

DefaultDaoManager

public DefaultDaoManager(DataSource dataSource,
                         DBAdapter dbAdapter,
                         DaoMonitor daoMonitor)
Constructor.

Parameters:
dataSource - default data source
dbAdapter - default database adapter
daoMonitor - default dao monitor

DefaultDaoManager

public DefaultDaoManager(DataSourceManager dataSourceManager,
                         DBAdapterMapper dbAdapterMapper)
Constructor.

Parameters:
dataSourceManager - data source manager
dbAdapterMapper - database adapter mapper

DefaultDaoManager

public DefaultDaoManager(DataSourceManager dataSourceManager,
                         DBAdapterMapper dbAdapterMapper,
                         String defaultDs)
Constructor.

Parameters:
dataSourceManager - data source manager
dbAdapterMapper - database adapter mapper
defaultDs - default data source

DefaultDaoManager

public DefaultDaoManager(DataSourceManager dataSourceManager,
                         DBAdapterMapper dbAdapterMapper,
                         String defaultDs,
                         DaoMonitor daoMonitor)
Constructor.

Parameters:
dataSourceManager - data source manager
dbAdapterMapper - database adapter mapper
defaultDs - default data source
daoMonitor - DAO monitor

DefaultDaoManager

public DefaultDaoManager(DataSourceManager dataSourceManager,
                         DBAdapterMapper dbAdapterMapper,
                         DaoMonitor daoMonitor)
Constructor.

Parameters:
dataSourceManager - data source manager
dbAdapterMapper - database adapter mapper
daoMonitor - DAO monitor
Method Detail

getDao

public <T> T getDao(Class<T> daoClass)
Description copied from interface: DaoManager
Returns a DAO object implementing the specified DAO interface. The returned DAO object uses a default data source. Example usage:
DaoManager daoManager = new DefaultDaoManager(ds, new PostgresDBAdapter());
daoManager.getDao(BookDAO.class);
     

Specified by:
getDao in interface DaoManager
Parameters:
daoClass - DAO object interface
Returns:
returns a DAO object for the specified class

getDao

public <T> T getDao(Class<T> daoClass,
                    String schemaName)
Description copied from interface: DaoManager
Returns a DAO object implementing the specified DAO interface using the specified schema name. The returned DAO object uses a default data source. If the schema name is null then the schema name is not used by DAO object. Example usage:
DaoManager daoManager = new DefaultDaoManager(ds, new PostgresDBAdapter());
daoManager.getDao(BookDAO.class, "schemaname");
     

Specified by:
getDao in interface DaoManager
Parameters:
daoClass - DAO object interface
schemaName - the name of the schema for the specified DAO's table. Might be null.
Returns:
returns a DAO object for the specified class

getDao

public <T> T getDao(Class<T> daoClass,
                    String dataSourceName,
                    String schemaName)
Description copied from interface: DaoManager
Returns a DAO object implementing the specified DAO interface using the data source and the specified schema name. If the schema name is null then the schema name is not used by DAO object. Example usage:
DaoManager daoManager = new DefaultDaoManager(ds, new PostgresDBAdapter());
daoManager.getDao(BookDAO.class, "datasourcename", "schemaname");
     

Specified by:
getDao in interface DaoManager
Parameters:
daoClass - DAO object interface
dataSourceName - datasource name
schemaName - the name of the schema for the specified DAO's table. Might be null.
Returns:
returns a DAO object for the specified class, using the given data source

getDataSourceManager

public DataSourceManager getDataSourceManager()
Description copied from interface: DaoManager
Returns the data source manager of this DaoManager.

Specified by:
getDataSourceManager in interface DaoManager
Returns:
data source manager

setDataSourceManager

public void setDataSourceManager(DataSourceManager dataSourceManager)
Set the data source manager

Parameters:
dataSourceManager - data source manager

getDbAdapterMapper

public DBAdapterMapper getDbAdapterMapper()
Description copied from interface: DaoManager
Returns the database adapter mapper of this DaoManager.

Specified by:
getDbAdapterMapper in interface DaoManager
Returns:
database adapter mapper

setDbAdapterMapper

public void setDbAdapterMapper(DBAdapterMapper dbAdapterMapper)
Sets the database adapter mapper.

Parameters:
dbAdapterMapper - database adapter mapper

getDefaultDs

public String getDefaultDs()
Returns the name of the default data source.

Returns:
name of the default data source

setDefaultDs

public void setDefaultDs(String defaultDs)
Sets the name of the default data source.

Parameters:
defaultDs - name of the default data source

setDaoMonitor

public void setDaoMonitor(DaoMonitor daoMonitor)
Sets the DAO monitor.

Parameters:
daoMonitor - default DAO monitor

getDaoMonitor

public DaoMonitor getDaoMonitor()
Returns the DAO monitor

Specified by:
getDaoMonitor in interface DaoManager
Returns:
DAO monitor

setDefaultDaoMonitor

public void setDefaultDaoMonitor()
Sets the default DAO monitor as this manager's DAO monitor



Copyright © 2011-2013 e-point SA. All Rights Reserved.