/** * 将<code>WebContext</code>对象和request相关联。 * * @param WebContext <code>WebContext</code>对象 */ public static void setWebContext(WebContext WebContext) { HttpServletRequest request = WebContext.getRequest(); request.setAttribute(REQUEST_CONTEXT_KEY, WebContext); }
private WebContext getWebContext(WebContext context, List<TinyFilter> tinyFilters, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { WebContext webContext = WebContextUtil.getWebContext(context .getRequest()); if (webContext == null) { webContext = createWrapperContext(context, tinyFilters, request, response); context.getRequest().setAttribute(WEB_CONTEXT_OWNER_KEY, this); } return webContext; }
private WebContext getWebContext(WebContext context, List<TinyFilter> tinyFilters, HttpServletRequest request, HttpServletResponse response) { WebContext webContext = WebContextUtil.getWebContext(context .getRequest()); if (webContext == null) { webContext = createWrapperContext(context, tinyFilters, request, response); context.getRequest().setAttribute(WEB_CONTEXT_OWNER_KEY, this); } return webContext; }
public void reallyProcess(String urlString, WebContext context) throws ServletException, IOException { HttpServletRequest request = context.getRequest(); HttpServletResponse response = context.getResponse(); servlet.service(request, response); }
public void execute(Context context) { Assert.assertNotNull(sessionKey, "sessionKey must not null"); WebContext webContext = (WebContext) context; webContext.getRequest().getSession(true).removeAttribute(sessionKey); }
public void execute(Context context) { try { WebContext webContext = (WebContext) context; HttpServletRequest request = webContext.getRequest(); request.getRequestDispatcher(path).forward(request, webContext.getResponse()); } catch (Exception e) { logger.errorMessage("Forward到地址[{}]出错,错误原因:{}", e, path, e.getMessage()); } }
public void execute(Context context) { try { WebContext webContext = (WebContext) context; HttpServletRequest request = webContext.getRequest(); request.getRequestDispatcher(path).forward(request, webContext.getResponse()); } catch (Exception e) { logger.errorMessage("Forward到地址[{}]出错,错误原因:{}", e, path, e.getMessage()); } }
/** * 包装一个<code>RequestContext</code>对象。 * * @param wrappedContext * 被包装的<code>RequestContext</code> */ public ParserWebContextImpl(WebContext wrappedContext) { super(wrappedContext); setRequest(new RequestWrapper(wrappedContext.getRequest())); }
public void reallyProcess(String urlString, WebContext context) { HttpServletRequest request = context.getRequest(); HttpServletResponse response = context.getResponse(); try { servlet.service(request, response); } catch (Exception e) { logger.errorMessage("servlet:{}执行出错", e, servlet.getServletName()); throw new RuntimeException("servlet执行出错", e); } }
/** * 包装一个<code>RequestContext</code>对象。 * * @param wrappedContext 被包装的<code>RequestContext</code> */ public ParserWebContextImpl(WebContext wrappedContext) { super(wrappedContext); setRequest(new RequestWrapper(wrappedContext.getRequest())); }
private String getHttpMethod(RewriteSubstitutionContext context) { WebContext webContext = context.getParserWebContext(); String httpMethod = webContext.get(HTTP_METHOD_KEY); if (StringUtil.isBlank(httpMethod)) { httpMethod = webContext.getRequest().getMethod(); } return httpMethod; }
public AbstractWebContextWrapper(WebContext wrappedContext) { assertNotNull(wrappedContext, "wrappedContext"); this.wrappedContext = wrappedContext; this.request = wrappedContext.getRequest(); this.response = wrappedContext.getResponse(); this.servletContext = wrappedContext.getServletContext(); }
public AbstractWebContextWrapper(WebContext wrappedContext) { assertNotNull(wrappedContext, "wrappedContext"); this.wrappedContext = wrappedContext; this.request = wrappedContext.getRequest(); this.response = wrappedContext.getResponse(); this.servletContext = wrappedContext.getServletContext(); }
public void execute(Context context) { Assert.assertNotNull(contextKey, "contextKey must not null"); Assert.assertNotNull(sessionKey, "sessionKey must not null"); Object object = context.get(contextKey); if (!ObjectUtil.isEmptyObject(object)) { WebContext webContext = (WebContext) context; logger.logMessage(LogLevel.INFO, "put object:[{}] to session,the key is [{}]", object, sessionKey); webContext.getRequest().getSession(true).setAttribute(sessionKey, object); } else { logger.logMessage(LogLevel.WARN, "not found object with key:[{}] from context", contextKey); } }
public void execute(Context context) { Assert.assertNotNull(contextKey, "contextKey must not null"); Assert.assertNotNull(sessionKey, "sessionKey must not null"); Object object=context.get(contextKey); if(!ObjectUtil.isEmptyObject(object)){ WebContext webContext=(WebContext)context; logger.logMessage(LogLevel.INFO, "put object:[{}] to session,the key is [{}]",object,sessionKey); webContext.getRequest().getSession(true).setAttribute(sessionKey, object); }else{ logger.logMessage(LogLevel.WARN, "not found object with key:[{}] from context",contextKey); } }
public WebContext getAlreadyWrappedContext(WebContext wrappedContext) { SessionWebContext sessionWebContext= new SessionWebContextImpl(wrappedContext, config); String pattern = config.ignoreSessionCheckPattern(); if(!StringUtil.isBlank(pattern)){ String servletPath = WebContextUtil.getServletPath(wrappedContext.getRequest()); if(Pattern.matches(pattern, servletPath)){ sessionWebContext.setIgnoreSessionTimeoutCheck(true); } } return sessionWebContext; }
/** 构造函数。 */ public SessionWebContextImpl(WebContext wrappedContext, SessionConfig sessionConfig) { super(wrappedContext); this.sessionConfig = sessionConfig; setRequest(new SessionRequestWrapper(wrappedContext.getRequest())); setResponse(new SessionResponseWrapper(wrappedContext.getResponse())); }
/** * 构造函数。 */ public SessionWebContextImpl(WebContext wrappedContext, SessionConfig sessionConfig) { super(wrappedContext); this.sessionConfig = sessionConfig; setRequest(new SessionRequestWrapper(wrappedContext.getRequest())); setResponse(new SessionResponseWrapper(wrappedContext.getResponse())); }
/** * 包装一个<code>RequestContext</code>对象。 * * @param wrappedContext 被包装的<code>RequestContext</code> */ public SetLocaleWebContextImpl(WebContext wrappedContext) { super(wrappedContext); setRequest(new RequestWrapper(wrappedContext.getRequest())); setResponse(new ResponseWrapper(wrappedContext.getResponse())); }
public void filterWrapper(WebContext context, FilterHandler handler) throws IOException, ServletException { HttpServletRequest request = context.getRequest(); HttpServletResponse response = context.getResponse(); String servletPath = handler.getServletPath(); List<Filter> matchFilters = getMatchFilters(servletPath, filterMap); logger.logMessage(LogLevel.DEBUG, "the pre wrapper httpFilters for the request path:[{0}] is [{1}]", servletPath, matchFilters); TinyFilterChain filterChain = new TinyFilterChain(matchFilters, handler); filterChain.doFilter(request, response); }