瀏覽代碼

启动执行调整

master
郑根木 2 年之前
父節點
當前提交
a31d86038a
共有 3 個文件被更改,包括 33 次插入4 次删除
  1. +29
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/BpmStartedListener.java
  2. +3
    -4
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/CoreApplicationStartedListener.java
  3. +1
    -0
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwConsts.java

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

@@ -0,0 +1,29 @@
package cc.smtweb.system.bpm.spring;

import cc.smtweb.framework.core.annotation.SwService;
import cc.smtweb.framework.core.cache.CacheManager;
import cc.smtweb.framework.core.common.SwConsts;
import cc.smtweb.framework.core.db.impl.DatabaseUtil;
import cc.smtweb.framework.core.systask.TaskStartEvent;
import cc.smtweb.framework.core.systask.WebStartedEvent;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
* Created by Akmm at 2022/7/8 19:57
*/
@Component
@Order(SwConsts.DEFAULT_ORDER + 1)
public class BpmStartedListener implements ApplicationListener<ApplicationStartedEvent> {

@Override
public void onApplicationEvent(ApplicationStartedEvent event) {
//初始化数据库
new DatabaseUtil(true, false).checkDb();
//初始化缓存
CacheManager.getIntance().init();
}
}

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

@@ -1,6 +1,7 @@
package cc.smtweb.framework.core;

import cc.smtweb.framework.core.cache.CacheManager;
import cc.smtweb.framework.core.common.SwConsts;
import cc.smtweb.framework.core.db.impl.DatabaseUtil;
import cc.smtweb.framework.core.mvc.controller.scan.ApplicationScanner;
import cc.smtweb.framework.core.systask.TaskStartEvent;
@@ -9,12 +10,14 @@ import lombok.SneakyThrows;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
* 执行接口扫描任务
*/
@Component
@Order(SwConsts.DEFAULT_ORDER)
public class CoreApplicationStartedListener implements ApplicationListener<ApplicationStartedEvent> {
@SneakyThrows
@Override
@@ -25,10 +28,6 @@ public class CoreApplicationStartedListener implements ApplicationListener<Appli
applicationContext.publishEvent(new TaskStartEvent());
//包扫描
ApplicationScanner.scan(applicationContext);
//初始化数据库
new DatabaseUtil(true, false).checkDb();
//初始化缓存
CacheManager.getIntance().init();

// 通知 controller 正式使用
applicationContext.publishEvent(new WebStartedEvent());


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

@@ -4,6 +4,7 @@ package cc.smtweb.framework.core.common;
* Created by Akmm at 2022/3/23 9:46
*/
public interface SwConsts {
int DEFAULT_ORDER = 1;
//缓存中:树节点按parent的key
String KEY_PARENT_ID = "pr";
//级次码、字符串连接符


Loading…
取消
儲存