优化
This commit is contained in:
@@ -330,15 +330,15 @@ public final class Application {
|
||||
}
|
||||
|
||||
public void init() throws Exception {
|
||||
//读取远程配置
|
||||
this.loadResourceProperties();
|
||||
//注册ResourceType
|
||||
this.initResourceTypeLoader();
|
||||
this.onAppPreInit();
|
||||
//读取远程配置
|
||||
this.loadResourceProperties();
|
||||
//设置WorkExecutor
|
||||
this.initWorkExecutor();
|
||||
//
|
||||
this.onAppPreInit();
|
||||
initResources();
|
||||
//结束时回调
|
||||
this.onAppPostInit();
|
||||
}
|
||||
|
||||
@@ -1340,6 +1340,7 @@ public final class Application {
|
||||
}
|
||||
this.watching = !watchs.isEmpty();
|
||||
|
||||
this.onServersPreStart();
|
||||
runServers(serverCdl, sncps); //必须确保SNCP服务都启动后再启动其他服务
|
||||
runServers(serverCdl, others);
|
||||
runServers(serverCdl, watchs); //必须在所有服务都启动后再启动WATCH服务
|
||||
@@ -1844,14 +1845,13 @@ public final class Application {
|
||||
if (this.workExecutor != null) {
|
||||
this.workExecutor.shutdownNow();
|
||||
}
|
||||
|
||||
if (this.clientAsyncGroup != null) {
|
||||
long s = System.currentTimeMillis();
|
||||
this.clientAsyncGroup.dispose();
|
||||
logger.info("AsyncGroup destroy in " + (System.currentTimeMillis() - s) + " ms");
|
||||
}
|
||||
|
||||
this.onAppPostShutdown();
|
||||
|
||||
long intms = System.currentTimeMillis() - f;
|
||||
String ms = String.valueOf(intms);
|
||||
int repeat = ms.length() > 7 ? 0 : (7 - ms.length()) / 2;
|
||||
|
||||
@@ -36,6 +36,9 @@ public abstract class ModuleEngine {
|
||||
|
||||
/**
|
||||
* 进入Application.init方法时被调用
|
||||
* 此时状态:
|
||||
* 1、远程配置项未获取
|
||||
* 2、WorkExecutor未初始化
|
||||
*/
|
||||
public void onAppPreInit() {
|
||||
//do nothing
|
||||
|
||||
@@ -21,9 +21,9 @@ public class CacheModuleEngine extends ModuleEngine {
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入Application.init方法时被调用
|
||||
* 结束Application.init方法前被调用
|
||||
*/
|
||||
public void onAppPreInit() {
|
||||
public void onAppPostInit() {
|
||||
//设置缓存管理器
|
||||
this.cacheManager = CacheManagerService.create(null).enabled(false);
|
||||
final AnyValue cacheConf = application.getAppConfig().getAnyValue("cache");
|
||||
|
||||
@@ -38,9 +38,10 @@ public class ClusterModuleEngine extends ModuleEngine {
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入Application.init方法时被调用
|
||||
* 结束Application.init方法前被调用
|
||||
*/
|
||||
public void onAppPreInit() {
|
||||
@Override
|
||||
public void onAppPostInit() {
|
||||
ClusterAgent cluster = null;
|
||||
AnyValue clusterConf = application.getAppConfig().getAnyValue("cluster");
|
||||
if (clusterConf != null) {
|
||||
@@ -87,13 +88,7 @@ public class ClusterModuleEngine extends ModuleEngine {
|
||||
}
|
||||
}
|
||||
this.clusterAgent = cluster;
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束Application.init方法前被调用
|
||||
*/
|
||||
@Override
|
||||
public void onAppPostInit() {
|
||||
|
||||
if (this.clusterAgent != null) {
|
||||
if (logger.isLoggable(Level.FINER)) {
|
||||
logger.log(Level.FINER, "ClusterAgent (type = " + this.clusterAgent.getClass().getSimpleName() + ") initing");
|
||||
|
||||
@@ -67,9 +67,10 @@ public class MessageModuleEngine extends ModuleEngine {
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入Application.init方法时被调用
|
||||
* 结束Application.init方法前被调用
|
||||
*/
|
||||
public void onAppPreInit() {
|
||||
@Override
|
||||
public void onAppPostInit() {
|
||||
MessageAgent[] mqs = null;
|
||||
AnyValue[] mqConfs = application.getAppConfig().getAnyValues("mq");
|
||||
if (mqConfs != null && mqConfs.length > 0) {
|
||||
@@ -161,13 +162,7 @@ public class MessageModuleEngine extends ModuleEngine {
|
||||
return ResourceProducer.class;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束Application.init方法前被调用
|
||||
*/
|
||||
@Override
|
||||
public void onAppPostInit() {
|
||||
if (this.messageAgents == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ public class ScheduleModuleEngine extends ModuleEngine {
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入Application.init方法时被调用
|
||||
* 结束Application.init方法前被调用
|
||||
*/
|
||||
public void onAppPreInit() {
|
||||
public void onAppPostInit() {
|
||||
//设置定时管理器
|
||||
this.scheduleManager = ScheduleManagerService.create(null).enabled(false);
|
||||
final AnyValue scheduleConf = application.getAppConfig().getAnyValue("schedule", true);
|
||||
|
||||
@@ -75,9 +75,10 @@ public class SourceModuleEngine extends ModuleEngine {
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入Application.init方法时被调用
|
||||
* 结束Application.init方法前被调用
|
||||
*/
|
||||
public void onAppPreInit() {
|
||||
@Override
|
||||
public void onAppPostInit() {
|
||||
//加载原生sql解析器
|
||||
Iterator<DataNativeSqlParserProvider> it = ServiceLoader.load(DataNativeSqlParserProvider.class, application.getClassLoader()).iterator();
|
||||
RedkaleClassLoader.putServiceLoader(DataNativeSqlParserProvider.class);
|
||||
@@ -94,13 +95,7 @@ public class SourceModuleEngine extends ModuleEngine {
|
||||
this.resourceFactory.register(DataNativeSqlParser.class, this.nativeSqlParser);
|
||||
break; //only first provider
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束Application.init方法前被调用
|
||||
*/
|
||||
@Override
|
||||
public void onAppPostInit() {
|
||||
|
||||
//------------------------------------- 注册 DataSource --------------------------------------------------------
|
||||
resourceFactory.register((ResourceFactory rf, String srcResourceName, final Object srcObj, String resourceName, Field field, final Object attachment) -> {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user