|
@@ -14,7 +14,6 @@ import java.awt.event.MouseAdapter;
|
|
|
import java.awt.event.MouseEvent;
|
|
import java.awt.event.MouseEvent;
|
|
|
import java.awt.event.WindowAdapter;
|
|
import java.awt.event.WindowAdapter;
|
|
|
import java.awt.event.WindowEvent;
|
|
import java.awt.event.WindowEvent;
|
|
|
-import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -24,15 +23,9 @@ import java.util.TimerTask;
|
|
|
import javax.imageio.ImageIO;
|
|
import javax.imageio.ImageIO;
|
|
|
import javax.swing.JButton;
|
|
import javax.swing.JButton;
|
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JFrame;
|
|
|
-import javax.swing.JMenu;
|
|
|
|
|
-import javax.swing.JMenuBar;
|
|
|
|
|
-import javax.swing.JMenu;
|
|
|
|
|
import javax.swing.JOptionPane;
|
|
import javax.swing.JOptionPane;
|
|
|
import javax.swing.JToolBar;
|
|
import javax.swing.JToolBar;
|
|
|
-import javax.swing.event.MenuEvent;
|
|
|
|
|
-import javax.swing.event.MenuListener;
|
|
|
|
|
|
|
|
|
|
-import org.apache.commons.exec.ExecuteWatchdog;
|
|
|
|
|
import org.apache.log4j.Logger;
|
|
import org.apache.log4j.Logger;
|
|
|
|
|
|
|
|
import com.leanwo.management.model.ApplicationSetting;
|
|
import com.leanwo.management.model.ApplicationSetting;
|
|
@@ -41,7 +34,6 @@ import com.leanwo.management.service.AutoUpdateService;
|
|
|
import com.leanwo.management.service.ProcessService;
|
|
import com.leanwo.management.service.ProcessService;
|
|
|
import com.leanwo.management.service.ProgramRunResult;
|
|
import com.leanwo.management.service.ProgramRunResult;
|
|
|
import com.leanwo.management.util.SpringUtil;
|
|
import com.leanwo.management.util.SpringUtil;
|
|
|
-import com.leanwo.management.widget.DefaultMenuListener;
|
|
|
|
|
import com.leanwo.management.widget.SelectEventListener;
|
|
import com.leanwo.management.widget.SelectEventListener;
|
|
|
import com.leanwo.management.widget.SelectObject;
|
|
import com.leanwo.management.widget.SelectObject;
|
|
|
|
|
|
|
@@ -93,6 +85,7 @@ public class MainFrame extends JFrame{
|
|
|
settings = applicationSettingCache.getSettings();
|
|
settings = applicationSettingCache.getSettings();
|
|
|
processService = (ProcessService) SpringUtil.getSingleBean(ProcessService.class);
|
|
processService = (ProcessService) SpringUtil.getSingleBean(ProcessService.class);
|
|
|
autoUpdateService = (AutoUpdateService) SpringUtil.getSingleBean(AutoUpdateService.class);
|
|
autoUpdateService = (AutoUpdateService) SpringUtil.getSingleBean(AutoUpdateService.class);
|
|
|
|
|
+ Thread.currentThread().setName("界面主线程");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void initView() {
|
|
private void initView() {
|
|
@@ -137,7 +130,6 @@ public class MainFrame extends JFrame{
|
|
|
serverLogFrame = new ServerLogFrame(settings);
|
|
serverLogFrame = new ServerLogFrame(settings);
|
|
|
add(serverLogFrame, BorderLayout.CENTER);
|
|
add(serverLogFrame, BorderLayout.CENTER);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
this.setTitle("Prodog程序管理器");
|
|
this.setTitle("Prodog程序管理器");
|
|
|
// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 设定按关闭时的操作,这里是关闭窗口,如果不设定,就什么也不会发生
|
|
// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 设定按关闭时的操作,这里是关闭窗口,如果不设定,就什么也不会发生
|
|
|
|
|
|
|
@@ -156,8 +148,6 @@ public class MainFrame extends JFrame{
|
|
|
|
|
|
|
|
// 设置窗体位置和大小
|
|
// 设置窗体位置和大小
|
|
|
this.setBounds((width - windowsWidth) / 2, (height - windowsHeight) / 2, windowsWidth, windowsHeight);
|
|
this.setBounds((width - windowsWidth) / 2, (height - windowsHeight) / 2, windowsWidth, windowsHeight);
|
|
|
-
|
|
|
|
|
- this.setVisible(true);
|
|
|
|
|
|
|
|
|
|
if(isAutoStart) {
|
|
if(isAutoStart) {
|
|
|
processService.autoStart(settings, serverLogFrame);
|
|
processService.autoStart(settings, serverLogFrame);
|
|
@@ -181,7 +171,7 @@ public class MainFrame extends JFrame{
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
ProgramRunResult programRunResult = processService.startProgram(setting);
|
|
ProgramRunResult programRunResult = processService.startProgram(setting);
|
|
|
- if(programRunResult == null || programRunResult.getWatchDog() == null) {
|
|
|
|
|
|
|
+ if(programRunResult == null || programRunResult.getProcess() == null) {
|
|
|
JOptionPane.showMessageDialog(null, "未配置启动文件或启动命令", "配置异常", JOptionPane.ERROR_MESSAGE);
|
|
JOptionPane.showMessageDialog(null, "未配置启动文件或启动命令", "配置异常", JOptionPane.ERROR_MESSAGE);
|
|
|
}else {
|
|
}else {
|
|
|
setting.setProgramRunResult(programRunResult);
|
|
setting.setProgramRunResult(programRunResult);
|
|
@@ -205,11 +195,11 @@ public class MainFrame extends JFrame{
|
|
|
ApplicationSetting setting = settings.get(selectedRow);
|
|
ApplicationSetting setting = settings.get(selectedRow);
|
|
|
try {
|
|
try {
|
|
|
ProgramRunResult programRunResult = setting.getProgramRunResult();
|
|
ProgramRunResult programRunResult = setting.getProgramRunResult();
|
|
|
- if(programRunResult != null && programRunResult.getWatchDog() != null) {
|
|
|
|
|
- programRunResult.getWatchDog().destroyProcess();
|
|
|
|
|
|
|
+ if(programRunResult != null && programRunResult.getProcess() != null) {
|
|
|
|
|
+ programRunResult.getProcess().destroyForcibly();
|
|
|
}
|
|
}
|
|
|
programRunResult = processService.stopProgram(setting);
|
|
programRunResult = processService.stopProgram(setting);
|
|
|
- if(programRunResult == null || programRunResult.getWatchDog() == null) {
|
|
|
|
|
|
|
+ if(programRunResult == null || programRunResult.getProcess() == null) {
|
|
|
JOptionPane.showMessageDialog(null, setting.getName() +"未配置停止文件", "程序关闭异常", JOptionPane.ERROR_MESSAGE);
|
|
JOptionPane.showMessageDialog(null, setting.getName() +"未配置停止文件", "程序关闭异常", JOptionPane.ERROR_MESSAGE);
|
|
|
}else {
|
|
}else {
|
|
|
setting.setProgramRunResult(null);
|
|
setting.setProgramRunResult(null);
|
|
@@ -292,11 +282,11 @@ public class MainFrame extends JFrame{
|
|
|
final ApplicationSetting setting = settings.get(i);
|
|
final ApplicationSetting setting = settings.get(i);
|
|
|
try {
|
|
try {
|
|
|
ProgramRunResult programRunResult = setting.getProgramRunResult();
|
|
ProgramRunResult programRunResult = setting.getProgramRunResult();
|
|
|
- if(programRunResult != null && programRunResult.getWatchDog() != null) {
|
|
|
|
|
- programRunResult.getWatchDog().destroyProcess();
|
|
|
|
|
|
|
+ if(programRunResult != null && programRunResult.getProcess() != null) {
|
|
|
|
|
+ programRunResult.getProcess().destroyForcibly();
|
|
|
}
|
|
}
|
|
|
programRunResult = processService.stopProgram(setting);
|
|
programRunResult = processService.stopProgram(setting);
|
|
|
- if(programRunResult == null || programRunResult.getWatchDog() == null) {
|
|
|
|
|
|
|
+ if(programRunResult == null || programRunResult.getProcess() == null) {
|
|
|
logger.error(setting.getName() + "程序关闭异常,未配置停止文件。");
|
|
logger.error(setting.getName() + "程序关闭异常,未配置停止文件。");
|
|
|
}else {
|
|
}else {
|
|
|
setting.setProgramRunResult(null);
|
|
setting.setProgramRunResult(null);
|
|
@@ -336,33 +326,29 @@ public class MainFrame extends JFrame{
|
|
|
protected void processWindowEvent(WindowEvent e) {
|
|
protected void processWindowEvent(WindowEvent e) {
|
|
|
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
|
|
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
|
|
|
//setVisible(false);
|
|
//setVisible(false);
|
|
|
- boolean result = false;
|
|
|
|
|
// 关闭其他子线程
|
|
// 关闭其他子线程
|
|
|
for(int i = 0; i < settings.size(); i ++) {
|
|
for(int i = 0; i < settings.size(); i ++) {
|
|
|
ApplicationSetting setting = settings.get(i);
|
|
ApplicationSetting setting = settings.get(i);
|
|
|
ProgramRunResult programRunResult = setting.getProgramRunResult();
|
|
ProgramRunResult programRunResult = setting.getProgramRunResult();
|
|
|
- if(programRunResult != null && programRunResult.getWatchDog() != null) {
|
|
|
|
|
- result = programRunResult.getWatchDog().killedProcess();
|
|
|
|
|
|
|
+ if(programRunResult != null && programRunResult.getProcess() != null) {
|
|
|
|
|
+ programRunResult.getProcess().destroyForcibly();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(result == false) {
|
|
|
|
|
- try {
|
|
|
|
|
- programRunResult = processService.stopProgram(setting);
|
|
|
|
|
- if(programRunResult == null || programRunResult.getWatchDog() == null) {
|
|
|
|
|
- logger.error("关闭程序失败" + setting.getName() +"未配置停止文件。");
|
|
|
|
|
- JOptionPane.showMessageDialog(null, "未配置停止文件", "配置异常", JOptionPane.ERROR_MESSAGE);
|
|
|
|
|
- }else {
|
|
|
|
|
- setting.setProgramRunResult(null);
|
|
|
|
|
- }
|
|
|
|
|
- } catch (IOException e1) {
|
|
|
|
|
- logger.error("关闭程序失败" + setting.getName(), e1);
|
|
|
|
|
- }
|
|
|
|
|
- }else {
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ programRunResult = processService.stopProgram(setting);
|
|
|
|
|
+ if(programRunResult == null || programRunResult.getProcess() == null) {
|
|
|
|
|
+ logger.error("关闭程序失败" + setting.getName() +"未配置停止文件。");
|
|
|
|
|
+ JOptionPane.showMessageDialog(null, "未配置停止文件", "配置异常", JOptionPane.ERROR_MESSAGE);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ setting.setProgramRunResult(null);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (IOException e1) {
|
|
|
|
|
+ logger.error("关闭程序失败" + setting.getName(), e1);
|
|
|
setting.setProgramRunResult(null);
|
|
setting.setProgramRunResult(null);
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- Timer timer = new Timer();
|
|
|
|
|
|
|
+ Timer timer = new Timer("定时器:延时关闭");
|
|
|
this.setEnabled(false);
|
|
this.setEnabled(false);
|
|
|
timer.schedule(new TimerTask() {
|
|
timer.schedule(new TimerTask() {
|
|
|
@Override
|
|
@Override
|