标签:and system bsp class cte protect oid public abs
public abstract class AbstractHandler { private static AbstractHandler handler = new Handler1(); static { handler.setNextHandler(new Handler2()) .setNextHandler(new Handler3()); } private AbstractHandler nextHandler; protected void handle(){ if(this.nextHandler != null){ this.nextHandler.handle(); } }
/**
*
* 流程链前置日志
*/
protected String getPreLog() {
return "handle";
}
public AbstractHandler setNextHandler(AbstractHandler nextHandler) { this.nextHandler = nextHandler; return this.nextHandler; } public static AbstractHandler getHandler(){ return handler; } }
public class Handler1 extends AbstractHandler{ @Override protected void handle() { System.out.println("handle-1"); super.handle(); } }
public class Test { public static void main(String[] args) { AbstractHandler.getHandler().handle(); } }
标签:and system bsp class cte protect oid public abs
原文地址:https://www.cnblogs.com/gucl/p/11331984.html