⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 server.java

📁 java的团队合作代码
💻 JAVA
字号:
package com.briup.main;

import java.lang.reflect.Method;
import java.util.Properties;
import com.briup.Config;
import com.briup.NetServer;
import com.briup.exception.ConfigException;
import com.briup.exception.NetServerException;

public class Server {
	Config config;
	NetServer netServer;
	public Server() {
		init();
		try {
			this.netServer=config.getNetServer();
		} catch (ConfigException e) {
			e.printStackTrace();
		}
	}
	private void init() {
		Properties props= new Properties();
		props.setProperty("class_name", "com.briup.impl.config.ConfigImpl");
		props.setProperty("constructor_method", "newInstance");
		props.setProperty("args", "java.util.Properties");
		props.setProperty("config_file_path", "src/com/briup/resource/config.xml");
		String class_name=props.getProperty("class_name");
		String constructor_method=props.getProperty("constructor_method");
		String args=props.getProperty("args");
		try {
			Class c = Class.forName(class_name);
			Method method=c.getMethod(constructor_method, Properties.class);
			config=(Config)method.invoke(null, new Object[]{props});
		} catch (Exception e) {
			e.printStackTrace();
		}	
	}

	public static void main(String[] args) {
		Server server=new Server();	
		try {
			server.netServer.setConfig(server.config);
		} catch (NetServerException e) {
			e.printStackTrace();
		}
		try {
			server.netServer.start();
		} catch (NetServerException e) {
			e.printStackTrace();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -