AbsenceManager/src/dao/DAOFactory.java

46 lines
1.0 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package dao;
import dao.impl.StudentDAOImpl;
import dao.impl.TeacherDAOImpl;
import dao.impl.LeaveRequestDAOImpl;
/**
* DAO工厂类用于获取各种DAO的实例
*/
public class DAOFactory {
private static final StudentDAO studentDAO = new StudentDAOImpl();
private static final TeacherDAO teacherDAO = new TeacherDAOImpl();
private static final LeaveRequestDAO leaveRequestDAO = new LeaveRequestDAOImpl();
/**
* 私有构造函数,防止实例化
*/
private DAOFactory() {
// 私有构造函数,阻止实例化
}
/**
* 获取StudentDAO实例
* @return StudentDAO实例
*/
public static StudentDAO getStudentDAO() {
return studentDAO;
}
/**
* 获取TeacherDAO实例
* @return TeacherDAO实例
*/
public static TeacherDAO getTeacherDAO() {
return teacherDAO;
}
/**
* 获取LeaveRequestDAO实例
* @return LeaveRequestDAO实例
*/
public static LeaveRequestDAO getLeaveRequestDAO() {
return leaveRequestDAO;
}
}