The company recently wrote to a third party interface called framework, in order to standardize and to help stabilize the business permit, close-up of this framework.
Frame ### Invoker.invoking facade -BizService service interface -BizAOPService service section + invoking service interface call BizService.check parameter checking BizService.pre pre-call service BizAOPService.pre front section business call BizService.execute service call BizAOPService.after after the service section set to call call only after BizService.after business BizService.handlerException exception handling
The actual frame structure is very simple, just the same thing templated, not clear what abstraction, not a bridge leading out of things.
Here I can actually be BizAOPService into a form similar set of interceptors like there is here to see specific needs.
public interface Invoker<M,N> { void invoking(BizService<M,N> bizService, BizAOPService<M,N> bizAOPService, M m, N n) throws Exception ; }
interface BizService public <M, N> { / ** Check parameter * / void Check (M Request, Response N); / ** before the call processing parameters such as the built-in assembly, update the service status * / void pre (M Request, N Response); / ** interface call * / void Execute (M Request, N Response); / ** call process after updating the service status * / void after (M Request, N Response); / * ** check parameter exception handling / void checkException (M Request, Response N, exception E) throws exception; exception processing / call ** * / void preException (M Request, Response N, exception E) throws exception; / call exception handling ** * / void executeException (M Request, Response N, exception E) throws exception; / exception handler after the invocation ** * / void afterException (M Request, Response N, exception E) throws exception; }
import org.slf4j.Logger; import org.slf4j.LoggerFactory; public abstract class AbstractBizService<M,N> implements BizService<M,N>{ private static final Logger LOGGER = LoggerFactory.getLogger(AbstractBizService.class); @Override public void check(M request, N response) { LOGGER.info("接口调用参数检查:{},{}", request, response); } @Override public void pre(M request, N response) { LOGGER.info("调用前处理:{},{}", request, response); } @Override public void after(M request, N response) { LOGGER.info("调用后处理:{},{}", request, response); } @Override void checkException public (M Request, Response N, Exception E) throws Exception { logger.info ( "post-call exception handling: {}, {}", request, response,is); LOGGER.info ( "interface call parameter check exception handler: {}, {}", Request, Response, E); the throw E; } @Override public void preException (M Request, Response N, Exception E) throws Exception { LOGGER. info ( "exception handling before calling: {}, {}", Request, Response, E); the throw E; } @Override public void executeException (M Request, Response N, exception E) throws exception { logger.info ( "Interface call exception handling: {}, {} ", Request, Response, E); the throw E; } @Override public void afterException (M Request, Response N, exception E) throws exception { the throw E; } }
public interface BizAOPService<M,N> { void pre(M request, N response); void after(M request, N response); String getBizNo(M request); }