Pārlūkot izejas kodu

1.添加虚拟机异常关闭的监控。
2.优化程序,删除了自动升级的功能,删除了编辑配置文件的功能。
3.添加了日志记录的功能。

YangZhiJie 7 gadi atpakaļ
vecāks
revīzija
b4e622027f
30 mainītis faili ar 305 papildinājumiem un 1466 dzēšanām
  1. 1 0
      .classpath
  2. 1 0
      .settings/org.eclipse.jdt.core.prefs
  3. 0 3
      autoStart.bat
  4. 18 73
      config/applicationContext.xml
  5. 4 0
      config/bat/autoRun.bat
  6. 0 0
      config/bat/schedule.bat
  7. 0 0
      config/kill.bat
  8. 43 0
      config/log4j2.xml
  9. 3 4
      config/run.bat
  10. 23 46
      pom.xml
  11. 32 49
      src/main/java/com/leanwo/management/App.java
  12. 135 0
      src/main/java/com/leanwo/management/JvmExitMonit.java
  13. 3 55
      src/main/java/com/leanwo/management/MainFrame.java
  14. 3 2
      src/main/java/com/leanwo/management/ServerLogFrame.java
  15. 0 136
      src/main/java/com/leanwo/management/SettingEditFrame.java
  16. 4 4
      src/main/java/com/leanwo/management/console/LogConsole.java
  17. 3 2
      src/main/java/com/leanwo/management/console/StreamOutputThread.java
  18. 0 86
      src/main/java/com/leanwo/management/model/ApplicationSetting.java
  19. 0 125
      src/main/java/com/leanwo/management/model/XmlConfigPath.java
  20. 0 422
      src/main/java/com/leanwo/management/service/AutoUpdateService.java
  21. 3 2
      src/main/java/com/leanwo/management/service/FileService.java
  22. 0 51
      src/main/java/com/leanwo/management/service/HttpService.java
  23. 3 2
      src/main/java/com/leanwo/management/service/ProcessService.java
  24. 3 2
      src/main/java/com/leanwo/management/util/CloseableUtil.java
  25. 23 0
      src/main/java/com/leanwo/management/util/LogUtil.java
  26. 0 67
      src/main/java/com/leanwo/management/util/ProgramAutoStartUtil.java
  27. 0 67
      src/main/java/com/leanwo/management/util/ProgramStartUtil.java
  28. 0 255
      src/main/java/com/leanwo/management/util/XmlConfigPathService.java
  29. 0 1
      src/main/resources/commons-logging.properties
  30. 0 12
      src/main/resources/log4j.properties

+ 1 - 0
.classpath

@@ -10,6 +10,7 @@
 		<attributes>
 			<attribute name="optional" value="true"/>
 			<attribute name="maven.pomderived" value="true"/>
+			<attribute name="test" value="true"/>
 		</attributes>
 	</classpathentry>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">

+ 1 - 0
.settings/org.eclipse.jdt.core.prefs

@@ -2,4 +2,5 @@ eclipse.preferences.version=1
 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
 org.eclipse.jdt.core.compiler.compliance=1.8
 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.release=disabled
 org.eclipse.jdt.core.compiler.source=1.8

+ 0 - 3
autoStart.bat

@@ -1,3 +0,0 @@
-title Server Management
-CD D:\LeanwoProgram_2018\OtherServer\ServerManagement
-D:

+ 18 - 73
config/applicationContext.xml

@@ -14,13 +14,7 @@
 	<bean id="springUtil" class="com.leanwo.management.util.SpringUtil" />
 	
 	<bean id="processService" class="com.leanwo.management.service.ProcessService"></bean>
-	<bean id="httpService" class="com.leanwo.management.service.HttpService"></bean>
 	<bean id="fileService" class="com.leanwo.management.service.FileService"></bean>
-	<bean id="xmlConfigPathService" class="com.leanwo.management.util.XmlConfigPathService"/>
-	
-	<bean id="autoUpdateService" class="com.leanwo.management.service.AutoUpdateService">
-		<property name="updateSite" value="http://192.168.1.200:8888/AutoUpdate"></property>
-	</bean>
 	
 	<bean id="applicationSettingCache" class="com.leanwo.management.model.ApplicationSettingCache">
 		<property name="settings">
@@ -44,116 +38,71 @@
 	<bean id="applicationSetting1" class="com.leanwo.management.model.ApplicationSetting">
 		<property name="name" value="应用服务器"></property>
 		<property name="installPath" value="D:\ProdogServers\ProdogServer"></property>
-		<property name="startBatFile" value="start.bat"></property>
+		<property name="startBatFile" value="run.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
-		<property name="autoUpdateFileNames">
-			<list>
-				<value>DingDingServer-0.0.1.jar</value>
-			</list>
-		</property>		
-		<property name="xmlConfigPath" >
-			<bean class="com.leanwo.management.model.XmlConfigPath">
-				<property name="xmlFileName" value="config/applicationContext.xml"></property>
-				<property name="nodeNames">
-					<list>
-						<value>dataSource</value>
-					</list>
-				</property>
-			</bean>
-		</property>		
 	</bean>
 	
 	<bean id="applicationSetting2" class="com.leanwo.management.model.ApplicationSetting">
 		<property name="name" value="文件服务器"></property>
 		<property name="installPath" value="D:\ProdogServers\FileServer"></property>
-		<property name="startBatFile" value="start.bat"></property>
+		<property name="startBatFile" value="run.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
-		<property name="monitorUrl" value="http://127.0.0.1:85/api/monitor"></property>
-		<property name="token" value="123456"></property>
 	</bean>
 	
 	<bean id="applicationSetting3" class="com.leanwo.management.model.ApplicationSetting">
 		<property name="name" value="反向代理服务器"></property>
 		<property name="installPath" value="D:\ProdogServers\nginx-1.13.8"></property>
-		<property name="startBatFile" value="start.bat"></property>
+		<property name="startBatFile" value="run.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
-		<property name="monitorUrl" value="http://127.0.0.1:85/api/monitor"></property>
-		<property name="token" value="123456"></property>
 	</bean>
 	
 	<bean id="applicationSetting4" class="com.leanwo.management.model.ApplicationSetting">
 		<property name="name" value="工作流服务器"></property>
 		<property name="installPath" value="D:\ProdogServers\WorkflowServer"></property>
-		<property name="startBatFile" value="start.bat"></property>
+		<property name="startBatFile" value="run.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
-		<property name="monitorUrl" value="http://127.0.0.1:82/activiti/explorer/monitor"></property>
-		<property name="token" value="123456"></property>
 	</bean>
 	
 	<bean id="applicationSetting5" class="com.leanwo.management.model.ApplicationSetting">
 		<property name="name" value="报表服务器"></property>
 		<property name="installPath" value="D:\ProdogServers\ReportServer"></property>
-		<property name="startBatFile" value="start.bat"></property>
+		<property name="startBatFile" value="run.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
-		<property name="monitorUrl" value="http://127.0.0.1:81/monitor"></property>
-		<property name="token" value="123456"></property>
-		<property name="autoUpdateFileNames">
-			<list>
-				<value>report-server-0.0.1.jar</value>
-			</list>
-		</property>
-		<property name="xmlConfigPath" >
-			<bean class="com.leanwo.management.model.XmlConfigPath">
-				<property name="xmlFileName" value="config\applicationContext.xml"></property>
-				<property name="nodeNames">
-					<list>
-						<value>dataSource1</value>
-						<value>dataSource2</value>
-					</list>
-				</property>
-			</bean>
-		</property>		
 	</bean>
 	
 	
 	<bean id="applicationSetting6" class="com.leanwo.management.model.ApplicationSetting">
 		<property name="name" value="钉钉服务器"></property>
 		<property name="installPath" value="D:\ProdogServers\DingTalkServer"></property>
-		<property name="startBatFile" value="start.bat"></property>
+		<property name="startBatFile" value="run.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
-		<property name="monitorUrl" value="http://127.0.0.1:83/monitor"></property>
-		<property name="token" value="123456"></property>
 	</bean>
 	
 	<bean id="applicationSetting7" class="com.leanwo.management.model.ApplicationSetting">
 		<property name="name" value="微信服务器"></property>
 		<property name="installPath" value="D:\ProdogServers\WeChatServer"></property>
-		<property name="startBatFile" value="start.bat"></property>
+		<property name="startBatFile" value="run.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
-		<property name="monitorUrl" value="http://127.0.0.1:80/monitor"></property>
-		<property name="token" value="123456"></property>
 	</bean>
 	
 	<bean id="applicationSetting8" class="com.leanwo.management.model.ApplicationSetting">
 		<property name="name" value="排产服务器"></property>
 		<property name="installPath" value="D:\ProdogServers\ApsServer"></property>
-		<property name="startBatFile" value="start.bat"></property>
+		<property name="startBatFile" value="run.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
-		<property name="monitorUrl" value="http://127.0.0.1:85/api/monitor"></property>
-		<property name="token" value="123456"></property>
 	</bean>
 	
 	<bean id="applicationSetting9" class="com.leanwo.management.model.ApplicationSetting">
 		<property name="name" value="中间件服务器"></property>
 		<property name="installPath" value=""></property>
