加载模板
来源:互联网 发布:c语言中double和float 编辑:程序博客网 时间:2024/04/29 17:40
package cn.richinfo.cmail.plugs.task.bill.common;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceAware;
import org.springframework.context.support.MessageSourceAccessor;
import cn.richinfo.cmail.common.log.AdminLogger;
import cn.richinfo.cmail.common.log.Log;
import richinfo.rmapi.common.ApiConfig;
public class InitLoad implements MessageSourceAware{
private final static Log log = AdminLogger.getInstance();
private static MessageSourceAccessor messageSourceAccessor;
private static ApiConfig apiConfig = ApiConfig.getInstance();
//mail 模板
static String sendMailMaste=null;
static String loginSituation=null;
static String bosomSendByNumSituation=null;
//星期
static Map<String, String> weekDay = new HashMap<String, String>();
static Map<String, String> visitType = new HashMap<String, String>();
static Map<String,String> activeUnits=new HashMap<String,String>();
public static String getMailMaste()
{
if(null!=sendMailMaste)
{
return sendMailMaste;
}
String path=apiConfig.loadLocalProps()+"/mail_bill.eml";
StringBuffer content=new StringBuffer();
content.append("");
InputStreamReader read;
try {
read = new InputStreamReader(new FileInputStream(new File(path)),"UTF-8");
BufferedReader reader=new BufferedReader(read);
String tempString = null;
while ((tempString = reader.readLine()) != null) {
content.append(tempString);
}
reader.close();
} catch (Exception e) {
log.error("load bill master mail_bill.eml is error",e);
}
sendMailMaste=content.toString();
return sendMailMaste;
}
public static String getLoginSituationMaste()
{
if(null!=loginSituation)
{
return loginSituation;
}
String path=apiConfig.loadLocalProps()+"/loginStatution.eml";
StringBuffer content=new StringBuffer();
content.append("");
InputStreamReader read;
try {
read = new InputStreamReader(new FileInputStream(new File(path)),"UTF-8");
BufferedReader reader=new BufferedReader(read);
String tempString = null;
while ((tempString = reader.readLine()) != null) {
content.append(tempString);
}
reader.close();
} catch (Exception e) {
log.error("load bill master loginStatution.eml is error",e);
}
loginSituation=content.toString();
return loginSituation;
}
public static String getBosomSendByNumSituationMaste()
{
if(null!=bosomSendByNumSituation)
{
return bosomSendByNumSituation;
}
String path=apiConfig.loadLocalProps()+"/bosomSendByNumSituation.eml";
StringBuffer content=new StringBuffer();
content.append("");
InputStreamReader read;
try {
read = new InputStreamReader(new FileInputStream(new File(path)),"UTF-8");
BufferedReader reader=new BufferedReader(read);
String tempString = null;
while ((tempString = reader.readLine()) != null) {
content.append(tempString);
}
reader.close();
} catch (IOException e) {
log.error("load bill master bosomSendByNumSituation.eml is error",e);
}
bosomSendByNumSituation=content.toString();
return bosomSendByNumSituation;
}
public static String getWeekDay(String key) {
String res = null;
if (weekDay.size() > 0) {
res = weekDay.get(key);
} else {
String weekDayStr = messageSourceAccessor.getMessage("log.user.bill_Week");
String[] weekDays = weekDayStr.split(";");
if (weekDays != null) {
for (int i = 0; i < weekDays.length; i++) {
String[] ch = weekDays[i].split(":");
if (ch.length == 2) {
weekDay.put(ch[0], ch[1]);
}
}
}
res = weekDay.get(key);
}
if (res != null) {
return res;
} else {
return key;
}
}
public static String getVisitType(String key) {
String res = null;
if (visitType.size() > 0) {
res = visitType.get(key);
} else {
String visitTypeStr =messageSourceAccessor.getMessage("log.user.bill.login_channel");
String[] visitTypeDays = visitTypeStr.split(";");
if (visitTypeDays != null) {
for (int i = 0; i < visitTypeDays.length; i++) {
String[] ch = visitTypeDays[i].split(":");
if (ch.length == 2) {
visitType.put(ch[0], ch[1]);
}
}
}
res = visitType.get(key);
}
if (res != null) {
return res;
} else {
return "";
}
}
public static String getUnit(String key,MessageSourceAccessor messageSourceAccessor) {
String res = null;
if (activeUnits.size() > 0) {
res = activeUnits.get(key);
} else {
String unitStr = messageSourceAccessor.getMessage("log.user.bill.active_units");
String[] units = unitStr.split(";");
if (units != null) {
for (int i = 0; i < units.length; i++) {
String[] ch = units[i].split("@");
if (ch.length == 2) {
activeUnits.put(ch[0], ch[1]);
}
}
}
res = weekDay.get(key);
}
if (res != null) {
return res;
} else {
return key;
}
}
@Override
public void setMessageSource(MessageSource messageSource) {
// TODO Auto-generated method stub
messageSourceAccessor=new MessageSourceAccessor(messageSource);
}
}
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceAware;
import org.springframework.context.support.MessageSourceAccessor;
import cn.richinfo.cmail.common.log.AdminLogger;
import cn.richinfo.cmail.common.log.Log;
import richinfo.rmapi.common.ApiConfig;
public class InitLoad implements MessageSourceAware{
private final static Log log = AdminLogger.getInstance();
private static MessageSourceAccessor messageSourceAccessor;
private static ApiConfig apiConfig = ApiConfig.getInstance();
//mail 模板
static String sendMailMaste=null;
static String loginSituation=null;
static String bosomSendByNumSituation=null;
//星期
static Map<String, String> weekDay = new HashMap<String, String>();
static Map<String, String> visitType = new HashMap<String, String>();
static Map<String,String> activeUnits=new HashMap<String,String>();
public static String getMailMaste()
{
if(null!=sendMailMaste)
{
return sendMailMaste;
}
String path=apiConfig.loadLocalProps()+"/mail_bill.eml";
StringBuffer content=new StringBuffer();
content.append("");
InputStreamReader read;
try {
read = new InputStreamReader(new FileInputStream(new File(path)),"UTF-8");
BufferedReader reader=new BufferedReader(read);
String tempString = null;
while ((tempString = reader.readLine()) != null) {
content.append(tempString);
}
reader.close();
} catch (Exception e) {
log.error("load bill master mail_bill.eml is error",e);
}
sendMailMaste=content.toString();
return sendMailMaste;
}
public static String getLoginSituationMaste()
{
if(null!=loginSituation)
{
return loginSituation;
}
String path=apiConfig.loadLocalProps()+"/loginStatution.eml";
StringBuffer content=new StringBuffer();
content.append("");
InputStreamReader read;
try {
read = new InputStreamReader(new FileInputStream(new File(path)),"UTF-8");
BufferedReader reader=new BufferedReader(read);
String tempString = null;
while ((tempString = reader.readLine()) != null) {
content.append(tempString);
}
reader.close();
} catch (Exception e) {
log.error("load bill master loginStatution.eml is error",e);
}
loginSituation=content.toString();
return loginSituation;
}
public static String getBosomSendByNumSituationMaste()
{
if(null!=bosomSendByNumSituation)
{
return bosomSendByNumSituation;
}
String path=apiConfig.loadLocalProps()+"/bosomSendByNumSituation.eml";
StringBuffer content=new StringBuffer();
content.append("");
InputStreamReader read;
try {
read = new InputStreamReader(new FileInputStream(new File(path)),"UTF-8");
BufferedReader reader=new BufferedReader(read);
String tempString = null;
while ((tempString = reader.readLine()) != null) {
content.append(tempString);
}
reader.close();
} catch (IOException e) {
log.error("load bill master bosomSendByNumSituation.eml is error",e);
}
bosomSendByNumSituation=content.toString();
return bosomSendByNumSituation;
}
public static String getWeekDay(String key) {
String res = null;
if (weekDay.size() > 0) {
res = weekDay.get(key);
} else {
String weekDayStr = messageSourceAccessor.getMessage("log.user.bill_Week");
String[] weekDays = weekDayStr.split(";");
if (weekDays != null) {
for (int i = 0; i < weekDays.length; i++) {
String[] ch = weekDays[i].split(":");
if (ch.length == 2) {
weekDay.put(ch[0], ch[1]);
}
}
}
res = weekDay.get(key);
}
if (res != null) {
return res;
} else {
return key;
}
}
public static String getVisitType(String key) {
String res = null;
if (visitType.size() > 0) {
res = visitType.get(key);
} else {
String visitTypeStr =messageSourceAccessor.getMessage("log.user.bill.login_channel");
String[] visitTypeDays = visitTypeStr.split(";");
if (visitTypeDays != null) {
for (int i = 0; i < visitTypeDays.length; i++) {
String[] ch = visitTypeDays[i].split(":");
if (ch.length == 2) {
visitType.put(ch[0], ch[1]);
}
}
}
res = visitType.get(key);
}
if (res != null) {
return res;
} else {
return "";
}
}
public static String getUnit(String key,MessageSourceAccessor messageSourceAccessor) {
String res = null;
if (activeUnits.size() > 0) {
res = activeUnits.get(key);
} else {
String unitStr = messageSourceAccessor.getMessage("log.user.bill.active_units");
String[] units = unitStr.split(";");
if (units != null) {
for (int i = 0; i < units.length; i++) {
String[] ch = units[i].split("@");
if (ch.length == 2) {
activeUnits.put(ch[0], ch[1]);
}
}
}
res = weekDay.get(key);
}
if (res != null) {
return res;
} else {
return key;
}
}
@Override
public void setMessageSource(MessageSource messageSource) {
// TODO Auto-generated method stub
messageSourceAccessor=new MessageSourceAccessor(messageSource);
}
}
0 0
- 模板加载
- 加载模板
- freemarker模板加载
- FreeMarker模板加载器
- velocity模板加载
- angular模板加载
- velocity模板加载
- freeMarker模板加载
- volocity加载模板&输出
- freemarker模板加载器
- velocity 模板加载
- django 模板加载优化
- freemarker模板加载器
- iOS动态模板加载
- 【FreeMarker】【程序开发】模板加载,模板缓存
- excel util;读取模板,动态加载模板
- Lodop 动态加载模板,动态加载数据
- gridview 动态加载模板列
- 将无线路由与交换机连接后实现【无线上网】
- B树
- 哈希
- [2]超全局变量$_POST,$_REQUEST
- 英特爾推出新一代 Intel® Atom™ ( 凌動™ )處理器平台
- 加载模板
- 【C语言天天练(四)】回调函数
- 从一个“Bug”说起
- 第十一周项目一存储班长信息的学生类(2)
- android Beam
- 第八周项目二 Time类中的运算符重载
- 监控action访问时间
- Python优势和用途--perfect!
- ubuntu 用户 用户组 设置