2024-05-13 14:41:54 +08:00
|
|
|
package org.aohe;
|
|
|
|
|
2024-05-29 14:41:24 +08:00
|
|
|
import com.formdev.flatlaf.FlatDarculaLaf;
|
2024-05-14 15:12:21 +08:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2024-05-21 16:52:55 +08:00
|
|
|
import org.aohe.core.sane.utils.SaneSessionUtils;
|
2024-05-29 14:41:24 +08:00
|
|
|
import org.aohe.core.swing.NewWindow;
|
2024-05-15 20:24:05 +08:00
|
|
|
import org.aohe.core.utils.CommandUtils;
|
2024-05-14 15:12:21 +08:00
|
|
|
import org.aohe.core.utils.SystemUtils;
|
2024-05-23 14:38:08 +08:00
|
|
|
import org.aohe.core.web.SocketFactory;
|
2024-05-15 20:24:05 +08:00
|
|
|
|
2024-05-23 14:38:08 +08:00
|
|
|
import javax.swing.*;
|
2024-05-14 15:12:21 +08:00
|
|
|
|
|
|
|
@Slf4j
|
2024-05-13 14:41:54 +08:00
|
|
|
public class Main {
|
2024-05-21 16:52:55 +08:00
|
|
|
|
2024-05-27 16:31:25 +08:00
|
|
|
public static void main(String[] args) {
|
2024-05-14 15:12:21 +08:00
|
|
|
log.info(" 当前系统类型: {}", SystemUtils.getOsName());
|
2024-05-23 14:38:08 +08:00
|
|
|
try {
|
|
|
|
//设置窗口主题
|
2024-05-28 13:53:31 +08:00
|
|
|
//FlatLightLaf.setup();
|
2024-05-29 14:41:24 +08:00
|
|
|
UIManager.setLookAndFeel(new FlatDarculaLaf());
|
2024-05-28 13:53:31 +08:00
|
|
|
} catch (UnsupportedLookAndFeelException e) {
|
2024-05-23 14:38:08 +08:00
|
|
|
throw new RuntimeException(e);
|
2024-05-15 20:24:05 +08:00
|
|
|
}
|
2024-05-23 14:38:08 +08:00
|
|
|
//初始化其他资源
|
|
|
|
init();
|
2024-05-29 14:41:24 +08:00
|
|
|
SwingUtilities.invokeLater(() -> new NewWindow().setVisible(true));
|
2024-05-23 14:38:08 +08:00
|
|
|
|
2024-05-13 14:41:54 +08:00
|
|
|
}
|
2024-05-21 16:52:55 +08:00
|
|
|
|
|
|
|
public static void init(){
|
|
|
|
log.info("程序初始化开始...");
|
|
|
|
CommandUtils.initSanedSocket();
|
|
|
|
stopGracefully();
|
|
|
|
log.info("Hook注册成功...");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void stopGracefully() {
|
|
|
|
log.info("优雅退出Hook注册");
|
|
|
|
//优雅退出,在程序停止时,销毁关键资源占用
|
|
|
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
2024-05-23 14:38:08 +08:00
|
|
|
log.info("开始资源释放");
|
|
|
|
//释放sane资源
|
|
|
|
SaneSessionUtils.resource();
|
|
|
|
SocketFactory.stop();
|
|
|
|
log.info("socket 服务已关闭 ");
|
2024-05-21 16:52:55 +08:00
|
|
|
}));
|
|
|
|
}
|
2024-05-13 14:41:54 +08:00
|
|
|
}
|