作者 朱兆平

默认配置更改

1 -#log4j=/home/imf/log_api.xml  
2 -isneedlog=Y 1 +#log4j=log_api.xml
  2 +isneedlog=N
3 #psip=218.28.199.134 3 #psip=218.28.199.134
4 psip=10.50.3.74 4 psip=10.50.3.74
5 psport=7484 5 psport=7484
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
  3 +<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
  4 + <appender name="INFOFILE" class="org.apache.log4j.RollingFileAppender">
  5 + <param name="File" value="Logs/INFO.log" />
  6 + <param name="MaxFileSize" value="3000KB" />
  7 + <param name="MaxBackupIndex" value="20" />
  8 + <param name="Encoding" value="UTF-8" />
  9 + <layout class="org.apache.log4j.PatternLayout">
  10 + <param name="ConversionPattern" value="[runtime] %d -%-4r [%t] %x - %m%n" />
  11 + </layout>
  12 + <filter class="org.apache.log4j.varia.LevelRangeFilter">
  13 + <param name="levelMin" value="debug" />
  14 + <param name="levelMax" value="info" />
  15 + <param name="AcceptOnMatch" value="true" />
  16 + </filter>
  17 + </appender>
  18 + <appender name="ERRFILE" class="org.apache.log4j.RollingFileAppender">
  19 + <param name="File" value="Logs/ERROR.log" />
  20 + <param name="MaxFileSize" value="3000KB" />
  21 + <param name="MaxBackupIndex" value="20" />
  22 + <param name="Encoding" value="UTF-8" />
  23 + <layout class="org.apache.log4j.PatternLayout">
  24 + <param name="ConversionPattern" value="[runtime] %d -%-4r [%t] %x - %m%n" />
  25 + </layout>
  26 + <filter class="org.apache.log4j.varia.LevelRangeFilter">
  27 + <param name="levelMin" value="error" />
  28 + <param name="levelMax" value="error" />
  29 + <param name="AcceptOnMatch" value="true" />
  30 + </filter>
  31 + </appender>
  32 + <appender name="WSINFOFILE" class="org.apache.log4j.RollingFileAppender">
  33 + <param name="File" value="Logs/wsINFO.log" />
  34 + <param name="MaxFileSize" value="3000KB" />
  35 + <param name="MaxBackupIndex" value="20" />
  36 + <param name="Encoding" value="UTF-8" />
  37 + <layout class="org.apache.log4j.PatternLayout">
  38 + <param name="ConversionPattern" value="[runtime] %d -%-4r [%t] %x - %m%n" />
  39 + </layout>
  40 + <filter class="org.apache.log4j.varia.LevelRangeFilter">
  41 + <param name="levelMin" value="debug" />
  42 + <param name="levelMax" value="info" />
  43 + <param name="AcceptOnMatch" value="true" />
  44 + </filter>
  45 + </appender>
  46 + <appender name="WSERRFILE" class="org.apache.log4j.RollingFileAppender">
  47 + <param name="File" value="Logs/wsERROR.log" />
  48 + <param name="MaxFileSize" value="3000KB" />
  49 + <param name="MaxBackupIndex" value="20" />
  50 + <param name="Encoding" value="UTF-8" />
  51 + <layout class="org.apache.log4j.PatternLayout">
  52 + <param name="ConversionPattern" value="[runtime] %d -%-4r [%t] %x - %m%n" />
  53 + </layout>
  54 + <filter class="org.apache.log4j.varia.LevelRangeFilter">
  55 + <param name="levelMin" value="error" />
  56 + <param name="levelMax" value="error" />
  57 + <param name="AcceptOnMatch" value="true" />
  58 + </filter>
  59 + </appender>
  60 + <logger name="apiLog">
  61 + <level value="INFO" />
  62 + <appender-ref ref="INFOFILE" />
  63 + <appender-ref ref="ERRFILE" />
  64 + </logger>
  65 + <logger name="WS">
  66 + <appender-ref ref="WSINFOFILE" />
  67 + <appender-ref ref="WSERRFILE" />
  68 + </logger>
  69 + <root>
  70 + <priority value="ERROR" />
  71 + </root>
  72 +</log4j:configuration>
