packagecn.imcompany.proxy;/**
* Created by tomyli on 2018/6/28.
* Github: https://github.com/peng051410
*/publicinterfaceSearch{voidqueryIncome(Stringusername);}
packagecn.imcompany.proxy;/**
* Created by tomyli on 2018/6/28.
* Github: https://github.com/peng051410
*/publicclassSearchServiceimplementsSearch{@OverridepublicvoidqueryIncome(Stringusername){System.out.println(username+"开始查询");try{Thread.sleep(1000);}catch(InterruptedExceptione){e.printStackTrace();}System.out.println(username+"查询完成");}}
packagecn.imcompany.proxy;/**
* Created by tomyli on 2018/6/28.
* Github: https://github.com/peng051410
*/publicclassAuth{publicbooleanvalid(Stringusername){return"admin".equals(username);}}publicclassLogger{publicvoidbeforeLog(Stringusername){System.out.println("开始记录"+username+"查询日志");}publicvoidafterLog(Stringusername){System.out.println("结束记录"+username+"查询日志");}}
packagecn.imcompany.proxy;/**
* Created by tomyli on 2018/6/28.
* Github: https://github.com/peng051410
*/publicclassSearchProxyimplementsSearch{privateLoggerlogger=newLogger();privateAuthauth=newAuth();privateSearchsearch=newSearchService();@OverridepublicvoidqueryIncome(Stringusername){logger.beforeLog(username);if(auth.valid(username)){search.queryIncome(username);}logger.afterLog(username);}}