-		<property name="startBatFile" value="start.bat"></property>
+		<property name="startBatFile" value="run.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
 	</bean>
 	
 	<bean id="applicationSetting10" class="com.leanwo.management.model.ApplicationSetting">
 		<property name="name" value="视频监控服务器"></property>
 		<property name="installPath" value=""></property>
-		<property name="startBatFile" value="start.bat"></property>
+		<property name="startBatFile" value="run.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
 	</bean>
 	
@@ -161,41 +110,37 @@
 	<bean id="applicationSetting11" class="com.leanwo.management.model.ApplicationSetting">
 		<property name="name" value="源代码服务器"></property>
 		<property name="installPath" value="D:\ProdogServers\TortoiseHg"></property>
-		<property name="startBatFile" value="start.bat"></property>
+		<property name="startBatFile" value="run.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
-	</bean>
-	
-	
+	</bean>	
 	<bean id="applicationSetting12" class="com.leanwo.management.model.ApplicationSetting">
 		<property name="name" value="natapp服务器"></property>
 		<property name="installPath" value="D:\ProdogServers\natapp_windows_8080"></property>
-		<property name="startBatFile" value="start.bat"></property>
+		<property name="startBatFile" value="run.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
-	</bean>
-	
-	
+	</bean>	
 	<bean id="applicationSetting13" class="com.leanwo.management.model.ApplicationSetting">
 		<property name="name" value="测试服务器"></property>
 		<property name="installPath" value="D:\LeanwoProgram_2018\OtherServer\ServerManagement\src\test\java"></property>
-		<property name="startBatFile" value="start.bat"></property>
+		<property name="startBatFile" value="run.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
 	</bean>
 	<bean id="applicationSetting14" class="com.leanwo.management.model.ApplicationSetting">
 		<property name="name" value="测试服务器"></property>
 		<property name="installPath" value="D:\LeanwoProgram_2018\OtherServer\ServerManagement\src\test\java"></property>
-		<property name="startBatFile" value="start.bat"></property>
+		<property name="startBatFile" value="run.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
 	</bean>
 	<bean id="applicationSetting15" class="com.leanwo.management.model.ApplicationSetting">
 		<property name="name" value="测试服务器"></property>
 		<property name="installPath" value="D:\LeanwoProgram_2018\OtherServer\ServerManagement\src\test\java"></property>
-		<property name="startBatFile" value="start.bat"></property>
+		<property name="startBatFile" value="run.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
 	</bean>
 	<bean id="applicationSetting16" class="com.leanwo.management.model.ApplicationSetting">
 		<property name="name" value="测试服务器"></property>
 		<property name="installPath" value="D:\LeanwoProgram_2018\OtherServer\ServerManagement\src\test\java"></property>
-		<property name="startBatFile" value="start.bat"></property>
+		<property name="startBatFile" value="run.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
 	</bean>
 </beans>

+ 4 - 0
config/bat/autoRun.bat

@@ -0,0 +1,4 @@
+title ServerManagement
+cd /d %~dp0
+set current_path=%~dp0
+start javaw -jar %current_path%\ServerManagement-0.0.1.jar autoRun

+ 0 - 0
config/schedule.bat → config/bat/schedule.bat


+ 0 - 0
config/killAllJava.bat → config/kill.bat


+ 43 - 0
config/log4j2.xml

@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration status="WARN" monitorInterval="30">
+
+    <Properties>
+        <Property name="LOG_HOME">logs/</Property>
+    </Properties>
+    
+	<!-- 先定义所有的appender -->
+	<appenders>
+		<Console name="Console" target="SYSTEM_OUT">
+            <!-- 控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch) -->
+            <ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
+            <!-- 这个都知道是输出日志的格式 -->
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} [%L] [%M] - %msg%xEx%n"/>
+        </Console>
+        
+		<!-- 这个会打印出所有的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档 -->
+		<RollingFile name="RollingFile"
+			fileName="${LOG_HOME}/server-management.log"
+			filePattern="${LOG_HOME}/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz">
+			<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY" />
+			<PatternLayout
+				pattern="%d{yyyy-MM-dd HH:mm:ss z} %-5level %class{36} [%L] [%M] - %msg%xEx%n" />
+			<SizeBasedTriggeringPolicy size="2MB" />
+		</RollingFile>
+	</appenders>
+	<!-- 然后定义logger,只有定义了logger并引入的appender,appender才会生效 -->
+	<loggers>
+		<!-- 建立一个默认的root的logger -->
+		<root level="debug">
+			<appender-ref ref="RollingFile" />
+			<appender-ref ref="Console" />
+		</root>
+		
+        <!-- 第三方日志系统 -->
+        <logger name="org.springframework" level="error"/>
+        <logger name="org.hibernate" level="error"/>
+        <logger name="com.mchange.v2" level="error"/>
+        <logger name="com.alibaba.druid" level="error"/>
+        <logger name="org.eclipse.jetty" level="error"/>
+        <logger name="net.sf.ehcache" level="error"/>
+	</loggers>
+</configuration>

+ 3 - 4
config/run.bat

@@ -1,5 +1,4 @@
-title Report Server
-set current_path="%cd%"
-cd %current_path%
-@echo off
+title ServerManagement
+cd /d %~dp0
+set current_path=%~dp0
 start javaw -jar %current_path%\ServerManagement-0.0.1.jar

+ 23 - 46
pom.xml

@@ -12,73 +12,50 @@
 
 	<properties>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<log4j.version>2.11.1</log4j.version>
+		<slf4j.version>1.7.25</slf4j.version>
+		<spring.version>5.1.4.RELEASE</spring.version>
 	</properties>
 
 	<dependencies>
+		<!-- 日志框架 slf4j(slf4j的api接口包)-->
 		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit</artifactId>
-			<version>3.8.1</version>
-			<scope>test</scope>
+		    <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+		    <version>${slf4j.version}</version>
 		</dependency>
-
+		
+		<!-- 日志 log4j2(log4j2的核心包) -->
 		<dependency>
-			<groupId>org.slf4j</groupId>
-			<artifactId>slf4j-api</artifactId>
-			<version>1.7.25</version>
+		    <groupId>org.apache.logging.log4j</groupId>
+		    <artifactId>log4j-core</artifactId>
+		    <version>${log4j.version}</version>
 		</dependency>
-
+				
+		<!-- 日志 log4j2(slf4j对应log4j2日志框架的驱动包) -->
 		<dependency>
-			<groupId>org.slf4j</groupId>
-			<artifactId>slf4j-log4j12</artifactId>
-			<version>1.7.25</version>
+		    <groupId>org.apache.logging.log4j</groupId>
+		    <artifactId>log4j-slf4j-impl</artifactId>
+		    <version>${log4j.version}</version>
 		</dependency>
 
 		<dependency>
 			<groupId>org.springframework</groupId>
 			<artifactId>spring-core</artifactId>
-			<version>5.0.1.RELEASE</version>
+			<version>${spring.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>org.springframework</groupId>
 			<artifactId>spring-context</artifactId>
-			<version>5.0.1.RELEASE</version>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework</groupId>
-			<artifactId>spring-beans</artifactId>
-			<version>5.0.1.RELEASE</version>
+			<version>${spring.version}</version>
 		</dependency>
 		
-		<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
 		<dependency>
-			<groupId>org.springframework</groupId>
-			<artifactId>spring-webmvc</artifactId>
-			<version>4.3.12.RELEASE</version>
-		</dependency>
-		
-		<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
-		<dependency>
-			<groupId>com.fasterxml.jackson.core</groupId>
-			<artifactId>jackson-core</artifactId>
-			<version>2.9.2</version>
-		</dependency>
-		<dependency>
-			<groupId>com.fasterxml.jackson.core</groupId>
-			<artifactId>jackson-databind</artifactId>
-			<version>2.9.2</version>
-		</dependency>
-		<dependency>
-			<groupId>com.fasterxml.jackson.core</groupId>
-			<artifactId>jackson-annotations</artifactId>
-			<version>2.9.2</version>
-		</dependency>
-		<dependency>
-			<groupId>org.dom4j</groupId>
-			<artifactId>dom4j</artifactId>
-			<version>2.0.0-RC1</version>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>3.8.1</version>
+			<scope>test</scope>
 		</dependency>
-		
 	</dependencies>
 	
 	

+ 32 - 49
src/main/java/com/leanwo/management/App.java

@@ -1,20 +1,20 @@
 package com.leanwo.management;
 
+import java.io.File;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 
 import javax.swing.JOptionPane;
 import javax.swing.SwingUtilities;
-import javax.swing.UIManager;
-import javax.swing.UIManager.LookAndFeelInfo;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.FileSystemXmlApplicationContext;
 
-import com.leanwo.management.util.ProgramAutoStartUtil;
-import com.leanwo.management.util.ProgramStartUtil;
+import com.leanwo.management.util.LogUtil;
 import com.leanwo.management.util.ProgramStopUtil;
 
 /**
@@ -22,67 +22,50 @@ import com.leanwo.management.util.ProgramStopUtil;
  *
  */
 public class App {
-	
+
 	private static Log logger = LogFactory.getLog(App.class);
 
 	public static void main(String[] args) {
-		ProgramStartUtil.generateStartBat();
-		ProgramAutoStartUtil.generateStartBat();
-		ProgramStopUtil.generateStopBat();
+		JvmExitMonit.jvmExitHook();
+
+		LogUtil.init();
 		
+		ProgramStopUtil.generateStopBat();
+
 		ApplicationContext factory = new FileSystemXmlApplicationContext("config/applicationContext.xml");
-		
+
 		boolean isAutoRun = false;
-		if(args != null && args.length > 0) {
-			if(args[0].equals("autoRun")) {
+		if (args != null && args.length > 0) {
+			if (args[0].equals("autoRun")) {
 				isAutoRun = true;
 			}
-			for(String arg : args) {
+			for (String arg : args) {
 				logger.info("输出参数:" + arg);
 			}
 		}
-		
-		if(isAutoRun) {
+
+		if (isAutoRun) {
 			logger.info("程序管理器将会自动运行。");
 		}
-		
+
 		final boolean isAutoRunFinal = isAutoRun;
-		
+
 		SwingUtilities.invokeLater(new Runnable() {
-            @Override
-            public void run() {
-//                installLookAndFeel();
-                try {
-                    final MainFrame mainFrame = new MainFrame(isAutoRunFinal);
-                    mainFrame.pack();
-                    mainFrame.setVisible(true);
-                } catch (final Exception ex) {
-                    ex.printStackTrace();
+			@Override
+			public void run() {
+				try {
+					final MainFrame mainFrame = new MainFrame(isAutoRunFinal);
+					mainFrame.pack();
+					mainFrame.setVisible(true);
+				} catch (final Exception ex) {
+					ex.printStackTrace();
 
-                    final StringWriter sr = new StringWriter();
-                    ex.printStackTrace(new PrintWriter(sr));
-                    JOptionPane.showMessageDialog(null, sr.toString(), "Error", JOptionPane.ERROR_MESSAGE);
-                }
-            }
-        });
+					final StringWriter sr = new StringWriter();
+					ex.printStackTrace(new PrintWriter(sr));
+					JOptionPane.showMessageDialog(null, sr.toString(), "Error", JOptionPane.ERROR_MESSAGE);
+				}
+			}
+		});
 	}
-	
 
-    private static void installLookAndFeel() {
-        try {
-            for (final LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
-                if ("Nimbus".equals(info.getName())) {
-                    UIManager.setLookAndFeel(info.getClassName());
-                    return;
-                }
-            }
-        } catch (final Exception ex) {
-            ex.printStackTrace();
-        }
-        try {
-            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
-        } catch (final Exception e) {
-            e.printStackTrace();
-        }
-    }
 }

+ 135 - 0
src/main/java/com/leanwo/management/JvmExitMonit.java

@@ -0,0 +1,135 @@
+package com.leanwo.management;
+
+import java.lang.management.GarbageCollectorMXBean;
+import java.lang.management.LockInfo;
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryMXBean;
+import java.lang.management.MonitorInfo;
+import java.lang.management.ThreadInfo;
+import java.lang.management.ThreadMXBean;
+import java.util.List;
+
+/**
+ * Java虚拟机异常退出监控
+ * @author YangZhiJie
+ *
+ */
+public class JvmExitMonit {
+	/**
+	 * 打印JVM退出堆栈信息
+	 */
+	public static void jvmExitHook() {
+		System.out.println("注册JVM Shutdown钩子方法");
+		Runtime.getRuntime().addShutdownHook(new Thread() {
+			@Override
+			public void run() {
+				MemoryMXBean memorymbean = ManagementFactory.getMemoryMXBean();
+				System.out.println("####################内存信息####################");
+				System.out.println("Heap Memory: " + memorymbean.getHeapMemoryUsage());
+				System.out.println("Non Heap Memory: " + memorymbean.getNonHeapMemoryUsage());
+
+				List<GarbageCollectorMXBean> list = ManagementFactory.getGarbageCollectorMXBeans();
+				if (list != null && list.size() > 0) {
+					System.out.println("####################Gc信息####################");
+					for (GarbageCollectorMXBean gcBean : list) {
+						String s = "gc name=" + gcBean.getName() + ",gc count=" + gcBean.getCollectionCount()
+								+ ",gc time=" + gcBean.getCollectionTime();
+						System.out.println(s);
+					}
+				}
+
+				ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
+				long[] ids = threadBean.getAllThreadIds();
+				System.out.println("####################线程信息####################");
+				for (long id : ids) {
+					ThreadInfo threadInfo = threadBean.getThreadInfo(id, Integer.MAX_VALUE);
+					if (threadInfo != null) {
+						String s = "blockcount=" + threadInfo.getBlockedCount() + ",blocktime="
+								+ threadInfo.getBlockedTime();
+						s = s + ",waitedcount=" + threadInfo.getWaitedCount() + ",waitedtime="
+								+ threadInfo.getWaitedTime();
+						System.out.println(s);
+						System.out.println(getThreadInfo(threadInfo));
+					}
+				}
+
+				long[] deadlock_ids = threadBean.findDeadlockedThreads();
+				if (deadlock_ids != null) {
+					System.out.println("####################死锁信息####################");
+					for (long id : deadlock_ids) {
+						System.out.println("死锁的线程号:" + id);
+					}
+				}
+			}
+		});
+	}
+
+	public static String getThreadInfo(ThreadInfo t) {
+		try {
+			StringBuilder sb = new StringBuilder(
+					"\"" + t.getThreadName() + "\"" + " Id=" + t.getThreadId() + " " + t.getThreadState());
+			if (t.getLockName() != null) {
+				sb.append(" on " + t.getLockName());
+			}
+			if (t.getLockOwnerName() != null) {
+				sb.append(" owned by \"" + t.getLockOwnerName() + "\" Id=" + t.getLockOwnerId());
+			}
+			if (t.isSuspended()) {
+				sb.append(" (suspended)");
+			}
+			if (t.isInNative()) {
+				sb.append(" (in native)");
+			}
+			sb.append('\n');
+			int i = 0;
+			for (StackTraceElement ste : t.getStackTrace()) {
+				sb.append("\tat " + ste.toString());
+				sb.append('\n');
+				if (i == 0 && t.getLockInfo() != null) {
+					Thread.State ts = t.getThreadState();
+					switch (ts) {
+					case BLOCKED:
+						sb.append("\t-  blocked on " + t.getLockInfo());
+						sb.append('\n');
+						break;
+					case WAITING:
+						sb.append("\t-  waiting on " + t.getLockInfo());
+						sb.append('\n');
+						break;
+					case TIMED_WAITING:
+						sb.append("\t-  waiting on " + t.getLockInfo());
+						sb.append('\n');
+						break;
+					default:
+					}
+				}
+
+				for (MonitorInfo mi : t.getLockedMonitors()) {
+					if (mi.getLockedStackDepth() == i) {
+						sb.append("\t-  locked " + mi);
+						sb.append('\n');
+					}
+				}
+			}
+			if (i < t.getStackTrace().length) {
+				sb.append("\t...");
+				sb.append('\n');
+			}
+
+			LockInfo[] locks = t.getLockedSynchronizers();
+			if (locks.length > 0) {
+				sb.append("\n\tNumber of locked synchronizers = " + locks.length);
+				sb.append('\n');
+				for (LockInfo li : locks) {
+					sb.append("\t- " + li);
+					sb.append('\n');
+				}
+			}
+			sb.append('\n');
+			return sb.toString();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return "";
+	}
+}

+ 3 - 55
src/main/java/com/leanwo/management/MainFrame.java

@@ -26,11 +26,11 @@ import javax.swing.JFrame;
 import javax.swing.JOptionPane;
 import javax.swing.JToolBar;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.leanwo.management.model.ApplicationSetting;
 import com.leanwo.management.model.ApplicationSettingCache;
-import com.leanwo.management.service.AutoUpdateService;
 import com.leanwo.management.service.ProcessService;
 import com.leanwo.management.service.ProgramRunResult;
 import com.leanwo.management.util.SpringUtil;
@@ -38,12 +38,10 @@ import com.leanwo.management.widget.SelectEventListener;
 import com.leanwo.management.widget.SelectObject;
 
 public class MainFrame extends JFrame{
-	private static Logger logger = Logger.getLogger(MainFrame.class);
+	private static Logger logger = LoggerFactory.getLogger(MainFrame.class);
 	
 	private JButton startMenu = null;
 	private JButton stopMenu = null;
-	private JButton upgradeMenu = null;
-	private JButton editConfigMenu = null;
 	private JButton startAllMenu = null;
 	private JButton stopAllMenu = null;
 	
@@ -67,9 +65,6 @@ public class MainFrame extends JFrame{
 	/** 流程服务 */
 	private ProcessService processService = null;
 
-	/** 升级服务 */
-	private AutoUpdateService autoUpdateService = null;
-
 	/** 自动启动 */
 	private boolean isAutoStart;
 	
@@ -84,7 +79,6 @@ public class MainFrame extends JFrame{
 		applicationSettingCache = (ApplicationSettingCache) SpringUtil.getSingleBean(ApplicationSettingCache.class);
 		settings = applicationSettingCache.getSettings();
 		processService = (ProcessService) SpringUtil.getSingleBean(ProcessService.class);
-		autoUpdateService = (AutoUpdateService) SpringUtil.getSingleBean(AutoUpdateService.class);
 		Thread.currentThread().setName("界面主线程");
 	}
 	
@@ -103,12 +97,6 @@ public class MainFrame extends JFrame{
         stopMenu = new JButton("停止");
         toolbar.add(stopMenu);
         
-        upgradeMenu = new JButton("更新");
-        toolbar.add(upgradeMenu);
-
-        editConfigMenu = new JButton("设置");
-        toolbar.add(editConfigMenu);
-        
         startAllMenu = new JButton("全部启动");
         toolbar.add(startAllMenu);
         
@@ -214,42 +202,6 @@ public class MainFrame extends JFrame{
 			}
 		});
 		
-		upgradeMenu.addActionListener(new ActionListener() {
-			@Override
-			public void actionPerformed(ActionEvent e) {
-				int selectedRow = serverFrame.getSelectedRow();
-				if(selectedRow >= 0 && selectedRow < settings.size()) {
-					ApplicationSetting setting = settings.get(selectedRow);
-					if(autoUpdateService.canUpdate(setting)) {
-						Object[] options = {"确定","取消"};
-						int response = JOptionPane.showOptionDialog(null, "如果您确定要升级,请点击\'确定\'按钮,否则点击\'取消\'按钮", "确定是否升级", JOptionPane.YES_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
-						if(response==0)
-						{
-							autoUpdateService.autoUpdate(setting);
-						}
-					}else {
-						JOptionPane.showMessageDialog(null, "在服务器上未找到可更新的程序", "没有可更新的程序", JOptionPane.ERROR_MESSAGE);
-					}
-				}else {
-					JOptionPane.showMessageDialog(null, "请先选择服务器", "请先选择服务器", JOptionPane.ERROR_MESSAGE);
-				}
-			}
-		});
-		
-		editConfigMenu.addActionListener(new ActionListener() {
-			@Override
-			public void actionPerformed(ActionEvent e) {
-				int selectedRow = serverFrame.getSelectedRow();
-				if(selectedRow >= 0 && selectedRow < settings.size()) {
-					ApplicationSetting setting = settings.get(selectedRow);
-					SettingEditFrame serverSettingJFrame = new SettingEditFrame(setting);
-					serverSettingJFrame.setVisible(true);
-				}else {
-					JOptionPane.showMessageDialog(null, "请先选择服务器", "请先选择服务器", JOptionPane.ERROR_MESSAGE);
-				}
-			}
-		});
-		
 		// 全部启动
 		startAllMenu.addActionListener(new ActionListener() {
 			@Override
@@ -309,13 +261,9 @@ public class MainFrame extends JFrame{
 			if(setting.isOnline()) {
 				startMenu.setEnabled(false);
 				stopMenu.setEnabled(true);
-				upgradeMenu.setEnabled(false);
-				editConfigMenu.setEnabled(true);
 			}else {
 				startMenu.setEnabled(true);
 				stopMenu.setEnabled(true);
-				upgradeMenu.setEnabled(true);
-				editConfigMenu.setEnabled(true);
 			}
 		}
 	}

+ 3 - 2
src/main/java/com/leanwo/management/ServerLogFrame.java

@@ -11,7 +11,8 @@ import javax.swing.JPanel;
 import javax.swing.JTabbedPane;
 import javax.swing.SwingUtilities;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.leanwo.management.console.LogConsole;
 import com.leanwo.management.model.ApplicationSetting;
@@ -23,7 +24,7 @@ import com.leanwo.management.service.ProgramRunResult;
  *
  */
 public class ServerLogFrame extends JPanel{
-	private static Logger logger = Logger.getLogger(ServerLogFrame.class);
+	private static Logger logger = LoggerFactory.getLogger(ServerLogFrame.class);
 	
 	private JTabbedPane tabbedpane = null;
 	private String[] tabNames = null;

+ 0 - 136
src/main/java/com/leanwo/management/SettingEditFrame.java

@@ -1,136 +0,0 @@
-package com.leanwo.management;
-
-import java.awt.Color;
-import java.awt.Container;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.swing.BoxLayout;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.leanwo.management.exception.ConfigFileException;
-import com.leanwo.management.model.ApplicationSetting;
-import com.leanwo.management.model.XmlConfigPath;
-import com.leanwo.management.util.SpringUtil;
-import com.leanwo.management.util.XmlConfigPathService;
-
-/**
- * 服务器配置
- * @author YangZhiJie
- *
- */
-public class SettingEditFrame  extends JFrame{
-	private static Log logger = LogFactory.getLog(SettingEditFrame.class);
-	private ApplicationSetting applicationSetting;
-	private XmlConfigPath xmlConfigPath;
-	private XmlConfigPathService xmlConfigPathService;
-	private Container jPanel = null;
-	private JLabel label = null;
-	private JTextField portTextField;
-	private JTextField tokenTextField;
-	private Map<String, JTextArea> textAreas = new HashMap<String, JTextArea>();
-	private JButton saveButton;
-	
-	public SettingEditFrame(ApplicationSetting applicationSetting) {
-		this.jPanel = this.getContentPane();  
-
-		this.setSize(800, 600);
-		this.setTitle("程序配置管理器");
-		this.xmlConfigPathService = (XmlConfigPathService) SpringUtil.getSingleBean(XmlConfigPathService.class);
-		this.applicationSetting = applicationSetting;
-		try {
-			this.xmlConfigPathService.load(applicationSetting);
-		} catch (ConfigFileException e1) {
-			logger.error("读取配置文件异常",e1);
-			JOptionPane.showMessageDialog(null, e1.getMessage(), "配置文件异常", JOptionPane.ERROR_MESSAGE);
-			this.dispose();
-		}
-		this.xmlConfigPath = applicationSetting.getXmlConfigPath();
-		jPanel.setLayout(new BoxLayout(jPanel, BoxLayout.Y_AXIS));  
-		
-        if(this.xmlConfigPath != null) {
-    		label = new JLabel("端口号");
-    		label.setAlignmentY(LEFT_ALIGNMENT);
-
-            jPanel.add(label);
-            
-            portTextField = new JTextField();
-            portTextField.setAlignmentY(LEFT_ALIGNMENT);
-            if(xmlConfigPath.getPortNo() != null) {
-            	portTextField.setText(xmlConfigPath.getPortNo().toString());
-            }
-            jPanel.add(portTextField);
-            
-            
-    		label = new JLabel("Token");
-    		label.setAlignmentY(LEFT_ALIGNMENT);
-            jPanel.add(label);
-
-            tokenTextField = new JTextField();
-            tokenTextField.setAlignmentY(LEFT_ALIGNMENT);
-            tokenTextField.setText(xmlConfigPath.getToken());
-            jPanel.add(tokenTextField);
-            
-            
-            
-        	Map<String, String> contents = applicationSetting.getXmlConfigPath().getContents();
-        	for(String key : contents.keySet()) {
-        		label = new JLabel(key);
-        		label.setAlignmentY(LEFT_ALIGNMENT);
-                jPanel.add(label);
-                
-        		JTextArea textArea = new JTextArea();
-        		textArea.setAlignmentY(LEFT_ALIGNMENT);
-        		textArea.setText(contents.get(key));
-        		textArea.setSelectedTextColor(Color.RED);
-        		textArea.setLineWrap(true);        //激活自动换行功能 
-        		textArea.setWrapStyleWord(true);            // 激活断行不断字功能
-                jPanel.add(textArea);
-                textAreas.put(key, textArea);
-        	}
-
-        	saveButton = new JButton("保存");
-            jPanel.add(saveButton);
-            
-            saveButton.addActionListener(new ActionListener() {
-				@Override
-				public void actionPerformed(ActionEvent e) {
-					String portStr = portTextField.getText();
-					if(portStr != null) {
-						try {
-							xmlConfigPath.setPortNo(Integer.parseInt(portStr));
-						}catch(Exception ex) {
-							JOptionPane.showMessageDialog(null, "端口号必须为整数", "端口号必须为整数", JOptionPane.ERROR_MESSAGE);
-							return;
-						}
-					}
-					xmlConfigPath.setToken(tokenTextField.getText());
-					if(xmlConfigPath.getContents() != null) {
-						for(String key : textAreas.keySet()) {
-							xmlConfigPath.getContents().put(key, textAreas.get(key).getText());
-						}
-					}
-					try {
-						xmlConfigPathService.save(applicationSetting);
-					} catch (ConfigFileException e1) {
-						logger.error("修改配置文件异常");
-						JOptionPane.showMessageDialog(null, e1.getMessage(), "修改配置文件异常", JOptionPane.ERROR_MESSAGE);
-						e1.printStackTrace();
-					}
-				}
-			});
-        }
-
-		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
-	}
-}

+ 4 - 4
src/main/java/com/leanwo/management/console/LogConsole.java

@@ -60,7 +60,7 @@ public class LogConsole extends JPanel{
 	 */
 	private void initData() {
 		// 自动滚动
-		autoScroll = true;
+		autoScroll = false;
 		
 		cacheStringBuilder = new StringBuilder();
 		
@@ -154,7 +154,9 @@ public class LogConsole extends JPanel{
 	        	 	textArea.append(cacheStringBuilder.toString());
 	        	 	cacheStringBuilder.setLength(0);
 	        	 	lastUpdateMills = currentMills;
-	        	 	scrollToEnd();	
+	        		if(autoScroll) {
+	        			scrollToEnd();	
+	        		}
 	             }
 	         });	
 		 }		 
@@ -164,8 +166,6 @@ public class LogConsole extends JPanel{
 	 * 滚动到最底端
 	 */
 	private void scrollToEnd() {
-		if(autoScroll) {
 			textArea.setCaretPosition(textArea.getText().length());
-		}
 	}
 }

+ 3 - 2
src/main/java/com/leanwo/management/console/StreamOutputThread.java

@@ -5,12 +5,13 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.UnsupportedEncodingException;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.leanwo.management.util.CloseableUtil;
 
 public class StreamOutputThread extends Thread {
-	private static Logger logger = Logger.getLogger(StreamOutputThread.class);
+	private static Logger logger = LoggerFactory.getLogger(StreamOutputThread.class);
 	
 	private LogEvent logEvent;
 	

+ 0 - 86
src/main/java/com/leanwo/management/model/ApplicationSetting.java

@@ -3,8 +3,6 @@
  */
 package com.leanwo.management.model;
 
-import java.util.List;
-
 import com.leanwo.management.service.ProgramRunResult;
 import com.leanwo.management.util.CloseableUtil;
 
@@ -26,19 +24,7 @@ public class ApplicationSetting {
 
 	/** 停止程序BAT文件路径. */
 	private String stopBatFile;
-	
-	/** 监控地址. */
-	private String monitorUrl;
-	
-	/** token. */
-	private String token;
 
-	/** 自动更新的文件名.	 */
-	private List<String> autoUpdateFileNames;
-
-	/** XML文件配置. */
-	private XmlConfigPath xmlConfigPath;
-		
 	/** 应用程序是否在线(计算值). */
 	private boolean online;
 
@@ -117,78 +103,6 @@ public class ApplicationSetting {
 		this.stopBatFile = stopBatFile;
 	}
 
-	/**
-	 * Gets the 监控地址.
-	 *
-	 * @return the 监控地址
-	 */
-	public String getMonitorUrl() {
-		return monitorUrl;
-	}
-
-	/**
-	 * Sets the 监控地址.
-	 *
-	 * @param monitorUrl the new 监控地址
-	 */
-	public void setMonitorUrl(String monitorUrl) {
-		this.monitorUrl = monitorUrl;
-	}
-
-	/**
-	 * Gets the token.
-	 *
-	 * @return the token
-	 */
-	public String getToken() {
-		return token;
-	}
-
-	/**
-	 * Sets the token.
-	 *
-	 * @param token the new token
-	 */
-	public void setToken(String token) {
-		this.token = token;
-	}
-
-	/**
-	 * Gets the 自动更新的文件名.
-	 *
-	 * @return the 自动更新的文件名
-	 */
-	public List<String> getAutoUpdateFileNames() {
-		return autoUpdateFileNames;
-	}
-
-	/**
-	 * Sets the 自动更新的文件名.
-	 *
-	 * @param autoUpdateFileNames the new 自动更新的文件名
-	 */
-	public void setAutoUpdateFileNames(List<String> autoUpdateFileNames) {
-		this.autoUpdateFileNames = autoUpdateFileNames;
-	}
-
-	/**
-	 * Gets the xML文件配置.
-	 *
-	 * @return the xML文件配置
-	 */
-	public XmlConfigPath getXmlConfigPath() {
-		return xmlConfigPath;
-	}
-
-	/**
-	 * Sets the xML文件配置.
-	 *
-	 * @param xmlConfigPath the new xML文件配置
-	 */
-	public void setXmlConfigPath(XmlConfigPath xmlConfigPath) {
-		this.xmlConfigPath = xmlConfigPath;
-	}
-
 	/**
 	 * Checks if is 应用程序是否在线(计算值).
 	 *

+ 0 - 125
src/main/java/com/leanwo/management/model/XmlConfigPath.java

@@ -1,125 +0,0 @@
-package com.leanwo.management.model;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * XML配置路径.
- */
-public class XmlConfigPath {
-	
-	/**
-	 * XML文件名.
-	 */
-	private String xmlFileName;
-	
-	/**
-	 * 端口号.
-	 */
-	private Integer portNo;
-	
-	/**
-	 * Token.
-	 */
-	private String token;
-	
-	/**
-	 * 节点名称.
-	 */
-	private List<String> nodeNames;
-	
-	/**
-	 * 节点数据.
-	 */
-	private Map<String, String> contents;
-
-	/**
-	 * Gets the xML文件名.
-	 *
-	 * @return the xML文件名
-	 */
-	public String getXmlFileName() {
-		return xmlFileName;
-	}
-
-	/**
-	 * Sets the xML文件名.
-	 *
-	 * @param xmlFileName the new xML文件名
-	 */
-	public void setXmlFileName(String xmlFileName) {
-		this.xmlFileName = xmlFileName;
-	}
-
-	/**
-	 * Gets the 端口号.
-	 *
-	 * @return the 端口号
-	 */
-	public Integer getPortNo() {
-		return portNo;
-	}
-
-	/**
-	 * Sets the 端口号.
-	 *
-	 * @param portNo the new 端口号
-	 */
-	public void setPortNo(Integer portNo) {
-		this.portNo = portNo;
-	}
-
-	/**
-	 * Gets the token.
-	 *
-	 * @return the token
-	 */
-	public String getToken() {
-		return token;
-	}
-
-	/**
-	 * Sets the token.
-	 *
-	 * @param token the new token
-	 */
-	public void setToken(String token) {
-		this.token = token;
-	}
-
-	/**
-	 * Gets the 节点数据.
-	 *
-	 * @return the 节点数据
-	 */
-	public Map<String, String> getContents() {
-		return contents;
-	}
-
-	/**
-	 * Sets the 节点数据.
-	 *
-	 * @param contents the new 节点数据
-	 */
-	public void setContents(Map<String, String> contents) {
-		this.contents = contents;
-	}
-
-	/**
-	 * Gets the 节点名称.
-	 *
-	 * @return the 节点名称
-	 */
-	public List<String> getNodeNames() {
-		return nodeNames;
-	}
-
-	/**
-	 * Sets the 节点名称.
-	 *
-	 * @param nodeNames the new 节点名称
-	 */
-	public void setNodeNames(List<String> nodeNames) {
-		this.nodeNames = nodeNames;
-	}
-}

+ 0 - 422
src/main/java/com/leanwo/management/service/AutoUpdateService.java

@@ -1,422 +0,0 @@
-package com.leanwo.management.service;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigInteger;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.net.URLConnection;
-import java.nio.charset.Charset;
-import java.security.MessageDigest;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import org.apache.log4j.Logger;
-
-import com.leanwo.management.model.ApplicationSetting;
-
-/**
- * 自动更新服务.
- *
- * @author YangZhiJie
- */
-public class AutoUpdateService {
-	private static Logger logger = Logger.getLogger(AutoUpdateService.class);
-	/**
-	 * 更新的网站.
-	 */
-	private String updateSite;
-	
-	/**
-	 * Gets the 更新的网站.
-	 *
-	 * @return the 更新的网站
-	 */
-	public String getUpdateSite() {
-		return updateSite;
-	}
-
-	/**
-	 * Sets the 更新的网站.
-	 *
-	 * @param updateSite the new 更新的网站
-	 */
-	public void setUpdateSite(String updateSite) {
-		this.updateSite = updateSite;
-	}
-
-	/**
-	 * 检查服务器上是否有可更新的程序
-	 * @return
-	 */
-	public boolean canUpdate(ApplicationSetting setting) {
-		List<String> autoUpdateFileNames = setting.getAutoUpdateFileNames();
-		
-		if (autoUpdateFileNames == null || autoUpdateFileNames.size() < 1) {
-			return false;
-		}
-		return true;
-	}
-	/**
-	 * 从输入流中获取字节数组 
-	 * @param inputStream
-	 * @return
-	 * @throws IOException
-	 */
-	 public static  byte[] readInputStream(InputStream inputStream) {    
-	        byte[] buffer = new byte[1024];    
-	        int len = 0;    
-	        ByteArrayOutputStream bos = new ByteArrayOutputStream();    
-	        try {
-				while((len = inputStream.read(buffer)) != -1) {    
-				    bos.write(buffer, 0, len);    
-				}
-			} catch (IOException e) {
-				e.printStackTrace();
-			} finally {
-				if(bos != null){
-					try {
-						bos.close();
-					} catch (IOException e) {
-						e.printStackTrace();
-					}    
-				}
-			}   
-	        return bos.toByteArray();    
-	    }    
-	
-	 /**
-	  * 判断文件是否存在
-	  * @param httpPath
-	  * @return
-	  */
-	 private static Boolean existHttpPath(String httpPath){
-		 URL httpurl = null;
-		 try {
-		 httpurl = new URL(new URI(httpPath).toASCIIString());
-		 URLConnection urlConnection = httpurl.openConnection();
-		// urlConnection.getInputStream();
-		Long TotalSize=Long.parseLong(urlConnection.getHeaderField("Content-Length"));  
-		    if (TotalSize <= 0){
-		     return false;
-		    }
-		    return true;
-		 } catch (Exception e) {
-			 logger.debug(httpurl + "文件不存在");
-		 return false;
-		 }
-		 }
-	 
-	/**
-	 * 确定执行更新.
-	 */
-	public void autoUpdate(ApplicationSetting setting) {
-		//需要更新的文件
-		List<String> autoUpdateFileNames = setting.getAutoUpdateFileNames();
-		String savePath = setting.getInstallPath();
-		//用于保存下载文件的目录 
-		File saveDir = new File(savePath);
-		File tempDir = new File(savePath + "/" + "temp");
-		String fileName = savePath.substring(savePath.lastIndexOf("\\")+1);
-		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
-		String dateStr = sdf.format(new Date());
-		URL url;
-		InputStream inputStream = null;
-		FileOutputStream fos = null;
-		try {
-			for (String s : autoUpdateFileNames) {
-				//url请求路径
-				String requestPath =  updateSite + "/" + fileName + "/" + s;
-				//判断需要下载的文件是否存在
-				if (!existHttpPath(requestPath)) {
-					throw new RuntimeException("需要更新的文件"+ requestPath + "不存在");
-				}
-				//判断需要下载的文件对应的MD5文件是否存在
-				String sd = s.substring(0 ,s.lastIndexOf(".")+1)+"md5";
-				String md5Path = updateSite + "/" + fileName + "/" + sd;
-				//判断需要下载的文件对应的MD5文件是否存在
-				if (!existHttpPath(md5Path)) {
-					throw new RuntimeException("需要更新的文件"+ requestPath + "的MD5文件不存在");
-				}
-				//读取远程md5文件中值
-				url = new URL(md5Path);
-				HttpURLConnection conn = (HttpURLConnection)url.openConnection();    
-				//设置超时间为5秒  
-				conn.setConnectTimeout(5*1000);  
-				//防止屏蔽程序抓取而返回403错误  
-				conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");  
-				//得到输入流  
-				inputStream = conn.getInputStream();    
-				//获取自己的输入流数组  
-				byte[] getData = readInputStream(inputStream);      
-				String md5Value = new String(getData);
-				//判断要保存的目录是否存在,不存在就创建
-				if(!saveDir.exists()){  
-					saveDir.mkdir();  
-				}  
-				File file = new File(saveDir + "/"  + s); 
-				if (file.exists()){
-					String fileMD5 = getFileMD5(file);
-					if (fileMD5.equals(md5Value)){
-						throw new RuntimeException("需要更新的文件"+ requestPath + "已经是最新的,暂时要不需要更新");
-					}
-					//如果元文件存在,且MD5值与远程不一样,移动原文件到old+time文件夹
-					boolean move1 = moveFileToDir(file, savePath + "/old" + dateStr);
-					if (!move1){
-						throw new RuntimeException("移动文件"+ file.getAbsolutePath() + "到old时出错");
-					}
-					//copyFile(file, saveDir + "/old" + dateStr);
-				}
-				if(!tempDir.exists()){  
-					tempDir.mkdir();  
-				}
-				//要更新的文件存在,并且改文件的MD5值与远程不一样
-				//或者要更新文件在本地不存在,执行更新操作
-					url = new URL(requestPath);
-					conn = (HttpURLConnection)url.openConnection();    
-					//设置超时间为5秒  
-					conn.setConnectTimeout(5*1000);  
-					//防止屏蔽程序抓取而返回403错误  
-					conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");  
-					//得到输入流  
-					inputStream = conn.getInputStream();    
-					//获取自己的输入流数组  
-					getData = readInputStream(inputStream);  
-					fos = new FileOutputStream(new File(tempDir + "/" + s));  
-					fos.write(getData);
-					inputStream.close();
-					fos.close();
-					String downloadFileMD5 = getFileMD5(new File(tempDir + "/" + s));
-					if (!downloadFileMD5.equals(md5Value)){
-						throw new RuntimeException("更新的文件"+ requestPath + "未下载完整,请重新更新");
-					}
-					//将temp中的新文件复制到指定目录并解压
-					boolean move2 = moveFileToDir(new File(tempDir + "/" + s), savePath);
-					if (!move2) {
-						throw new RuntimeException("从temp移动文件"+ requestPath + "到指定目录出错");
-					}
-					//copyFile(new File(tempDir + "/" + s), savePath);
-					if (s.substring(s.lastIndexOf(".")+1).equals("zip")) {
-						//将更新后的文件解压
-						unZipFiles(new File(saveDir + "//"  + s), savePath+"\\");
-					}
-				}
-			//unzipFromLoc(savePath);
-			} catch (MalformedURLException e) {
-				e.printStackTrace();
-			} catch (FileNotFoundException e) {
-				e.printStackTrace();
-			} catch (IOException e) {
-				e.printStackTrace();
-			} catch (Exception e) {
-				e.printStackTrace();
-			} finally {
-				if(fos!=null){  
-					try {
-						fos.close();
-					} catch (IOException e) {
-						e.printStackTrace();
-					}    
-				}  
-				if(inputStream!=null){  
-					try {
-						inputStream.close();
-					} catch (IOException e) {
-						e.printStackTrace();
-					}  
-				} 
-			}   
-	}
-	
-	
- 	
-	  /** 
-     * 解压文件到指定目录 
-     * 解压后的文件名,和之前一致 
-     * @param zipFile   待解压的zip文件 
-     * @param descDir   指定目录 
-     */  
-    public static void unZipFiles(File zipFile, String descDir) {  
-        ZipFile zip = null;
-        InputStream in = null;
-        FileOutputStream out = null;
-		try {
-			zip = new ZipFile(zipFile, Charset.forName("gbk"));
-			String name = zip.getName().substring(zip.getName().lastIndexOf('\\')+1, zip.getName().lastIndexOf('.'));  
-			File pathFile = new File(descDir+name); 
-			//判断解压到的目录是否存在,存在则清空并删除
-			if (pathFile.exists() && pathFile.isDirectory()) { 
-				deleteAllFile(pathFile);
-			}
-			//不存在就创建后解压
-			pathFile.mkdirs();
-			
-			for (Enumeration<? extends ZipEntry> entries = zip.entries(); entries.hasMoreElements();) {  
-				ZipEntry entry = (ZipEntry) entries.nextElement();  
-				String zipEntryName = entry.getName();  
-				in = zip.getInputStream(entry);  
-				String outPath = (descDir + name +"/"+ zipEntryName).replaceAll("\\*", "/");  
-				// 判断路径是否存在,不存在则创建文件路径  
-				File file = new File(outPath.substring(0, outPath.lastIndexOf('/')));  
-				if (!file.exists()) {  
-					file.mkdirs();  
-				}  
-				// 判断文件全路径是否为文件夹,如果是,不需要解压  
-				 if (new File(outPath).isDirectory()) {  
-                	continue;  
-            	} 
-				
-				out = new FileOutputStream(outPath);  
-				byte[] buf1 = new byte[1024];  
-				int len;  
-				while ((len = in.read(buf1)) > 0) {  
-					out.write(buf1, 0, len);  
-				}  
-			}  
-			logger.debug("解压完毕"); 
-		} catch (IOException e) {
-			e.printStackTrace();
-		}finally {
-			if (in != null){
-				try {
-					in.close();
-				} catch (IOException e) {
-					e.printStackTrace();
-				}
-			}
-			if (out != null){
-				try {
-					in.close();
-				} catch (IOException e) {
-					e.printStackTrace();
-				}
-			}
-		}
-    }  
-    
-    /**
-     * 清空并删除指定目录
-     * @param filePath
-     */
-    public static void deleteAllFile(File file){
-    	File[] listFiles = file.listFiles();
-    	if (listFiles.length == 0){
-    		file.delete();
-    	}else{
-    		for (File f : listFiles) {
-    			if(f.isDirectory()){
-    				deleteAllFile(f);
-    			}else{
-    				f.delete();
-    			}
-    		}
-    		file.delete();
-    	}
-    }
-    
-    /**
-     * 读取指定文件的MD5值
-     * @param file
-     * @return
-     */
-    public static String getFileMD5(File file) {
-        if (!file.isFile()) {
-            return null;
-        }
-        MessageDigest digest = null;
-        FileInputStream in = null;
-        byte buffer[] = new byte[2014];
-        int len;
-        try {
-            digest =MessageDigest.getInstance("MD5");
-            in = new FileInputStream(file);
-            while ((len = in.read(buffer)) != -1) {
-                digest.update(buffer, 0, len);
-            }
-            BigInteger bigInt = new BigInteger(1, digest.digest());
-            return bigInt.toString(16);
-        } catch (Exception e) {
-            e.printStackTrace();
-            return null;
-        } finally {
-        	if (in != null){
-        		try {
-        			in.close();
-        		} catch (Exception e) {
-        			e.printStackTrace();
-        		}
-        	}
-        }
-    }
-    
-    /**
-     * 复制文件到指定文件夹下
-     * @param oldPath
-     * @param newPath
-     * @throws IOException
-     */
-    public static void copyFile(File file, String newPath) {
-        File newDir = new File(newPath);
-        if (!newDir.exists()){
-        	newDir.mkdirs();
-        }
-        File newFile = new File(newPath + "/" + file.getName());
-        FileInputStream in = null;
-        FileOutputStream out = null;
-		try {
-			in = new FileInputStream(file);
-			out = new FileOutputStream(newFile);;
-			byte[] buffer=new byte[2097152];
-			
-			while((in.read(buffer)) != -1){
-				out.write(buffer);
-			}
-			
-		} catch (FileNotFoundException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}finally {
-			if (in != null){
-				try {
-					in.close();
-				} catch (IOException e) {
-					e.printStackTrace();
-				}
-			}
-			if (out != null){
-				try {
-					out.close();
-				} catch (IOException e) {
-					e.printStackTrace();
-				}
-			}
-		}
-    }
-    
-    /**
-     * 移动指定文件到指定目录下
-     */
-    public static boolean moveFileToDir(File file, String dirPath){
-    	boolean flag;
-    	File saveDir = new File(dirPath);
-    	if (!saveDir.exists()){
-    		saveDir.mkdirs();
-    	}
-    	flag = file.renameTo(new File(saveDir+"/"+file.getName()));
-    	return flag;
-    }
-    
-	
-}

+ 3 - 2
src/main/java/com/leanwo/management/service/FileService.java

@@ -12,11 +12,12 @@ import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class FileService {
 
-	private static Logger logger = Logger.getLogger(FileService.class);
+	private static Logger logger = LoggerFactory.getLogger(FileService.class);
 
 	
 	public List<File> getFileList(String fullPath) {

+ 0 - 51
src/main/java/com/leanwo/management/service/HttpService.java

@@ -1,51 +0,0 @@
-package com.leanwo.management.service;
-
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.http.client.SimpleClientHttpRequestFactory;
-import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.web.client.RestTemplate;
-
-import com.leanwo.management.model.ApplicationSetting;
-
-/**
- * HTTP 状态服务
- * @author YangZhiJie1
- *
- */
-public class HttpService implements StatusService {
-	
-	/**
-	 * 获取服务器的状态
-	 * @param setting
-	 * @return true: 运行中 false: 不在运行
-	 */
-	@Override
-	public Boolean getStatus(ApplicationSetting setting) {
-		// 监控各个服务程序是否正在运行
-		String url = setting.getMonitorUrl();
-		String token = setting.getToken();
-		if(url == null || "".equals(url) || token == null || "".equals(token)){
-			return false;
-		}
-		RestTemplate restTemplate = new RestTemplate();		
-		restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
-		HttpHeaders headers = new HttpHeaders();
-		headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
-		headers.add("account", "2");
-		headers.add("token", token);
-		HttpEntity entity = new HttpEntity(headers);
-		try{			
-			ResponseEntity<Long> response = restTemplate.exchange(url, HttpMethod.GET, entity, Long.class);
-			((SimpleClientHttpRequestFactory)restTemplate.getRequestFactory()).setReadTimeout(1000*30);
-			((SimpleClientHttpRequestFactory)restTemplate.getRequestFactory()).setConnectTimeout(1000*30);
-			Long result = response.getBody();
-			return true;
-		}catch(Exception ex){
-			return false;
-		}
-	}
-}

+ 3 - 2
src/main/java/com/leanwo/management/service/ProcessService.java

@@ -5,7 +5,8 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.List;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.leanwo.management.ServerLogFrame;
 import com.leanwo.management.model.ApplicationSetting;
@@ -17,7 +18,7 @@ import com.leanwo.management.model.ApplicationSetting;
  */
 public class ProcessService implements StatusService {
 	
-	private static Logger logger = Logger.getLogger(ProcessService.class);
+	private static Logger logger = LoggerFactory.getLogger(ProcessService.class);
 	
 	/**
 	 * 启动新的程序

+ 3 - 2
src/main/java/com/leanwo/management/util/CloseableUtil.java

@@ -3,7 +3,8 @@ package com.leanwo.management.util;
 import java.io.Closeable;
 import java.io.IOException;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * 需关闭资源工具类
@@ -11,7 +12,7 @@ import org.apache.log4j.Logger;
  *
  */
 public class CloseableUtil {
-	private final static Logger logger = Logger.getLogger(CloseableUtil.class);
+	private final static Logger logger = LoggerFactory.getLogger(CloseableUtil.class);
 
 	/**
 	 * 关闭资源

+ 23 - 0
src/main/java/com/leanwo/management/util/LogUtil.java

@@ -0,0 +1,23 @@
+package com.leanwo.management.util;
+
+import java.io.File;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.LoggerContext;
+
+/**
+ * 日志初始化
+ * @author YangZhiJie
+ *
+ */
+public class LogUtil {
+	/**
+	 * 初始化
+	 */
+	public static void init() {
+		LoggerContext logContext = (LoggerContext) LogManager.getContext(false);
+		File conFile = new File("config/log4j2.xml");
+		logContext.setConfigLocation(conFile.toURI());
+		logContext.reconfigure();
+	}
+}

+ 0 - 67
src/main/java/com/leanwo/management/util/ProgramAutoStartUtil.java

@@ -1,67 +0,0 @@
-package com.leanwo.management.util;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileWriter;
-import java.io.IOException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * 程序启动通用类
- * 
- * @author YangZhiJie
- *
- */
-public class ProgramAutoStartUtil {
-	private static Log logger = LogFactory.getLog(ProgramAutoStartUtil.class);
-
-	/**
-	 * 生成停止程序的BAT文件
-	 */
-	public static void generateStartBat() {
-		File file = new File("autoStart.bat");
-		if (file.exists() == false) {
-			try {
-				file.createNewFile();
-			} catch (IOException e) {
-				logger.error("autoStart.bat文件创建失败.");
-				e.printStackTrace();
-			}
-		}
-
-		logger.info("autoStart.bat文件的路径如下:" + file.getAbsolutePath());
-
-		try {
-			BufferedWriter out = new BufferedWriter(new FileWriter(file, false));
-			String path = file.getAbsolutePath().replace(File.separatorChar + file.getName(), "");
-			
-			String command = "title Server Management\r\n";
-			command += ("CD " + path + "\r\n");
-			String diskName = path.substring(0, path.indexOf(":") + 1);
-			command += (diskName + "\r\n");
-			
-
-			File pathFolder = new File(path);
-			File[] files = pathFolder.listFiles(new FileFilter() {
-				@Override
-				public boolean accept(File pathname) {
-					if (pathname.isFile() && pathname.getName().endsWith(".jar")) {
-						return true;
-					}
-					return false;
-				}
-			});
-			
-			if(files != null && files.length > 0) {
-				command += ("start javaw -jar " + files[0].getName() + " autoRun");
-			}
-			out.write(command);
-			out.close();
-		} catch (IOException e) {
-			logger.error("autoStart.bat文件写入失败。");
-		}
-	}
-}

+ 0 - 67
src/main/java/com/leanwo/management/util/ProgramStartUtil.java

@@ -1,67 +0,0 @@
-package com.leanwo.management.util;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileWriter;
-import java.io.IOException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * 程序启动通用类
- * 
- * @author YangZhiJie
- *
- */
-public class ProgramStartUtil {
-	private static Log logger = LogFactory.getLog(ProgramStartUtil.class);
-
-	/**
-	 * 生成停止程序的BAT文件
-	 */
-	public static void generateStartBat() {
-		File file = new File("start.bat");
-		if (file.exists() == false) {
-			try {
-				file.createNewFile();
-			} catch (IOException e) {
-				logger.error("start.bat文件创建失败.");
-				e.printStackTrace();
-			}
-		}
-
-		logger.info("start.bat文件的路径如下:" + file.getAbsolutePath());
-
-		try {
-			BufferedWriter out = new BufferedWriter(new FileWriter(file, false));
-			String path = file.getAbsolutePath().replace(File.separatorChar + file.getName(), "");
-			
-			String command = "title Server Management\r\n";
-			command += ("CD " + path + "\r\n");
-			String diskName = path.substring(0, path.indexOf(":") + 1);
-			command += (diskName + "\r\n");
-			
-
-			File pathFolder = new File(path);
-			File[] files = pathFolder.listFiles(new FileFilter() {
-				@Override
-				public boolean accept(File pathname) {
-					if (pathname.isFile() && pathname.getName().endsWith(".jar")) {
-						return true;
-					}
-					return false;
-				}
-			});
-			
-			if(files != null && files.length > 0) {
-				command += ("javaw -jar " + files[0].getName());
-			}
-			out.write(command);
-			out.close();
-		} catch (IOException e) {
-			logger.error("start.bat文件写入失败。");
-		}
-	}
-}

+ 0 - 255
src/main/java/com/leanwo/management/util/XmlConfigPathService.java

@@ -1,255 +0,0 @@
-package com.leanwo.management.util;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.dom4j.Attribute;
-import org.dom4j.Document;
-import org.dom4j.DocumentException;
-import org.dom4j.DocumentHelper;
-import org.dom4j.Element;
-import org.dom4j.io.OutputFormat;
-import org.dom4j.io.SAXReader;
-import org.dom4j.io.XMLWriter;
-
-import com.leanwo.management.exception.ConfigFileException;
-import com.leanwo.management.model.ApplicationSetting;
-import com.leanwo.management.model.XmlConfigPath;
-
-public class XmlConfigPathService {
-	
-	
-	
-
-	/**
-	 * 从文件中加载ApplicationSetting中的
-	 * 从config/config.properteis文件中加载portNo,token属性
-	 * 从xml配中获取node 的数据
-	 * ,contents等属性
-	 * @param setting
-	 * @throws ConfigFileException 
-	 */
-	public void load(ApplicationSetting setting) throws ConfigFileException {
-		Map<String, String> contentMap = new HashMap<String, String>();
-		XmlConfigPath xmlConfigPath = setting.getXmlConfigPath();
-		String xmlFilePath = setting.getInstallPath() + "\\" + xmlConfigPath.getXmlFileName();
-		File file = new File(xmlFilePath);
-		if (file.exists()) {
-			try {
-				
-				SAXReader reader = new SAXReader();  
-				Document document = reader.read(file);
-				Element root = document.getRootElement();
-				List<String> nodeNames = xmlConfigPath.getNodeNames();
-				for (String s : nodeNames) {
-					Element dataSource = parse(root , "id" , s);
-					if (dataSource == null) {
-						throw new ConfigFileException("在文件:"+xmlFilePath+",中未找到id="+s+"的标签");
-					}
-					String asXML = dataSource.asXML();
-					String result = asXML.substring(asXML.indexOf(">") + 1 , asXML.lastIndexOf("<"));
-					/*StringBuilder sb = new StringBuilder();
-					List<Element> propertys = dataSource.elements();
-					for (Element e : propertys) {
-						int i = 1;
-						List<Attribute> attributes = e.attributes();
-						for (Attribute a : attributes) {
-							if(i == 1) {
-								sb.append(a.getStringValue());
-							}else{
-								sb.append("=").append(a.getStringValue()).append(",");
-							}
-							i++;
-						}
-					}
-					contentMap.put(s, sb.toString());*/
-					contentMap.put(s, result);
-				}
-			} catch (DocumentException e) {
-				e.printStackTrace();
-			} 
-		}else{
-			throw new ConfigFileException("文件:"+xmlFilePath+",不存在");
-		}
-		//读取propertis信息
-		String propertiesPath = setting.getInstallPath()+"/config/config.properties";
-		Properties properties = new Properties();
-		File file2 = new File(propertiesPath);
-		Integer port = null;
-		String token = "";
-		InputStream in = null;
-		if (file2.exists()) {
-			try {
-				in = new BufferedInputStream(new FileInputStream(file2));
-				properties.load(in);
-				port = Integer.parseInt(properties.getProperty("port"));
-				token = properties.getProperty("token");
-			} catch (FileNotFoundException e) {
-				e.printStackTrace();
-			} catch (IOException e) {
-				e.printStackTrace();
-			}finally {
-				if(in != null){
-					try {
-						in.close();
-					} catch (IOException e) {
-						e.printStackTrace();
-					}
-				}
-			} 
-		}else{
-			throw new ConfigFileException("文件:"+propertiesPath+",不存在");
-		}
-		if(xmlConfigPath != null) {
-			xmlConfigPath.setPortNo(port);
-			xmlConfigPath.setToken(token);
-			xmlConfigPath.setContents(contentMap);
-		}
-	}
-	
-	
-	/**
-	 * 获得X属性结果是X值的整个标签
-	 */
-	public static Element parse(Element node , String type , String val) {
-	    for (Iterator iter = node.elementIterator(); iter.hasNext();) {
-	        Element element = (Element) iter.next();
-	        Attribute name = element.attribute(type);
-	        if (name != null) {
-	            String value = name.getValue();
-	            if (value != null && val.equals(value))
-	                return element;
-	            else
-	                parse(element , type , val);
-	        }
-	    }
-	    return null;
-	}
-	
-	
-	
-	/**
-	 * 将ApplicationSetting的属性portNo,token保存到config/config.properteis文件中
-	 * 从xml配中获取node 的数据
-	 * ,contents保存到文件
-	 * @param setting
-	 * @throws ConfigFileException 
-	 */
-	public void save(ApplicationSetting setting) throws ConfigFileException {
-		XmlConfigPath xmlConfigPath = setting.getXmlConfigPath();
-		Map<String, String> contents = xmlConfigPath.getContents();
-		//目标xml文件路径
-		String xmlFilePath = setting.getInstallPath() + "/" + xmlConfigPath.getXmlFileName();
-		//目标文件对象
-		File file = new File(xmlFilePath);
-		XMLWriter writer = null;// 声明写XML的对象  
-		if (file.exists()) {
-			try {
-		        SAXReader reader = new SAXReader();  
-		        OutputFormat format = OutputFormat.createPrettyPrint();  
-		        format.setEncoding("utf-8");// 设置XML文件的编码格式  
-				Document document = reader.read(file);
-				Element root = document.getRootElement();
-				List<String> nodeNames = xmlConfigPath.getNodeNames();
-				for (String s : nodeNames) {
-					Element dataSource = parse(root , "id" , s);
-					if (dataSource == null) {
-						throw new ConfigFileException("在文件:"+xmlFilePath+",中未找到id="+s+"的标签");
-					}
-					//清空bean节点
-					dataSource.clearContent();
-					String xmlText = contents.get(s).replaceAll("\n|\t", "");
-					//将xml文本转换为document对象
-					Document parseText = DocumentHelper.parseText("<myroot>" + xmlText.trim() + "</myroot>");
-					Element rootElement = parseText.getRootElement();
-					//将文本节点写入目标xml的节点下
-					dataSource.setContent(rootElement.content());
-					writer = new XMLWriter(new FileWriter(file), format);  
-					writer.write(document);  
-					/*List<Element> dataSources = dataSource.elements();
-					for (Element e : dataSources) {
-						dataSource.remove(e);
-					}*/
-					/*List<Element> elements = rootElement.elements();
-					for (Element e : elements) {
-						dataSource.addElement("property");
-						
-					}*/
-					//dataSource.addCDATA(contents.get(s));
-					//dataSource.addText(contents.get(s));
-					//dataSource.setText("<![CDATA["+contents.get(s)+"]]>");
-					 
-				}
-               
-				} catch (DocumentException e) {
-					e.printStackTrace();
-				} catch (IOException e) {
-					e.printStackTrace();
-				}finally {
-					if (writer != null){
-						try {
-							writer.close();
-						} catch (IOException e) {
-							e.printStackTrace();
-						}
-					}
-				}
-			}
-		
-		
-			//设置propertis信息
-				String propertiesPath = setting.getInstallPath()+"/config/config.properties";
-				Properties properties = new Properties();
-				File file2 = new File(propertiesPath);
-				Integer port = xmlConfigPath.getPortNo();
-				String token = xmlConfigPath.getToken();
-				OutputStream out = null;
-				if (file2.exists()) {
-					try {
-						out = new BufferedOutputStream(new FileOutputStream(file2));
-						properties.setProperty("token", token);
-						properties.setProperty("port", port.toString());
-						properties.store(out, "修改");
-					} catch (FileNotFoundException e) {
-						e.printStackTrace();
-					} catch (IOException e) {
-						e.printStackTrace();
-					}finally {
-						if (writer != null) {
-							try {
-								writer.close();
-							} catch (IOException e) {
-								e.printStackTrace();
-							}
-						}
-						if(out != null){
-							try {
-								out.close();
-							} catch (IOException e) {
-								e.printStackTrace();
-							}
-						}
-					} 
-				}else{
-					throw new RuntimeException("文件:"+propertiesPath+",不存在");
-				}
-	}
-	
-	
-	
-	
-	
-}

+ 0 - 1
src/main/resources/commons-logging.properties

@@ -1 +0,0 @@
-org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

+ 0 - 12
src/main/resources/log4j.properties

@@ -1,12 +0,0 @@
-log4j.rootLogger=INFO, A1 ,R 
-
-log4j.appender.A1=org.apache.log4j.ConsoleAppender 
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout 
-log4j.appender.A1.layout.ConversionPattern=%-d{yyyy-MM-dd HH\:mm\:ss} [%c]-[%p] %m%n
-
-log4j.appender.R=org.apache.log4j.RollingFileAppender 
-log4j.appender.R.File=logs/server-management.log
-log4j.appender.R.MaxFileSize=500KB
-log4j.appender.R.MaxBackupIndex=10000
-log4j.appender.R.layout=org.apache.log4j.PatternLayout 
-log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n