|
@@ -30,6 +30,7 @@ import org.hswebframework.web.ScriptScope;
|
|
import org.hswebframework.web.datasource.DataSourceHolder;
|
|
import org.hswebframework.web.datasource.DataSourceHolder;
|
|
import org.hswebframework.web.datasource.DatabaseType;
|
|
import org.hswebframework.web.datasource.DatabaseType;
|
|
import org.hswebframework.web.service.Service;
|
|
import org.hswebframework.web.service.Service;
|
|
|
|
+import org.hswebframework.web.starter.event.SystemInitializeEvent;
|
|
import org.hswebframework.web.starter.init.SystemInitialize;
|
|
import org.hswebframework.web.starter.init.SystemInitialize;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -37,6 +38,7 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
|
|
import org.springframework.boot.CommandLineRunner;
|
|
import org.springframework.boot.CommandLineRunner;
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
import org.springframework.context.ApplicationContext;
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
+import org.springframework.context.ApplicationEventPublisher;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.core.Ordered;
|
|
import org.springframework.core.Ordered;
|
|
import org.springframework.core.annotation.AnnotationUtils;
|
|
import org.springframework.core.annotation.AnnotationUtils;
|
|
@@ -75,6 +77,9 @@ public class SystemInitializeAutoConfiguration implements CommandLineRunner, Bea
|
|
@Autowired
|
|
@Autowired
|
|
private ApplicationContext applicationContext;
|
|
private ApplicationContext applicationContext;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ApplicationEventPublisher eventPublisher;
|
|
|
|
+
|
|
private List<DynamicScriptEngine> engines;
|
|
private List<DynamicScriptEngine> engines;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -158,6 +163,12 @@ public class SystemInitializeAutoConfiguration implements CommandLineRunner, Bea
|
|
|
|
|
|
SimpleDatabase database = new SimpleDatabase(metaData, sqlExecutor);
|
|
SimpleDatabase database = new SimpleDatabase(metaData, sqlExecutor);
|
|
database.setAutoParse(true);
|
|
database.setAutoParse(true);
|
|
|
|
+
|
|
|
|
+ SystemInitializeEvent event = new SystemInitializeEvent(database);
|
|
|
|
+ eventPublisher.publishEvent(event);
|
|
|
|
+ if (event.isIgnore()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
SystemInitialize initialize = new SystemInitialize(sqlExecutor, database, version);
|
|
SystemInitialize initialize = new SystemInitialize(sqlExecutor, database, version);
|
|
|
|
|
|
initialize.addScriptContext("db", jdbcUserName);
|
|
initialize.addScriptContext("db", jdbcUserName);
|