Java 类javax.portlet.filter.PortletResponseWrapper 实例源码

项目:spring4-understanding    文件:PortletWebRequestTests.java   
@Test
public void testDecoratedNativeRequest() {
    MockRenderRequest portletRequest = new MockRenderRequest();
    MockRenderResponse portletResponse = new MockRenderResponse();
    PortletRequest decoratedRequest = new PortletRequestWrapper(portletRequest);
    PortletResponse decoratedResponse = new PortletResponseWrapper(portletResponse);
    PortletWebRequest request = new PortletWebRequest(decoratedRequest, decoratedResponse);
    assertSame(decoratedRequest, request.getNativeRequest());
    assertSame(decoratedRequest, request.getNativeRequest(PortletRequest.class));
    assertSame(portletRequest, request.getNativeRequest(RenderRequest.class));
    assertSame(portletRequest, request.getNativeRequest(MockRenderRequest.class));
    assertNull(request.getNativeRequest(MultipartRequest.class));
    assertSame(decoratedResponse, request.getNativeResponse());
    assertSame(decoratedResponse, request.getNativeResponse(PortletResponse.class));
    assertSame(portletResponse, request.getNativeResponse(RenderResponse.class));
    assertSame(portletResponse, request.getNativeResponse(MockRenderResponse.class));
    assertNull(request.getNativeResponse(MultipartRequest.class));
}
项目:class-guard    文件:PortletWebRequestTests.java   
@Test
public void testDecoratedNativeRequest() {
    MockRenderRequest portletRequest = new MockRenderRequest();
    MockRenderResponse portletResponse = new MockRenderResponse();
    PortletRequest decoratedRequest = new PortletRequestWrapper(portletRequest);
    PortletResponse decoratedResponse = new PortletResponseWrapper(portletResponse);
    PortletWebRequest request = new PortletWebRequest(decoratedRequest, decoratedResponse);
    assertSame(decoratedRequest, request.getNativeRequest());
    assertSame(decoratedRequest, request.getNativeRequest(PortletRequest.class));
    assertSame(portletRequest, request.getNativeRequest(RenderRequest.class));
    assertSame(portletRequest, request.getNativeRequest(MockRenderRequest.class));
    assertNull(request.getNativeRequest(MultipartRequest.class));
    assertSame(decoratedResponse, request.getNativeResponse());
    assertSame(decoratedResponse, request.getNativeResponse(PortletResponse.class));
    assertSame(portletResponse, request.getNativeResponse(RenderResponse.class));
    assertSame(portletResponse, request.getNativeResponse(MockRenderResponse.class));
    assertNull(request.getNativeResponse(MultipartRequest.class));
}
项目:spring4-understanding    文件:PortletUtils.java   
/**
 * Return an appropriate response object of the specified type, if available,
 * unwrapping the given response as far as necessary.
 * @param response the portlet response to introspect
 * @param requiredType the desired type of response object
 * @return the matching response object, or {@code null} if none
 * of that type is available
 */
@SuppressWarnings("unchecked")
public static <T> T getNativeResponse(PortletResponse response, Class<T> requiredType) {
    if (requiredType != null) {
        if (requiredType.isInstance(response)) {
            return (T) response;
        }
        else if (response instanceof PortletResponseWrapper) {
            return getNativeResponse(((PortletResponseWrapper) response).getResponse(), requiredType);
        }
    }
    return null;
}
项目:class-guard    文件:PortletUtils.java   
/**
 * Return an appropriate response object of the specified type, if available,
 * unwrapping the given response as far as necessary.
 * @param response the portlet response to introspect
 * @param requiredType the desired type of response object
 * @return the matching response object, or {@code null} if none
 * of that type is available
 */
@SuppressWarnings("unchecked")
public static <T> T getNativeResponse(PortletResponse response, Class<T> requiredType) {
    if (requiredType != null) {
        if (requiredType.isInstance(response)) {
            return (T) response;
        }
        else if (response instanceof PortletResponseWrapper) {
            return getNativeResponse(((PortletResponseWrapper) response).getResponse(), requiredType);
        }
    }
    return null;
}