📄 daofactory.java
字号:
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package eti.bi.alphaminer.core.dao;
import java.util.Hashtable;
import eti.bi.exception.AppException;
/**
* @since 1.0
* @version $Revision$ $Date$
* @author $Author$
*/
public class DAOFactory {
private static Hashtable<String, String> aDAOPackageMap = new Hashtable<String, String>();
static
{
// aDAOPackageMap.put("KB", "hk.hku.eti.bi.bkb");
aDAOPackageMap.put("BIML", "eti.bi.alphaminer.core.dao");
// aDAOPackageMap.put("User", "hk.hku.eti.bi.securitymanager");
// aDAOPackageMap.put("BIACL", "hk.hku.eti.bi.securitymanager");
}
/**
*
* Gets the DAO instance for the specified DAO type and the repository type.
*
* @param aDAOType The type of DAO. e.g. BIML, KB
* @param aRepositoryType The type or DB type of the repository. e.g. File, Mysql
* @return DAO The instance of the corresponding DAO
*/
public static DAO getDAO(String aDAOType, String aRepositoryType) throws AppException
{
String aDAOClassName = aDAOPackageMap.get(aDAOType) + "." + aDAOType + "DAO" + aRepositoryType;
try
{
return (DAO)Class.forName(aDAOClassName).newInstance();
}
catch(Exception e)
{
e.printStackTrace();
throw new AppException("Error instantiate DAO with class: " + aDAOClassName, e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -