daofactory.java
来自「用java开发的QQ管理系统」· Java 代码 · 共 88 行
JAVA
88 行
package com.zlf.dao;
import com.zlf.dao.xml.XmlDeptDao;
import com.zlf.dao.xml.XmlUserDao;
import com.zlf.qqserver.utils.QQUtils;
public class DaoFactory {
private static DaoFactory daoFactory ;
private DaoFactory() {
}
public static DaoFactory newInstance() {
if (daoFactory == null){
daoFactory = new DaoFactory();
}
return daoFactory;
}
/**
*
* @return DeptDao
* 部门工厂
*/
public DeptDao createDeptDao() {
String type = QQUtils.properties.getProperty("StoredDirection");
if (type.equalsIgnoreCase("XML")) {
return new XmlDeptDao();
} else if (type.equalsIgnoreCase("oracle")) {
return (DeptDao) new DeptDaoOracleImp();
} else {
return (DeptDao) new XmlDeptDao();
}
}
public UserDao createUserDao() {
String type = QQUtils.properties.getProperty("StoredDirection");
if (type.equalsIgnoreCase("xml"))
return (UserDao) new XmlUserDao();
else if (type.equalsIgnoreCase("oracle"))
return (UserDao) new UserDaoOracleImp();
else
return (UserDao) new XmlUserDao();
}
/**
*
* 指定方式
* 特殊情况return xmldeptdao
* @param s
* @return DeptDao
*
*/
public DeptDao createDeptDao(String s) {
if (s.equalsIgnoreCase("XML")) {
return new XmlDeptDao();
} else if (s.equalsIgnoreCase("oracle")) {
return (DeptDao) new DeptDaoOracleImp();
} else {
return (DeptDao) new XmlDeptDao();
}
}
public UserDao createUserDao(String s) {
if (s.equalsIgnoreCase("xml"))
return (UserDao) new XmlUserDao();
else if (s.equalsIgnoreCase("oracle"))
return (UserDao) new UserDaoOracleImp();
else
return (UserDao) new XmlUserDao();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?