From a739c574ab35a4564f5cc56ecc49ae373ba30698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E5=8A=B2Alex?= Date: Fri, 13 Mar 2020 15:12:52 +0800 Subject: [PATCH] =?UTF-8?q?update=20RPC=E6=A0=B8=E5=BF=83=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BB=A3=E7=A0=81=E4=BA=8C.md.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...75\344\273\243\347\240\201\344\272\214.md" | 47 ++++++++++++------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git "a/RPC\346\240\270\345\277\203\345\212\237\350\203\275\344\273\243\347\240\201\344\272\214.md" "b/RPC\346\240\270\345\277\203\345\212\237\350\203\275\344\273\243\347\240\201\344\272\214.md" index c39e7a4..d6c2187 100644 --- "a/RPC\346\240\270\345\277\203\345\212\237\350\203\275\344\273\243\347\240\201\344\272\214.md" +++ "b/RPC\346\240\270\345\277\203\345\212\237\350\203\275\344\273\243\347\240\201\344\272\214.md" @@ -122,14 +122,40 @@ public class OperateSignal implements SignalHandler { } } - + + + +// RequestFilter +public void filter(RpcContext context) throws Exception { + if (zzscfContext.getServerState() == ServerStateType.Reboot && (protocol.getPlatformType() == PlatformType.Java || protocol.getPlatformType() == PlatformType.PHP)) { + RpcResponse response = new RpcResponse(); + ResetProtocol rp = new ResetProtocol(); + rp.setMsg("This server is reboot!"); + responseProtocol.setSdpEntity(rp); + responseProtocol.setSDPType(SDPType.Reset); + response.setResponseBuffer(responseProtocol.toBytes(false, null)); + context.setRpcResponse(response); + context.setExecFilter(ExecFilterType.None); + context.setDoInvoke(false); + } +} + + + + public Object innerInvoke(RpcContext context, MethodSignature methodSignature) throws Exception { requestFilter(context); logger.debug("------------------------------ begin request-----------------------------"); Object response = null; RpcContext.setThreadLocal(context) - ... - ... + + //判断是否需要Invoke,在filter中被设置 + if (context.isDoInvoke()) { + //反射调用实际处理方法逻辑 + ...... + ...... + } + context.getResponseProtocol().setSdpEntity(response); responseFilter(context); RpcContext.clear(); @@ -146,20 +172,7 @@ protected void requestFilter(RpcContext context) throws Exception { logger.debug("end requestFilters"); } -// RequestFilter -public void filter(RpcContext context) throws Exception { - if (zzscfContext.getServerState() == ServerStateType.Reboot && (protocol.getPlatformType() == PlatformType.Java || protocol.getPlatformType() == PlatformType.PHP)) { - RpcResponse response = new RpcResponse(); - ResetProtocol rp = new ResetProtocol(); - rp.setMsg("This server is reboot!"); - responseProtocol.setSdpEntity(rp); - responseProtocol.setSDPType(SDPType.Reset); - response.setResponseBuffer(responseProtocol.toBytes(false, null)); - context.setRpcResponse(response); - context.setExecFilter(ExecFilterType.None); - context.setDoInvoke(false); - } -} + -- Gitee