瀏覽代碼

系统:启动监听,按order先执行init,再执行run;

4.0
郑根木 2 年之前
父節點
當前提交
84d31f32c1
共有 4 個檔案被更改,包括 14 行新增2 行删除
  1. +5
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/BpmStartedListener.java
  2. +4
    -0
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/CoreApplicationStartedListener.java
  3. +1
    -1
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwConsts.java
  4. +4
    -1
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/controller/IStartListener.java

+ 5
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/BpmStartedListener.java 查看文件

@@ -28,6 +28,11 @@ public class BpmStartedListener implements IStartListener {
}

@Override
public void init() {
SwConsts.SysParam.RUN_PROJECTS = "bpm";
}

@Override
public void run() {
//初始化数据库
new DatabaseUtil(true, false).checkDb();


+ 4
- 0
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/CoreApplicationStartedListener.java 查看文件

@@ -33,9 +33,13 @@ public class CoreApplicationStartedListener implements ApplicationListener<Appli
applicationContext.publishEvent(new TaskStartEvent());
//包扫描
ApplicationScanner.scan(applicationContext);

List<IStartListener> list = BeanManager.getInstance().getStartListeners();
list.sort(Comparator.comparingInt(IStartListener::order));
for (IStartListener sl : list) {
sl.init();
}
for (IStartListener sl : list) {
sl.run();
}
// 通知 controller 正式使用


+ 1
- 1
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwConsts.java 查看文件

@@ -10,7 +10,7 @@ public interface SwConsts {
//系统启动完成
public static boolean SYS_STARTED = false;
//运行的项目,多个用半角逗号分隔
public static String RUN_PROJECTS = "bpm";
public static String RUN_PROJECTS = "";
}




+ 4
- 1
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/controller/IStartListener.java 查看文件

@@ -2,10 +2,13 @@ package cc.smtweb.framework.core.mvc.controller;

/**
* Created by Akmm at 2022-08-24 09:26
* 启动监听
* 启动监听,按order先执行init,再执行run;
*/
public interface IStartListener {
//启动执行顺序
int order();
//初始化设置,一般为设置参数配置
void init();
//启动事件
void run();
}

Loading…
取消
儲存