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

📄 client.java

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

import java.lang.reflect.Method;
import java.util.*;
import com.briup.*;
import com.briup.exception.*;

public class Client {
	Config config;
	Log log;
	Backup backup;
	Gather gather;
	NetClient netClient;
	
	public Client(){
		init();
		try {
			this.backup=config.getBackup();
			this.gather=config.getGather();
			this.log=config.getLog();
			this.netClient=config.getNetClient();
		} catch (ConfigException e) {
			e.printStackTrace();
		}	
	}
	@SuppressWarnings({ "unused", "unchecked" })
	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) {
		Client client=new Client();	
		Collection<BIDR> collection=null;
		Collection<BIDR> c=null;
		try {
			try {
				collection=client.backup.load();
				if(collection.size()!=0){
					client.log.writeInfo("Backup File Load Success!");
					client.backup.clear();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
			c=client.gather.doGather();
			collection.addAll(c);
			client.log.writeInfo("Gather Information Success!");
		} catch (Exception e) {
			e.printStackTrace();
		}
		try {
			client.netClient.send(collection);
			client.log.writeInfo("File Send Success!");
		} catch (Exception e1) {
			try {
				client.backup.store(collection);
				client.log.writeInfo("Backup File Success!");
			} catch (Exception e) {
				e.printStackTrace();
			}
			e1.printStackTrace();
		}	
	}
}

⌨️ 快捷键说明

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