testclient.java

来自「springGather 在JAVA环境开发的电信运营支持系统」· Java 代码 · 共 64 行

JAVA
64
字号
package lianxi;

import org.com.gather.*; 
import java.util.*;
import java.lang.reflect.*;

public class TestClient{
	public static void main(String[] args)throws Exception{
		Properties pro = new Properties();

		String value = System.getProperty("beanFactory.xml");
		// 如果没有从命令行获取参数,则初始值为本机路径;
		if(value == null){
			value = "D:/EXAMPLE/NetCTOSS/springGather/beanFactory.xml";
		}
		pro.setProperty("beanFactory.xml",value);

		String config_Class = System.getProperty("config");

		if(config_Class == null){
			config_Class = "org.com.gather.SpringConfig";
		}

		ClassLoader cl = ClassLoader.getSystemClassLoader();
		Class c = cl.loadClass(config_Class);
		Constructor[] ctr = c.getConstructors();
		Config config = (Config)ctr[0].newInstance(new Object[]{pro});




	//	Config config = new SpringConfig(pro);

		Gather gather = config.getGather();
		long start = System.currentTimeMillis();
		Collection col = gather.getData();
		BackUp back = config.getBackUp();
		Client client = config.getClient();

		if(!col.isEmpty()){
			Collection backCol = back.load();
			
			if(!backCol.isEmpty()){
				//如果成功把备份文件东西调出,则把备份文件清空;
				back.clear();
				backCol.addAll(col);
				client.send(backCol);
			}else{
				client.send(col);
				back.clear();
			}
		}else{
			Collection backCol = back.load();
			System.out.println("采集到的数据为空,检测备份文件;");
			client.send(backCol);
			back.clear();
		}

		long end = System.currentTimeMillis();
		long time = end - start;
		System.out.println("时间是:"+time/1000+"秒");
	}
}

⌨️ 快捷键说明

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