001 /* 002 * Copyright 2010 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package com.hs.mail.imap.dao; 017 018 /** 019 * Static factory to conceal the automatic choice of the data access object 020 * implementation class. 021 * 022 * @author Won Chul Doh 023 * @since Mar 8, 2010 024 * 025 */ 026 public class DaoFactory { 027 028 private static DaoFactory instance; 029 030 private MailboxDao mailboxDao; 031 private MessageDao messageDao; 032 private SearchDao searchDao; 033 private UserDao userDao; 034 035 public static DaoFactory getInstance() { 036 if (null == instance) { 037 instance = new DaoFactory(); 038 } 039 return instance; 040 } 041 042 public void setMailboxDao(MailboxDao mailboxDao) { 043 this.mailboxDao = mailboxDao; 044 } 045 046 public void setMessageDao(MessageDao messageDao) { 047 this.messageDao = messageDao; 048 } 049 050 public void setSearchDao(SearchDao searchDao) { 051 this.searchDao = searchDao; 052 } 053 054 public void setUserDao(UserDao userDao) { 055 this.userDao = userDao; 056 } 057 058 public static MailboxDao getMailboxDao() { 059 return getInstance().mailboxDao; 060 } 061 062 public static MessageDao getMessageDao() { 063 return getInstance().messageDao; 064 } 065 066 public static SearchDao getSearchDao() { 067 return getInstance().searchDao; 068 } 069 070 public static UserDao getUserDao() { 071 return getInstance().userDao; 072 } 073 074 }