作者 朱兆平

最初状态

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport;
import com.airport.core.IMFReader;
import com.airport.core.SendMessageTask;
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;
public class Main {
private static final Logger logger = Logger.getLogger(Main.class);
public static boolean LOGIN_OK = false;
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());
Timer timer = new Timer();
SendMessageTask sender = new SendMessageTask(client, "data/fid_index.txt");
timer.schedule(sender, 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();
System.exit(-1);
}
}
}
}
public static void main(String[] args) throws Exception {
start();
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.bean;
public class MessageBak {
private int fid;
private String content;
public MessageBak(int fid, String content) {
this.fid = fid;
this.content = content;
}
public String toString() {
return this.fid + " " + this.content;
}
public int getFid() {
return this.fid;
}
public void setFid(int fid) {
this.fid = fid;
}
public String getContent() {
return this.content;
}
public void setContent(String content) {
this.content = content;
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.bean;
public class XMLHeader {
private String sndr;
private String rcvr;
private String type;
private String stype;
public XMLHeader() {
}
public String toString() {
return "sndr=[" + this.sndr + "]\t rcvr=[" + this.rcvr + "]\t type=[" + this.type + "]\t stype=[" + this.stype + "]";
}
public String getSndr() {
return this.sndr;
}
public void setSndr(String sndr) {
this.sndr = sndr;
}
public String getRcvr() {
return this.rcvr;
}
public void setRcvr(String rcvr) {
this.rcvr = rcvr;
}
public String getType() {
return this.type;
}
public void setType(String type) {
this.type = type;
}
public String getStype() {
return this.stype;
}
public void setStype(String stype) {
this.stype = stype;
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.core;
import com.airport.Main;
import com.airport.dao.impl.DaoImpl;
import com.airport.util.SystemBean;
import com.airport.util.Utils;
import com.airport.util.parse.XMPParse;
import com.caac.imf.api.IMFClient;
import java.util.Date;
import org.apache.log4j.Logger;
public class IMFReader extends Thread {
private static final Logger logger = Logger.getLogger(IMFReader.class);
private static final String stype = "/MSG/META/STYP";
private IMFClient client;
public IMFReader(IMFClient client) {
this.client = client;
}
public void run() {
while(true) {
if (Main.LOGIN_OK) {
synchronized(this) {
String message = this.client.getMSG();
if (message != null) {
this.save(message);
}
}
} else {
logger.info("***");
}
try {
Thread.sleep(100L);
} catch (InterruptedException var3) {
var3.printStackTrace();
}
}
}
private void save(String message) {
Date dt = new Date();
DaoImpl dao = (DaoImpl)SystemBean.getBean("dao");
String path = "data/" + Utils.dateToStr(dt, "yyyy-MM-dd") + "/";
if (Utils.createDir(path)) {
String fileName = "";
try {
String stype_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/STYP");
fileName = path + stype_value + "_" + Utils.dateToStr(dt, "yyyyMMddhhmmssSSS") + ".xml";
Utils.saveFile(fileName, message);
dao.saveRecord("ALL", "FIMS", message);
logger.info("created " + fileName + " ok");
} catch (Exception var7) {
fileName = path + Utils.dateToStr(dt, "yyyyMMddhhmmssSSS") + ".txt";
Utils.saveFile(fileName, message);
logger.warn("created " + fileName + " ok");
}
} else {
logger.info("创建目录失败.");
logger.info(message);
}
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.core;
import com.airport.bean.MessageBak;
import com.airport.bean.XMLHeader;
import com.airport.dao.Dao;
import com.airport.dao.impl.DaoImpl;
import com.airport.util.ConfigUtils;
import com.airport.util.SystemBean;
import com.airport.util.Utils;
import com.caac.imf.api.IMFClient;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TimerTask;
import org.apache.log4j.Logger;
public class SendMessageTask extends TimerTask {
private static final Logger logger = Logger.getLogger(SendMessageTask.class);
private Dao dao = (DaoImpl)SystemBean.getBean("dao");
private IMFClient client;
private String indexFileName;
public SendMessageTask(IMFClient client, String fileName) {
this.indexFileName = fileName;
this.client = client;
}
public void run() {
try {
if (this.client == null) {
logger.info("IMFClient has been closed");
return;
}
logger.info("job start:");
int lastFID = Utils.readFIDIndex(this.indexFileName);
int maxFID = this.dao.getMaxFID();
logger.info("lastFID=" + lastFID + " maxFID=" + maxFID);
int is_ok = 0;
if (maxFID > lastFID) {
List<MessageBak> list = this.dao.getRecordByFID(lastFID);
Map<Integer, XMLHeader> map = ConfigUtils.XML_HEADER_MAP;
Iterator var7 = list.iterator();
while(true) {
while(var7.hasNext()) {
MessageBak m = (MessageBak)var7.next();
if (is_ok != 0) {
logger.error("记录FID时发生异常,发送消息任务被迫中断");
return;
}
if (m.getContent() != null) {
int times = 0;
for(Iterator var10 = map.keySet().iterator(); var10.hasNext(); Thread.sleep((long)ConfigUtils.SEND_MESSAGE_INTERVAL)) {
Integer key = (Integer)var10.next();
XMLHeader header = (XMLHeader)map.get(key);
logger.info("key=" + key + " value=" + ((XMLHeader)map.get(key)).toString());
logger.info("准备发送数据 FID:" + m.getFid() + " XML.length=:" + m.getContent().length());
String sendMsg = Utils.searchReplace(m.getContent(), header.getSndr(), "SNDR");
sendMsg = Utils.searchReplace(sendMsg, header.getType(), "TYPE");
sendMsg = Utils.searchReplace(sendMsg, header.getStype(), "STYP");
sendMsg = Utils.searchReplaceSingle(sendMsg, header.getRcvr(), "RCVR");
if (!"".equals(sendMsg)) {
logger.info("开始发送数据 XML:" + sendMsg);
String is_send_ok = this.client.sendMSG(sendMsg);
logger.info("is_send_ok=" + is_send_ok);
is_ok = Utils.writeFIDIndex(this.indexFileName, m.getFid());
logger.debug("FID:" + m.getFid() + " 缓存成功");
++times;
} else {
logger.error("查找替换节点数据出现异常,可能找不到这个节点,原始XML=" + m.getContent());
}
}
this.dao.update(m.getFid(), times);
} else {
logger.info("FID=" + m.getFid() + "XML is null ");
}
}
return;
}
} else {
logger.info("lastFID=" + lastFID + ">= maxFID=" + maxFID + " 忽略发送数据");
}
} catch (Exception var14) {
var14.printStackTrace();
logger.info(var14.getMessage());
}
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.dao;
import com.airport.bean.MessageBak;
import java.util.List;
public interface Dao {
int insertRecord(String var1, String var2);
void saveRecord(String var1, String var2, String var3) throws Exception;
void delete(int var1);
List<MessageBak> getRecordByFID(int var1);
int getRecordCount();
int getMaxFID();
void update(int var1, int var2);
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.dao.impl;
import com.airport.bean.MessageBak;
import com.airport.dao.Dao;
import com.airport.util.ConfigUtils;
import java.io.IOException;
import java.io.Writer;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import oracle.sql.CLOB;
import org.apache.log4j.Logger;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementCreator;
import org.springframework.jdbc.core.support.AbstractLobStreamingResultSetExtractor;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.jdbc.support.lob.DefaultLobHandler;
import org.springframework.jdbc.support.lob.LobHandler;
public class DaoImpl implements Dao {
private static final Logger logger = Logger.getLogger(DaoImpl.class);
private JdbcTemplate jdbcTemplate;
public DaoImpl() {
}
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
public int insertRecord(final String oper, final String sndr) {
KeyHolder keyHolder = new GeneratedKeyHolder();
this.jdbcTemplate.update(new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
DaoImpl.logger.info("oper=" + oper + " sndr=" + sndr);
String sql = "insert into T_ETL_MESSAGE(OPER,SNDR,SNTM,content) values(?,?,sysdate,empty_clob())";
PreparedStatement ps = connection.prepareStatement(sql, new String[]{"FID"});
ps.setString(1, oper);
ps.setString(2, sndr);
return ps;
}
}, keyHolder);
int generatedId = keyHolder.getKey().intValue();
return generatedId;
}
public void saveRecord(String messaegType, String sndr, String xmlContent) throws Exception {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
int fid = -100;
try {
fid = this.insertRecord(messaegType, sndr);
conn = this.jdbcTemplate.getDataSource().getConnection();
conn.setAutoCommit(false);
stmt = conn.createStatement();
String SQL = "select CONTENT from T_ETL_MESSAGE where FID=" + fid + " and SNDR='FIMS' for update";
rs = stmt.executeQuery(SQL);
while(rs.next()) {
CLOB clob = (CLOB)rs.getClob(1);
Writer os = clob.getCharacterOutputStream();
os.write(xmlContent);
os.flush();
os.close();
}
conn.commit();
} catch (SQLException var14) {
if (fid > 0) {
this.delete(fid);
}
var14.printStackTrace();
conn.rollback();
} finally {
if (conn != null) {
conn.setAutoCommit(true);
}
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
}
}
public void delete(int fid) {
this.jdbcTemplate.update("delete from T_ETL_MESSAGE where fid=" + fid);
}
public int getMaxFID() {
return this.jdbcTemplate.queryForInt("select max(FID) from T_ETL_MESSAGE where SNDR='FIMS'");
}
public List<MessageBak> getRecordByFID(int fid) {
String SQL_FMT = "select FID,CONTENT from T_ETL_MESSAGE where (FID>%s and FID<%s+%s) and SNDR='FIMS' order by FID";
String sql = String.format(SQL_FMT, fid, fid, ConfigUtils.RECORD_COUNT);
logger.info(sql);
final LobHandler lobHandler = new DefaultLobHandler();
final ArrayList xmlList = new ArrayList();
try {
this.jdbcTemplate.query(sql, new AbstractLobStreamingResultSetExtractor() {
protected void streamData(ResultSet rs) throws SQLException, IOException, DataAccessException {
String content = "";
while(rs.next()) {
int fid = rs.getInt(1);
content = lobHandler.getClobAsString(rs, "CONTENT");
if (content != null) {
MessageBak obj = new MessageBak(fid, content);
xmlList.add(obj);
} else {
DaoImpl.logger.error("FID=" + fid + " content is NULL");
}
}
}
});
} catch (EmptyResultDataAccessException var7) {
var7.printStackTrace();
}
return xmlList;
}
public int getRecordCount() {
return this.jdbcTemplate.queryForInt("select count(*) from T_ETL_MESSAGE where SNDR='FIMS' ");
}
public void update(int fid, int times) {
String sql = String.format("update T_ETL_MESSAGE set OUTFLAG=%s ,OUTTM=sysdate where FID=%s", times, fid);
logger.info("sql=" + sql);
this.jdbcTemplate.update(sql);
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util;
import com.airport.bean.XMLHeader;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
public class ConfigUtils {
private static final Logger logger = Logger.getLogger(ConfigUtils.class);
public static String ROLE;
public static String IMF_USERNAME;
public static String IMF_PASSWORD;
public static final String IFM_CONSUMER = "config/imf_config.properties";
public static final String IMF_PRUDUCER = "config/imf_config.properties";
public static final String INDEX_FILE_NAME = "data/fid_index.txt";
public static int SEND_MESSAGE_INTERVAL = 1;
public static int RECORD_COUNT = 1000;
public static String XML_HEADER_SNDR = "";
public static String XML_HEADER_TYPE = "";
public static String XML_HEADER_STYPE = "";
public static String XML_HEADER_RCVR = "";
public static Map<Integer, XMLHeader> XML_HEADER_MAP = new HashMap();
public ConfigUtils() {
}
public void Initialize() throws LteException {
logger.debug("Loading all the config parameters...");
this.loadParameter();
}
private final void loadParameter() throws LteException {
boolean ok = false;
logger.info("================Initialize system parameter =================");
Configuration config = (Configuration)SystemBean.getBean("configurationBean");
ROLE = config.getProperty("role").trim();
IMF_USERNAME = config.getProperty("imf_username").trim();
IMF_PASSWORD = config.getProperty("imf_password").trim();
String interval = config.getProperty("interval").trim();
String record_count = config.getProperty("record_count").trim();
logger.info(String.format("role=%s", ROLE));
logger.info(String.format("imf_username=%s", IMF_USERNAME));
logger.info(String.format("imf_password=%s", IMF_PASSWORD));
logger.info(String.format("interval=%s", interval));
if (StringUtils.isBlank(ROLE)) {
logger.error("role 参数错误");
ok = true;
} else if ("R".equalsIgnoreCase(ROLE)) {
if (!isFileExists("config/imf_config.properties")) {
logger.error("如果要从IMF接收数据,需要在config/imf_config.properties 配置IMF参数");
ok = true;
}
} else if ("S".equalsIgnoreCase(ROLE)) {
if (!isFileExists("config/imf_config.properties")) {
logger.error("如果向IMF发送数据,需要在config/imf_config.properties 配置IMF参数");
ok = true;
}
} else {
logger.error("role 参数错误,必须是S(从IMF接收消息) 或者 R(发送消息到IMF)");
}
int int_total_group;
if ("S".equalsIgnoreCase(ROLE)) {
String total_group = config.getProperty("total_group").trim();
int_total_group = 0;
logger.info(String.format("record_count=%s", record_count));
logger.info(String.format("total_group=%s", total_group));
if (StringUtils.isBlank(total_group)) {
logger.error("total_group 参数错误");
ok = true;
} else {
int_total_group = Integer.parseInt(total_group);
if (int_total_group <= 10 && int_total_group >= 1) {
this.loadXMLHeaderParameter(config, int_total_group);
} else {
logger.error("total_group 参数设置错误,范围在1--10之间");
ok = true;
}
}
int x;
if (StringUtils.isBlank(record_count)) {
logger.error("record_count 参数错误");
ok = true;
} else {
x = Integer.parseInt(record_count);
if (x <= 10000 && x >= 100) {
RECORD_COUNT = x;
} else {
logger.error("record_count 参数设置错误,范围在100--10000之间");
ok = true;
}
}
if (StringUtils.isBlank(interval)) {
logger.error("interval 参数错误");
ok = true;
} else {
x = Integer.parseInt(interval);
if (x <= 60 && x >= 1) {
SEND_MESSAGE_INTERVAL = x * 1000;
} else {
logger.error("interval 参数设置错误,范围在1---60之间");
ok = true;
}
}
}
if (!isFileExists("data/")) {
File f = new File("data");
f.mkdir();
Utils.writeFIDIndex("data/fid_index.txt", 0);
int_total_group = Utils.readFIDIndex("data/fid_index.txt");
logger.info("FID=" + int_total_group);
} else {
logger.info("data/fid_index.txt exists");
}
boolean hasError = false;
hasError = this.validate(IMF_USERNAME, "imf_username 参数错误");
hasError = this.validate(IMF_PASSWORD, "imf_password 参数错误");
if (ok && !hasError) {
logger.error("参数错误 启动程序失败。");
System.exit(-1);
}
}
private void loadXMLHeaderParameter(Configuration config, int total) throws LteException {
String sndr = "";
String rcvr = "";
String type = "";
String stype = "";
for(int i = 1; i <= total; ++i) {
logger.info(String.format("group %d--------------------------", i));
sndr = config.getProperty("sndr_" + i).trim();
rcvr = config.getProperty("rcvr_" + i).trim();
type = config.getProperty("type_" + i).trim();
stype = config.getProperty("stype_" + i).trim();
logger.info(String.format("SNDR_%d=%s", i, sndr));
logger.info(String.format("RCVR_%d=%s", i, rcvr));
logger.info(String.format("TYPE_%d=%s", i, type));
logger.info(String.format("STYPE_%d=%s", i, stype));
XMLHeader header = new XMLHeader();
header.setSndr(sndr);
header.setRcvr(rcvr);
header.setType(type);
header.setStype(stype);
logger.info("group[" + i + "]\t" + header.toString());
XML_HEADER_MAP.put(i, header);
}
}
private boolean validate(String paraValue, String tipText) {
if (StringUtils.isBlank(paraValue)) {
logger.error(tipText);
return false;
} else {
return true;
}
}
private static boolean isFileExists(String filename) {
File f = new File(filename);
return f.exists();
}
public static void main(String[] argc) {
File f = new File("config/producer_imf_config.properties");
if (f.exists()) {
System.out.println("file exists");
} else {
System.out.println("file not exists");
}
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.core.io.Resource;
import org.springframework.util.DefaultPropertiesPersister;
import org.springframework.util.PropertiesPersister;
public class Configuration extends PropertyPlaceholderConfigurer {
private static final Logger logger = Logger.getLogger(Configuration.class);
private static final Map<String, String> parameterMap = new HashMap();
private Resource location;
public void setLocation(Resource location) {
this.location = location;
}
public void loadProperties(Properties props) throws IOException {
PropertiesPersister propertiesPersister = new DefaultPropertiesPersister();
InputStream is = null;
try {
Resource location = this.location;
is = location.getInputStream();
propertiesPersister.load(props, is);
Iterator var6 = props.keySet().iterator();
while(var6.hasNext()) {
Object key = var6.next();
String code = props.getProperty((String)key).trim();
parameterMap.put((String)key, code);
}
} catch (Exception var11) {
logger.error("initialization error", var11);
var11.printStackTrace();
} finally {
if (is != null) {
is.close();
}
}
}
public Configuration() {
logger.setLevel(Level.INFO);
}
public String getProperty(String name) throws LteException {
String str = (String)parameterMap.get(name);
if (str == null) {
String errMsg = String.format("config.properties key Error, can not find key [%s]", name);
logger.error(errMsg);
throw new LteException(errMsg);
} else {
return str.trim();
}
}
public String getPropertyMaybeNull(String name) throws LteException {
String str = (String)parameterMap.get(name);
if (StringUtils.isBlank(str)) {
str = "";
}
return str.trim();
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util;
import java.io.PrintWriter;
import java.io.StringWriter;
public class ExceptionUtils {
public ExceptionUtils() {
}
public static String outputExceptionDetailsInfo(String label, String msg, Throwable t) {
StringBuffer sb = new StringBuffer();
StackTraceElement[] messages = t.getStackTrace();
int length = messages.length;
sb.append("\n");
sb.append("\n");
sb.append("\t");
sb.append("[");
sb.append(label + " component exception super class name");
sb.append(":");
sb.append(msg);
sb.append("]");
sb.append("\n");
sb.append("\t********Exception Detail List Begin********");
sb.append("\n\t" + t + "\n");
for(int i = 0; i < length; ++i) {
sb.append("\t" + messages[i].toString() + "\n");
}
sb.append("\t********Exception Detail List End********");
return sb.toString();
}
public static String getStackTrace(Throwable t) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
String var4;
try {
t.printStackTrace(pw);
var4 = sw.toString();
} finally {
pw.close();
}
return var4;
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util;
import org.apache.log4j.Logger;
public class LteException extends Exception {
private static final Logger logger = Logger.getLogger(LteException.class);
private static final long serialVersionUID = -3047721096749400047L;
private int errorCode = -1;
public LteException() {
}
public LteException(String s) {
super(s);
}
public LteException(int errorCode, String errmsg) {
super(errmsg);
this.errorCode = errorCode;
if (errorCode > 0) {
logger.debug("ErrorCode: " + errorCode + " " + errmsg);
}
}
public int getErrorCode() {
return this.errorCode;
}
public LteException(String s, Throwable cause) {
super(s, cause);
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util;
import org.apache.log4j.Logger;
import org.springframework.beans.BeansException;
import org.springframework.context.support.FileSystemXmlApplicationContext;
public class SystemBean {
private static Logger logger = Logger.getLogger(SystemBean.class);
private static SystemBean inistance;
private static FileSystemXmlApplicationContext fileSystemXmlApplicationContext;
private static Object lock = new Object();
public SystemBean() {
}
public static final synchronized void createInstance(String path) throws LteException {
if (inistance == null) {
Object var1 = lock;
synchronized(lock) {
if (inistance == null) {
inistance = new SystemBean();
String err;
try {
logger.info("Initialization ApplicationContext ");
fileSystemXmlApplicationContext = new FileSystemXmlApplicationContext(path);
fileSystemXmlApplicationContext.registerShutdownHook();
} catch (BeansException var4) {
err = ExceptionUtils.getStackTrace(var4);
throw new LteException("Initialization ApplicationContext error:" + err);
} catch (Exception var5) {
err = ExceptionUtils.getStackTrace(var5);
throw new LteException("Initialization ApplicationContext error:" + err);
}
}
}
}
}
public static final Object getBean(String beanName) {
return fileSystemXmlApplicationContext.getBean(beanName);
}
public static final void destroy() {
fileSystemXmlApplicationContext.getBeanFactory().destroySingletons();
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
public class Utils {
private static Logger logger = Logger.getLogger(SystemBean.class);
public Utils() {
}
public static final Date iso8601DateStrToDate(String dateStr) {
Date dt = null;
String str_ = dateStr.replace("T", " ");
str_ = str_.substring(0, 19);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
dt = format.parse(str_);
} catch (ParseException var5) {
var5.printStackTrace();
}
return dt;
}
public static String dateToStr(Date date) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String str = format.format(date);
return str;
}
public static String dateToStr(Date date, String dateFmt) {
SimpleDateFormat format = new SimpleDateFormat(dateFmt);
String str = format.format(date);
return str;
}
public static boolean createDir(String destDirName) {
File dir = new File(destDirName);
if (dir.exists()) {
return true;
} else {
if (!destDirName.endsWith(File.separator)) {
destDirName = destDirName + File.separator;
}
if (dir.mkdirs()) {
return true;
} else {
logger.info("创建目录失败! 目录名称:" + destDirName);
return false;
}
}
}
public static void saveFile(String fileName, String content) {
try {
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), "utf-8")));
out.write(content);
out.flush();
out.close();
} catch (IOException var3) {
var3.printStackTrace();
logger.error(var3.getMessage());
}
}
public static int writeFIDIndex(String fileName, int fid) {
PrintStream ps = null;
byte is_ok = 1;
try {
File file = new File(fileName);
ps = new PrintStream(new FileOutputStream(file));
ps.println(fid);
is_ok = 0;
} catch (IOException var8) {
var8.printStackTrace();
logger.error(var8.getMessage());
} finally {
ps.close();
}
return is_ok;
}
public static int readFIDIndex(String fileName) {
FileReader reader = null;
BufferedReader br = null;
int index = 0;
try {
reader = new FileReader(fileName);
br = new BufferedReader(reader);
String str = br.readLine();
index = Integer.parseInt(str);
} catch (FileNotFoundException var15) {
var15.printStackTrace();
} catch (IOException var16) {
var16.printStackTrace();
} finally {
try {
br.close();
reader.close();
} catch (IOException var14) {
var14.printStackTrace();
}
}
return index;
}
public static String searchReplace(String xml, String replacement, String nodeName) {
String pStr = String.format("(?<=<%s>).*(?=</%s>)", nodeName, nodeName);
Pattern pat = Pattern.compile(pStr);
Matcher matcher = pat.matcher(xml);
if (matcher.find()) {
if (!StringUtils.isBlank(replacement)) {
return xml.replace(matcher.group(), replacement);
}
} else {
logger.error("can not find " + nodeName + " in " + xml);
}
return xml;
}
public static String searchReplaceSingle(String xml, String replacement, String nodeName) {
String pStr = String.format("(<%s/>)", nodeName);
String rep = String.format("<%s>%s</%s>", nodeName, replacement, nodeName);
Pattern pat = Pattern.compile(pStr);
Matcher mat = pat.matcher(xml);
return mat.find() && !StringUtils.isBlank(replacement) ? xml.replace(mat.group(), rep) : xml;
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util.parse;
import org.jdom.Element;
public class SubNode {
private Element element;
public SubNode(Element element) {
this.element = element;
}
public Element getElement() {
return this.element;
}
public void setElement(Element element) {
this.element = element;
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util.parse;
import com.airport.util.Utils;
import java.io.IOException;
import java.io.StringReader;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.xml.sax.InputSource;
public class XMPParse {
public XMPParse() {
}
public static final Date nodeValue2Date(String xmlFile, String xmlNodePath) {
String str = getNodeValue(xmlFile, xmlNodePath);
return !"".equals(str) ? Utils.iso8601DateStrToDate(str) : null;
}
public static final Date nodeValue2Date(String xmlFile, String xmlNodePath, Date date) {
String str = getNodeValue(xmlFile, xmlNodePath);
return !"".equals(str) ? Utils.iso8601DateStrToDate(str) : date;
}
public static final Date nodeAttribute2Date(String xmlFile, String xmlNodePath, String attributeName, Date date) {
String str = getNodeAttribute(xmlFile, xmlNodePath, attributeName, "");
return !"".equals(str) ? Utils.iso8601DateStrToDate(str) : date;
}
public static final String getNodeValue(String xmlFile, String xmlNodePath) {
String[] nodes = xmlNodePath.split("/");
new Document();
SAXBuilder builder = new SAXBuilder();
Element root = null;
LinkedList<SubNode> listNode = new LinkedList();
String value = "";
Document document;
try {
document = builder.build(xmlFile);
for(int i = 1; i < nodes.length; ++i) {
SubNode snode;
if (i > 1) {
snode = (SubNode)listNode.getLast();
List<Element> eList = snode.getElement().getChildren(nodes[i]);
if (eList != null && eList.size() > 0) {
SubNode s1 = new SubNode((Element)eList.get(0));
listNode.add(s1);
}
} else if (1 == i) {
root = document.getRootElement();
snode = new SubNode(root);
listNode.add(snode);
}
}
SubNode n = (SubNode)listNode.getLast();
value = n.getElement().getText();
n = null;
} catch (Exception var15) {
var15.printStackTrace();
} finally {
listNode.clear();
document = null;
root = null;
builder = null;
nodes = null;
}
System.out.println("key=" + xmlNodePath + " value=" + value);
return value;
}
public static final String getNodeValueFromXmlString(String xmlString, String xmlNodePath) throws Exception {
String[] nodes = xmlNodePath.split("/");
new Document();
SAXBuilder builder = new SAXBuilder();
Element root = null;
LinkedList<SubNode> listNode = new LinkedList();
String value = "";
Document document;
try {
StringReader xmlReader = new StringReader(xmlString);
InputSource xmlSource = new InputSource(xmlReader);
document = builder.build(xmlSource);
for(int i = 1; i < nodes.length; ++i) {
SubNode snode;
if (i > 1) {
snode = (SubNode)listNode.getLast();
List<Element> eList = snode.getElement().getChildren(nodes[i]);
if (eList != null && eList.size() > 0) {
SubNode s1 = new SubNode((Element)eList.get(0));
listNode.add(s1);
}
} else if (1 == i) {
root = document.getRootElement();
snode = new SubNode(root);
listNode.add(snode);
}
}
SubNode n = (SubNode)listNode.getLast();
value = n.getElement().getText();
n = null;
return value;
} catch (Exception var17) {
var17.printStackTrace();
throw var17;
} finally {
listNode.clear();
document = null;
root = null;
builder = null;
nodes = null;
}
}
public static final String getNodeAttribute(String xmlFile, String xmlNodePath, String attributeName, String defaultValue) {
String[] nodes = xmlNodePath.split("/");
new Document();
SAXBuilder builder = new SAXBuilder();
Element root = null;
LinkedList<SubNode> listNode = new LinkedList();
String value = "";
Document document;
try {
document = builder.build(xmlFile);
for(int i = 1; i < nodes.length; ++i) {
SubNode snode;
if (i > 1) {
snode = (SubNode)listNode.getLast();
List<Element> eList = snode.getElement().getChildren(nodes[i]);
if (eList != null && eList.size() > 0) {
SubNode s1 = new SubNode((Element)eList.get(0));
listNode.add(s1);
}
} else if (1 == i) {
root = document.getRootElement();
snode = new SubNode(root);
listNode.add(snode);
}
}
SubNode n = (SubNode)listNode.getLast();
value = n.getElement().getAttributeValue(attributeName, defaultValue);
n = null;
} catch (JDOMException var18) {
var18.printStackTrace();
} catch (IOException var19) {
var19.printStackTrace();
} finally {
listNode.clear();
document = null;
root = null;
builder = null;
nodes = null;
}
System.out.println("key=" + xmlNodePath + " node attrivte value=" + value);
return value;
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util.parse;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
public class XmlDocument {
private Document document = null;
private SAXBuilder builder = null;
private Element root = null;
private String xmlFile;
public XmlDocument(String xmlFileName) {
this.xmlFile = xmlFileName;
try {
this.builder = new SAXBuilder();
this.document = new Document();
this.document = this.builder.build(this.xmlFile);
} catch (JDOMException var3) {
var3.printStackTrace();
} catch (IOException var4) {
var4.printStackTrace();
}
}
public void destory() {
this.document = null;
this.root = null;
this.builder = null;
}
public String getStringFromInnerText(String xmlNodePath) {
String[] nodes = xmlNodePath.split("/");
LinkedList<SubNode> listNode = new LinkedList();
String value = "";
try {
for(int i = 1; i < nodes.length; ++i) {
SubNode snode;
if (i > 1) {
snode = (SubNode)listNode.getLast();
List<Element> eList = snode.getElement().getChildren(nodes[i]);
if (eList != null && eList.size() > 0) {
SubNode s1 = new SubNode((Element)eList.get(0));
listNode.add(s1);
}
} else if (1 == i) {
this.root = this.document.getRootElement();
snode = new SubNode(this.root);
listNode.add(snode);
}
}
SubNode n = (SubNode)listNode.getLast();
value = n.getElement().getText();
n = null;
} catch (Exception var12) {
var12.printStackTrace();
} finally {
listNode.clear();
}
return value;
}
public String getStringFromXmlNodeAttribute(String xmlNodePath, String attributeName, String defaultValue) {
String[] nodes = xmlNodePath.split("/");
LinkedList<SubNode> listNode = new LinkedList();
String value = "";
try {
for(int i = 1; i < nodes.length; ++i) {
SubNode snode;
if (i > 1) {
snode = (SubNode)listNode.getLast();
List<Element> eList = snode.getElement().getChildren(nodes[i]);
if (eList != null && eList.size() > 0) {
SubNode s1 = new SubNode((Element)eList.get(0));
listNode.add(s1);
}
} else if (1 == i) {
this.root = this.document.getRootElement();
snode = new SubNode(this.root);
listNode.add(snode);
}
}
SubNode n = (SubNode)listNode.getLast();
value = n.getElement().getAttributeValue(attributeName, defaultValue);
n = null;
} catch (Exception var14) {
var14.printStackTrace();
} finally {
listNode.clear();
}
return value;
}
}
... ...
Manifest-Version: 1.0
Class-Path: org.springframework.jdbc-3.0.0.CI-331.jar spring-jms-3.0.5
.RELEASE.jar spring-expression-3.0.5.RELEASE.jar spring-aop-3.0.5.REL
EASE.jar imfmsg.jar HeartbeatService.jar c3p0-0.9.5.2.jar spring-bean
s-3.0.5.RELEASE.jar mchange-commons-java-0.2.11.jar UploadService.jar
spring-core-3.0.5.RELEASE.jar spring-asm-3.0.5.RELEASE.jar apiConfig
.jar CL3Export.jar CL3Nonexport.jar com.ibm.mq.axis2.jar com.ibm.mq.c
ommonservices.jar com.ibm.mq.defaultconfig.jar com.ibm.mq.headers.jar
com.ibm.mq.jar com.ibm.mq.jmqi.jar com.ibm.mq.jms.Nojndi.jar com.ibm
.mq.pcf.jar com.ibm.mq.postcard.jar com.ibm.mq.soap.jar com.ibm.mq.to
ols.ras.jar com.ibm.mqetclient.jar com.ibm.mqjms.jar connector.jar dh
bcore.jar fscontext.jar jms.jar jndi.jar jta.jar ldap.jar provideruti
l.jar rmm.jar antlr-2.7.7.jar antlr-3.2.jar antlr-runtime-3.2.jar aop
alliance-1.0.jar asm-3.3.jar bcprov-jdk15-1.45.jar commons-collection
s-3.2.1.jar commons-lang-2.5.jar commons-logging-1.1.1.jar commons-po
ol-1.5.5.jar cxf-2.3.2.jar cxf-xjc-boolean-2.3.2.jar cxf-xjc-bug671-2
.3.2.jar cxf-xjc-dv-2.3.2.jar cxf-xjc-ts-2.3.2.jar FastInfoset-1.2.8.
jar geronimo-activation_1.1_spec-1.1.jar geronimo-annotation_1.0_spec
-1.1.1.jar geronimo-javamail_1.4_spec-1.7.1.jar geronimo-jaxws_2.2_sp
ec-1.0.jar geronimo-jms_1.1_spec-1.1.1.jar geronimo-servlet_3.0_spec-
1.0.jar geronimo-stax-api_1.0_spec-1.0.1.jar geronimo-ws-metadata_2.0
_spec-1.1.3.jar jaxb-api-2.2.1.jar jaxb-impl-2.2.1.1.jar jettison-1.2
.jar jetty-continuation-7.2.2.v20101205.jar jetty-http-7.2.2.v2010120
5.jar jetty-io-7.2.2.v20101205.jar jetty-server-7.2.2.v20101205.jar j
etty-util-7.2.2.v20101205.jar jra-1.0-alpha-4.jar js-1.7R2.jar jsr173
_1.0_api.jar jsr311-api-1.1.1.jar neethi-2.0.4.jar oro-2.0.8.jar reso
lver.jar saaj-api-1.3.jar saaj-impl-1.3.2.jar serializer-2.7.1.jar si
gar.jar slf4j-api-1.6.1.jar slf4j-jdk14-1.6.1.jar stax2-api-3.0.2.jar
stringtemplate-3.2.jar velocity-1.6.4.jar woodstox-core-asl-4.0.8.ja
r wsdl4j-1.6.2.jar wss4j-1.5.11.jar xalan-2.7.1.jar xbean_xpath.jar x
bean.jar xml-resolver-1.2.jar xmlbeans-2.4.0.jar xmlbeans-qname.jar x
mlpublic.jar XmlSchema-1.4.7.jar xmlsec-1.4.4.jar com.ibm.mq.fta.jar
log4j-1.2.16.jar jaxb-xjc-2.2.1.1.jar spring-tx-3.0.5.RELEASE.jar ojd
bc6.jar jdom-1.1.3.jar IMFClient.1.0.0.jar spring-web-3.0.5.RELEASE.j
ar spring-context-3.0.5.RELEASE.jar returnXml.jar ProcessService.jar
Main-Class: com.airport.Main
... ...
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd"
default-lazy-init="false">
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${db_driver}" />
<property name="jdbcUrl" value="${db_url}" />
<property name="user" value="${db_user}" />
<property name="password" value="${db_pass}" />
<property name="minPoolSize" value="1" />
<property name="maxPoolSize" value="1" />
<property name="initialPoolSize" value="1" />
<property name="maxIdleTime" value="1800" />
<property name="acquireIncrement" value="1" />
<property name="idleConnectionTestPeriod" value="10000" />
<property name="acquireRetryAttempts" value="30" />
<property name="testConnectionOnCheckin" value="true" />
<property name="acquireRetryDelay" value="1000"/>
<property name="automaticTestTable" value="c3p0TestTable_jwe"/>
<property name="checkoutTimeout" value="60000"/>
<property name="numHelperThreads" value="5"/>
</bean>
<bean id='configurationBean' class="com.airport.util.Configuration" >
<property name="location" value="file:config/config.properties"/>
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="dao" class="com.airport.dao.impl.DaoImpl">
<property name="jdbcTemplate" ref="jdbcTemplate" />
</bean>
</beans>
\ No newline at end of file
... ...
#########################################################
db_driver=oracle.jdbc.driver.OracleDriver
db_url=jdbc:oracle:thin:@10.50.3.68:1521:CGODW
db_user=cgoetl
db_pass=1q2w3e4r
#########################################################
#R:receiver S:sender,
role=S
imf_username=DLCF
imf_password=DLCF_P
#########################################################
interval=5
record_count=350
total_group=1
#########################################################
sndr_1=DLCF
rcvr_1=
type_1=HYXX
stype_1=DLCF
#########################################################
sndr_2=SJCK
rcvr_2=
type_2=HYXX
stype_2=CKSY
... ...
#log4j=/home/imf/log_api.xml
isneedlog=N
psip=10.50.3.74
psport=7484
encoding=UTF-8
... ...
########Log4j configuration#####################################
log4j.rootLogger=INFO, stdout, fileout
log4j.logger.com.fiscal = INFO
#*******************************
log4j.logger.com.system = INFO
#*******************************
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{MM-dd HH:mm:ss,SSSS}[%p] %m%n
#yyyy-MM-dd HH:mm:ss
log4j.appender.fileout=org.apache.log4j.RollingFileAppender
log4j.appender.fileout.File=logs/imf.log
log4j.appender.fileout.MaxFileSize=50MB
log4j.appender.fileout.MaxBackupIndex=10
log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
log4j.appender.fileout.layout.ConversionPattern=%d{MM-dd HH:mm:ss,SSSS}[%p] %m%n
... ...