public class AppContext extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected Lazier<cn.xnatural.enet.event.EP> |
_ep
初始化 事件中心
|
protected Lazier<ThreadPoolExecutor> |
_exec
初始化一个
ThreadPoolExecutor
NOTE: 如果线程池在不停的创建线程, 有可能是因为 提交的 Runnable 的异常没有被处理. |
protected Lazier<String> |
_id
实例Id
NOTE: 保证唯一
|
protected Lazier<String> |
_name
系统名字.
|
protected Lazier<ScheduledThreadPoolExecutor> |
_scheduler |
protected static org.slf4j.Logger |
log |
protected Map<String,Devourer> |
queues
对列执行器映射
|
protected Thread |
shutdownHook
jvm关闭钩子. kill
System.exit(0)
|
protected Map<String,Object> |
sourceMap
服务对象源
|
Date |
startup
启动时间
|
| 构造器和说明 |
|---|
AppContext() |
| 限定符和类型 | 方法和说明 |
|---|---|
AppContext |
addSource(Object... sources)
添加对象源
ep() 会找出source对象中所有其暴露的功能. |
AppContext |
addSource(Object source,
String name)
添加对象源
ep() 会找出source对象中所有其暴露的功能. |
Map<String,Object> |
attrs(String key)
属性集:一组属性
|
<T> T |
bean(Class<T> type)
全局查找 bean 对象
|
<T> T |
bean(Class<T> type,
String name)
全局查找 bean 对象
|
Iterator<Map.Entry<String,Object>> |
beans()
遍历所有bean
|
<T> List<T> |
beans(Class<T> type)
全局查找 bean 对象
|
protected void |
customEnv(Map<String,Object> already)
额外自定义环境配置
|
Map<String,Object> |
env()
环境属性配置
|
cn.xnatural.enet.event.EP |
ep()
事件中心
|
ExecutorService |
exec()
系统线程池
|
<T> T |
getAttr(String key,
Class<T> type,
T defaultValue)
获取属性
|
String |
getProfile()
get profile
|
String |
id() |
void |
inject(Object source)
为bean对象中的
Inject注解字段注入对应的bean对象 |
protected <T> List<T> |
localBean(cn.xnatural.enet.event.EC ec,
Class<T> bType,
String bName)
sourceMap中查找对象 |
String |
name() |
Devourer |
queue(String qName,
Runnable fn)
加入到对列行器执行函数
每个对列里面的函数同一时间只执行一个, 各对列相互执行互不影响
|
ScheduledExecutorService |
scheduler() |
AppContext |
start() |
AppContext |
start(String... scanPkgName)
启动
|
protected cn.xnatural.enet.event.EP |
wrapEpForSource(Object source)
为每个Source包装EP
|
protected static final org.slf4j.Logger log
public final Date startup
protected final Thread shutdownHook
protected final Lazier<ThreadPoolExecutor> _exec
ThreadPoolExecutor
NOTE: 如果线程池在不停的创建线程, 有可能是因为 提交的 Runnable 的异常没有被处理.
see: ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor.Worker) 这里面当有异常抛出时 1128行代码 ThreadPoolExecutor.processWorkerExit(java.util.concurrent.ThreadPoolExecutor.Worker, boolean)protected final Lazier<ScheduledThreadPoolExecutor> _scheduler
protected final Lazier<cn.xnatural.enet.event.EP> _ep
public ExecutorService exec()
ExecutorServicepublic ScheduledExecutorService scheduler()
public cn.xnatural.enet.event.EP ep()
EPpublic AppContext start()
public AppContext start(String... scanPkgName)
scanPkgName - 扫描包public AppContext addSource(Object source, String name)
ep() 会找出source对象中所有其暴露的功能. 即: 用 EL 标注的方法
注: 为每个对象源都配一个 name 属性标识source - bean 对象name - bean 名字AppContextpublic AppContext addSource(Object... sources)
ep() 会找出source对象中所有其暴露的功能. 即: 用 @EL 标注的方法
注: 为每个对象源都配一个 name 属性标识sources - bean 对象AppContextpublic Devourer queue(String qName, Runnable fn)
qName - 对列名fn - 要执行的函数Devourer@EL(name="inject") public void inject(Object source)
Inject注解字段注入对应的bean对象source - beanpublic <T> T bean(Class<T> type)
type - 对象类型public <T> T bean(Class<T> type, String name)
type - 对象类型name - 对象名字@EL(name={"bean.get","sys.bean.get"},
order=-1.0f)
protected <T> List<T> localBean(cn.xnatural.enet.event.EC ec,
Class<T> bType,
String bName)
sourceMap中查找对象ec - 事件上下文bType - bean 对象类型bName - bean 对象名字protected cn.xnatural.enet.event.EP wrapEpForSource(Object source)
source - 源对象EPpublic <T> T getAttr(String key, Class<T> type, T defaultValue)
key - 属性keytype - 值类型defaultValue - 默认值public String getProfile()
public String name()
public String id()
Copyright © 2024. All rights reserved.