YangZhiJie 8 år sedan
incheckning
53df1fd668

+ 26 - 0
.classpath

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" 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">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

+ 4 - 0
.hgignore

@@ -0,0 +1,4 @@
+syntax: glob
+*.class
+target/*
+*.log

+ 23 - 0
.project

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>ServerManagement</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+	</natures>
+</projectDescription>

+ 4 - 0
.settings/org.eclipse.core.resources.prefs

@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding//src/test/java=UTF-8
+encoding/<project>=UTF-8

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

@@ -0,0 +1,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.source=1.8

+ 4 - 0
.settings/org.eclipse.m2e.core.prefs

@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1

+ 66 - 0
config/applicationContext.xml

@@ -0,0 +1,66 @@
+<?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:context="http://www.springframework.org/schema/context"
+	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
+	xsi:schemaLocation="
+	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
+	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
+	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
+	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd">
+
+	<!-- 自动扫描 -->
+	<context:component-scan base-package="com.leanwo" />
+
+
+	<bean id="applicationSettingCache" class="com.leanwo.management.model.ApplicationSettingCache">
+		<property name="settings">
+			<list>
+				<ref bean="applicationSetting1" />
+				<ref bean="applicationSetting2" />
+				<ref bean="applicationSetting3" />
+				<ref bean="applicationSetting4" />
+				<ref bean="applicationSetting5" />
+				<ref bean="applicationSetting6" />
+				<ref bean="applicationSetting7" />
+			</list>
+		</property>
+	</bean>
+
+	<bean id="applicationSetting1" class="com.leanwo.management.model.ApplicationSetting">
+		<property name="name" value="Prodog服务程序"></property>
+		<property name="startBatFile" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171212\start.bat"></property>
+		<property name="stopBatFile" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171212\stop.bat"></property>
+	</bean>
+	<bean id="applicationSetting2" class="com.leanwo.management.model.ApplicationSetting">
+		<property name="name" value="报表服务程序"></property>
+		<property name="startBatFile" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171212\start.bat"></property>
+		<property name="stopBatFile" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171212\stop.bat"></property>
+	</bean>
+	<bean id="applicationSetting3" class="com.leanwo.management.model.ApplicationSetting">
+		<property name="name" value="工作流服务程序"></property>
+		<property name="startBatFile" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171212\start.bat"></property>
+		<property name="stopBatFile" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171212\stop.bat"></property>
+	</bean>
+	<bean id="applicationSetting4" class="com.leanwo.management.model.ApplicationSetting">
+		<property name="name" value="钉钉服务程序"></property>
+		<property name="startBatFile" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171212\start.bat"></property>
+		<property name="stopBatFile" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171212\stop.bat"></property>
+	</bean>
+	<bean id="applicationSetting5" class="com.leanwo.management.model.ApplicationSetting">
+		<property name="name" value="微信服务程序"></property>
+		<property name="startBatFile" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171212\start.bat"></property>
+		<property name="stopBatFile" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171212\stop.bat"></property>
+	</bean>
+	<bean id="applicationSetting6" class="com.leanwo.management.model.ApplicationSetting">
+		<property name="name" value="中间件程序"></property>
+		<property name="startBatFile" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171212\start.bat"></property>
+		<property name="stopBatFile" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171212\stop.bat"></property>
+	</bean>
+	<bean id="applicationSetting7" class="com.leanwo.management.model.ApplicationSetting">
+		<property name="name" value="抓拍程序"></property>
+		<property name="startBatFile" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171212\start.bat"></property>
+		<property name="stopBatFile" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171212\stop.bat"></property>
+	</bean>
+	
+	<bean id="springUtil" class="org.leanwo.management.util.SpringUtil" />
+</beans>

+ 5 - 0
config/run.bat

@@ -0,0 +1,5 @@
+title Report Server
+set current_path="%cd%"
+cd %current_path%
+java -jar %current_path%\report-server-0.0.1-SNAPSHOT.jar
+pause

+ 167 - 0
pom.xml

@@ -0,0 +1,167 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+	<groupId>org.leanwo.server.management</groupId>
+	<artifactId>ServerManagement</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<packaging>jar</packaging>
+
+	<name>ServerManagement</name>
+	<url>http://maven.apache.org</url>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
+
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>3.8.1</version>
+			<scope>test</scope>
+		</dependency>
+
+
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<version>1.7.25</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-log4j12</artifactId>
+			<version>1.7.25</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-core</artifactId>
+			<version>5.0.1.RELEASE</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>
+		</dependency>
+		<dependency>
+		    <groupId>org.apache.commons</groupId>
+		    <artifactId>commons-exec</artifactId>
+		    <version>1.3</version>
+		</dependency>
+	</dependencies>
+	
+	
+	<build>
+		<plugins>
+	  		<plugin>
+	    		<groupId>org.apache.maven.plugins</groupId>
+	    		<artifactId>maven-compiler-plugin</artifactId>
+	    		<configuration>
+	      			<source>1.8</source>
+	      			<target>1.8</target>
+	    		</configuration>
+	  		</plugin>
+	  		
+	  		
+	  		<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-shade-plugin</artifactId>
+				<version>3.1.0</version>
+				<executions>
+					<execution>
+						<phase>package</phase>
+						<goals>
+							<goal>shade</goal>
+						</goals>
+						<configuration>
+							<filters>  
+                            	<filter>  
+	                                <artifact>*:*</artifact>  
+	                                <excludes>  
+	                                    <exclude>META-INF/*.SF</exclude>  
+	                                    <exclude>META-INF/*.DSA</exclude>  
+	                                    <exclude>META-INF/*.RSA</exclude>  
+	                                </excludes>  
+	                            </filter>  
+	                        </filters>
+							<transformers>
+								<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+									<resource>jasperreports_extension.properties</resource>
+								</transformer>
+								<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+									<resource>META-INF/spring.schemas</resource>
+								</transformer> 
+			                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">  
+			                        <resource>META-INF/spring.handlers</resource>  
+			                    </transformer>  
+								<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+									<manifestEntries>
+										<Main-Class>com.leanwo.report.server.ReportServerApp</Main-Class>
+									</manifestEntries>
+								</transformer>
+							</transformers>
+							<createDependencyReducedPom>false</createDependencyReducedPom>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-resources-plugin</artifactId>
+				<version>3.0.2</version>
+				<executions>
+					<execution>
+						<id>copy-resources-config</id>
+						<phase>package</phase>
+						<goals>
+							<goal>copy-resources</goal>
+						</goals>
+						<configuration>
+							<encoding>UTF-8</encoding>
+							<outputDirectory>${project.build.directory}/config
+							</outputDirectory>
+							<resources>
+								<resource>
+									<directory>config/</directory>
+									<excludes>
+										<exclude>*.bat</exclude>
+									</excludes>
+								</resource>
+							</resources>
+						</configuration>
+					</execution>
+					<execution>
+						<id>copy-resources-bat</id>
+						<phase>package</phase>
+						<goals>
+							<goal>copy-resources</goal>
+						</goals>
+						<configuration>
+							<encoding>UTF-8</encoding>
+							<outputDirectory>${project.build.directory}/
+							</outputDirectory>
+							<resources>
+								<resource>
+									<directory>config/</directory>
+									<includes>
+										<include>*.bat</include>
+									</includes>
+								</resource>
+							</resources>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			
+		</plugins>
+	</build>
+	
+</project>

+ 248 - 0
src/main/java/com/leanwo/management/ServerManagmentJFrame.java

@@ -0,0 +1,248 @@
+package com.leanwo.management;
+
+import java.awt.BorderLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.Timer;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecuteResultHandler;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteWatchdog;
+import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.leanwo.management.util.SpringUtil;
+
+import com.leanwo.management.model.ApplicationSetting;
+import com.leanwo.management.model.ApplicationSettingCache;
+
+/**
+ * 服务器管理界面
+ * 
+ * @author YangZhiJie
+ *
+ */
+public class ServerManagmentJFrame extends JFrame implements ActionListener {
+	private static Log logger = LogFactory.getLog(ServerManagmentJFrame.class);
+	
+	// 得到显示器屏幕的宽高
+	private int width = Toolkit.getDefaultToolkit().getScreenSize().width;
+	private int height = Toolkit.getDefaultToolkit().getScreenSize().height;
+
+	// 定义窗体的宽高
+	private int windowsWidth = 800;
+	private int windowsHeight = 400;
+
+	private JPanel jPanel = null;
+	private Timer timer;
+
+	private Map<ApplicationSetting, JLabel> statusLabels = null;
+	
+	public ServerManagmentJFrame() {
+		this.setLayout(new BorderLayout());
+		
+		jPanel = new JPanel(new GridBagLayout());
+		this.add(jPanel, BorderLayout.NORTH);
+        
+		this.setTitle("Prodog程序管理器");
+		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 设定按关闭时的操作,这里是关闭窗口,如果不设定,就什么也不会发生
+		// 设置窗体位置和大小
+		this.setBounds((width - windowsWidth) / 2, (height - windowsHeight) / 2, windowsWidth, windowsHeight);
+		
+		statusLabels = new HashMap<ApplicationSetting, JLabel>();
+		generateViewFromJson();
+		
+		this.setVisible(true); // 显示,如果不设置就什么都看不到
+		
+		timer = new Timer(1000,this);
+		timer.start();
+	}
+
+	public void generateViewFromJson() {
+		GridBagConstraints constrains = null;
+        
+		JLabel label = new JLabel("程序");
+        label.setBorder(BorderFactory.createEtchedBorder());
+		constrains = new GridBagConstraints();
+		constrains.insets = new Insets(0, 0, 0, 0);
+        constrains.fill = GridBagConstraints.BOTH;
+        constrains.gridx = 0;
+        constrains.gridy = 0;
+        constrains.weightx = 25;        
+        constrains.anchor = GridBagConstraints.NORTH;
+        jPanel.add(label, constrains);
+		
+		label = new JLabel("状态");
+        label.setBorder(BorderFactory.createEtchedBorder());
+		constrains = new GridBagConstraints();
+		constrains.insets = new Insets(0, 0, 0, 0);
+        constrains.fill = GridBagConstraints.BOTH;
+        constrains.gridx = 1;
+        constrains.gridy = 0;
+        constrains.weightx = 25;
+        constrains.anchor = GridBagConstraints.NORTH;
+        jPanel.add(label, constrains);
+		
+		label = new JLabel("启动");
+        label.setBorder(BorderFactory.createEtchedBorder());
+		constrains = new GridBagConstraints();
+		constrains.insets = new Insets(0, 0, 0, 0);
+        constrains.fill = GridBagConstraints.BOTH;
+        constrains.gridx = 2;
+        constrains.gridy = 0;
+        constrains.weightx = 10;        
+        constrains.anchor = GridBagConstraints.NORTH;
+        jPanel.add(label, constrains);
+		
+		label = new JLabel("关闭");
+        label.setBorder(BorderFactory.createEtchedBorder());
+		constrains = new GridBagConstraints();
+		constrains.insets = new Insets(0, 0, 0, 0);
+        constrains.fill = GridBagConstraints.BOTH;
+        constrains.gridx = 3;
+        constrains.gridy = 0;
+        constrains.weightx = 10;        
+        constrains.anchor = GridBagConstraints.NORTH;
+        jPanel.add(label, constrains);
+
+		ApplicationSettingCache applicationSettingCache = (ApplicationSettingCache) SpringUtil.getSingleBean(ApplicationSettingCache.class);
+		List<ApplicationSetting> settings = applicationSettingCache.getSettings();
+		if (settings != null && settings.size() > 0) {
+			for(int i = 0; i < settings.size(); i ++) {
+				int rowIndex = (i + 1);
+				final ApplicationSetting setting = settings.get(i);
+				
+				label = new JLabel(setting.getName());
+				constrains = new GridBagConstraints();
+				constrains.insets = new Insets(5, 5, 5, 5);
+		        constrains.fill = GridBagConstraints.BOTH;
+		        constrains.gridx = 0;
+		        constrains.gridy = rowIndex;
+		        constrains.weightx = 25;		        
+		        jPanel.add(label, constrains);
+				
+				
+				label = new JLabel(setting.getStatus());
+				constrains = new GridBagConstraints();
+				constrains.insets = new Insets(5, 5, 5, 5);
+		        constrains.fill = GridBagConstraints.BOTH;
+		        constrains.gridx = 1;
+		        constrains.gridy = rowIndex;
+		        constrains.weightx = 25;		        
+		        jPanel.add(label, constrains);
+		        
+		        statusLabels.put(setting, label);
+				
+				JButton startButton = new JButton("启动");
+				constrains = new GridBagConstraints();
+				constrains.insets = new Insets(5, 5, 5, 5);
+		        constrains.fill = GridBagConstraints.BOTH;
+		        constrains.gridx = 2;
+		        constrains.gridy = rowIndex;
+		        constrains.weightx = 10;		        
+		        jPanel.add(startButton, constrains);
+		        startButton.addActionListener(new ActionListener() {
+					@Override
+					public void actionPerformed(ActionEvent e) {
+						try {
+							ExecuteWatchdog executeWatchdog = runProcess(setting.getStartBatFile());
+							setting.setExecuteWatchdog(executeWatchdog);
+						} catch (IOException e1) {
+							e1.printStackTrace();
+						}
+					}
+				});
+				
+				JButton stopButton = new JButton("停止");
+				constrains = new GridBagConstraints();
+				constrains.insets = new Insets(5, 5, 5, 5);
+		        constrains.fill = GridBagConstraints.BOTH;
+		        constrains.gridx = 3;
+		        constrains.gridy = rowIndex;
+		        constrains.weightx = 10;		        
+		        jPanel.add(stopButton, constrains);
+		        stopButton.addActionListener(new ActionListener() {
+					@Override
+					public void actionPerformed(ActionEvent e) {
+						try {
+							ExecuteWatchdog executeWatchdog = runProcess(setting.getStopBatFile());
+							setting.setExecuteWatchdog(null);
+						} catch (IOException e1) {
+							e1.printStackTrace();
+						}
+					}
+				});
+			}
+		}
+	}
+	
+	/**
+	 * 运行流程
+	 * @param command "cmd.exe /c start c://example.exe"
+	 * @return
+	 * @throws IOException
+	 */
+	private ExecuteWatchdog runProcess(String command) throws IOException {
+		final CommandLine cmdLine = CommandLine.parse(command);
+		
+		final ExecuteWatchdog watchDog = new ExecuteWatchdog(Long.MAX_VALUE);
+		
+		final DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
+		DefaultExecutor executor = new DefaultExecutor();
+		executor.setWatchdog(watchDog);
+
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		executor.setStreamHandler(new PumpStreamHandler(baos, baos));
+
+		executor.execute(cmdLine, resultHandler);
+		
+		//等待5秒。
+		try {
+			resultHandler.waitFor(5000);
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+
+		//这里开始的代码会被立即执行下去,因为上面的语句不会被阻塞。
+		final String result = baos.toString().trim();
+		logger.debug(result);//这个result就是ping输出的结果。如果是JAVA程序,抛出了异常,也被它获取。
+		return watchDog;
+	}
+
+	@Override
+	public void actionPerformed(ActionEvent e) {
+		ApplicationSettingCache applicationSettingCache = (ApplicationSettingCache) SpringUtil.getSingleBean(ApplicationSettingCache.class);
+
+		List<ApplicationSetting> settings = applicationSettingCache.getSettings();
+		if (settings != null && settings.size() > 0) {
+			for(int i = 0; i < settings.size(); i ++) {
+				final ApplicationSetting setting = settings.get(i);
+				JLabel statusLabel = statusLabels.get(setting);
+				if(statusLabel != null) {
+					ExecuteWatchdog executeWatchdog = setting.getExecuteWatchdog();
+					if(executeWatchdog == null) {
+						statusLabel.setText("未运行");
+					}else{
+						statusLabel.setText("运行中");
+					}
+				}
+			}
+		}
+	}
+}

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

@@ -0,0 +1,126 @@
+package com.leanwo.management.model;
+
+import org.apache.commons.exec.ExecuteWatchdog;
+
+/**
+ * 应用程序实体类.
+ *
+ * @author YangZhiJie
+ */
+public class ApplicationSetting {
+	
+	/**
+	 * 应用程序名称.
+	 */
+	private String name;
+
+	/**
+	 * 应用程序状态.
+	 */
+	private String status;
+
+	/**
+	 * 启动程序BAT文件路径.
+	 */
+	private String startBatFile;
+
+	/**
+	 * 停止程序BAT文件路径.
+	 */
+	private String stopBatFile;
+	
+	/**
+	 * 
+	 */
+	private ExecuteWatchdog executeWatchdog;
+
+	/**
+	 * Gets the 应用程序名称.
+	 *
+	 * @return the 应用程序名称
+	 */
+	public String getName() {
+		return name;
+	}
+
+	/**
+	 * Sets the 应用程序名称.
+	 *
+	 * @param name the new 应用程序名称
+	 */
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	/**
+	 * Gets the 应用程序状态.
+	 *
+	 * @return the 应用程序状态
+	 */
+	public String getStatus() {
+		return status;
+	}
+
+	/**
+	 * Sets the 应用程序状态.
+	 *
+	 * @param status the new 应用程序状态
+	 */
+	public void setStatus(String status) {
+		this.status = status;
+	}
+
+	/**
+	 * Gets the 启动程序BAT文件路径.
+	 *
+	 * @return the 启动程序BAT文件路径
+	 */
+	public String getStartBatFile() {
+		return startBatFile;
+	}
+
+	/**
+	 * Sets the 启动程序BAT文件路径.
+	 *
+	 * @param startBatFile the new 启动程序BAT文件路径
+	 */
+	public void setStartBatFile(String startBatFile) {
+		this.startBatFile = startBatFile;
+	}
+
+	/**
+	 * Gets the 停止程序BAT文件路径.
+	 *
+	 * @return the 停止程序BAT文件路径
+	 */
+	public String getStopBatFile() {
+		return stopBatFile;
+	}
+
+	/**
+	 * Sets the 停止程序BAT文件路径.
+	 *
+	 * @param stopBatFile the new 停止程序BAT文件路径
+	 */
+	public void setStopBatFile(String stopBatFile) {
+		this.stopBatFile = stopBatFile;
+	}
+
+	/**
+	 * 
+	 *
+	 * @return 
+	 */
+	public ExecuteWatchdog getExecuteWatchdog() {
+		return executeWatchdog;
+	}
+
+	/**
+	 * 
+	 *
+	 * @param executeWatchdog 
+	 */
+	public void setExecuteWatchdog(ExecuteWatchdog executeWatchdog) {
+		this.executeWatchdog = executeWatchdog;
+	}
+}

+ 34 - 0
src/main/java/com/leanwo/management/model/ApplicationSettingCache.java

@@ -0,0 +1,34 @@
+package com.leanwo.management.model;
+
+import java.util.List;
+
+/**
+ * 应用程序缓存.
+ *
+ * @author YangZhiJie
+ */
+public class ApplicationSettingCache {
+	
+	/**
+	 * 应用程序集合.
+	 */
+	private List<ApplicationSetting> settings;
+
+	/**
+	 * Gets the 应用程序集合.
+	 *
+	 * @return the 应用程序集合
+	 */
+	public List<ApplicationSetting> getSettings() {
+		return settings;
+	}
+
+	/**
+	 * Sets the 应用程序集合.
+	 *
+	 * @param settings the new 应用程序集合
+	 */
+	public void setSettings(List<ApplicationSetting> settings) {
+		this.settings = settings;
+	}
+}

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

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

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

@@ -0,0 +1,12 @@
+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/report-server.log
+log4j.appender.R.MaxFileSize=500KB
+log4j.appender.R.MaxBackupIndex=1
+log4j.appender.R.layout=org.apache.log4j.PatternLayout 
+log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n 

+ 19 - 0
src/main/java/org/leanwo/management/ServerManagementApp.java

@@ -0,0 +1,19 @@
+package org.leanwo.management;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.FileSystemXmlApplicationContext;
+
+import com.leanwo.management.ServerManagmentJFrame;
+
+/**
+ * Hello world!
+ *
+ */
+public class ServerManagementApp {
+	public static void main(String[] args) {
+		ApplicationContext factory = new FileSystemXmlApplicationContext("config/applicationContext.xml");
+		ServerManagmentJFrame serverManagmentJFrame = new ServerManagmentJFrame();
+		
+		
+	}
+}

+ 18 - 0
src/main/java/org/leanwo/management/exception/BeanNotInjectException.java

@@ -0,0 +1,18 @@
+package org.leanwo.management.exception;
+
+/**
+ * Bean未注入异常
+ * @author YangZhiJie
+ * @version 20171213 1.0 *
+ */
+public class BeanNotInjectException extends RuntimeException {
+
+	public BeanNotInjectException() {
+		super();
+	}
+
+	public BeanNotInjectException(String message) {
+		super(message);
+	}
+	
+}

+ 80 - 0
src/main/java/org/leanwo/management/util/SpringUtil.java

@@ -0,0 +1,80 @@
+package org.leanwo.management.util;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.leanwo.management.exception.BeanNotInjectException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+
+public class SpringUtil implements ApplicationContextAware {
+	private static Log logger = LogFactory.getLog(SpringUtil.class);
+	private static ApplicationContext applicationContext;
+
+	@Override
+	public void setApplicationContext(ApplicationContext arg0) {
+		applicationContext = arg0;
+		String[] names = beanNames();
+		logger.info("IOC容器共管理:" + names.length + "个对象。");
+		logger.info("Spring容器初始化成功。");
+	}
+
+	public static ApplicationContext getApplicationContext() {
+		checkApplicationContext();
+		return applicationContext;
+	}
+
+	/**
+	 * 从静态变量ApplicationContext中取得Bean, 自动转型为所赋值对象的类型.
+	 */
+	@SuppressWarnings("unchecked")
+	public static <T> T getBean(String name) {
+		checkApplicationContext();
+		return (T) applicationContext.getBean(name);
+	}
+
+	/**
+	 * 从静态变量ApplicationContext中取得Bean, 自动转型为所赋值对象的类型.
+	 */
+	public static <T> T getBean(Class<T> clazz) {
+		checkApplicationContext();
+		return (T) applicationContext.getBeansOfType(clazz);
+	}
+
+	/**
+	 * 从静态变量ApplicationContext中取得Bean, 自动转型为所赋值对象的类型.
+	 */
+	public static Object getSingleBean(Class clazz) {
+		checkApplicationContext();
+		Map<String, Object> map = applicationContext.getBeansOfType(clazz);
+		if (map == null || map.size() == 0) {
+			throw new BeanNotInjectException(clazz.getName() + "未注入。");
+		} else if (map.size() > 1) {
+			throw new IllegalStateException(clazz.getName() + "存在" + map.size() + "个对象。");
+		} else {
+			Iterator iterator = map.entrySet().iterator();
+			Map.Entry entry = (Map.Entry) iterator.next();
+			return entry.getValue();
+		}
+	}
+
+	/**
+	 * 获取当前IOC所有Bean的名称
+	 * 
+	 * @return
+	 */
+	public static String[] beanNames() {
+		checkApplicationContext();
+		return applicationContext.getBeanDefinitionNames();
+
+	}
+
+	private static void checkApplicationContext() {
+		if (applicationContext == null) {
+			throw new IllegalStateException("applicaitonContext未注入,请在applicationContext.xml中定义SpringContextHolder");
+		}
+	}
+}

+ 38 - 0
src/test/java/org/leanwo/server/management/AppTest.java

@@ -0,0 +1,38 @@
+package org.leanwo.server.management;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest 
+    extends TestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public AppTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( AppTest.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testApp()
+    {
+        assertTrue( true );
+    }
+}