📄 mvncoreconfig.java
字号:
/*
* $Header: /cvsroot/mvnforum/myvietnam/src/net/myvietnam/mvncore/MVNCoreConfig.java,v 1.15 2006/04/15 02:59:18 minhnn Exp $
* $Author: minhnn $
* $Revision: 1.15 $
* $Date: 2006/04/15 02:59:18 $
*
* ====================================================================
*
* Copyright (C) 2002-2006 by MyVietnam.net
*
* All copyright notices regarding MyVietnam and MyVietnam CoreLib
* MUST remain intact in the scripts and source code.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Correspondence and Marketing Questions can be sent to:
* info at MyVietnam net
*
* @author: Phong Ta Quoc
*/
package net.myvietnam.mvncore;
import java.io.File;
import net.myvietnam.mvncore.configuration.DOM4JConfiguration;
import net.myvietnam.mvncore.util.FileUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class MVNCoreConfig {
private static Log log = LogFactory.getLog(MVNCoreConfig.class);
final static String OPTION_FILE_NAME = "mvncore.xml";
/* <Module Options> */
private static boolean enable_mvnforum = true;
public static boolean getEnableMVNForum() {
return enable_mvnforum;
}
private static boolean enable_mvncms = false;
public static boolean getEnableMVNCMS() {
return enable_mvncms;
}
/* <Database Options> */
private static boolean useDataSource = false;
public static boolean isUseDataSource() {
return useDataSource;
}
private static String dataSourceName = "";
public static String getDataSourceName() {
return dataSourceName;
}
// MUST NOT refer to DBUtils, or we will get an infinite recurse ???
private static int databaseType = 0;//DATABASE_UNKNOWN
public static int getDatabaseType() {
return databaseType;
}
private static String driverClassName = "com.mysql.jdbc.Driver";
public static String getDriverClassName() {
return driverClassName;
}
private static String databaseURL = "jdbc:mysql://localhost/mvnforum";
public static String getDatabaseURL() {
return databaseURL;
}
private static String databaseUser = "root";
public static String getDatabaseUser() {
return databaseUser;
}
private static String databasePassword = "";
public static String getDatabasePassword() {
return databasePassword;
}
private static int maxConnection = 20;
public static int getMaxConnection() {
return maxConnection;
}
/* by default, the unit of time is milisecond */
private static int maxTimeToWait = 2000;// 2 seconds
public static int getMaxTimeToWait() {
return maxTimeToWait;
}
private static int minutesBetweenRefresh = 30;// 30 minutes
public static int getMinutesBetweenRefresh() {
return minutesBetweenRefresh;
}
/* </Database Options> */
/* <Mail Options> */
private static boolean useMailSource = false;
public static boolean isUseMailSource() {
return useMailSource;
}
private static String mailSourceName = "";
public static String getMailSourceName() {
return mailSourceName;
}
private static String mailServer = "mail.yourdomain";
public static String getMailServer() {
return mailServer;
}
private static int mailServerPort = 25;
public static int getMailServerPort() {
return mailServerPort;
}
private static String defaultMailFrom = "youruser@yourdomain";
public static String getDefaultMailFrom() {
return defaultMailFrom;
}
private static String mailUserName = "";// allow empty username
public static String getMailUserName() {
return mailUserName;
}
private static String mailPassword = "";
public static String getMailPassword() {
return mailPassword;
}
/* </Mail Options> */
/* <Param Options> */
private static String contextPath = "";// allow ROOT context
public static String getContextPath() {
return contextPath;
}
private static String serverPath = "http://localhost:8080";
public static String getServerPath() {
return serverPath;
}
/* <Param Options> */
/* <Date Options> */
/* the unit of the server offset is hour*/
private static int serverHourOffset = 0; /* GMT timezone */
public static int getServerHourOffset() {
return serverHourOffset;
}
/* </Date Options> */
/* <User Agent Options>*/
private static String blockedUserAgents = "";
public static String getBlockedUserAgents() {
return blockedUserAgents;
}
/* </User Agent Options>*/
/* <IP Options>*/
private static String blockedIPs = "";
public static String getBlockedIPs() {
return blockedIPs;
}
/* </IP Options>*/
/* <Interceptor> */
private static String mailInterceptorClassName = "";
public static String getMailInterceptorClassName() {
return mailInterceptorClassName;
}
private static String contentInterceptorClassName = "";
public static String getContentInterceptorClassName() {
return contentInterceptorClassName;
}
private static String loginInterceptorClassName = "";
public static String getLoginIdInterceptorClassName() {
return loginInterceptorClassName;
}
/* </Interceptor> */
private static boolean enableLinkNofollow = false;
public static boolean getEnableLinkNofollow() {
return enableLinkNofollow;
}
private static boolean enableEncodeURL = true;
public static boolean getEnableEncodeURL() {
return enableEncodeURL;
}
private static String portalType = "non-portal";//Portal.DEFAULT;
public static String getPortalType() {
return portalType;
}
private static String urlResolverClassName = "net.myvietnam.mvncore.web.impl.URLResolverServletImpl";
public static String getURLResolverClassName() {
return urlResolverClassName;
}
private static String uploadParserClassName = "net.myvietnam.mvncore.web.impl.FileUploadParserServletImpl";
public static String getUploadParserClassName() {
return uploadParserClassName;
}
private static String mvnCoreServiceClassName = "net.myvietnam.mvncore.service.impl.MvnCoreServiceImpl";
public static String getMvnCoreServiceClassName() {
return mvnCoreServiceClassName;
}
static {
load();
}
public static void load() {
reload();
}
public static void reload() {
String classPath = FileUtil.getServletClassesPath();
String configFilename = classPath + OPTION_FILE_NAME;
try {
DOM4JConfiguration conf = new DOM4JConfiguration(new File(configFilename));
/* <Plugin Options> */
enable_mvnforum = conf.getBoolean("plugin_options.enable_mvnforum", true);
enable_mvncms = conf.getBoolean("plugin_options.enable_mvncms", false);
/* <Database Options> */
useDataSource = conf.getBoolean("dboptions.use_datasource", false);
databaseType = conf.getInt("dboptions.database_type", 0);
if (useDataSource) {
dataSourceName = conf.getString("dboptions.datasource_name");
} else {
driverClassName = conf.getString("dboptions.driver_class_name", driverClassName);
databaseURL = conf.getString("dboptions.database_url", databaseURL);
databaseUser = conf.getString("dboptions.database_user", databaseUser);
databasePassword = conf.getString("dboptions.database_password",databasePassword);
maxConnection = conf.getInt("dboptions.max_connection", maxConnection);
maxTimeToWait = conf.getInt("dboptions.max_time_to_wait", maxTimeToWait);
minutesBetweenRefresh = conf.getInt("dboptions.minutes_between_refresh", minutesBetweenRefresh);
if (minutesBetweenRefresh < 1) {
minutesBetweenRefresh = 1; //min is 1 minute
}
}
/* <Database Options> */
/* <Mail Options> */
useMailSource = conf.getBoolean("mailoptions.use_mailsource", false);
if (useMailSource) {
mailSourceName = conf.getString("mailoptions.mailsource_name");
} else {
mailServer = conf.getString("mailoptions.mail_server", mailServer);
defaultMailFrom = conf.getString("mailoptions.default_mail_from", defaultMailFrom);
mailUserName = conf.getString("mailoptions.username", mailUserName);
mailPassword = conf.getString("mailoptions.password", mailPassword);
mailServerPort = conf.getInt("mailoptions.port", mailServerPort);
}
/* </Mail Options> */
/* <Parameter Options> */
contextPath = conf.getString("paramoptions.context_path", contextPath);
serverPath = conf.getString("paramoptions.server_path", serverPath);
if (serverPath.endsWith("/")) {
serverPath = serverPath.substring(0, serverPath.length() - 1);
}
/* </Parameter Options> */
/* <Date Time Options> */
serverHourOffset = conf.getInt("dateoptions.server_hour_offset", serverHourOffset);
if ((serverHourOffset < -13) || (serverHourOffset > 13)) {
serverHourOffset = 0;
}
/* </Date Time Options> */
/* <User Agent Options>*/
blockedUserAgents = conf.getString("useragentoptions.blocked_user_agent", blockedUserAgents);
/* </User Agent Options>*/
/* <IP Options>*/
blockedIPs = conf.getString("ipoptions.blocked_ip", blockedIPs);
/* </IP Options>*/
/* <Interceptor Options>*/
mailInterceptorClassName = conf.getString("interceptor.mailinterceptor_implementation", mailInterceptorClassName);
contentInterceptorClassName = conf.getString("interceptor.contentinterceptor_implementation", contentInterceptorClassName);
loginInterceptorClassName = conf.getString("interceptor.loginidinterceptor_implementation", loginInterceptorClassName);
/* </Interceptor Options>*/
/* <MVNCore Options>*/
enableLinkNofollow = conf.getBoolean("mvncoreconfig.enable_link_nofollow", false);
enableEncodeURL = conf.getBoolean("mvncoreconfig.enable_encode_url", true);
portalType = conf.getString("mvncoreconfig.portal_type", portalType);
urlResolverClassName = conf.getString("mvncoreconfig.urlresolver_implementation", urlResolverClassName);
uploadParserClassName = conf.getString("mvncoreconfig.uploadparser_implementation", uploadParserClassName);
mvnCoreServiceClassName = conf.getString("mvncoreconfig.mvncoreservice_implementation", mvnCoreServiceClassName);
/* </MVNCore Options>*/
} catch (Exception e) {
String message = "com.mvnforum.MVNCoreConfig: Can't read the configuration file: '" + configFilename + "'. Make sure the file is in your CLASSPATH";
log.error(message, e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -