001: /*
002: * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/MVNForumFactoryConfig.java,v 1.29 2007/10/09 11:09:22 lexuanttkhtn Exp $
003: * $Author: lexuanttkhtn $
004: * $Revision: 1.29 $
005: * $Date: 2007/10/09 11:09:22 $
006: *
007: * ====================================================================
008: *
009: * Copyright (C) 2002-2007 by MyVietnam.net
010: *
011: * All copyright notices regarding mvnForum MUST remain
012: * intact in the scripts and in the outputted HTML.
013: * The "powered by" text/logo with a link back to
014: * http://www.mvnForum.com and http://www.MyVietnam.net in
015: * the footer of the pages MUST remain visible when the pages
016: * are viewed on the internet or intranet.
017: *
018: * This program is free software; you can redistribute it and/or modify
019: * it under the terms of the GNU General Public License as published by
020: * the Free Software Foundation; either version 2 of the License, or
021: * any later version.
022: *
023: * This program is distributed in the hope that it will be useful,
024: * but WITHOUT ANY WARRANTY; without even the implied warranty of
025: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
026: * GNU General Public License for more details.
027: *
028: * You should have received a copy of the GNU General Public License
029: * along with this program; if not, write to the Free Software
030: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
031: *
032: * Support can be obtained from support forums at:
033: * http://www.mvnForum.com/mvnforum/index
034: *
035: * Correspondence and Marketing Questions can be sent to:
036: * info at MyVietnam net
037: *
038: * @author: Luis Miguel Hernanz
039: * @author: Minh Nguyen
040: */
041: package com.mvnforum;
042:
043: import java.io.File;
044:
045: import net.myvietnam.mvncore.configuration.DOM4JConfiguration;
046: import org.apache.commons.logging.Log;
047: import org.apache.commons.logging.LogFactory;
048: import net.myvietnam.mvncore.util.FileUtil;
049:
050: /**
051: * Class that loads and makes accesible the factory configuration.
052: *
053: * @author <a href="luish@germinus.com">Luis Miguel Hernanz</a>
054: * @version $Revision: 1.29 $
055: */
056: public class MVNForumFactoryConfig {
057:
058: private static Log log = LogFactory
059: .getLog(MVNForumFactoryConfig.class);
060:
061: private static final String OPTION_FILE_NAME = "mvnforum.xml";
062:
063: private static String authenticatorClassName = null;
064: private static String memberManagerClassName = "com.mvnforum.db.jdbc.MemberDAOImplJDBC";
065: private static String onlineUserFactoryClassName = "com.mvnforum.auth.OnlineUserFactoryImpl";
066: private static String requestProcessorClassName = "com.mvnforum.RequestProcessorDefault";
067: private static String luceneAnalyzerClassName = "org.apache.lucene.analysis.standard.StandardAnalyzer";
068: private static String mvnAuthServiceClassName = "com.mvnforum.auth.service.impl.MvnAuthServiceImplDefault";
069: private static String mvnForumServiceClassName = "com.mvnforum.service.impl.MvnForumServiceImpl";
070:
071: public static String getMemberManagerClassName() {
072: return memberManagerClassName;
073: }
074:
075: public static void setMemberManagerClassName(
076: String memberManagerClassName) {
077: MVNForumFactoryConfig.memberManagerClassName = memberManagerClassName;
078: }
079:
080: public static String getOnlineUserFactoryClassName() {
081: return onlineUserFactoryClassName;
082: }
083:
084: public static void setOnlineUserFactoryClassName(
085: String onlineUserFactoryClassName) {
086: MVNForumFactoryConfig.onlineUserFactoryClassName = onlineUserFactoryClassName;
087: }
088:
089: public static String getAuthenticatorClassName() {
090: return authenticatorClassName;
091: }
092:
093: public static void setAuthenticatorClassName(
094: String authenticatorClassName) {
095: MVNForumFactoryConfig.authenticatorClassName = authenticatorClassName;
096: }
097:
098: public static String getRequestProcessorClassName() {
099: return requestProcessorClassName;
100: }
101:
102: public static void setRequestProcessorClassName(
103: String requestProcessorClassName) {
104: MVNForumFactoryConfig.requestProcessorClassName = requestProcessorClassName;
105: }
106:
107: public static String getLuceneAnalyzerClassName() {
108: return luceneAnalyzerClassName;
109: }
110:
111: public static void setLuceneAnalyzerClassName(
112: String luceneAnalyzerClassName) {
113: MVNForumFactoryConfig.luceneAnalyzerClassName = luceneAnalyzerClassName;
114: }
115:
116: public static String getMvnAuthServiceClassName() {
117: return mvnAuthServiceClassName;
118: }
119:
120: public static void setMvnAuthServiceClassName(
121: String mvnAuthServiceClassName) {
122: MVNForumFactoryConfig.mvnAuthServiceClassName = mvnAuthServiceClassName;
123: }
124:
125: public static String getMvnForumServiceClassName() {
126: return mvnForumServiceClassName;
127: }
128:
129: public static void setMvnForumServiceClassName(
130: String mvnForumServiceClassName) {
131: MVNForumFactoryConfig.mvnForumServiceClassName = mvnForumServiceClassName;
132: }
133:
134: static {
135: try {
136: String strPathName = FileUtil.getServletClassesPath();
137: String configFilename = strPathName + OPTION_FILE_NAME;
138: DOM4JConfiguration conf = new DOM4JConfiguration(new File(
139: configFilename));
140:
141: memberManagerClassName = conf.getString(
142: "mvnforumfactoryconfig.member_implementation", "");
143: onlineUserFactoryClassName = conf.getString(
144: "mvnforumfactoryconfig.onlineuser_implementation",
145: onlineUserFactoryClassName);
146: authenticatorClassName = conf
147: .getString(
148: "mvnforumfactoryconfig.authenticator_implementation",
149: authenticatorClassName);
150: requestProcessorClassName = conf
151: .getString(
152: "mvnforumfactoryconfig.requestprocessor_implementation",
153: requestProcessorClassName);
154: luceneAnalyzerClassName = conf
155: .getString(
156: "mvnforumfactoryconfig.lucene_analyzer_implementation",
157: luceneAnalyzerClassName);
158: mvnAuthServiceClassName = conf
159: .getString(
160: "mvnforumfactoryconfig.mvn_auth_service_implementation",
161: mvnAuthServiceClassName);
162: mvnForumServiceClassName = conf
163: .getString(
164: "mvnforumfactoryconfig.mvnforum_service_implementation",
165: mvnForumServiceClassName);
166: } catch (Exception e) {
167: log.error("Error loading the factory properties", e);
168: }
169: }
170: }
|