忽然记起spring的context的N重继承风格,一个抽象类实现一部份功能,想从那重改复写就从哪重开始。脑子一抽,也在业务代码里面玩了下。效果嘛。学得是有模有样,感觉就是越搞越复杂。有点过度设计了,折腾个啥呢。哈哈哈…
Spring效果:
画瓢效果:
产品中一重抽象实现一部分功能。二次开发随便改
顶层抽象类:
public abstract class SuggestionFlowStatusHandler implements BusinessStatusHandler {
@Override
public boolean supportFlow(String flowId) {
return SuggestionFlowContext.SUGGESTION_FLOW_ID.equals(flowId);
}
@Override
public void updateBusinessStatus(FlowContext nodeContext, Node node) {
SuggestionFlowContext context = (SuggestionFlowContext) nodeContext;
// 更新建议信息
updateSuggestionFlowStatus(node, context);
// 处理附议人
handleSubmitJoinInfo(node, context);
// 记录一些流程产生的泛化数据
toRecordFlowAboutInfo(node, context);
// 其他更新
updateOtherBusinessStatus(node, context);
// 同步履职档案和学习提升同步数据
handlePerformDuties(node, context);
// 发送消息
sendNoticeMessage(node, context);
}
protected abstract void updateSuggestionFlowStatus(Node node, SuggestionFlowContext context);
protected abstract void handleSubmitJoinInfo(Node node, SuggestionFlowContext context);
protected abstract void toRecordFlowAboutInfo(Node node, SuggestionFlowContext nodeContext);
protected abstract void handlePerformDuties(Node node, SuggestionFlowContext context);
protected abstract void sendNoticeMessage(Node node, SuggestionFlowContext context);
protected void updateOtherBusinessStatus(Node node, SuggestionFlowContext context) {
}
}
支持复写:
@Bean
@ConditionalOnMissingBean
public BusinessStatusHandler businessStatusHandler() {
return new DefaultSuggestionFlowHandler();
}