@@ -17,13 +17,6 @@ public class Main { @@ -17,13 +17,6 @@ public class Main {
17 public static boolean isSuc = true; 17 public static boolean isSuc = true;
18 public static IMFClient client = null; 18 public static IMFClient client = null;
19 19
20 - public static void sendMsg(String msg){  
21 - if (!msg.equals(null) && !msg.isEmpty()){  
22 -  
23 - }  
24 -  
25 - }  
26 -  
27 20
28 private static void start() throws Exception { 21 private static void start() throws Exception {
29 PropertyConfigurator.configure("config/log4j.properties"); 22 PropertyConfigurator.configure("config/log4j.properties");
@@ -34,7 +27,7 @@ public class Main { @@ -34,7 +27,7 @@ public class Main {
34 while (true) { 27 while (true) {
35 if (client != null) { 28 if (client != null) {
36 IMF_Reader reader = new IMF_Reader(client); 29 IMF_Reader reader = new IMF_Reader(client);
37 - if (!reader.isrunning) { 30 + if (!IMF_Reader.isrunning) {
38 reader.start(); 31 reader.start();
39 logger.info("*********KAKO读取线程已开启***********"); 32 logger.info("*********KAKO读取线程已开启***********");
40 } else { 33 } else {
@@ -42,7 +35,7 @@ public class Main { @@ -42,7 +35,7 @@ public class Main {
42 } 35 }
43 36
44 IMF_Sender kako_sender = new IMF_Sender(client); 37 IMF_Sender kako_sender = new IMF_Sender(client);
45 - if(!kako_sender.isrunning) { 38 + if(!IMF_Sender.isrunning) {
46 kako_sender.start(); 39 kako_sender.start();
47 } 40 }
48 } 41 }
@@ -15,6 +15,7 @@ public class IMF_Reader extends Thread{ @@ -15,6 +15,7 @@ public class IMF_Reader extends Thread{
15 this.client = client; 15 this.client = client;
16 } 16 }
17 17
  18 + @Override
18 public void run() { 19 public void run() {
19 try{ 20 try{
20 isrunning =true; 21 isrunning =true;
@@ -25,6 +25,7 @@ public class IMF_Sender extends Thread{ @@ -25,6 +25,7 @@ public class IMF_Sender extends Thread{
25 this.content = content; 25 this.content = content;
26 } 26 }
27 27
  28 + @Override
28 public void run(){ 29 public void run(){
29 try { 30 try {
30 String sendDir = FileTool.readProperties("readDirectory"); 31 String sendDir = FileTool.readProperties("readDirectory");
1 -package com.tianbo.util.XML;  
2 -  
3 -import org.jdom.Element;  
4 -  
5 -public class SubNode {  
6 - private Element element;  
7 -  
8 - public SubNode(Element element) {  
9 - this.element = element;  
10 - }  
11 -  
12 - public Element getElement() {  
13 - return this.element;  
14 - }  
15 -  
16 - public void setElement(Element element) {  
17 - this.element = element;  
18 - }  
19 -}  
1 -package com.tianbo.util.XML;  
2 -  
3 -  
4 -  
5 -import org.jdom.Document;  
6 -import org.jdom.Element;  
7 -import org.jdom.JDOMException;  
8 -import org.jdom.input.SAXBuilder;  
9 -import org.slf4j.Logger;  
10 -import org.slf4j.LoggerFactory;  
11 -import org.xml.sax.InputSource;  
12 -  
13 -import java.io.IOException;  
14 -import java.io.StringReader;  
15 -import java.util.*;  
16 -  
17 -public class XMLParse {  
18 - private static final Logger logger = LoggerFactory.getLogger(XMLParse.class);  
19 - private static String xmlString;  
20 - private static Document document;  
21 - private static SAXBuilder builder;  
22 - private static Element root;  
23 - private static LinkedList<SubNode> listNode;  
24 - private static StringReader xmlReader;  
25 - private static InputSource xmlSource;  
26 - private static List<Map> maps = new ArrayList<Map>();  
27 - private static Map<String,Map> allElementValue = new HashMap<String, Map>();  
28 - private static int domCount=0;  
29 - private String value;  
30 -  
31 - public XMLParse() {  
32 - }  
33 - public XMLParse(String XmlString) {  
34 - builder = new SAXBuilder();  
35 - root = null;  
36 - listNode = new LinkedList();  
37 - value = "";  
38 - document =new Document();  
39 - xmlString = XmlString;  
40 - }  
41 -  
42 - public Map getAllValuesFromXmlString() throws Exception{  
43 - try {  
44 - xmlReader = new StringReader(xmlString);  
45 - xmlSource = new InputSource(xmlReader);  
46 - document = builder.build(xmlSource);  
47 - root = document.getRootElement();  
48 - getElements(root);  
49 -  
50 - }catch (Exception var17) {  
51 - var17.printStackTrace();  
52 - throw var17;  
53 - } finally {  
54 - listNode.clear();  
55 - document = null;  
56 - root = null;  
57 -// builder = null;  
58 -  
59 - }  
60 - return allElementValue;  
61 - }  
62 -  
63 - public void getElements (Element element) throws Exception{  
64 - try {  
65 - domCount++;  
66 - List<Element> Children = element.getChildren();  
67 - if (Children.size()>0){  
68 - for (Element elements : Children){  
69 - if(elements.getChildren().size()>0){  
70 - getElements(elements);  
71 - }else {//确定是最末节点了 开始取末节点的数据  
72 - String childName = elements.getName();  
73 - String childValue = elements.getText();  
74 - Map<String,String> childMap = new HashMap<String, String>(); //用map存储每个最终节点的值  
75 - childMap.put(childName,childValue);  
76 - allElementValue.put(domCount+elements.getParentElement().getName()+"-"+childName,childMap);  
77 - }  
78 - }  
79 - }  
80 -  
81 -  
82 - }catch (Exception e){  
83 - e.printStackTrace();  
84 - throw e;  
85 - }  
86 -  
87 - }  
88 -  
89 - public List<Map> getNodeValuesFromXmlStringForPffm(String xmlNodePath) throws Exception{  
90 - String[] nodes = xmlNodePath.split("/");  
91 - try {  
92 - xmlReader = new StringReader(xmlString);  
93 - xmlSource = new InputSource(xmlReader);  
94 - document = builder.build(xmlSource);  
95 - List<Map> maps = new ArrayList<Map>();  
96 - for(int i = 1; i < nodes.length; ++i) {  
97 - SubNode snode;  
98 -  
99 - if (i >1) {  
100 - snode = (SubNode)listNode.getLast();  
101 - List<Element> eList = snode.getElement().getChildren(nodes[i]); //这里得到所有Arrival节点 从ArrivalEvent开始取  
102 - if (eList != null && eList.size() > 0) {  
103 - SubNode s1 = new SubNode((Element)eList.get(0));  
104 - listNode.add(s1);  
105 -  
106 - }  
107 - if(eList != null && eList.size() > 1 && i==nodes.length-1){ //只有进入的最尾节点的时候再循环去取同名下的一对多的ELEMENT所有子节点  
108 -  
109 - for (Element element : eList){ //开始取出每个ArrivalEven每个字节点  
110 - List<Element> elements=element.getChildren();  
111 - Map<String,String> childMap = new HashMap<String, String>(); //用map存储AssociatedTransportCargo节点下每个值  
112 - for (Element childElements : elements){  
113 - if (childElements.getChildren().size()>1){  
114 - for (Element grandChildrenEle : (List<Element>)childElements.getChildren()){ //IncludedMasterConsignment重复节点  
115 - String childName = grandChildrenEle.getName();  
116 - String childValue = grandChildrenEle.getText();  
117 - childMap.put(childName,childValue);  
118 - }  
119 - }  
120 - String childName = childElements.getName();  
121 - String childValue = childElements.getText();  
122 - childMap.put(childName,childValue);  
123 - logger.info(childValue);  
124 - }  
125 - maps.add(childMap);  
126 - }  
127 - }  
128 -  
129 - } else if (1 == i) {  
130 - root = document.getRootElement();  
131 - snode = new SubNode(root);  
132 - listNode.add(snode);  
133 - }  
134 -  
135 - }  
136 - return maps;  
137 - } catch (Exception var17) {  
138 - var17.printStackTrace();  
139 - throw var17;  
140 - } finally {  
141 - listNode.clear();  
142 - document = null;  
143 - root = null;  
144 -// builder = null;  
145 - nodes = null;  
146 - }  
147 -  
148 - }  
149 -  
150 - /**  
151 - * 取一对多关系的节点下的所有子节点的属性名 和 值,//这个方法作为FWB解析使用  
152 - * @return 返回重复节点下的所有节点数据  
153 - * @throws Exception  
154 - */  
155 - public List<Map> getNodeValuesFromXmlString(String xmlNodePath) throws Exception{  
156 - String[] nodes = xmlNodePath.split("/");  
157 - try {  
158 - xmlReader = new StringReader(xmlString);  
159 - xmlSource = new InputSource(xmlReader);  
160 - document = builder.build(xmlSource);  
161 - List<Map> maps = new ArrayList<Map>();  
162 - for(int i = 1; i < nodes.length; ++i) {  
163 - SubNode snode;  
164 -  
165 - if (i >1) {  
166 - snode = (SubNode)listNode.getLast();  
167 - List<Element> eList = snode.getElement().getChildren(nodes[i]); //这里等于3的时候得到associatedPary节点 两个,下面应该循环这两个element,取他下面的所有children  
168 - if (eList != null && eList.size() > 0) {  
169 - SubNode s1 = new SubNode((Element)eList.get(0));  
170 - listNode.add(s1);  
171 -  
172 - }  
173 - if(eList != null && eList.size() > 1 && i==nodes.length-1){ //只有进入的最尾节点的时候再循环去取同名下的一对多的ELEMENT所有子节点  
174 -  
175 - for (Element element : eList){ //开始取出每个字节点  
176 - List<Element> elements=element.getChildren();  
177 - Map<String,String> childMap = new HashMap<String, String>(); //用map存储每个值  
178 - for (Element childElements : elements){  
179 - if (childElements.getChildren().size()>1){  
180 - for (Element grandChildrenEle : (List<Element>)childElements.getChildren()){  
181 - String childName = grandChildrenEle.getName();  
182 - String childValue = grandChildrenEle.getText();  
183 - childMap.put(childName,childValue);  
184 - }  
185 - }  
186 - String childName = childElements.getName();  
187 - String childValue = childElements.getText();  
188 - childMap.put(childName,childValue);  
189 - logger.info(childValue);  
190 - }  
191 - maps.add(childMap);  
192 - }  
193 - }  
194 -  
195 - } else if (1 == i) {  
196 - root = document.getRootElement();  
197 - snode = new SubNode(root);  
198 - listNode.add(snode);  
199 - }  
200 -  
201 - }  
202 - return maps;  
203 - } catch (Exception var17) {  
204 - var17.printStackTrace();  
205 - throw var17;  
206 - } finally {  
207 - listNode.clear();  
208 - document = null;  
209 - root = null;  
210 -// builder = null;  
211 - nodes = null;  
212 - }  
213 -  
214 - }  
215 -  
216 - /***  
217 - * 获取单一节点的值  
218 - * @return 单一节点值  
219 - * @throws Exception  
220 - */  
221 - public final String getNodeValueFromXmlString(String xmlNodePath) throws Exception {  
222 - String[] nodes = xmlNodePath.split("/");  
223 - try {  
224 - xmlReader = new StringReader(xmlString);  
225 - xmlSource = new InputSource(xmlReader);  
226 - document = builder.build(xmlSource);  
227 -  
228 - for(int i = 1; i < nodes.length; ++i) {  
229 - SubNode snode;  
230 - if (i > 1) {  
231 - snode = (SubNode)listNode.getLast();  
232 - List<Element> eList = snode.getElement().getChildren(nodes[i]);  
233 - if (eList != null && eList.size() > 0) {  
234 - SubNode s1 = new SubNode((Element)eList.get(0));  
235 - listNode.add(s1);  
236 - }  
237 - } else if (1 == i) {  
238 - root = document.getRootElement();  
239 - snode = new SubNode(root);  
240 - listNode.add(snode);  
241 - }  
242 - }  
243 -  
244 - SubNode n = (SubNode)listNode.getLast();  
245 - value = n.getElement().getText();  
246 - n = null;  
247 - return value;  
248 - } catch (Exception var17) {  
249 - var17.printStackTrace();  
250 - throw var17;  
251 - } finally {  
252 - listNode.clear();  
253 - document = null;  
254 - root = null;  
255 -// builder = null;  
256 - nodes = null;  
257 - }  
258 -  
259 - }  
260 -  
261 - public static final String getNodeAttribute(String xmlFile, String xmlNodePath, String attributeName, String defaultValue) {  
262 - String[] nodes = xmlNodePath.split("/");  
263 - new Document();  
264 - SAXBuilder builder = new SAXBuilder();  
265 - Element root = null;  
266 - LinkedList<SubNode> listNode = new LinkedList();  
267 - String value = "";  
268 -  
269 - Document document;  
270 - try {  
271 - document = builder.build(xmlFile);  
272 -  
273 - for(int i = 1; i < nodes.length; ++i) {  
274 - SubNode snode;  
275 - if (i > 1) {  
276 - snode = (SubNode)listNode.getLast();  
277 - List<Element> eList = snode.getElement().getChildren(nodes[i]);  
278 - if (eList != null && eList.size() > 0) {  
279 - SubNode s1 = new SubNode((Element)eList.get(0));  
280 - listNode.add(s1);  
281 - }  
282 - } else if (1 == i) {  
283 - root = document.getRootElement();  
284 - snode = new SubNode(root);  
285 - listNode.add(snode);  
286 - }  
287 - }  
288 -  
289 - SubNode n = (SubNode)listNode.getLast();  
290 - value = n.getElement().getAttributeValue(attributeName, defaultValue);  
291 - n = null;  
292 - } catch (JDOMException var18) {  
293 - var18.printStackTrace();  
294 - } catch (IOException var19) {  
295 - var19.printStackTrace();  
296 - } finally {  
297 - listNode.clear();  
298 - document = null;  
299 - root = null;  
300 - builder = null;  
301 - nodes = null;  
302 - }  
303 -  
304 - System.out.println("key=" + xmlNodePath + " node attrivte value=" + value);  
305 - return value;  
306 - }  
307 -}  
  1 +work_home=`pwd`
  2 +param="-Xms512m -Xmx1024m -Xmn256m -Xss512k -XX:PermSize=256m -XX:MaxPermSize=256m"
  3 +java $param -cp .:lib/* com.tianbo.Main & echo $! > process.pid &
  4 +
  1 +#!/bin/bash
  2 +echo " Current module will shutdown ..."
  3 +pid=`cat process.pid | awk 'echo $1'`
  4 +echo "pid:$pid"
  5 +kill -9 $pid
  6 +rm -f process.pid