classChainAextendsAbsChain{publicChainA(ResChain next){this.next = next;this.level =1;}@OverridepublicvoiddoChain(CustomRequest request){
Assert.notNull(request,"request must be not null");int type = request.getLevel();if(this.level >= type){
System.out.println("ChainA handle request...."+request.getName());}else{if(this.next != null)this.next.doChain(request);}}}classChainBextendsAbsChain{publicChainB(ResChain next){this.next = next;this.level =3;}@OverridepublicvoiddoChain(CustomRequest request){
Assert.notNull(request,"request must be not null");int type = request.getLevel();if(this.level >= type && type >1){
System.out.println("ChainB handle request...."+request.getName());}else{if(this.next !=null)this.next.doChain(request);}}}classChainCextendsAbsChain{publicChainC(ResChain next){this.next = next;this.level =5;}@OverridepublicvoiddoChain(CustomRequest request){
Assert.notNull(request,"request must be not null");int type = request.getLevel();if(this.level >= type && type >3){
System.out.println("ChainC handle request...."+request.getName());}else{if(this.next != null)this.next.doChain(request);}}}