001/*
002 * Copyright 2002-2015 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.async;
018
019import javax.servlet.http.HttpServletRequest;
020import javax.servlet.http.HttpServletResponse;
021
022import org.springframework.web.context.request.ServletWebRequest;
023
024/**
025 * An {@code AsyncWebRequest} to use when there is no underlying async support.
026 *
027 * @author Rossen Stoyanchev
028 * @since 3.2
029 */
030public class NoSupportAsyncWebRequest extends ServletWebRequest implements AsyncWebRequest {
031
032        public NoSupportAsyncWebRequest(HttpServletRequest request, HttpServletResponse response) {
033                super(request, response);
034        }
035
036
037        @Override
038        public void addCompletionHandler(Runnable runnable) {
039                // ignored
040        }
041
042        @Override
043        public void setTimeout(Long timeout) {
044                // ignored
045        }
046
047        @Override
048        public void addTimeoutHandler(Runnable runnable) {
049                // ignored
050        }
051
052        @Override
053        public boolean isAsyncStarted() {
054                return false;
055        }
056
057
058        // Not supported
059
060        @Override
061        public void startAsync() {
062                throw new UnsupportedOperationException("No async support in a pre-Servlet 3.0 runtime");
063        }
064
065        @Override
066        public boolean isAsyncComplete() {
067                throw new UnsupportedOperationException("No async support in a pre-Servlet 3.0 runtime");
068        }
069
070        @Override
071        public void dispatch() {
072                throw new UnsupportedOperationException("No async support in a pre-Servlet 3.0 runtime");
073        }
074
075}