📄 cmpp3gateway.java
字号:
package com.khan.sms.cmpp3control;
import java.util.Vector;
import com.khan.file.*;
import com.khan.util.*;
import java.io.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class Cmpp3Gateway {
Vector routers = null;
public Cmpp3Gateway() {
LoadResourceIni lr = new LoadResourceIni("smsgwj.properties");
try {
String props[] = lr.readINI("propertites").split(",");
if (props == null) {
throw new ExceptionInInitializerError("cmpp3gateway smsgwj.properties文件系统初始化错误!");
}
routers = new Vector();
for (int i = 0; i < props.length; i++) {
routers.add(new CmppParam(props[i] + ".properties"));
}
} catch (IOException e) {
common.Assert("读smsgwj.properties IO错误");
} catch (Exception e) {
common.Assert("读smsgwj.properties 错误");
}
}
private void startFlag() {
Log log = new Log("flag.out");
log.logOut("flag");
log.close();
}
private boolean isRun() {
return Log.isFileExist("flag.out");
}
public static void main(String[] args) {
common.Assert("debug:系统开始");
/*启动标志*/
Cmpp3Gateway smsgw = new Cmpp3Gateway();
Thread login_thread[] = new Thread[smsgw.routers.size()];
Thread trans_thread[] = new Thread[smsgw.routers.size()];
Thread mo_thread[] = new Thread[smsgw.routers.size()];
smsgw.startFlag();
while (smsgw.isRun()) { //判断启动标志,适当的时候退出系统
for (int i = 0; i < smsgw.routers.size(); i++) {
CmppParam cp = (CmppParam) smsgw.routers.get(i);
SendQueue sq = new SendQueue(cp.MAX_TRANSMIT);
RecvQueue rq = new RecvQueue(cp.MAX_RECVQUEUE_SIZE);
if (Cmpp3Login.flag) {
if (null == login_thread[i]) {
login_thread[i] = new Thread(new Cmpp3Login(cp), "cmpp_login_" + cp.Name);
login_thread[i].start();
}
} else {
common.sleep(1000);
login_thread[i] = null;
}
if (Cmpp3Transceiver.flag) {
if (null == trans_thread[i]) {
trans_thread[i] = new Thread(new Cmpp3Transceiver(cp, rq), "cmpp_trans_" + cp.Name);
trans_thread[i].start();
}
} else {
common.sleep(1000);
trans_thread[i] = null;
}
if (Cmpp3MO.flag) {
if (null == mo_thread[i]) {
mo_thread[i] = new Thread(new Cmpp3MO(cp, rq, sq), "mo_thread_" + cp.Name);
mo_thread[i].start();
}
} else {
common.sleep(1000);
mo_thread[i] = null;
}
common.sleep(1000);
}
}
Cmpp3Login.stopThread();
common.Assert("debug:cmpp3login线程发送终止信号");
common.sleep(1000);
Cmpp3Transceiver.stopThread();
common.Assert("debug:cmpp3Transceiver线程发送终止信号");
common.sleep(1000);
Cmpp3MO.stopThread();
common.Assert("debug:cmpp3mo线程发送终止信号");
common.sleep(1000);
common.Assert("debug:系统停止");
}
class Router {
public String prop_file = null;
public int trans_mode = 0;
public Router(String file_name, int mode) {
this.prop_file = file_name;
this.trans_mode = mode;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -