/**
* JabRef MainClass
*/
public class JabRefMain extends Application {
/*
Application类Life-cycle :
The entry point for JavaFX applications is the Application class. The JavaFX runtime does the following, in order, whenever an application is launched:
1. Constructs an instance of the specified Application class
2. Calls the init method
3. Calls the start method
4. Waits for the application to finish, which happens when either of the following occur:
- the application calls Platform.exit
- the last window has been closed and the implicitExit attribute on Platform is true
5. Calls the stop method
*/
//用户的logger?###
private static final Logger LOGGER = LoggerFactory.getLogger(JabRefMain.class);
//一个字符数组,关于命令的字符串
private static String[] arguments;
//关注launch,查询了关于application的lifecircle,执行次序是,创建实例,init函数,start函数(必须重写),关闭
public static void main(String[] args) {
arguments = args;
launch(arguments);
}
@Override
public void start(Stage mainStage) throws Exception {
try {
// Fail on unsupported Java versions 确保版本为java8
ensureCorrectJavaVersion();
FallbackExceptionHandler.installExceptionHandler();
// Init preferences 加载配置文件?
final JabRefPreferences preferences = JabRefPreferences.getInstance();
Globals.prefs = preferences;
// Perform migrations 首选项偏移?或许是个性化设置?
PreferencesMigrations.runMigrations();
//配置代理?
configureProxy(preferences.getProxyPreferences());
Globals.startBackgroundTasks();
applyPreferences(preferences);
// Process arguments 处理参数
//这个类可以处理从文本框输入的查询语句并给出结果,可以打开文件并显示打开结果
ArgumentProcessor argumentProcessor = new ArgumentProcessor(arguments, ArgumentProcessor.Mode.INITIAL_START);
// Check for running JabRef 首先查看是否之前有正在运行的jabref,是否能联系上(关闭
if (!handleMultipleAppInstances(arguments) || argumentProcessor.shouldShutDown()) {
Platform.exit();//退出程序
return;
}
// If not, start GUI 大致的修改代码的部分应该在gui函数里
new JabRefGUI(mainStage, argumentProcessor.getParserResults(), argumentProcessor.isBlank());
} catch (Exception ex) {
LOGGER.error("Unexpected exception", ex);
}
}
@Override
public void stop() {
Globals.stopBackgroundTasks();//停掉后台的任务
Globals.shutdownThreadPools();
}
JabRef main函数 注释
最新推荐文章于 2022-04-17 16:34:06 发布
本文详细解析了JabRef软件的主要入口函数,包括其核心功能和逻辑流程,帮助读者理解JabRef的启动过程和工作原理。
摘要由CSDN通过智能技术生成