介绍一个自己写的简陋业务身份扩展框架 solf
solf
is the business solution, also shows our logical framework
是一个业务解决方案,关于展示我们的业务逻辑框架
Design background
设计背景
Project description
工程描述
demo/solf-bundle-demo 业务扩展包示例 demo/solf-service-demo 服务示例 solf-core 核心实现 solf-model 核心模型 wiki 介绍
Core design
核心设计
Register
Business identity register
业务身份注册
Domain ability register
领域能力注册
Flow node register
流程节点注册
Processor
Domain ability processor
领域能力处理
Flow chain processor
流程链处理
Class diagram
类图
How to use
使用方式
import dependency
引入依赖包 引入solf-core依赖
<dependency>
<groupId>com.zzqfsy.io</groupId>
<artifactId>solf-core</artifactId>
</dependency>
scan to load bean
扫描加载
@ComponentScan(basePackages = {
"com.zzqfsy.solf.core"
})
Register custom business identity
注册自定义业务身份
@Component
@BizIdentitySpec(code = "xxxBizId", name = "xxx")
public class XxxBizIdentityConfig {
/**
* 获取xxx的身份
*
* @return
*/
public BizIdentity getBizIdentity(T t) {
...
}
}
Register custom domain ability
注册自定义领域能力
@DomainSpec(name = "xxx", domain = "xxxDomain", description = "xxx")
public class XxxEventHandler {
@AbilityOrderSpec(300)
@AbilitySpec(name = "xxx",
scenario = "xxx",
description = "",
bizIdentityCode = "xxxBizId")
public <E> E handler(T t) {
...
}
Register custom flow node chain
注册自定义流程节点链
@Component
@FlowChainSpec(name = "xxx", code = "xxxFlow")
public class XxxFlowChain {
@FlowNodeOrderSpec(1)
@FlowNodeSpec(name = "xxx", code = "xxxFlowNode",
domainName = "xxxDomain", abilityName = "xxxAbility")
public void valid(T t){
...
}
Run it to understand
运行来了解
debug com.zzqfsy.solf.service.demo.ServiceApplicaiton.main
then browser request http://127.0.0.1:8081/stockIn
console println execute handler:
PurchaseOrderStockInValidEventHandler handler
PurchaseOrderStockInAssemblyEventHandler handler
PurchaseOrderStockInCreateEventHandler handler
PurchaseOrderStockInCreateEventHandler wms handler
View
视图
flowChainView
流程链视图 请求示例
debug com.zzqfsy.solf.service.demo.ServiceApplicaiton.main
then browser request http://127.0.0.1:8081/flowChain/config
输出示例
[{
"chainName": "入库通知",
"chainCode": "stockInNoticeFlow",
"flowNodeList": [{
"name": "入库通知校验",
"code": "StockInNotice.valid",
"domainName": "stockInNoticeDomain",
"abilityName": "valid",
"order": 1
}, {
"name": "入库通知组装",
"code": "StockInNotice.assembly",
"domainName": "stockInNoticeDomain",
"abilityName": "assembly",
"order": 2
}, {
"name": "入库通知创建",
"code": "StockInNotice.create",
"domainName": "stockInNoticeDomain",
"abilityName": "create",
"order": 3
}]
}]
bizIdentityDomainAbilityView
业务身份能力视图 请求示例
debug com.zzqfsy.solf.service.demo.ServiceApplicaiton.main
then browser request http://127.0.0.1:8081/domain/ability/config
输出示例
[{
"bizIdentityName": "采购单",
"bizIdentityCode": "purchaseOrderBizId",
"bizIdentityMethodObject": {
"className": "com.zzqfsy.solf.service.demo.config.bizId.stock.in.PurchaseOrderBizIdentityConfig",
"methodName": "getBizIdentity",
"parameterType": "com.zzqfsy.solf.service.demo.model.StockInDo",
"returnType": "com.zzqfsy.solf.model.identity.BizIdentity"
},
"domainCode": "stockInNoticeDomain",
"domainName": "入库领域",
"abilityScenario": "valid",
"abilityName": "校验",
"abilityOrder": 100,
"abilityMethodObject": {
"beanClass": "com.zzqfsy.solf.service.demo.domain.event.handler.stock.in.notice.valid.PurchaseOrderStockInValidEventHandler",
"methodName": "handler",
"parameterType": "com.zzqfsy.solf.service.demo.model.StockInDo",
"returnType": "java.lang.Integer",
"order": 100
}
}]
request object match flow and ability view
请求对象匹配流程和能力视图
todo