public static <REQ extends Request, RESP extends Response> Context<REQ, RESP> registerContext(REQ req, RESP resp) { Context<REQ, RESP> context = new Context<REQ, RESP>(req, resp); contexts.set(context); return context; }
public <T> T getAttribute(String name, T defaultValue) { return (T) this.context.getAttribute(name, defaultValue); }
public <T> void setAttribute(String name, T value) { this.context.setAttribute(name, value); }
public void writeException(Throwable ex) throws IOException { TarsServantResponse response = this.context.response(); response.setRet(TarsHelper.SERVERUNKNOWNERR); response.setCause(ex); response.setResult(null); response.asyncCallEnd(); getCapHomeSkeleton().postInvokeCapHomeSkeleton(); Long startTime = this.context.getAttribute(Context.INTERNAL_START_TIME); TarsServantProcessor.printServiceFlowLog(flowLogger, this.context.request(), response.getRet(), (System.currentTimeMillis() - startTime.longValue()), ex.toString()); }
public static AsyncContext startAsync() throws IOException { Context<TarsServantRequest, TarsServantResponse> context = ContextManager.getContext(); AsyncContext aContext = new AsyncContext(context); context.response().asyncCallStart(); context.setAttribute(PORTAL_CAP_ASYNC_CONTEXT_ATTRIBUTE, aContext); return aContext; }
context.setAttribute(Context.INTERNAL_START_TIME, startTime); context.setAttribute(Context.INTERNAL_CLIENT_IP, session.getRemoteIp()); context.setAttribute(Context.INTERNAL_SERVICE_NAME, request.getServantName()); context.setAttribute(Context.INTERNAL_METHOD_NAME, request.getFunctionName()); context.setAttribute(Context.INTERNAL_SESSION_DATA, session); try { Context<TarsServantRequest, TarsServantResponse> context = ContextManager.getContext(); AsyncContext aContext = context.getAttribute(AsyncContext.PORTAL_CAP_ASYNC_CONTEXT_ATTRIBUTE); if (aContext != null) aContext.writeException(cause); } catch (Exception ex) {
public Object invoke(Method method, Object... args) throws Exception { Object value = null; try { preInvokeCapHomeSkeleton(); value = method.invoke(this.servantImpl, fixParamValueType(method, args)); } finally { if (!ContextManager.getContext().response().isAsyncMode()) { postInvokeCapHomeSkeleton(); } } return value; }
private ServantHomeSkeleton getCapHomeSkeleton() { AppContext appContext = AppContextManager.getInstance().getAppContext(); return appContext.getCapHomeSkeleton(this.context.request().getServantName()); }
public void writeException(Throwable ex) throws IOException { TarsServantResponse response = this.context.response(); response.setRet(TarsHelper.SERVERUNKNOWNERR); response.setCause(ex); response.setResult(null); response.asyncCallEnd(); getCapHomeSkeleton().postInvokeCapHomeSkeleton(); Long startTime = this.context.getAttribute(Context.INTERNAL_START_TIME); TarsServantProcessor.printServiceFlowLog(flowLogger, this.context.request(), response.getRet(), (System.currentTimeMillis() - startTime.longValue()), ex.toString()); }
public static AsyncContext startAsync() throws IOException { Context<TarsServantRequest, TarsServantResponse> context = ContextManager.getContext(); AsyncContext aContext = new AsyncContext(context); context.response().asyncCallStart(); context.setAttribute(PORTAL_CAP_ASYNC_CONTEXT_ATTRIBUTE, aContext); return aContext; }
context.setAttribute(Context.INTERNAL_START_TIME, startTime); context.setAttribute(Context.INTERNAL_CLIENT_IP, session.getRemoteIp()); context.setAttribute(Context.INTERNAL_SERVICE_NAME, request.getServantName()); context.setAttribute(Context.INTERNAL_METHOD_NAME, request.getFunctionName()); context.setAttribute(Context.INTERNAL_SESSION_DATA, session); try { Context<TarsServantRequest, TarsServantResponse> context = ContextManager.getContext(); AsyncContext aContext = context.getAttribute(AsyncContext.PORTAL_CAP_ASYNC_CONTEXT_ATTRIBUTE); if (aContext != null) aContext.writeException(cause); } catch (Exception ex) {
public Object invoke(Method method, Object... args) throws Exception { Object value = null; try { preInvokeCapHomeSkeleton(); value = method.invoke(this.servantImpl, fixParamValueType(method, args)); } finally { if (!ContextManager.getContext().response().isAsyncMode()) { postInvokeCapHomeSkeleton(); } } return value; }
private ServantHomeSkeleton getCapHomeSkeleton() { AppContext appContext = AppContextManager.getInstance().getAppContext(); return appContext.getCapHomeSkeleton(this.context.request().getServantName()); }
public void writeResult(Object result) throws IOException { TarsServantResponse response = this.context.response(); response.setRet(TarsHelper.SERVERSUCCESS); response.setCause(null); response.setResult(result); response.asyncCallEnd(); getCapHomeSkeleton().postInvokeCapHomeSkeleton(); Long startTime = this.context.getAttribute(Context.INTERNAL_START_TIME); TarsServantProcessor.printServiceFlowLog(flowLogger, this.context.request(), response.getRet(), (System.currentTimeMillis() - startTime.longValue()), ""); } }
@SuppressWarnings("unchecked") public <T> T getAttribute(String name) { return (T) getAttribute(name, null); }
public <T> void setAttribute(String name, T value) { this.context.setAttribute(name, value); }
public static <REQ extends Request, RESP extends Response> Context<REQ, RESP> registerContext(REQ req, RESP resp) { Context<REQ, RESP> context = new Context<REQ, RESP>(req, resp); contexts.set(context); return context; }
public void writeResult(Object result) throws IOException { TarsServantResponse response = this.context.response(); response.setRet(TarsHelper.SERVERSUCCESS); response.setCause(null); response.setResult(result); response.asyncCallEnd(); getCapHomeSkeleton().postInvokeCapHomeSkeleton(); Long startTime = this.context.getAttribute(Context.INTERNAL_START_TIME); TarsServantProcessor.printServiceFlowLog(flowLogger, this.context.request(), response.getRet(), (System.currentTimeMillis() - startTime.longValue()), ""); } }
@SuppressWarnings("unchecked") public <T> T getAttribute(String name) { return (T) getAttribute(name, null); }
if (appContext == null) throw new RuntimeException("failed to find the application named:[ROOT]"); Context<?, ?> context = ContextManager.registerContext(request, response); context.setAttribute(Context.INTERNAL_START_TIME, startTime); context.setAttribute(Context.INTERNAL_CLIENT_IP, session.getRemoteIp()); context.setAttribute(Context.INTERNAL_APP_NAME, appContext.name()); context.setAttribute(Context.INTERNAL_SERVICE_NAME, request.getServantName()); context.setAttribute(Context.INTERNAL_METHOD_NAME, request.getFunctionName()); context.setAttribute(Context.INTERNAL_SESSION_DATA, session);