📄 servermainclass.java
字号:
package com.tarena.abs.server;
import java.net.*;
import java.io.*;
import java.util.*;
import com.tarena.abs.dao.*;
public class ServerMainClass {
public static Set allPlaneModels;//所有飞机型号对象
public static Set allOnlineAgents;//所有在线代理商
public static AgentDAO agentDao;
public static FlightDAO flightDao;
public static FlightDAO flightDaoSch;
public static PlaneModelDAO planeModelDao;
public static Set orders;//所有成交的订单
public static Properties pro;//初始化配置参数
/**
* 静态初始化方法。
*
*/
public static void init(){
pro=new Properties();
try {
pro.load(new FileInputStream("server_config.txt"));
}catch (IOException e) {
System.out.println("找不到配置文件或配置文件格式不正确!");
e.printStackTrace();
}
try {
agentDao=new AgentDAOFromFile(new File(pro.getProperty("AgentFile")));
flightDao=new FlightDAOFromFile(new File(pro.getProperty("FlightFile")));
flightDaoSch=new FlightDAOFromFile(new File(pro.getProperty("FlightFileSch")));
planeModelDao=new PlaneModelDAOFromFile(new File(pro.getProperty("PlaneModelFile")));
} catch (Exception e) {
System.out.println("找不到数据文件,请检查数据文件是否存在!");
e.printStackTrace();
}
orders = new HashSet();
allOnlineAgents=new HashSet();
allPlaneModels=planeModelDao.getAllPlaneModel();
}
public static void main(String[] args) {
init();
ServerMainFrame sFrame=new ServerMainFrame();
sFrame.showMe();
ServerSocket ss=null;
Socket s=null;
try {
ss=new ServerSocket(Integer.parseInt(pro.getProperty("ServerPort")));
while(true){
s=ss.accept();
new ServerThread(s).start();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -