|
What this is
Other links
The source code/* * $Header: /cvsroot/mvnforum/myvietnam/src/net/myvietnam/mvncore/MVNCoreConfig.java,v 1.5 2005/01/30 18:14:20 minhnn Exp $ * $Author: minhnn $ * $Revision: 1.5 $ * $Date: 2005/01/30 18:14:20 $ * * ==================================================================== * * Copyright (C) 2002-2005 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: Phong Ta Quoc phongtq@MyVietnam.net */ 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"; /* <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 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; } 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)); /* <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> */ 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>*/ enableLinkNofollow = conf.getBoolean("mvncoreconfig.enable_link_nofollow", false); } 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); } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.