修复Application空指针问题
This commit is contained in:
@@ -156,12 +156,11 @@ public final class Application {
|
|||||||
//本地IP地址
|
//本地IP地址
|
||||||
final InetSocketAddress localAddress;
|
final InetSocketAddress localAddress;
|
||||||
|
|
||||||
//日志组件
|
//配置信息,只读版Properties
|
||||||
//@since 2.8.0
|
private final Environment environment;
|
||||||
final LoggingModule loggingModule = new LoggingModule(this);
|
|
||||||
|
|
||||||
//数据源组件
|
//全局根ResourceFactory
|
||||||
private final SourceModuleEngine sourceModule = new SourceModuleEngine(this);
|
final ResourceFactory resourceFactory = ResourceFactory.create();
|
||||||
|
|
||||||
//NodeServer 资源, 顺序必须是sncps, others, watchs
|
//NodeServer 资源, 顺序必须是sncps, others, watchs
|
||||||
final List<NodeServer> servers = new CopyOnWriteArrayList<>();
|
final List<NodeServer> servers = new CopyOnWriteArrayList<>();
|
||||||
@@ -169,6 +168,9 @@ public final class Application {
|
|||||||
//配置项里的group信息, 注意: 只给SNCP使用
|
//配置项里的group信息, 注意: 只给SNCP使用
|
||||||
private final SncpRpcGroups sncpRpcGroups = new SncpRpcGroups();
|
private final SncpRpcGroups sncpRpcGroups = new SncpRpcGroups();
|
||||||
|
|
||||||
|
//除logging配置之外的所有配置项,包含本地和远程配置项
|
||||||
|
final Properties envProperties = new Properties();
|
||||||
|
|
||||||
//业务逻辑线程池
|
//业务逻辑线程池
|
||||||
//@since 2.3.0
|
//@since 2.3.0
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@@ -177,25 +179,24 @@ public final class Application {
|
|||||||
//给客户端使用,包含SNCP客户端、自定义数据库客户端连接池
|
//给客户端使用,包含SNCP客户端、自定义数据库客户端连接池
|
||||||
private AsyncIOGroup clientAsyncGroup;
|
private AsyncIOGroup clientAsyncGroup;
|
||||||
|
|
||||||
//配置组件
|
|
||||||
final PropertiesModule propertiesModule = new PropertiesModule(this);
|
|
||||||
|
|
||||||
//除logging配置之外的所有配置项,包含本地和远程配置项
|
|
||||||
final Properties envProperties = new Properties();
|
|
||||||
|
|
||||||
//配置信息,只读版Properties
|
|
||||||
private final Environment environment;
|
|
||||||
|
|
||||||
//全局根ResourceFactory
|
|
||||||
final ResourceFactory resourceFactory = ResourceFactory.create();
|
|
||||||
|
|
||||||
//服务配置项
|
//服务配置项
|
||||||
final AnyValue config;
|
final AnyValue config;
|
||||||
|
|
||||||
//是否启动了WATCH协议服务
|
//是否启动了WATCH协议服务
|
||||||
boolean watching;
|
boolean watching;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------
|
//------------- 模块组件(必须靠后放,否则new Module时resourceFactory会为null) -------------
|
||||||
|
//日志组件
|
||||||
|
//@since 2.8.0
|
||||||
|
final LoggingModule loggingModule;
|
||||||
|
|
||||||
|
//配置组件
|
||||||
|
final PropertiesModule propertiesModule;
|
||||||
|
|
||||||
|
//数据源组件
|
||||||
|
private final SourceModuleEngine sourceModule;
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------------
|
||||||
//是否用于main方法运行
|
//是否用于main方法运行
|
||||||
private final boolean singletonMode;
|
private final boolean singletonMode;
|
||||||
|
|
||||||
@@ -255,6 +256,10 @@ public final class Application {
|
|||||||
this.classLoader = appConfig.classLoader;
|
this.classLoader = appConfig.classLoader;
|
||||||
this.serverClassLoader = appConfig.serverClassLoader;
|
this.serverClassLoader = appConfig.serverClassLoader;
|
||||||
|
|
||||||
|
this.loggingModule = new LoggingModule(this);
|
||||||
|
this.propertiesModule = new PropertiesModule(this);
|
||||||
|
this.sourceModule = new SourceModuleEngine(this);
|
||||||
|
|
||||||
//设置基础信息资源
|
//设置基础信息资源
|
||||||
this.resourceFactory.register(RESNAME_APP_NAME, String.class, this.name);
|
this.resourceFactory.register(RESNAME_APP_NAME, String.class, this.name);
|
||||||
|
|
||||||
@@ -306,7 +311,7 @@ public final class Application {
|
|||||||
this.resourceFactory.register("protobufconvert", Convert.class, ProtobufFactory.root().getConvert());
|
this.resourceFactory.register("protobufconvert", Convert.class, ProtobufFactory.root().getConvert());
|
||||||
|
|
||||||
//系统内部模块组件
|
//系统内部模块组件
|
||||||
moduleEngines.add(sourceModule); //放第一,很多module依赖于source
|
moduleEngines.add(this.sourceModule); //放第一,很多module依赖于source
|
||||||
moduleEngines.add(new MessageModuleEngine(this));
|
moduleEngines.add(new MessageModuleEngine(this));
|
||||||
moduleEngines.add(new ClusterModuleEngine(this));
|
moduleEngines.add(new ClusterModuleEngine(this));
|
||||||
moduleEngines.add(new CacheModuleEngine(this));
|
moduleEngines.add(new CacheModuleEngine(this));
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
package org.redkale.boot;
|
package org.redkale.boot;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.redkale.inject.ResourceEvent;
|
import org.redkale.inject.ResourceEvent;
|
||||||
@@ -35,8 +36,8 @@ public abstract class ModuleEngine {
|
|||||||
|
|
||||||
public ModuleEngine(Application application) {
|
public ModuleEngine(Application application) {
|
||||||
this.application = application;
|
this.application = application;
|
||||||
this.resourceFactory = application.getResourceFactory();
|
this.resourceFactory = Objects.requireNonNull(application.resourceFactory);
|
||||||
this.environment = application.getEnvironment();
|
this.environment = Objects.requireNonNull(application.getEnvironment());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -118,10 +118,8 @@ public class SourceModuleEngine extends ModuleEngine {
|
|||||||
break; //only first provider
|
break; //only first provider
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------- 注册 DataSource --------------------------------------------------------
|
//--------------------------------- 注册 DataSource、CacheSource ---------------------------------
|
||||||
resourceFactory.register(new DataSourceLoader(), DataSource.class);
|
resourceFactory.register(new DataSourceLoader(), DataSource.class);
|
||||||
|
|
||||||
//------------------------------------- 注册 CacheSource --------------------------------------------------------
|
|
||||||
resourceFactory.register(new CacheSourceLoader(), CacheSource.class);
|
resourceFactory.register(new CacheSourceLoader(), CacheSource.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user