0.2.5b fix

1.bug修复
This commit is contained in:
jianguo 2024-05-23 15:23:53 +08:00
parent 7653f15af1
commit 667fa242d3
4 changed files with 12 additions and 13 deletions

View File

@ -6,7 +6,7 @@
<groupId>org.aohe</groupId> <groupId>org.aohe</groupId>
<artifactId>sane-service</artifactId> <artifactId>sane-service</artifactId>
<version>0.2.5</version> <version>0.2.5-b</version>
<properties> <properties>
<maven.compiler.source>21</maven.compiler.source> <maven.compiler.source>21</maven.compiler.source>

View File

@ -4,7 +4,7 @@ import java.io.IOException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.aohe.core.sane.utils.SaneSessionUtils; import org.aohe.core.sane.utils.SaneSessionUtils;
import org.aohe.core.swing.LogWindow; import org.aohe.core.swing.MainWindow;
import org.aohe.core.utils.CommandUtils; import org.aohe.core.utils.CommandUtils;
import org.aohe.core.utils.SystemUtils; import org.aohe.core.utils.SystemUtils;
import org.aohe.core.web.SocketFactory; import org.aohe.core.web.SocketFactory;
@ -25,7 +25,7 @@ public class Main {
} }
//初始化其他资源 //初始化其他资源
init(); init();
SwingUtilities.invokeLater(() -> new LogWindow().setVisible(true)); SwingUtilities.invokeLater(() -> new MainWindow().setVisible(true));
} }

View File

@ -5,16 +5,15 @@ import org.aohe.core.web.SocketFactory;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.net.UnknownHostException;
@Slf4j @Slf4j
public class LogWindow extends JFrame { public class MainWindow extends JFrame {
private static boolean serviceStatus = false; private static boolean serviceStatus = false;
private static JTextArea logTextArea; private static JTextArea logTextArea;
public LogWindow() { public MainWindow() {
// 设置窗口标题 // 设置窗口标题
setTitle("扫描仪控制器"); setTitle("扫描仪控制器");
@ -44,7 +43,8 @@ public class LogWindow extends JFrame {
getContentPane().add(scrollPane, BorderLayout.CENTER); getContentPane().add(scrollPane, BorderLayout.CENTER);
JLabel textField = new JLabel(); JLabel textField = new JLabel();
textField.setText("服务状态:" + getServiceStatus()); textField.setForeground(Color.GRAY);
textField.setText("服务状态:未知");
JPanel bottomPanel = new JPanel(); JPanel bottomPanel = new JPanel();
@ -58,6 +58,7 @@ public class LogWindow extends JFrame {
initSocket(); initSocket();
setView("服务已打开..."); setView("服务已打开...");
serviceStatus = true; serviceStatus = true;
textField.setForeground(Color.GREEN);
textField.setText("服务状态:" + getServiceStatus()); textField.setText("服务状态:" + getServiceStatus());
}); });
stopButton.addActionListener(e -> { stopButton.addActionListener(e -> {
@ -68,6 +69,7 @@ public class LogWindow extends JFrame {
stopSocket(); stopSocket();
serviceStatus = false; serviceStatus = false;
startButton.setEnabled(true); startButton.setEnabled(true);
textField.setForeground(Color.RED);
textField.setText("服务状态:" + getServiceStatus()); textField.setText("服务状态:" + getServiceStatus());
}).start(); }).start();
@ -91,7 +93,7 @@ public class LogWindow extends JFrame {
log.error("出错了 " , e); log.error("出错了 " , e);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
SwingUtilities.invokeLater(() -> new LogWindow().setVisible(true)); SwingUtilities.invokeLater(() -> new MainWindow().setVisible(true));
} }
public static String getServiceStatus() { public static String getServiceStatus() {

View File

@ -20,8 +20,6 @@ public class SocketFactory {
@Getter @Getter
private static SocketServer socketServer; private static SocketServer socketServer;
private static SocketFactory instance ;
private SocketFactory() { private SocketFactory() {
} }
@ -53,9 +51,8 @@ public class SocketFactory {
*/ */
public static void stop(){ public static void stop(){
try { try {
SocketServer server = getSocketServer(); if(socketServer != null){
if(server != null){ socketServer.stop();
server.stop();
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);