1 40 package com.mvnforum.db; 41 42 import com.mvnforum.*; 43 import com.mvnforum.db.jdbc.*; 44 import net.myvietnam.mvncore.MVNCoreConfig; 45 import org.apache.commons.logging.Log; 46 import org.apache.commons.logging.LogFactory; 47 48 55 public class DAOFactory { 56 57 private static Log log = LogFactory.getLog(DAOFactory.class); 58 59 private DAOFactory() {} 60 61 private static MemberDAO localMemberDAO = null; 62 private static MemberDAO memberDAO = null; 63 private static MessageFolderDAO messageFolderDAO = null; 64 private static MemberForumDAO memberForumDAO = null; 65 private static MemberGroupDAO memberGroupDAO = null; 66 private static MemberPermissionDAO memberPermissionDAO = null; 67 private static CategoryDAO categoryDAO = null; 68 private static ForumDAO forumDAO = null; 69 private static FavoriteThreadDAO favoriteThreadDAO = null; 70 private static GroupForumDAO groupForumDAO = null; 71 private static GroupPermissionDAO groupPermissionDAO = null; 72 private static GroupsDAO groupsDAO = null; 73 private static AttachmentDAO attachmentDAO = null; 74 private static ThreadDAO threadDAO = null; 75 private static PostDAO postDAO = null; 76 private static RankDAO rankDAO = null; 77 private static WatchDAO watchDAO = null; 78 private static MessageDAO messageDAO = null; 79 private static MessageStatisticsDAO messageStatisticsDAO = null; 80 private static PmAttachmentDAO pmAttachmentDAO = null; 81 private static PmAttachMessageDAO pmAttachMessageDAO = null; 82 83 private static CompanyDAO companyDAO = null; 84 private static MemberTutorDAO memberTutorDAO = null; 85 private static MemberCompanyDAO memberCompanyDAO = null; 86 87 public static MemberDAO getMemberDAO() { 88 return memberDAO; 89 } 90 91 public static MemberDAO getLocalMemberDAO() { 92 return localMemberDAO; 93 } 94 95 public static MessageFolderDAO getMessageFolderDAO() { 96 return messageFolderDAO; 97 } 98 99 public static MemberForumDAO getMemberForumDAO() { 100 return memberForumDAO; 101 } 102 103 public static MemberGroupDAO getMemberGroupDAO() { 104 return memberGroupDAO; 105 } 106 107 public static MemberPermissionDAO getMemberPermissionDAO() { 108 return memberPermissionDAO; 109 } 110 111 public static CategoryDAO getCategoryDAO() { 112 return categoryDAO; 113 } 114 115 public static ForumDAO getForumDAO() { 116 return forumDAO; 117 } 118 119 public static FavoriteThreadDAO getFavoriteThreadDAO() { 120 return favoriteThreadDAO; 121 } 122 123 public static GroupForumDAO getGroupForumDAO() { 124 return groupForumDAO; 125 } 126 127 public static GroupPermissionDAO getGroupPermissionDAO() { 128 return groupPermissionDAO; 129 } 130 131 public static GroupsDAO getGroupsDAO() { 132 return groupsDAO; 133 } 134 135 public static AttachmentDAO getAttachmentDAO() { 136 return attachmentDAO; 137 } 138 139 public static ThreadDAO getThreadDAO() { 140 return threadDAO; 141 } 142 143 public static PostDAO getPostDAO() { 144 return postDAO; 145 } 146 147 public static RankDAO getRankDAO() { 148 return rankDAO; 149 } 150 151 public static WatchDAO getWatchDAO() { 152 return watchDAO; 153 } 154 155 public static MessageDAO getMessageDAO() { 156 return messageDAO; 157 } 158 159 public static MessageStatisticsDAO getMessageStatisticsDAO() { 160 return messageStatisticsDAO; 161 } 162 163 public static PmAttachmentDAO getPmAttachmentDAO() { 164 return pmAttachmentDAO; 165 } 166 167 public static PmAttachMessageDAO getPmAttachMessageDAO() { 168 return pmAttachMessageDAO; 169 } 170 171 public static CompanyDAO getCompanyDAO() { 172 return companyDAO; 173 } 174 175 public static MemberCompanyDAO getMemberCompanyDAO() { 176 return memberCompanyDAO; 177 } 178 179 public static MemberTutorDAO getMemberTutorDAO() { 180 return memberTutorDAO; 181 } 182 183 static { 184 boolean enablePortlet = MVNForumConfig.getEnablePortlet(); 185 186 String memberImpl = ""; 188 189 192 if (MVNForumFactoryConfig.getMemberManagerClassName().length() > 0) { memberImpl = MVNForumFactoryConfig.getMemberManagerClassName(); 194 } else if (enablePortlet) { 195 memberImpl = Portal.getMemberImplementation(MVNCoreConfig.getPortalType()); 196 } else { 197 log.error("Error: not config <member_implementation> properly in mvnforum.xml. Try loading the default implementation for Member."); 198 199 memberImpl = "com.mvnforum.db.jdbc.MemberDAOImplJDBC"; 200 log.info("Try loading default MemberDAO = " + memberImpl); 201 } 202 203 try { 204 Class c = Class.forName(memberImpl); 205 memberDAO = (MemberDAO) c.newInstance(); 206 log.info("memberDAO = " + memberDAO); 207 } catch (Exception e) { 208 log.error("Error returning the DAOFactory.", e); 209 log.warn("Cannot init MemberDAO, about to use the default implementation."); 210 211 memberDAO = new MemberDAOImplJDBC(); 212 } 213 214 localMemberDAO = new MemberDAOImplJDBC(); 215 216 messageFolderDAO = new MessageFolderDAOImplJDBC(); 217 218 memberForumDAO = new MemberForumDAOImplJDBC(); 219 220 memberGroupDAO = new MemberGroupDAOImplJDBC(); 221 222 memberPermissionDAO = new MemberPermissionDAOImplJDBC(); 223 224 categoryDAO = new CategoryDAOImplJDBC(); 225 226 forumDAO = new ForumDAOImplJDBC(); 227 228 favoriteThreadDAO = new FavoriteThreadDAOImplJDBC(); 229 230 groupForumDAO = new GroupForumDAOImplJDBC(); 231 232 groupPermissionDAO = new GroupPermissionDAOImplJDBC(); 233 234 groupsDAO = new GroupsDAOImplJDBC(); 235 236 attachmentDAO = new AttachmentDAOImplJDBC(); 237 238 threadDAO = new ThreadDAOImplJDBC(); 239 240 postDAO = new PostDAOImplJDBC(); 241 242 rankDAO = new RankDAOImplJDBC(); 243 244 watchDAO = new WatchDAOImplJDBC(); 245 246 messageDAO = new MessageDAOImplJDBC(); 247 248 messageStatisticsDAO = new MessageStatisticsDAOImplJDBC(); 249 250 pmAttachmentDAO = new PmAttachmentDAOImplJDBC(); 251 252 pmAttachMessageDAO = new PmAttachMessageDAOImplJDBC(); 253 254 memberTutorDAO = new MemberTutorDAOImplJDBC(); 255 256 companyDAO = new CompanyDAOImplJDBC(); 257 258 memberCompanyDAO = new MemberCompanyDAOImplJDBC(); 259 260 } 261 262 } 263 | Popular Tags |