List of usage examples for javax.servlet.http HttpServletRequestWrapper setRequest
public void setRequest(ServletRequest request)
From source file:com.sinosoft.one.mvc.web.portal.impl.PortalFactoryImpl.java
public Portal createPortal(Invocation inv) { PortalImpl portal = (PortalImpl) inv.getAttribute("$$one-mvc-portal.portal"); if (portal != null) { return portal; }/*from w ww .j a v a 2s. c om*/ portal = new PortalImpl(inv, executorService, windowListener); // long timeout = 0; PortalSetting portalSetting = inv.getMethod().getAnnotation(PortalSetting.class); if (portalSetting != null) { if (portalSetting.timeout() >= 0) { long annotationTimeout = portalSetting.timeUnit().toMillis(portalSetting.timeout()); // < 0PortalSetting?PortalSettingtimeoutdefaultTimeout // == 0????defaultTimeout if (annotationTimeout >= 0) { timeout = annotationTimeout; } } } if (timeout > 0) { portal.setTimeout(timeout); } // ?request HttpServletRequest innerRequest = inv.getRequest(); HttpServletRequestWrapper requestWrapper = null; while (innerRequest instanceof HttpServletRequestWrapper) { requestWrapper = (HttpServletRequestWrapper) innerRequest; innerRequest = (HttpServletRequest) ((HttpServletRequestWrapper) innerRequest).getRequest(); } final PortalRequest portalRequest = new PortalRequest(portal, innerRequest); if (requestWrapper == null) { inv.setRequest(portalRequest); } else { requestWrapper.setRequest(portalRequest); } // ?response HttpServletResponse innerResponse = inv.getResponse(); HttpServletResponseWrapper responseWrapper = null; while (innerResponse instanceof HttpServletResponseWrapper) { responseWrapper = (HttpServletResponseWrapper) innerResponse; innerResponse = (HttpServletResponse) ((HttpServletResponseWrapper) innerResponse).getResponse(); } final PortalResponse portalResponse = new PortalResponse(portal, innerResponse); if (responseWrapper == null) { ((InvocationBean) inv).setResponse(portalResponse); } else { responseWrapper.setResponse(portalResponse); } // inv.setAttribute("$$one-mvc-portal.portal", portal); return portal; }
From source file:net.paoding.rose.web.portal.impl.PortalFactoryImpl.java
@Override public Portal createPortal(Invocation inv) { PortalImpl portal = (PortalImpl) inv.getAttribute("$$paoding-rose-portal.portal"); if (portal != null) { return portal; }/* www . jav a 2s. c o m*/ portal = new PortalImpl(inv, executorService, windowListener); // long timeout = 0; PortalSetting portalSetting = inv.getMethod().getAnnotation(PortalSetting.class); if (portalSetting != null) { if (portalSetting.timeout() >= 0) { long annotationTimeout = portalSetting.timeUnit().toMillis(portalSetting.timeout()); // < 0PortalSetting?PortalSettingtimeoutdefaultTimeout // == 0????defaultTimeout if (annotationTimeout >= 0) { timeout = annotationTimeout; } } } if (timeout > 0) { portal.setTimeout(timeout); } // ?request HttpServletRequest innerRequest = inv.getRequest(); HttpServletRequestWrapper requestWrapper = null; while (innerRequest instanceof HttpServletRequestWrapper) { requestWrapper = (HttpServletRequestWrapper) innerRequest; innerRequest = (HttpServletRequest) ((HttpServletRequestWrapper) innerRequest).getRequest(); } final PortalRequest portalRequest = new PortalRequest(portal, innerRequest); if (requestWrapper == null) { inv.setRequest(portalRequest); } else { requestWrapper.setRequest(portalRequest); } // ?response HttpServletResponse innerResponse = inv.getResponse(); HttpServletResponseWrapper responseWrapper = null; while (innerResponse instanceof HttpServletResponseWrapper) { responseWrapper = (HttpServletResponseWrapper) innerResponse; innerResponse = (HttpServletResponse) ((HttpServletResponseWrapper) innerResponse).getResponse(); } final PortalResponse portalResponse = new PortalResponse(portal, innerResponse); if (responseWrapper == null) { ((InvocationBean) inv).setResponse(portalResponse); } else { responseWrapper.setResponse(portalResponse); } // inv.setAttribute("$$paoding-rose-portal.portal", portal); return portal; }
From source file:com.laxser.blitz.web.portal.impl.PortalFactoryImpl.java
@Override public Portal createPortal(Invocation inv) { PortalImpl portal = (PortalImpl) inv.getAttribute("$$blitz-portal.portal"); if (portal != null) { return portal; }// ww w.j a va 2s . co m portal = new PortalImpl(inv, executorService, windowListener); // long timeout = 0; PortalSetting portalSetting = inv.getMethod().getAnnotation(PortalSetting.class); if (portalSetting != null) { if (portalSetting.timeout() >= 0) { long annotationTimeout = portalSetting.timeUnit().toMillis(portalSetting.timeout()); // < 0PortalSetting?PortalSettingtimeoutdefaultTimeout // == 0????defaultTimeout if (annotationTimeout >= 0) { timeout = annotationTimeout; } } } if (timeout > 0) { portal.setTimeout(timeout); } // ?request HttpServletRequest innerRequest = inv.getRequest(); HttpServletRequestWrapper requestWrapper = null; while (innerRequest instanceof HttpServletRequestWrapper) { requestWrapper = (HttpServletRequestWrapper) innerRequest; innerRequest = (HttpServletRequest) ((HttpServletRequestWrapper) innerRequest).getRequest(); } final PortalRequest portalRequest = new PortalRequest(portal, innerRequest); if (requestWrapper == null) { inv.setRequest(portalRequest); } else { requestWrapper.setRequest(portalRequest); } // ?response HttpServletResponse innerResponse = inv.getResponse(); HttpServletResponseWrapper responseWrapper = null; while (innerResponse instanceof HttpServletResponseWrapper) { responseWrapper = (HttpServletResponseWrapper) innerResponse; innerResponse = (HttpServletResponse) ((HttpServletResponseWrapper) innerResponse).getResponse(); } final PortalResponse portalResponse = new PortalResponse(portal, innerResponse); if (responseWrapper == null) { ((InvocationBean) inv).setResponse(portalResponse); } else { responseWrapper.setResponse(portalResponse); } // inv.setAttribute("$$blitz-portal.portal", portal); return portal; }
From source file:org.primeframework.mvc.parameter.RequestBodyWorkflow.java
@Override public void perform(WorkflowChain workflowChain) throws IOException, ServletException { // Let the container parse out the GET and POST parameters by calling the getParameterMap method // After this call, if the method is GET with any content-type or POST with the content-type as // x-www-form-urlencoded the InputStream will be empty Map<String, String[]> parameters = request.getParameterMap(); Map<String, List<String>> parsedParameters = null; String contentType = request.getContentType(); if (contentType != null) { contentType = contentType.toLowerCase(); if (contentType.startsWith("multipart/")) { FilesAndParameters filesAndParameters = handleFiles(); request.setAttribute(RequestKeys.FILE_ATTRIBUTE, filesAndParameters.files); parsedParameters = filesAndParameters.parameters; } else if (contentType.startsWith("application/x-www-form-urlencoded")) { parsedParameters = parse(request.getInputStream(), request.getContentLength(), request.getCharacterEncoding()); }// w w w . ja v a2s .c o m } if (parsedParameters != null && parsedParameters.size() > 0) { HttpServletRequestWrapper wrapper = (HttpServletRequestWrapper) request; HttpServletRequest previous = (HttpServletRequest) wrapper.getRequest(); HttpServletRequest newRequest = new ParameterHttpServletRequestWrapper(previous, combine(parameters, parsedParameters)); wrapper.setRequest(newRequest); } workflowChain.continueWorkflow(); }
From source file:servletunit.struts.MockStrutsTestCase.java
/** * Set this TestCase to use a given HttpServletRequestWrapper * class when calling Action.execute(). Note that if this * method is not called, then the normal HttpServletRequest * object is used./*from w w w . java 2 s . c o m*/ * * @param wrapper an HttpServletRequestWrapper object to be * used when calling Action.execute(). */ public void setRequestWrapper(HttpServletRequestWrapper wrapper) { if (logger.isDebugEnabled()) logger.debug("Entering - wrapper = " + wrapper); init(); if (wrapper == null) throw new IllegalArgumentException("wrapper class cannot be null!"); else { if (wrapper.getRequest() == null) wrapper.setRequest(this.request); this.requestWrapper = wrapper; } if (logger.isDebugEnabled()) logger.debug("Exiting"); }