
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);
????????????}
????????}
????}
} 以上就是小編今天的分享了,希望可以幫助到大家。
