ConfigPath.java 4.4 KB
package com.espeed.tool;
  
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.util.Properties;
/*
 * 程序名称:    	EspeedMail_时速邮箱
 * 程序版本:    	V1.0
 * 作    者:    	深圳市科飞时速网络技术有限公司(0755-88843776)
 * 版权所有:    	深圳市科飞时速网络技术有限公司
 * 技术支持:    	Tech@21gmail.com
 * 单元名称:    读取配置文件工具类
 * 开始时间:    	2013.09.26
 * 程 序 员:    	谢勇
 * 最后修改:    
 * 备    注:		如需修改请通知程序员    
 */
public class ConfigPath {

  static Properties p = loadPropertyFile("config.properties");
   
   	/**webmail项目路径*/
   	public static String getWebMailUrl(){
   		return p.get("webmailurl")+"";
   	}
   
   	/**webmail定时器URL*/
   	public static String getWebMailTimeUrl(){
	   	return p.get("webmailtimeurl")+"";
   	}
   
   	/**webmail接口URL*/
   	public static String getWebmailInterfaceUrl(){
	   	return p.get("webmailinterfaceurl")+"";
   	}
 
   	/**地址最大存放量*/
   	public static int getAddressmaxnum(){
   		return Integer.parseInt(p.get("addressmaxnum").toString());
   	}
   
   	/**每个类别下地址最大存放量*/
   	public static int getAddresstypenum(){
	   	return Integer.parseInt(p.get("addresstypenum").toString());
   	}
   
   	/**导入地址最大行数*/
   	public static int getFilemaxline(){
   		return Integer.parseInt(p.get("filemaxline").toString());
   	}
   
   	/**email地址验证表达式*/
   	public static String getEmailYZ(){
   		return p.get("emailyz").toString();
   	}
   
   	/**域名验证表达式*/
   	public static String getDomainYZ(){
   		return p.get("domainyz").toString();
   	}
   
   	/**获取token解析密钥*/
	public static String getSecretKey(){
		return p.getProperty("secretkey");
	}
	
	/**获取token-id*/
	public static String getTokenId(){
		return p.getProperty("tokenid");
	}
	
	/**获取token-subject*/
	public static String getTokenSubject(){
		return p.getProperty("tokensubject");
	}
	
	/**获取CRM库月发上限*/
	public static int getSendMonthLimit(){
		return Integer.parseInt(p.getProperty("sendmonthlimit"));
	}
	
	/**获取CRM库单次发上限*/
	public static int getSendOnceLimit(){
		return Integer.parseInt(p.getProperty("sendoncelimit"));
	}
	
	/**获取新客户营销月发上限*/
	public static int getSendMonthLimitNew(){
		return Integer.parseInt(p.getProperty("sendmonthlimitnew"));
	}
	
	/**获取新客户营销单次发上限*/
	public static int getSendOnceLimitNew(){
		return Integer.parseInt(p.getProperty("sendoncelimitnew"));
	}
	
	/**获取模板推广默认域名*/
	public static String getStencilDomain(){
		return p.getProperty("stencildomain");
	}
	
	/**获取模板推广网页存储路径*/
	public static String getStencilHtmlUrl(){
		return p.getProperty("stencilhtmlurl");
	}
	
	/**获取本项目web路径*/
	public static String getLocalWebUrl(){
		return p.getProperty("localweburl");
	}
	
	/**获取推广返回服务器路径*/
	public static String getSpreadUrl(){
		return p.getProperty("spreadurl");
	}
	
	/**获取超链接跟踪url*/
	public static String getTrackUrl(){
		return p.getProperty("trackurl");
	}
	
	/**IP地址访问路径URL*/
	public static String getCentreUrl(){
		return p.get("centreurl")+"";
	}
   
	public static Properties loadPropertyFile(String fullFile) {
		String webRootPath = null;
		if ( fullFile.equals(""))
			throw new IllegalArgumentException("Properties file path can not be null : " + fullFile);
		try {
			webRootPath = ConfigPath.class.getClassLoader().getResource("").toURI().getPath();
		} catch (URISyntaxException e1) {
			e1.printStackTrace();
		}
		webRootPath = new File(webRootPath).getParent();
		InputStream inputStream = null;
		Properties p = null;
		try {
			inputStream = new FileInputStream(new File(webRootPath+ File.separator + fullFile));
           	p = new Properties();
           	p.load(inputStream);
           
		} catch (FileNotFoundException e) {
			throw new IllegalArgumentException("Properties file not found: "
                   + fullFile);
		} catch (IOException e) {
			throw new IllegalArgumentException(
                   "Properties file can not be loading: " + fullFile);
		} finally {
			try {
				if (inputStream != null)
					inputStream.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return p;
   }  
}