📄 smsmain.java
字号:
package com.gctech.sms.voice.api;
import java.util.*;
import org.apache.log4j.Logger;
import com.gctech.sms.voice.*;
import com.gctech.sms.voice.common.*;
import com.gctech.sms.sp.cms.core2.*;
import com.gctech.sms.sp.cms.msg2.*;
/**
*
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author lijz@gctech.com.cn
* @version 1.0
*/
public class SMSMain
{
private static SMSMain api = new SMSMain();
//确认weak,与soft的区别
//用于保存所有计费的下行信息
public Map seqMap = new LRUHashMap();
public Map messageMap = new LRUHashMap();
static Logger logger = Logger.getLogger(SMSMain.class);
PlatformAPI pfa = null;
private SMSMain()
{
}
public static SMSMain instance()
{
return api;
}
public static void init() throws SMSException
{
}
public Integer send(SMSRequest request)
throws SMSException
{
logger.info(request);
// return new Integer(0);
Integer id = send(request.getSrc(),request.getDest(),request.getServiceId(),request.getContent());
APIFacade.voicelogger.info("发送SMS成功:返回Seq="+id);
return id;
}
public void start() throws SMSException
{
logger.info("SMS SERVICE START.......");
pfa = new PlatformAPI(Config.instance().getPlatformIp(),
Config.instance().getPlatformPort());
pfa.addRecevierListener(new BusinessListener(pfa));
pfa.addRecevierListener(new FeeListener());
int status = pfa.login(Config.instance().getSpId(),
Config.instance().getSecret());
if(status != 0)
{
logger.info("连接平台失败!Exit");
throw new SMSException("连接平台失败!Exit");
}
else
{
logger.info("SMS SERVICE START OK");
}
}
public void colse()
{
pfa.logout();
logger.info("SMS SERVICE CLOSED");
}
public Integer send(String src,String dest,String serviceId,String respContent) throws SMSException
{
SubmitMessage sm = new SubmitMessage(Config.instance().getSpId(),
serviceId,respContent,dest,dest,src);
try
{
// logger.info("add response content " + respContent + " src:" + src +
// " dest:" + dest);
//
//
pfa.addMessage(sm);
Integer i = new Integer(sm.sequenceId);
synchronized(APIFacade.SMSLock)
{
this.seqMap.put(i,sm);
logger.info("send message seqid "+i);
}
return i;
}
catch(Exception ex)
{
ex.printStackTrace();
throw new SMSException(ex.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -