package ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
public class SocketKeep {
private static Log logger = (SocketKeep.class);
public static List<SocketEntity> socketEntityList = new ArrayList<SocketEntity>();
public static Map<String, SocketCui> socketMap = new LinkedHashMap<String, SocketCui>();
public static Map<String, String> socketIsLock = new LinkedHashMap<String, String>();
public static int commonCheckTime = 2;
public static int socketConnCount = 0;
public static ExecutorService executorService = null;
public static void initSocketKeep() {
Properties properties = null;
try {
properties = new Properties();
(SocketKeep.class.getClassLoader().getResourceAsStream(""));
("加载文件成功!");
} catch (Exception e) {
("加载文件失败!", e);
properties = null;
}
if (null != properties) {
try {
commonCheckTime = (("commonCheckTime"));
socketConnCount = (("socketConnCount"));
executorService = (socketConnCount + 1);
} catch (Exception e) {
executorService = (1);
("解析共用信息时错误!", e);
}
SocketEntity socketEntity = null;
for (int i = 1; i <= socketConnCount; i++) {
String name = ("socket" + i);
if(null != name){
socketEntity = new SocketEntity();
String ip = ("socket" + i + "_ip");
String port = ("socket" + i + "_port");
String isKeep = ("socket" + i + "_isKeep");
(name);
(ip);
((port));
boolean keepConn = false;
if(null != isKeep && "1".equals(isKeep)){
keepConn = true;
}
(keepConn);
(socketEntity);
}
}
}
("加载Socket连接配置信息结束!");
("开始初始化Socket连接!");
SocketCui socket = null;
for(SocketEntity socketEntity : socketEntityList){
if(null != socketEntity && ()){
try {
socket = new SocketCui((),());
(0);
(true);
(());
} catch (Exception e) {
("初始化某个连接时错误!错误的连接将放弃!资源名称:" + (), e);
socket = null;
}
if(null != socket){
((), socket);
}else{
((), new SocketCui());
}
((), "0");
}
}
(new CheckThread());
("初始化Socket连接结束!");
}
}