CONFIG
- 对应的插件配置类类型SEND
- sender送信器对应类型SET
- setter送信器对应类型GET
- getter送信器对应类型public abstract class BaseApplication<CONFIG extends BaseConfiguration,SEND extends SenderSendList,SET extends SenderSetList,GET extends SenderGetList,CONTEXT extends SimpleRobotContext<SEND,SET,GET>> extends Object implements Closeable
Modifier and Type | Field and Description |
---|---|
protected static QQLogLang |
RUN_LOG
启动器使用的日志,前缀为“run”
|
Constructor and Description |
---|
BaseApplication()
无参构造
|
BaseApplication(QQLogBack qqLogBack)
日志拦截构造
|
Modifier and Type | Method and Description |
---|---|
protected void |
_hello$()
打个招呼
|
protected void |
afterDepend(CONFIG config,
Application<CONFIG> app,
Register register,
DependCenter dependCenter)
依赖扫描之后
同时也是监听函数扫描之前
|
protected Consumer<Class<?>[]>[] |
afterListener(CONFIG config,
Application<CONFIG> app)
监听函数扫描之后
|
protected void |
afterStart(CONFIG config)
服务启动后, 构建无参数送信器之前
|
protected void |
beforeDepend(CONFIG config,
Application<CONFIG> app,
Register register)
依赖扫描之前
|
protected void |
beforeRegisterListener(CONFIG config,
Application<CONFIG> app,
ListenerMethodScanner scanner,
DependCenter dependCenter)
监听函数注册之前,可以执行重写并进行额外的监听注入
|
protected void |
beforeStart(CONFIG config)
服务启动前
|
protected String[] |
getArgs()
直接返回参数列表对象。
|
BotManager |
getBotManager()
获取账号管理器,在dependCenter初始化完成被初始化
|
protected abstract CONTEXT |
getComponentContext(MsgSender defaultMsgSender,
BotManager manager,
MsgParser msgParser,
MsgProcessor processor,
DependCenter dependCenter)
获取一个组件专属的SimpleRobotContext对象
|
protected CONFIG |
getConf()
获取Config对象。如果尚未初始化则会优先初始化
|
protected abstract CONFIG |
getConfiguration()
开发者实现的获取Config对象实例的方法
此方法将会最先被执行,并会将值保存,使用时可使用
getConf() 方法获取 |
protected Object |
getContext(String key) |
protected abstract MsgSender |
getDefaultSender(DependCenter dependCenter,
ListenerManager manager,
BotManager botManager)
获取一个不使用在监听函数中的默认送信器
|
DependCenter |
getDependCenter()
获取依赖获取器
|
protected SenderGetList |
getGetter()
Deprecated.
|
protected abstract GET |
getGetter(MsgGet msgGet,
BotManager botManager)
提供一个msgGet,将其转化为GetList
|
protected QQLogLang |
getLog()
获取日志对象
|
protected MsgParser |
getMsgParser()
获取MsgParser函数, 默认根据
msgParse(String) 生成 |
MsgSender |
getMsgSender()
获取空函数送信器
※ 此送信器无法进行阻断 |
protected Function<MsgGet,RootSenderList> |
getRootSenderFunction(BotManager botManager)
根据
getSender(MsgGet, BotManager) , getSetter(MsgGet, BotManager) , getGetter(MsgGet, BotManager) 三个函数构建一个RootSenderList
参数分别为一个BotManager和一个MsgGet对象
如果组件不是分为三个部分而构建,则可以考虑重写此函数
此函数最终会被送入组件实现的runServer中 |
protected SenderSendList |
getSender()
Deprecated.
|
protected abstract SEND |
getSender(MsgGet msgGet,
BotManager botManager)
提供一个msgGet,将其转化为SendList
|
protected SenderSetList |
getSetter()
Deprecated.
|
protected abstract SET |
getSetter(MsgGet msgGet,
BotManager botManager)
提供一个msgGet,将其转化为SetList
|
Object |
getSpecialApi()
Deprecated.
|
protected abstract MsgGet |
msgParse(String str)
字符串转化为MsgGet的方法,最终会被转化为
MsgParser 函数,
会作为参数传入runServer(DependCenter, ListenerManager, MsgProcessor, MsgParser) , 也会封装进SimpleRobotContext 中 |
protected abstract void |
resourceInit()
开发者实现的资源初始化
此方法将会在所有的无配置初始化方法最后执行
将会在用户配置之前执行
|
protected abstract void |
resourceInit(CONFIG config)
开发者实现的资源初始化
此方法将会在所有的初始化方法最后执行
增加一个参数
此资源配置将会在配置之后执行
|
CONTEXT |
run(Application<CONFIG> app,
String... args)
执行的主程序
|
CONTEXT |
run(Class<?> appClass,
String... args)
使用一个Class来指定启动器。
如果这个类存在
SimpleRobotApplication 注解,则以注解信息为主。
如果不存在,则判断是否为Application 接口的子类。如果是,尝试实例化,否则抛出异常。 |
protected abstract String |
runServer(DependCenter dependCenter,
ListenerManager manager,
MsgProcessor msgProcessor,
MsgParser msgParser)
启动一个服务,这有可能是http或者是ws的监听服务
|
CONTEXT |
runWithApplication(Application<CONFIG> app,
String... args)
使一个实例也可以进行注解解析。
此时,
SimpleRobotApplication.application() 参数将会失效 |
protected void |
setArgs(String[] args)
设置执行参数
|
protected void |
setContext(String key,
Object value) |
protected void |
threadPoolInit(CONFIG config)
线程工厂初始化
|
protected VerifyFunction |
verifyBot()
获取账号验证的函数
|
protected BotInfo[] |
verifyBot(Map<String,List<BotInfo>> confBotInfos)
启动时候的初始验证函数
|
protected abstract BotInfo |
verifyBot(String code,
BotInfo info)
start之前,会先对账号进行验证。将会使用此方法对注册的bot账号信息进行验证。
|
protected static final QQLogLang RUN_LOG
public BaseApplication()
public BaseApplication(QQLogBack qqLogBack)
protected QQLogLang getLog()
protected void threadPoolInit(CONFIG config)
protected abstract void resourceInit(CONFIG config)
protected abstract void resourceInit()
@Deprecated protected SenderSendList getSender()
@Deprecated protected SenderSetList getSetter()
@Deprecated protected SenderGetList getGetter()
protected abstract SEND getSender(MsgGet msgGet, BotManager botManager)
msgGet
- msgGetSenderSendList
protected abstract SET getSetter(MsgGet msgGet, BotManager botManager)
msgGet
- msgGetSenderSetList
protected abstract GET getGetter(MsgGet msgGet, BotManager botManager)
msgGet
- msgGetSenderGetList
protected abstract CONTEXT getComponentContext(MsgSender defaultMsgSender, BotManager manager, MsgParser msgParser, MsgProcessor processor, DependCenter dependCenter)
defaultMsgSender
- 函数getDefaultSender(DependCenter, ListenerManager, BotManager)
的最终返回值manager
- botManager对象msgParser
- 消息字符串转化函数processor
- 消息处理器dependCenter
- 依赖中心protected Function<MsgGet,RootSenderList> getRootSenderFunction(BotManager botManager)
getSender(MsgGet, BotManager)
, getSetter(MsgGet, BotManager)
, getGetter(MsgGet, BotManager)
三个函数构建一个RootSenderList
参数分别为一个BotManager和一个MsgGet对象
如果组件不是分为三个部分而构建,则可以考虑重写此函数
此函数最终会被送入组件实现的runServer中protected MsgParser getMsgParser()
msgParse(String)
生成protected BotInfo[] verifyBot(Map<String,List<BotInfo>> confBotInfos)
confBotInfos
- protected abstract BotInfo verifyBot(String code, BotInfo info)
start之前,会先对账号进行验证。将会使用此方法对注册的bot账号信息进行验证。鉴于机制的变更,最好在bot初始化的时候便将每个bot所对应的sender初始化结束。此验证函数后续会被注入至BotManager对象中用于动态验证。推荐在验证失败的时候抛出异常。
code
- 用户账号,可能为nullinfo
- 用于验证的bot,一般来讲应当至少存在一个pathprotected VerifyFunction verifyBot()
@Deprecated public Object getSpecialApi()
protected abstract MsgSender getDefaultSender(DependCenter dependCenter, ListenerManager manager, BotManager botManager)
dependCenter
- 依赖中心manager
- 监听器管理中心botManager
- bot管理中心protected abstract String runServer(DependCenter dependCenter, ListenerManager manager, MsgProcessor msgProcessor, MsgParser msgParser)
dependCenter
- 依赖中心manager
- 监听管理器msgProcessor
- 送信解析器protected abstract MsgGet msgParse(String str)
MsgParser
函数,
会作为参数传入runServer(DependCenter, ListenerManager, MsgProcessor, MsgParser)
, 也会封装进SimpleRobotContext
中str
- protected abstract CONFIG getConfiguration()
getConf()
方法获取protected CONFIG getConf()
protected void beforeDepend(CONFIG config, Application<CONFIG> app, Register register)
config
- 配置文件app
- 启动器接口实现类register
- 注册器protected void afterDepend(CONFIG config, Application<CONFIG> app, Register register, DependCenter dependCenter)
protected Consumer<Class<?>[]>[] afterListener(CONFIG config, Application<CONFIG> app)
protected void beforeStart(CONFIG config)
protected void afterStart(CONFIG config)
protected void beforeRegisterListener(CONFIG config, Application<CONFIG> app, ListenerMethodScanner scanner, DependCenter dependCenter)
public CONTEXT run(Class<?> appClass, String... args)
SimpleRobotApplication
注解,则以注解信息为主。
如果不存在,则判断是否为Application
接口的子类。如果是,尝试实例化,否则抛出异常。appClass
- 启动类args
- 参数public CONTEXT runWithApplication(Application<CONFIG> app, String... args)
SimpleRobotApplication.application()
参数将会失效app
- 启动器实例args
- java执行参数public CONTEXT run(Application<CONFIG> app, String... args)
app
- 启动器接口的实现类args
- 可能会有用的额外指令参数,一般是main方法的参数protected void setArgs(String[] args)
args
- 执行参数数组protected String[] getArgs()
public BotManager getBotManager()
public DependCenter getDependCenter()
public MsgSender getMsgSender()
protected void _hello$()
使得这个方法可以被覆盖。别吐槽里面的变量名了。
Copyright © 2020. All rights reserved.