java pipeline是什么,让我们一起了解一下?
pipeline又称为管道,是一种在计算机普遍使用的技术。在分布式处理领域,由于管道模式是数据驱动,而目前流行的Spark分布式处理平台也是数据驱动的,两者非常合拍,于是在spark的新的api里面pipeline模式得到了广泛的应用。还有java web中的struct的filter、netty的pipeline,无处不见pipeline模式。
管道模式设计其实和责任链模式很像,都是按照顺序往下执行不同的方法,管道只是负责顺序执行,不管是否执行不同方法。
管道入口:
Map context = new HashMap<>();
context.put("BusinessType", BusinessType.CREDIT_FLOW.getBusinessType());
context.put("CheckType", CertificateBusinessTypeEnum.THREE_ELEMENTS.name());
context.put("ZaUser", user);
context.put("RequestParam", relavants);
//管道入口
context = certificateElementService.checkAdmittance(context);
JSONObject jsonObject = (JSONObject) context.get("ResponseParam");AaaThreeElementsCheckValve 的实现:
@Component("aaaThreeElementsCheckValve")
public class AaaThreeElementsCheckValve extends AbstractLogableValveBbbThreeElementsCheckValve 的实现:
@Component("bbbThreeElementsCheckValve")
public class BbbThreeElementsCheckValve extends AbstractLogableValve {
@Autowired
private ICodeLibraryService codeLibraryService;
@Autowired
private IShuJuBaoCreditService shuJuBaoCreditService;
@Override
public void handle(Map context, ValveChain chain) throws I18NSupportException {
JSONObject jsonObject = (JSONObject) context.get("ResponseParam");
if (Objects.equals(Integer.valueOf(jsonObject.get(WebUtil.JSON_RESULT_STATUS_CODE).toString()), WebUtil.ERROR)) {
//aaa三要素接口已强控,因此不继续调用bbb三要素接口,也不调用后续阀门进行校验
} else {
ZaUser user = (ZaUser) context.get("ZaUser");
Object requestParam = context.get("RequestParam");
List relavants = JSON.parseArray(JSON.toJSONString(requestParam), CustomerCreditRelavant.class);
CodeLibrary codeLibrary = codeLibraryService.queryLibraryNoException("shujubaoCompanyIdAndCobankId", user.getCompanyId() + "-" + relavants.get(0).getInquryBankId());
if (Objects.nonNull(codeLibrary)) {
String s = shuJuBaoCreditService.sjbThreeElmentVerify(relavants);
if (StringUtils.isNotBlank(s)) {
jsonObject.put(WebUtil.JSON_RESULT_STATUS_CODE, WebUtil.ERROR);
jsonObject.put(WebUtil.JSON_RESULT_DATA, JSONObject.toJSONString(s));
}
}else{
//bbb三要素校验通过,调用后续阀门进行校验
chain.handleNext(context);
}
}
}
} 以上就是小编今天的分享了,希望可以帮助到大家。