servermainclass.java

来自「一个用java实现 的飞机订票系统,超级好用....」· Java 代码 · 共 67 行

JAVA
67
字号
package com.zhu.server;

import java.net.*;
import java.io.*;
import java.util.*;

import com.zhu.dao.*;
import com.zhu.dao.impl.*;





/*
 *  @author zhutingfa
 */
public class ServerMainClass {
	
	public static Set allOnlineAgents;//所有在线代理商
	public static AgentDAO agentDao;
	public static FlightDAO flightDao;
	public static FlightDAO flightDaoSch;
	public static PlaneModelDAO planeModelDao;
	public static OrderDAO	orderDao;
   public static Set currentAgents;
	public static Properties pro;//初始化配置参数

	/**
	 * 静态初始化方法。
	 *
	 */
	public static void init(){
		currentAgents=new HashSet();
		pro=new Properties();
		try {
			pro.load(new FileInputStream("server_config.txt"));
		}catch (IOException e) {
			System.out.println("找不到配置文件或配置文件格式不正确!");
			e.printStackTrace();
		}
			agentDao=new AgentDAOImpl();
			flightDao=new FlightDAOImpl();
			flightDaoSch=new FlightDAOImpl();
			planeModelDao=new PlaneModelDAOImpl();
			orderDao=new OrderDAOImpl();
		   allOnlineAgents=new HashSet();
	}
	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 + =
减小字号Ctrl + -
显示快捷键?