001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     *  http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied.  See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    
020    
021    package javax.servlet;
022    
023    /**
024     * @version $Rev: 881527 $ $Date: 2009-11-17 16:14:26 -0500 (Tue, 17 Nov 2009) $
025     * @since 3.0
026     */
027    public interface AsyncContext {
028    
029        String ASYNC_CONTEXT_PATH = "javax.servlet.async.context_path";
030        String ASYNC_PATH_INFO = "javax.servlet.async.path_info";
031        String ASYNC_QUERY_STRING = "javax.servlet.async.query_string";
032        String ASYNC_REQUEST_URI = "javax.servlet.async.request_uri";
033        String ASYNC_SERVLET_PATH = "javax.servlet.async.servlet_path";
034    
035        void addListener(AsyncListener listener) throws IllegalStateException;
036    
037        void addListener(AsyncListener listener, ServletRequest request, ServletResponse response) throws IllegalStateException;
038    
039        void complete();
040    
041        <T extends AsyncListener> T createListener(Class<T> clazz) throws ServletException;
042    
043        void dispatch() throws IllegalStateException;
044    
045        void dispatch(ServletContext servletContext, String path) throws IllegalStateException;
046    
047        void dispatch(String path) throws IllegalStateException;
048    
049        ServletRequest getRequest();
050    
051        ServletResponse getResponse();
052    
053        /**
054         * Returns current timeout value in milliseconds. Zero or less means no timeout.
055         * If setTimeout has not been called, the container-specific default timeout is returned.
056         *
057         * @return timeout in milliseconds
058         */
059        long getTimeout();
060    
061        boolean hasOriginalRequestAndResponse();
062    
063        void setTimeout(long timeoutMilliseconds) throws IllegalStateException;
064    
065        void start(Runnable run);
066    }