Java 类org.apache.catalina.AsyncDispatcher 实例源码

项目:tomcat7    文件:AsyncContextImpl.java   
@Override
public void dispatch(ServletContext context, String path) {
    synchronized (asyncContextLock) {
        if (log.isDebugEnabled()) {
            logDebug("dispatch   ");
        }
        check();
        if (dispatch != null) {
            throw new IllegalStateException(
                    sm.getString("asyncContextImpl.dispatchingStarted"));
        }
        if (request.getAttribute(ASYNC_REQUEST_URI)==null) {
            request.setAttribute(ASYNC_REQUEST_URI, request.getRequestURI());
            request.setAttribute(ASYNC_CONTEXT_PATH, request.getContextPath());
            request.setAttribute(ASYNC_SERVLET_PATH, request.getServletPath());
            request.setAttribute(ASYNC_PATH_INFO, request.getPathInfo());
            request.setAttribute(ASYNC_QUERY_STRING, request.getQueryString());
        }
        final RequestDispatcher requestDispatcher = context.getRequestDispatcher(path);
        if (!(requestDispatcher instanceof AsyncDispatcher)) {
            throw new UnsupportedOperationException(
                    sm.getString("asyncContextImpl.noAsyncDispatcher"));
        }
        final AsyncDispatcher applicationDispatcher =
                (AsyncDispatcher) requestDispatcher;
        final ServletRequest servletRequest = getRequest();
        final ServletResponse servletResponse = getResponse();
        Runnable run = new Runnable() {
            @Override
            public void run() {
                request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCHED, null);
                try {
                    applicationDispatcher.dispatch(servletRequest, servletResponse);
                }catch (Exception x) {
                    //log.error("Async.dispatch",x);
                    throw new RuntimeException(x);
                }
            }
        };

        this.dispatch = run;
        this.request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCH, null);
        clearServletRequestResponse();
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:AsyncContextImpl.java   
@Override
public void dispatch(ServletContext context, String path) {
    synchronized (asyncContextLock) {
        if (log.isDebugEnabled()) {
            logDebug("dispatch   ");
        }
        check();
        if (dispatch != null) {
            throw new IllegalStateException(
                    sm.getString("asyncContextImpl.dispatchingStarted"));
        }
        if (request.getAttribute(ASYNC_REQUEST_URI)==null) {
            request.setAttribute(ASYNC_REQUEST_URI, request.getRequestURI());
            request.setAttribute(ASYNC_CONTEXT_PATH, request.getContextPath());
            request.setAttribute(ASYNC_SERVLET_PATH, request.getServletPath());
            request.setAttribute(ASYNC_PATH_INFO, request.getPathInfo());
            request.setAttribute(ASYNC_QUERY_STRING, request.getQueryString());
        }
        final RequestDispatcher requestDispatcher = context.getRequestDispatcher(path);
        if (!(requestDispatcher instanceof AsyncDispatcher)) {
            throw new UnsupportedOperationException(
                    sm.getString("asyncContextImpl.noAsyncDispatcher"));
        }
        final AsyncDispatcher applicationDispatcher =
                (AsyncDispatcher) requestDispatcher;
        final ServletRequest servletRequest = getRequest();
        final ServletResponse servletResponse = getResponse();
        Runnable run = new Runnable() {
            @Override
            public void run() {
                request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCHED, null);
                try {
                    applicationDispatcher.dispatch(servletRequest, servletResponse);
                }catch (Exception x) {
                    //log.error("Async.dispatch",x);
                    throw new RuntimeException(x);
                }
            }
        };

        this.dispatch = run;
        this.request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCH, null);
        clearServletRequestResponse();
    }
}
项目:lazycat    文件:AsyncContextImpl.java   
@Override
public void dispatch(ServletContext context, String path) {
    synchronized (asyncContextLock) {
        if (log.isDebugEnabled()) {
            logDebug("dispatch   ");
        }
        check();
        if (dispatch != null) {
            throw new IllegalStateException(sm.getString("asyncContextImpl.dispatchingStarted"));
        }
        if (request.getAttribute(ASYNC_REQUEST_URI) == null) {
            request.setAttribute(ASYNC_REQUEST_URI, request.getRequestURI());
            request.setAttribute(ASYNC_CONTEXT_PATH, request.getContextPath());
            request.setAttribute(ASYNC_SERVLET_PATH, request.getServletPath());
            request.setAttribute(ASYNC_PATH_INFO, request.getPathInfo());
            request.setAttribute(ASYNC_QUERY_STRING, request.getQueryString());
        }
        final RequestDispatcher requestDispatcher = context.getRequestDispatcher(path);
        if (!(requestDispatcher instanceof AsyncDispatcher)) {
            throw new UnsupportedOperationException(sm.getString("asyncContextImpl.noAsyncDispatcher"));
        }
        final AsyncDispatcher applicationDispatcher = (AsyncDispatcher) requestDispatcher;
        final ServletRequest servletRequest = getRequest();
        final ServletResponse servletResponse = getResponse();
        Runnable run = new Runnable() {
            @Override
            public void run() {
                request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCHED, null);
                try {
                    applicationDispatcher.dispatch(servletRequest, servletResponse);
                } catch (Exception x) {
                    // log.error("Async.dispatch",x);
                    throw new RuntimeException(x);
                }
            }
        };

        this.dispatch = run;
        this.request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCH, null);
        clearServletRequestResponse();
    }
}
项目:class-guard    文件:AsyncContextImpl.java   
@Override
public void dispatch(ServletContext context, String path) {
    if (log.isDebugEnabled()) {
        logDebug("dispatch   ");
    }
    check();
    if (dispatch != null) {
        throw new IllegalStateException(
                sm.getString("asyncContextImpl.dispatchingStarted"));
    }
    if (request.getAttribute(ASYNC_REQUEST_URI)==null) {
        request.setAttribute(ASYNC_REQUEST_URI, request.getRequestURI());
        request.setAttribute(ASYNC_CONTEXT_PATH, request.getContextPath());
        request.setAttribute(ASYNC_SERVLET_PATH, request.getServletPath());
        request.setAttribute(ASYNC_PATH_INFO, request.getPathInfo());
        request.setAttribute(ASYNC_QUERY_STRING, request.getQueryString());
    }
    final RequestDispatcher requestDispatcher = context.getRequestDispatcher(path);
    if (!(requestDispatcher instanceof AsyncDispatcher)) {
        throw new UnsupportedOperationException(
                sm.getString("asyncContextImpl.noAsyncDispatcher"));
    }
    final AsyncDispatcher applicationDispatcher =
            (AsyncDispatcher) requestDispatcher;
    final ServletRequest servletRequest = getRequest();
    final ServletResponse servletResponse = getResponse();
    Runnable run = new Runnable() {
        @Override
        public void run() {
            request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCHED, null);
            try {
                applicationDispatcher.dispatch(servletRequest, servletResponse);
            }catch (Exception x) {
                //log.error("Async.dispatch",x);
                throw new RuntimeException(x);
            }
        }
    };

    this.dispatch = run;
    this.request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCH, null);
}
项目:apache-tomcat-7.0.57    文件:AsyncContextImpl.java   
@Override
public void dispatch(ServletContext context, String path) {
    if (log.isDebugEnabled()) {
        logDebug("dispatch   ");
    }
    check();
    if (dispatch != null) {
        throw new IllegalStateException(
                sm.getString("asyncContextImpl.dispatchingStarted"));
    }
    if (request.getAttribute(ASYNC_REQUEST_URI)==null) {
        request.setAttribute(ASYNC_REQUEST_URI, request.getRequestURI());
        request.setAttribute(ASYNC_CONTEXT_PATH, request.getContextPath());
        request.setAttribute(ASYNC_SERVLET_PATH, request.getServletPath());
        request.setAttribute(ASYNC_PATH_INFO, request.getPathInfo());
        request.setAttribute(ASYNC_QUERY_STRING, request.getQueryString());
    }
    final RequestDispatcher requestDispatcher = context.getRequestDispatcher(path);
    if (!(requestDispatcher instanceof AsyncDispatcher)) {
        throw new UnsupportedOperationException(
                sm.getString("asyncContextImpl.noAsyncDispatcher"));
    }
    final AsyncDispatcher applicationDispatcher =
            (AsyncDispatcher) requestDispatcher;
    final ServletRequest servletRequest = getRequest();
    final ServletResponse servletResponse = getResponse();
    Runnable run = new Runnable() {
        @Override
        public void run() {
            request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCHED, null);
            try {
                applicationDispatcher.dispatch(servletRequest, servletResponse);
            }catch (Exception x) {
                //log.error("Async.dispatch",x);
                throw new RuntimeException(x);
            }
        }
    };

    this.dispatch = run;
    this.request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCH, null);
}
项目:apache-tomcat-7.0.57    文件:AsyncContextImpl.java   
@Override
public void dispatch(ServletContext context, String path) {
    if (log.isDebugEnabled()) {
        logDebug("dispatch   ");
    }
    check();
    if (dispatch != null) {
        throw new IllegalStateException(
                sm.getString("asyncContextImpl.dispatchingStarted"));
    }
    if (request.getAttribute(ASYNC_REQUEST_URI)==null) {
        request.setAttribute(ASYNC_REQUEST_URI, request.getRequestURI());
        request.setAttribute(ASYNC_CONTEXT_PATH, request.getContextPath());
        request.setAttribute(ASYNC_SERVLET_PATH, request.getServletPath());
        request.setAttribute(ASYNC_PATH_INFO, request.getPathInfo());
        request.setAttribute(ASYNC_QUERY_STRING, request.getQueryString());
    }
    final RequestDispatcher requestDispatcher = context.getRequestDispatcher(path);
    if (!(requestDispatcher instanceof AsyncDispatcher)) {
        throw new UnsupportedOperationException(
                sm.getString("asyncContextImpl.noAsyncDispatcher"));
    }
    final AsyncDispatcher applicationDispatcher =
            (AsyncDispatcher) requestDispatcher;
    final ServletRequest servletRequest = getRequest();
    final ServletResponse servletResponse = getResponse();
    Runnable run = new Runnable() {
        @Override
        public void run() {
            request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCHED, null);
            try {
                applicationDispatcher.dispatch(servletRequest, servletResponse);
            }catch (Exception x) {
                //log.error("Async.dispatch",x);
                throw new RuntimeException(x);
            }
        }
    };

    this.dispatch = run;
    this.request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCH, null);
}