⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fileconfig.java

📁 国内很牛的软件公司花费两年半开发的用EJB3开发的代码,采用STRUTS和EJB3,目前系统进行第二版.所以拿出来共享
💻 JAVA
字号:
package com.ufmobile.common.config;

import java.util.ResourceBundle;

import com.ufmobile.mstreet.util.CommonUtil;
import com.ufmobile.mstreet.wap.WAPFacade;
import com.ufmobile.platform.log.RunTimeLogger;

/**
 * <p>
 * 从配置文件中读取参数值。

 * <p>
 * 创建日期:2007-2-13
 * 
 * @author qbh
 * @since v3.0
 */
public class FileConfig {

	/** 群发短信时上传文件目录 */
	public static final String PATH_SMS_UPLOAD = "PATH_TEMP";

	/** 商铺认证图片临时目录 */
	public static final String PATH_BOOTH_AUTH = "PATH_BOOTH_AUTH";

	/** 商品logo */
	public static final String PATH_BOOTH_LOGO = "PATH_BOOTH_LOGO";
	
	/** 商铺信息logo */
	public static final String PATH_BOOTH_INFO_LOGO = "PATH_BOOTH_INFO_LOGO"; 

	/** 券卡图片目录 */
	public static final String PATH_TICKET = "PATH_TICKET";

	/** 商铺商品图片目录 */
	public static final String PATH_BOOTH_PRODUCT = "PATH_PRODUCT";

	/** 图片上下文 */
	public static final String PATH_IMAGE_CONTEX = "PATH_IMAGE_CONTEX";

	/*
	 Web服务器的IP
	public static final String WEB_SERVER_IP = "WEB_SERVER_IP";

	Web服务器的端口
	public static final String WEB_SERVER_PORT = "WEB_SERVER_PORT";

	Wap服务器的IP
	public static final String WAP_SERVER_IP = "WAP_SERVER_IP";

	Wap服务器的端口
	public static final String WAP_SERVER_PORT = "WAP_SERVER_PORT";
	*/
	
	/** Wap服务器的上下文 */
	public static final String WAP_SERVER_CONTEX_PATH = "WAP_SERVER_CONTEX_PATH";
	
	/**省份特服号*/
	public static final String USE_PROVINCE_PORT = "USE_PROVINCE_PORT";
	
	/**默认下发号码*/
	public static final String DEFAULT_PORT ="DEFAULT_PORT";

	/** HTTP头 */
	private static final String HTTP = "http://";

	/** 被推荐的游客进行会员注册的页面 */
	private static final String WAP_REGISTER_MEMBER_PAGE = "recommend";

	/** 配置文件的名称 */
	private static final String CONFIG_FILE_NAME = "ufconfig";

	private static ResourceBundle bundle;

	private static void initBundle() {
		if (bundle == null) {
			bundle = ResourceBundle.getBundle(CONFIG_FILE_NAME);
		}
	}

	public static String getValue(String key) {
		String value = null;
		try {
			initBundle();
			value = bundle.getString(key);
		} catch (Exception e) {
			RunTimeLogger.info(FileConfig.class, e.getMessage());
		}

		return value;
	}

	public static String getImageRootPath() {
		return getValue(PATH_IMAGE_CONTEX);
	}
	
	/**
	 * <p>
	 *取得图片对应的相对路径


	 * <p>
	 * 作者:lgb <br>
	 * 日期:Feb 13, 2007
	 * @param key
	 * @return
	 */
	public static String getImagePath(String key) {
		String root = getImageRootPath();
		String path = getValue(key);
		
		if(root != null && path != null)
			return root + path;
		return null;
	}
	
	
	
	private static String getWebUrl(String webServerIp, String webServerPort) {
		return HTTP + webServerIp + ":" + webServerPort;
	}
	
	private static String getBoothInfoPicUrlRoot(String webServerIp, String webServerPort) {
		return HTTP + webServerIp + ":" + webServerPort;
	}
	

	private static String getWapUrl(String wapServerIp, String wapServerPort) {
		String url = HTTP + wapServerIp + ":" + wapServerPort;
		String contexPath = getValue(WAP_SERVER_CONTEX_PATH);
		if (!CommonUtil.isNull(contexPath)) {
			url += "/" + contexPath;
		}
		return url;
	}

	public static String getBoothInfoPicUrl(String webServerIp, String webServerPort) {
		String picurl = getBoothInfoPicUrlRoot(webServerIp, webServerPort) + getValue(PATH_BOOTH_INFO_LOGO) ;
		return getBoothInfoPicUrlRoot(webServerIp, webServerPort) + getValue(PATH_IMAGE_CONTEX) + getValue(PATH_BOOTH_INFO_LOGO) ;
	}
	
	public static String getTicketUrl(String webServerIp, String webServerPort) {
		return getWebUrl(webServerIp, webServerPort) + getValue(PATH_IMAGE_CONTEX) + getValue(PATH_TICKET);
	}

	public static String getBoothLogoUrl(String webServerIp, String webServerPort) {
		return getWebUrl(webServerIp, webServerPort) + getValue(PATH_IMAGE_CONTEX) + getValue(PATH_BOOTH_LOGO);
	}

	public static String getBoothProductUrl(String webServerIp, String webServerPort) {
		return getWebUrl(webServerIp, webServerPort) + getValue(PATH_IMAGE_CONTEX) + getValue(PATH_BOOTH_PRODUCT);
	}

	public static String getBoothAuthUrl(String webServerIp, String webServerPort) {
		return getWebUrl(webServerIp, webServerPort) + getValue(PATH_IMAGE_CONTEX) + getValue(PATH_BOOTH_AUTH);
	}

	/**
	 * <p>
	 * 返回Wap会员注册的URL。

	 * <p>
	 * 作者:qbh <br>
	 * 日期:2007-3-6
	 * 
	 * @param streetID 商街ID
	 * @param mobileNumber 手机号码
	 * @return
	 */
	public static String getWapRegisterUrl(long streetID, String mobileNumber, String wapServerIp, String wapServerPort) {
		return getWapUrl(wapServerIp, wapServerPort) + "/" + WAP_REGISTER_MEMBER_PAGE + "?"
				+ WAPFacade.REGISTER_URL_PARAM_STREET_ID + "=" + String.valueOf(streetID) + "&"
				+ WAPFacade.REGISTER_URL_PARAM_MOBILE_NUMBER + "="
				+ CommonUtil.toString(mobileNumber);
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -