Example usage for javax.servlet.http HttpServletResponseWrapper setResponse

List of usage examples for javax.servlet.http HttpServletResponseWrapper setResponse

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletResponseWrapper setResponse.

Prototype


public void setResponse(ServletResponse response) 

Source Link

Document

Sets the response being wrapped.

Usage

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  w  w  .  j  a  v a  2  s.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("$$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;
    }//  w  ww .j  av a2  s . 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("$$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;
    }//from ww  w .  j a v  a 2 s . 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("$$blitz-portal.portal", portal);

    return portal;
}

From source file:servletunit.struts.MockStrutsTestCase.java

/**
 * Set this TestCase to use a given HttpServletResponseWrapper
 * class when calling Action.execute().  Note that if this
 * method is not called, then the normal HttpServletResponse
 * object is used./*from   w w  w .j  ava2s  .c  o  m*/
 *
 * @param wrapper an HttpServletResponseWrapper object to be
 *                used when calling Action.execute().
 */
public void setResponseWrapper(HttpServletResponseWrapper wrapper) {
    if (logger.isDebugEnabled())
        logger.debug("Entering - wrapper = " + wrapper);
    init();
    if (wrapper == null)
        throw new IllegalArgumentException("wrapper class cannot be null!");
    else {
        if (wrapper.getResponse() == null)
            wrapper.setResponse(this.response);
        this.responseWrapper = wrapper;
    }
    if (logger.isDebugEnabled())
        logger.debug("Exiting");
}