Package org.glassfish.grizzly

Examples of org.glassfish.grizzly.ReadHandler


     * This method shouldn't be invoked by developers directly.
     */
    protected void finished() {
        if (!contentRead) {
            contentRead = true;
            final ReadHandler localHandler = handler;
            if (localHandler != null) {
                handler = null;
                invokeHandlerAllRead(localHandler, getThreadPool());
            }
        }
View Full Code Here


            if (closed) {
                buffer.dispose();
                return false;
            }
           
            final ReadHandler localHandler = handler;
           
            final boolean isLast = httpContent.isLast();
           
            // if we have a handler registered - switch the flag to true
            boolean askForMoreDataInThisThread = !isLast && localHandler != null;
            boolean invokeDataAvailable = false;

            if (buffer.hasRemaining()) {
                updateInputContentBuffer(buffer);
                if (localHandler != null) {
                    final int available = readyData();
                    if (available >= requestedSize) {
                        invokeDataAvailable = true;
                        askForMoreDataInThisThread = false;
                    }
                }
            }
           
            if (askForMoreDataInThisThread) {
                // There is a ReadHandler registered, but it requested more
                // data to be available before we can notify it - so wait for
                // more data to come
                isWaitingDataAsynchronously = true;
                return true;
            }
           
            handler = null;
           
            if (isLast) {
                checkHttpTrailer(httpContent);
            }
           
            invokeHandlerOnProperThread(localHandler,
                    invokeDataAvailable, isLast);
           
        } else { // broken content
            final ReadHandler localHandler = handler;
            handler = null;
            invokeErrorHandlerOnProperThread(localHandler,
                                             ((HttpBrokenContent) httpContent).getException());
        }
       
View Full Code Here

     * </p>
     *
     * @since 2.0.1
     */
    public void terminate() {
        final ReadHandler localHandler = handler;
        if (localHandler != null) {
            handler = null;
            // call in the current thread, because otherwise handler executed
            // in the different thread may deal with recycled Request/Response objects
            localHandler.onError(
                    connection.isOpen()
                    ? new CancellationException()
                    : new EOFException());
        }
    }
View Full Code Here

        final HttpContext context = HttpContext.get(ctx);
        if (context != null) {
            final Request request = httpRequestInProgress.get(context);

            if (request != null) {
                final ReadHandler handler = request.getInputBuffer().getReadHandler();
                if (handler != null) {
                    handler.onError(error);
                }
            }
        }
    }
View Full Code Here

    public void exceptionOccurred(FilterChainContext ctx, Throwable error) {
        final HttpContext context = HttpContext.get(ctx);
        final Request request = httpRequestInProgress.get(context);

        if (request != null) {
            final ReadHandler handler = request.getInputBuffer().getReadHandler();
            if (handler != null) {
                handler.onError(error);
            }
        }
    }
View Full Code Here

     * This method shouldn't be invoked by developers directly.
     */
    public void finished() {
        if (!contentRead) {
            contentRead = true;
            final ReadHandler localHandler = handler;
            if (localHandler != null) {
                handler = null;
                invokeHandlerAllRead(localHandler, getThreadPool());
            }
        }
View Full Code Here

            if (closed) {
                buffer.dispose();
                return false;
            }
           
            final ReadHandler localHandler = handler;
           
            final boolean isLast = httpContent.isLast();
           
            // if we have a handler registered - switch the flag to true
            boolean askForMoreDataInThisThread = !isLast && localHandler != null;
            boolean invokeDataAvailable = false;

            if (buffer.hasRemaining()) {
                updateInputContentBuffer(buffer);
                if (localHandler != null) {
                    final int available = readyData();
                    if (available >= requestedSize) {
                        invokeDataAvailable = true;
                        askForMoreDataInThisThread = false;
                    }
                }
            }
           
            if (askForMoreDataInThisThread) {
                // There is a ReadHandler registered, but it requested more
                // data to be available before we can notify it - so wait for
                // more data to come
                isWaitingDataAsynchronously = true;
                return true;
            }
           
            handler = null;
           
            if (isLast) {
                checkHttpTrailer(httpContent);
            }
           
            invokeHandlerOnProperThread(localHandler,
                    invokeDataAvailable, isLast);
           
        } else { // broken content
            final ReadHandler localHandler = handler;
            handler = null;
            invokeErrorHandlerOnProperThread(localHandler,
                                             ((HttpBrokenContent) httpContent).getException());
        }
       
View Full Code Here

     * </p>
     *
     * @since 2.0.1
     */
    public void terminate() {
        final ReadHandler localHandler = handler;
        if (localHandler != null) {
            handler = null;
            if (connection.isOpen()) {
                invokeErrorHandlerOnProperThread(localHandler,
                                                 new CancellationException());
View Full Code Here

TOP

Related Classes of org.glassfish.grizzly.ReadHandler

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.