Package org.apache.catalina.core

Examples of org.apache.catalina.core.AsyncContextImpl$PrivilegedSetTccl


            throw new IllegalStateException(
                    "Dispatch may only happen on an existing request.");
        }
        boolean comet = false;
        boolean success = true;
        AsyncContextImpl asyncConImpl = (AsyncContextImpl)request.getAsyncContext();
        req.getRequestProcessor().setWorkerThreadName(Thread.currentThread().getName());
        try {
            if (!request.isAsync() && !comet) {
                // Error or timeout - need to tell listeners the request is over
                // Have to test this first since state may change while in this
                // method and this is only required if entering this method in
                // this state
                Context ctxt = request.getMappingData().context;
                if (ctxt != null) {
                    ctxt.fireRequestDestroyEvent(request);
                }
                // Lift any suspension (e.g. if sendError() was used by an async
                // request) to allow the response to be written to the client
                response.setSuspended(false);
            }

            if (status==SocketStatus.TIMEOUT) {
                success = true;
                if (!asyncConImpl.timeout()) {
                    asyncConImpl.setErrorState(null, false);
                }
            } else if (status==SocketStatus.ASYNC_READ_ERROR) {
                // A async read error is an IO error which means the socket
                // needs to be closed so set success to false to trigger a
                // close
                success = false;
                Throwable t = (Throwable)req.getAttribute(
                        RequestDispatcher.ERROR_EXCEPTION);
                req.getAttributes().remove(RequestDispatcher.ERROR_EXCEPTION);
                ReadListener readListener = req.getReadListener();
                if (readListener != null) {
                    ClassLoader oldCL = null;
                    try {
                        oldCL = request.getContext().bind(false, null);
                        readListener.onError(t);
                    } finally {
                        request.getContext().unbind(false, oldCL);
                    }
                }
                if (t != null) {
                    asyncConImpl.setErrorState(t, true);
                }
            } else if (status==SocketStatus.ASYNC_WRITE_ERROR) {
                // A async write error is an IO error which means the socket
                // needs to be closed so set success to false to trigger a
                // close
                success = false;
                Throwable t = (Throwable)req.getAttribute(
                        RequestDispatcher.ERROR_EXCEPTION);
                req.getAttributes().remove(RequestDispatcher.ERROR_EXCEPTION);
                if (res.getWriteListener() != null) {
                    ClassLoader oldCL = null;
                    try {
                        oldCL = request.getContext().bind(false, null);
                        res.getWriteListener().onError(t);
                    } finally {
                        request.getContext().unbind(false, oldCL);
                    }
                }
                if (t != null) {
                    asyncConImpl.setErrorState(t, true);
                }
            }

            // Check to see if non-blocking writes or reads are being used
            if (!request.isAsyncDispatching() && request.isAsync()) {
                WriteListener writeListener = res.getWriteListener();
                ReadListener readListener = req.getReadListener();
                if (writeListener != null && status == SocketStatus.OPEN_WRITE) {
                    ClassLoader oldCL = null;
                    try {
                        oldCL = request.getContext().bind(false, null);
                        res.onWritePossible();
                        if (request.isFinished() && req.sendAllDataReadEvent() &&
                                readListener != null) {
                            readListener.onAllDataRead();
                        }
                    } catch (Throwable t) {
                        ExceptionUtils.handleThrowable(t);
                        writeListener.onError(t);
                        throw t;
                    } finally {
                        request.getContext().unbind(false, oldCL);
                    }
                    success = true;
                } else if (readListener != null && status == SocketStatus.OPEN_READ) {
                    ClassLoader oldCL = null;
                    try {
                        oldCL = request.getContext().bind(false, null);
                        // If data is being read on a non-container thread a
                        // dispatch with status OPEN_READ will be used to get
                        // execution back on a container thread for the
                        // onAllDataRead() event. Therefore, make sure
                        // onDataAvailable() is not called in this case.
                        if (!request.isFinished()) {
                            readListener.onDataAvailable();
                        }
                        if (request.isFinished() && req.sendAllDataReadEvent()) {
                            readListener.onAllDataRead();
                        }
                    } catch (Throwable t) {
                        ExceptionUtils.handleThrowable(t);
                        readListener.onError(t);
                        throw t;
                    } finally {
                        request.getContext().unbind(false, oldCL);
                    }
                    success = true;
                }
            }

            if (request.isAsyncDispatching()) {
                success = true;
                connector.getService().getContainer().getPipeline().getFirst().invoke(request, response);
                Throwable t = (Throwable) request.getAttribute(
                        RequestDispatcher.ERROR_EXCEPTION);
                if (t != null) {
                    asyncConImpl.setErrorState(t, true);
                }
            }

            if (request.isComet()) {
                if (!response.isClosed() && !response.isError()) {
View Full Code Here


                        request.setFilterChain(null);
                    }
                }

            }
            AsyncContextImpl asyncConImpl = (AsyncContextImpl)request.getAsyncContext();
            if (asyncConImpl != null) {
                async = true;
                ReadListener readListener = req.getReadListener();
                if (readListener != null && request.isFinished()) {
                    // Possible the all data may have been read during service()
View Full Code Here

            throw new IllegalStateException(
                    "Dispatch may only happen on an existing request.");
        }
        boolean comet = false;
        boolean success = true;
        AsyncContextImpl asyncConImpl = (AsyncContextImpl)request.getAsyncContext();
        req.getRequestProcessor().setWorkerThreadName(Thread.currentThread().getName());
        try {
            if (!request.isAsync() && !comet) {
                // Error or timeout - need to tell listeners the request is over
                // Have to test this first since state may change while in this
                // method and this is only required if entering this method in
                // this state
                Context ctxt = (Context) request.getMappingData().context;
                if (ctxt != null) {
                    ctxt.fireRequestDestroyEvent(request);
                }
                // Lift any suspension (e.g. if sendError() was used by an async
                // request
                response.setSuspended(false);
            }

            if (status==SocketStatus.TIMEOUT) {
                success = true;
                if (!asyncConImpl.timeout()) {
                    asyncConImpl.setErrorState(null);
                }
            }
            if (request.isAsyncDispatching()) {
                success = true;
                connector.getService().getContainer().getPipeline().getFirst().invoke(request, response);
                Throwable t = (Throwable) request.getAttribute(
                        RequestDispatcher.ERROR_EXCEPTION);
                if (t != null) {
                    asyncConImpl.setErrorState(t);
                }
            }

            if (request.isComet()) {
                if (!response.isClosed() && !response.isError()) {
View Full Code Here

                        request.setFilterChain(null);
                    }
                }

            }
            AsyncContextImpl asyncConImpl = (AsyncContextImpl)request.getAsyncContext();
            if (asyncConImpl != null) {
                async = true;
            } else if (!comet) {
                request.finishRequest();
                response.finishResponse();
View Full Code Here

            throw new IllegalStateException(
                    "Dispatch may only happen on an existing request.");
        }
        boolean comet = false;
        boolean success = true;
        AsyncContextImpl asyncConImpl = (AsyncContextImpl)request.getAsyncContext();
        req.getRequestProcessor().setWorkerThreadName(Thread.currentThread().getName());
        try {
            if (!request.isAsync() && !comet) {
                // Error or timeout - need to tell listeners the request is over
                // Have to test this first since state may change while in this
                // method and this is only required if entering this method in
                // this state
                Context ctxt = (Context) request.getMappingData().context;
                if (ctxt != null) {
                    ctxt.fireRequestDestroyEvent(request);
                }
                // Lift any suspension (e.g. if sendError() was used by an async
                // request) to allow the response to be written to the client
                response.setSuspended(false);
            }

            if (status==SocketStatus.TIMEOUT) {
                success = true;
                if (!asyncConImpl.timeout()) {
                    asyncConImpl.setErrorState(null, false);
                }
            }
            if (request.isAsyncDispatching()) {
                success = true;
                connector.getService().getContainer().getPipeline().getFirst().invoke(request, response);
                Throwable t = (Throwable) request.getAttribute(
                        RequestDispatcher.ERROR_EXCEPTION);
                if (t != null) {
                    asyncConImpl.setErrorState(t, true);
                }
            }

            if (request.isComet()) {
                if (!response.isClosed() && !response.isError()) {
View Full Code Here

                        request.setFilterChain(null);
                    }
                }

            }
            AsyncContextImpl asyncConImpl = (AsyncContextImpl)request.getAsyncContext();
            if (asyncConImpl != null) {
                async = true;
            } else if (!comet) {
                request.finishRequest();
                response.finishResponse();
View Full Code Here

        if (!isAsyncSupported()) {
            throw new IllegalStateException(sm.getString("request.asyncNotSupported"));
        }

        if (asyncContext == null) {
            asyncContext = new AsyncContextImpl(this);
        }

        asyncContext.setStarted(getContext(), request, response,
                request==getRequest() && response==getResponse().getResponse());
        asyncContext.setTimeout(getConnector().getAsyncTimeout());
View Full Code Here

            throw new IllegalStateException(
                    "Dispatch may only happen on an existing request.");
        }
        boolean comet = false;
        boolean success = true;
        AsyncContextImpl asyncConImpl = (AsyncContextImpl)request.getAsyncContext();
        req.getRequestProcessor().setWorkerThreadName(Thread.currentThread().getName());
        try {
            if (!request.isAsync() && !comet) {
                // Error or timeout - need to tell listeners the request is over
                // Have to test this first since state may change while in this
                // method and this is only required if entering this method in
                // this state
                Context ctxt = request.getMappingData().context;
                if (ctxt != null) {
                    ctxt.fireRequestDestroyEvent(request);
                }
                // Lift any suspension (e.g. if sendError() was used by an async
                // request) to allow the response to be written to the client
                response.setSuspended(false);
            }

            if (status==SocketStatus.TIMEOUT) {
                success = true;
                if (!asyncConImpl.timeout()) {
                    asyncConImpl.setErrorState(null, false);
                }
            } else if (status==SocketStatus.ASYNC_READ_ERROR) {
                // A async read error is an IO error which means the socket
                // needs to be closed so set success to false to trigger a
                // close
                success = false;
                Throwable t = (Throwable)req.getAttribute(
                        RequestDispatcher.ERROR_EXCEPTION);
                req.getAttributes().remove(RequestDispatcher.ERROR_EXCEPTION);
                if (req.getReadListener() != null) {
                    ClassLoader oldCL =
                            Thread.currentThread().getContextClassLoader();
                    ClassLoader newCL =
                            request.getContext().getLoader().getClassLoader();
                    try {
                        Thread.currentThread().setContextClassLoader(newCL);
                        req.getReadListener().onError(t);
                    } finally {
                        Thread.currentThread().setContextClassLoader(oldCL);
                    }
                }
                if (t != null) {
                    asyncConImpl.setErrorState(t, true);
                }
            } else if (status==SocketStatus.ASYNC_WRITE_ERROR) {
                // A async write error is an IO error which means the socket
                // needs to be closed so set success to false to trigger a
                // close
                success = false;
                Throwable t = (Throwable)req.getAttribute(
                        RequestDispatcher.ERROR_EXCEPTION);
                req.getAttributes().remove(RequestDispatcher.ERROR_EXCEPTION);
                if (res.getWriteListener() != null) {
                    ClassLoader oldCL =
                            Thread.currentThread().getContextClassLoader();
                    ClassLoader newCL =
                            request.getContext().getLoader().getClassLoader();
                    try {
                        Thread.currentThread().setContextClassLoader(newCL);
                        res.getWriteListener().onError(t);
                    } finally {
                        Thread.currentThread().setContextClassLoader(oldCL);
                    }
                }
                if (t != null) {
                    asyncConImpl.setErrorState(t, true);
                }
            }

            // Check to see if non-blocking writes or reads are being used
            if (!request.isAsyncDispatching() && request.isAsync()) {
                if (res.getWriteListener() != null &&
                        status == SocketStatus.OPEN_WRITE) {
                    ClassLoader oldCL =
                            Thread.currentThread().getContextClassLoader();
                    ClassLoader newCL =
                            request.getContext().getLoader().getClassLoader();
                    try {
                        Thread.currentThread().setContextClassLoader(newCL);
                        res.onWritePossible();
                    } catch (Throwable t) {
                        ExceptionUtils.handleThrowable(t);
                        res.getWriteListener().onError(t);
                        throw t;
                    } finally {
                        Thread.currentThread().setContextClassLoader(oldCL);
                    }
                    success = true;
                } else if (req.getReadListener() != null &&
                        status == SocketStatus.OPEN_READ) {
                    ClassLoader oldCL =
                            Thread.currentThread().getContextClassLoader();
                    ClassLoader newCL =
                            request.getContext().getLoader().getClassLoader();
                    try {
                        Thread.currentThread().setContextClassLoader(newCL);
                        req.getReadListener().onDataAvailable();
                        if (request.isFinished()) {
                            req.getReadListener().onAllDataRead();
                        }
                    } catch (Throwable t) {
                        ExceptionUtils.handleThrowable(t);
                        req.getReadListener().onError(t);
                        throw t;
                    } finally {
                        Thread.currentThread().setContextClassLoader(oldCL);
                    }
                    success = true;
                }
            }

            if (request.isAsyncDispatching()) {
                success = true;
                connector.getService().getContainer().getPipeline().getFirst().invoke(request, response);
                Throwable t = (Throwable) request.getAttribute(
                        RequestDispatcher.ERROR_EXCEPTION);
                if (t != null) {
                    asyncConImpl.setErrorState(t, true);
                }
            }

            if (request.isComet()) {
                if (!response.isClosed() && !response.isError()) {
View Full Code Here

                        request.setFilterChain(null);
                    }
                }

            }
            AsyncContextImpl asyncConImpl = (AsyncContextImpl)request.getAsyncContext();
            if (asyncConImpl != null) {
                async = true;
                ReadListener readListener = req.getReadListener();
                if (readListener != null) {
                    // Possible the all data may have been read during service()
View Full Code Here

        if (!isAsyncSupported()) {
            throw new IllegalStateException("Not supported.");
        }

        if (asyncContext == null) {
            asyncContext = new AsyncContextImpl(this);
        }

        asyncContext.setStarted(getContext(), request, response,
                request==getRequest() && response==getResponse().getResponse());
        asyncContext.setTimeout(getConnector().getAsyncTimeout());
View Full Code Here

TOP

Related Classes of org.apache.catalina.core.AsyncContextImpl$PrivilegedSetTccl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.