Main.java
3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport;
import com.airport.core.AgentSender;
import com.airport.core.IMFReader;
import com.airport.core.IMFSender;
import com.airport.util.ConfigUtils;
import com.airport.util.SystemBean;
import com.caac.imf.api.IMFClient;
import com.caac.imf.api.IMFClientFactory;
import java.util.Timer;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import sun.management.Agent;
public class Main {
private static final Logger logger = Logger.getLogger(Main.class);
public static boolean LOGIN_OK = false;
public static boolean isSuc = true;
public static IMFClient client = null;
public Main() {
}
private static void start() throws Exception {
PropertyConfigurator.configure("config/log4j.properties");
SystemBean.createInstance("config/ApplicationContext.xml");
ConfigUtils conf = new ConfigUtils();
conf.Initialize();
client = IMFClientFactory.createInstance();
if ("R".equalsIgnoreCase(ConfigUtils.ROLE)) {
if (client != null) {
IMFReader reader = new IMFReader(client);
reader.start();
}
loginIMF(client, ConfigUtils.IMF_USERNAME, ConfigUtils.IMF_PASSWORD, "config/imf_config.properties");
} else if ("S".equalsIgnoreCase(ConfigUtils.ROLE)) {
loginIMF(client, ConfigUtils.IMF_USERNAME, ConfigUtils.IMF_PASSWORD, "config/imf_config.properties");
if (LOGIN_OK && client != null) {
logger.info("start run Timer,client hasocde=" + client.hashCode());
//代理人发送程序
// AgentSender send = new AgentSender(client);
// send.start();
//数据仓库给九州的发送程序
Timer timer = new Timer();
IMFSender CangKu2Jiuzhou = new IMFSender(client,"data/fid_index.txt");
timer.schedule(CangKu2Jiuzhou, 30000L, 1200000L);
}
}
}
private static void loginIMF(IMFClient client, String userName, String password, String confFileName) {
if (client.initial(confFileName)) {
String message = client.login(userName, password);
logger.info("message=" + message);
if (message.indexOf("<CODE>1</CODE>") > 0) {
logger.info("登陆成功");
LOGIN_OK = true;
} else {
int times = 0;
while(times <= 3) {
logger.info("try connection...");
++times;
logger.info("message.=" + message);
if (message.indexOf("<CODE>1</CODE>") > 0) {
logger.info("登陆成功");
LOGIN_OK = true;
break;
}
logger.info("登录失败~~~~");
message = client.login(userName, password);
try {
Thread.sleep(4000L);
} catch (InterruptedException var7) {
var7.printStackTrace();
}
}
if (!LOGIN_OK) {
logger.info("多次尝试登录失败,退出登陆");
client.disconnect();
isSuc =false;
System.exit(-1);
}
}
}
}
public static void main(String[] args) throws Exception {
start();
}
}