001/*
002 * Copyright 2002-2017 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.web.context.request;
018
019import org.springframework.lang.Nullable;
020
021/**
022 * Extension of the {@link WebRequest} interface, exposing the
023 * native request and response objects in a generic fashion.
024 *
025 * <p>Mainly intended for framework-internal usage,
026 * in particular for generic argument resolution code.
027 *
028 * @author Juergen Hoeller
029 * @since 2.5.2
030 */
031public interface NativeWebRequest extends WebRequest {
032
033        /**
034         * Return the underlying native request object.
035         * @see javax.servlet.http.HttpServletRequest
036         */
037        Object getNativeRequest();
038
039        /**
040         * Return the underlying native response object, if any.
041         * @see javax.servlet.http.HttpServletResponse
042         */
043        @Nullable
044        Object getNativeResponse();
045
046        /**
047         * Return the underlying native request object, if available.
048         * @param requiredType the desired type of request object
049         * @return the matching request object, or {@code null} if none
050         * of that type is available
051         * @see javax.servlet.http.HttpServletRequest
052         */
053        @Nullable
054        <T> T getNativeRequest(@Nullable Class<T> requiredType);
055
056        /**
057         * Return the underlying native response object, if available.
058         * @param requiredType the desired type of response object
059         * @return the matching response object, or {@code null} if none
060         * of that type is available
061         * @see javax.servlet.http.HttpServletResponse
062         */
063        @Nullable
064        <T> T getNativeResponse(@Nullable Class<T> requiredType);
065
066}