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