⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 daofactory.java

📁 java servlet著名论坛源代码
💻 JAVA
字号:
/*
 * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/db/DAOFactory.java,v 1.3 2004/01/18 19:13:11 minhnn Exp $
 * $Author: minhnn $
 * $Revision: 1.3 $
 * $Date: 2004/01/18 19:13:11 $
 *
 * ====================================================================
 *
 * Copyright (C) 2002-2004 by MyVietnam.net
 *
 * 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 any later version.
 *
 * All copyright notices regarding mvnForum MUST remain intact
 * in the scripts and in the outputted HTML.
 * The "powered by" text/logo with a link back to
 * http://www.mvnForum.com and http://www.MyVietnam.net in the
 * footer of the pages MUST remain visible when the pages
 * are viewed on the internet or intranet.
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Support can be obtained from support forums at:
 * http://www.mvnForum.com/mvnforum/index
 *
 * Correspondence and Marketing Questions can be sent to:
 * info@MyVietnam.net
 *
 * @author: Minh Nguyen  minhnn@MyVietnam.net
 */
package com.mvnforum.db;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.mvnforum.MVNForumFactoryConfig;
import com.mvnforum.db.jdbc.*;

/**
 * Instance that returns the right implementation for the different
 * DAO implementation such as JDBC or Hibernate.
 *
 * @author Minh Nguyen
 * @version $Revision: 1.3 $
 */
public class DAOFactory {

    private static Log log = LogFactory.getLog(DAOFactory.class);

    private DAOFactory() {}

    private static MemberDAO             memberDAO             = null;
    private static MessageFolderDAO      messageFolderDAO      = null;
    private static MemberForumDAO        memberForumDAO        = null;
    private static MemberGroupDAO        memberGroupDAO        = null;
    private static MemberPermissionDAO   memberPermissionDAO   = null;
    private static CategoryDAO           categoryDAO           = null;
    private static ForumDAO              forumDAO              = null;
    private static FavoriteThreadDAO     favoriteThreadDAO     = null;
    private static GroupForumDAO         groupForumDAO         = null;
    private static GroupPermissionDAO    groupPermissionDAO    = null;
    private static GroupsDAO             groupsDAO             = null;
    private static AttachmentDAO         attachmentDAO         = null;
    private static ThreadDAO             threadDAO             = null;
    private static PostDAO               postDAO               = null;
    private static RankDAO               rankDAO               = null;
    private static WatchDAO              watchDAO              = null;

    public static MemberDAO getMemberDAO() {
        return memberDAO;
    }

    public static MessageFolderDAO getMessageFolderDAO() {
        return messageFolderDAO;
    }

    public static MemberForumDAO getMemberForumDAO() {
        return memberForumDAO;
    }

    public static MemberGroupDAO getMemberGroupDAO() {
        return memberGroupDAO;
    }

    public static MemberPermissionDAO getMemberPermissionDAO() {
        return memberPermissionDAO;
    }

    public static CategoryDAO getCategoryDAO() {
        return categoryDAO;
    }

    public static ForumDAO getForumDAO() {
        return forumDAO;
    }

    public static FavoriteThreadDAO getFavoriteThreadDAO() {
        return favoriteThreadDAO;
    }

    public static GroupForumDAO getGroupForumDAO() {
        return groupForumDAO;
    }

    public static GroupPermissionDAO getGroupPermissionDAO() {
        return groupPermissionDAO;
    }

    public static GroupsDAO getGroupsDAO() {
        return groupsDAO;
    }

    public static AttachmentDAO getAttachmentDAO() {
        return attachmentDAO;
    }

    public static ThreadDAO getThreadDAO() {
        return threadDAO;
    }

    public static PostDAO getPostDAO() {
        return postDAO;
    }

    public static RankDAO getRankDAO() {
        return rankDAO;
    }

    public static WatchDAO getWatchDAO() {
        return watchDAO;
    }

    static {
        try {
            Class c = Class.forName(MVNForumFactoryConfig.getMemberManagerClassName());
            memberDAO = (MemberDAO) c.newInstance();
            log.info("memberDAO = " + memberDAO);
        } catch (Exception e) {
            log.error("Error returning the DAOFactory.", e);
            //throw new RuntimeException(e.getMessage());
            log.warn("Cannot init MemberDAO, about to use the default implementation.");
            memberDAO = new MemberDAOImplJDBC();
        }

        messageFolderDAO = new MessageFolderDAOImplJDBC();

        memberForumDAO = new MemberForumDAOImplJDBC();

        memberGroupDAO = new MemberGroupDAOImplJDBC();

        memberPermissionDAO = new MemberPermissionDAOImplJDBC();

        categoryDAO = new CategoryDAOImplJDBC();

        forumDAO = new ForumDAOImplJDBC();

        favoriteThreadDAO = new FavoriteThreadDAOImplJDBC();

        groupForumDAO = new GroupForumDAOImplJDBC();

        groupPermissionDAO = new GroupPermissionDAOImplJDBC();

        groupsDAO = new GroupsDAOImplJDBC();

        attachmentDAO = new AttachmentDAOImplJDBC();

        threadDAO = new ThreadDAOImplJDBC();

        postDAO = new PostDAOImplJDBC();

        rankDAO = new RankDAOImplJDBC();

        watchDAO = new WatchDAOImplJDBC();

    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -