com.acgist.main.Application Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snail Show documentation
Show all versions of snail Show documentation
基于Java开发的下载工具,支持下载协议:BT(BitTorrent、磁力链接、种子文件)、HLS(M3U8)、FTP、HTTP。
package com.acgist.main;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.acgist.snail.gui.main.MainWindow;
import com.acgist.snail.gui.menu.TrayMenu;
import com.acgist.snail.system.context.SystemContext;
import com.acgist.snail.system.context.SystemThreadContext;
import javafx.application.Platform;
/**
* Snail系统启动类。
* Snail(蜗牛)是一款下载软件,支持下载协议:BT、FTP、HTTP。
*
* @author acgist
* @since 1.0.0
*/
public class Application {
private static final Logger LOGGER = LoggerFactory.getLogger(Application.class);
/**
* 启动
*/
public static final void main(String[] args) {
LOGGER.info("系统开始启动");
SystemContext.info();
final boolean enable = listen();
if(enable) {
buildContext();
buildWindow();
}
LOGGER.info("系统启动完成");
}
/**
* 启动系统监听
*/
private static final boolean listen() {
return SystemContext.listen();
}
/**
* 初始化系统上下文
*/
private static final void buildContext() {
SystemContext.init();
}
/**
* 初始化JavaFX平台
*/
private static final void buildWindow() {
LOGGER.info("初始化窗口");
final Thread thread = new Thread();
thread.setName(SystemThreadContext.SNAIL_THREAD_PLATFORM);
thread.setDaemon(true);
Platform.startup(thread);
Platform.runLater(() -> {
TrayMenu.getInstance();
MainWindow.getInstance().show();
});
}
}