Procházet zdrojové kódy

启动执行调整

master
郑根木 před 2 roky
rodič
revize
a31d86038a
3 změnil soubory, kde provedl 33 přidání a 4 odebrání
  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 Zobrazit soubor

@@ -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 Zobrazit soubor

@@ -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 Zobrazit soubor

@@ -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";
//级次码、字符串连接符


Načítá se…
Zrušit
Uložit