Package org.apache.http.nio.reactor

Examples of org.apache.http.nio.reactor.IOSession


    }

    @Override
  protected void readable(final SelectionKey key) {
        SessionHandle handle = (SessionHandle) key.attachment();
        IOSession session = handle.getSession();
        handle.resetLastRead();

        try {
            this.eventDispatch.inputReady(session);
        } catch (RuntimeException ex) {
            handleRuntimeException(ex);
        }
        if (session.hasBufferedInput()) {
            this.bufferingSessions.add(session);
        }
    }
View Full Code Here


    }

    @Override
  protected void writable(final SelectionKey key) {
        SessionHandle handle = (SessionHandle) key.attachment();
        IOSession session = handle.getSession();
        handle.resetLastWrite();
       
        try {
            this.eventDispatch.outputReady(session);
        } catch (RuntimeException ex) {
View Full Code Here

                }
            }
        }
        if (!this.bufferingSessions.isEmpty()) {
            for (Iterator<IOSession> it = this.bufferingSessions.iterator(); it.hasNext(); ) {
                IOSession session = it.next();
                if (!session.hasBufferedInput()) {
                    it.remove();
                    continue;
                }
                try {
                    int ops = session.getEventMask();
                    if ((ops & EventMask.READ) > 0) {
                        try {
                            this.eventDispatch.inputReady(session);
                        } catch (RuntimeException ex) {
                            handleRuntimeException(ex);
                        }
                        if (!session.hasBufferedInput()) {
                            it.remove();
                        }
                    }
                } catch (CancelledKeyException ex) {
                    it.remove();
View Full Code Here

    @Override
  protected void timeoutCheck(final SelectionKey key, long now) {
        Object attachment = key.attachment();
        if (attachment instanceof SessionHandle) {
            SessionHandle handle = (SessionHandle) key.attachment();
            IOSession session = handle.getSession();
            int timeout = session.getSocketTimeout();
            if (timeout > 0) {
                if (handle.getLastReadTime() + timeout < now) {
                    try {
                        this.eventDispatch.timeout(session);
                    } catch (RuntimeException ex) {
View Full Code Here

            }
            if (key.isWritable()) {
                writable(key);
            }
        } catch (CancelledKeyException ex) {
            IOSession session = keyCancelled(key);
            if (session != null) {
                this.closedSessions.add(session);
            }
            key.attach(null);
        }
View Full Code Here

            } catch (IOException ex) {
                throw new IOReactorException("Failure registering channel " +
                        "with the selector", ex);
            }

            IOSession session = new IOSessionImpl(key, new SessionClosedCallback() {

                public void sessionClosed(IOSession session) {
                    closedSessions.add(session);
                }
               
            });
           
            int timeout = 0;
            try {
                timeout = channel.socket().getSoTimeout();
            } catch (IOException ex) {
                // Very unlikely to happen and is not fatal
                // as the protocol layer is expected to overwrite
                // this value anyways
            }
           
            session.setAttribute(IOSession.ATTACHMENT_KEY, entry.getAttachment());
            session.setSocketTimeout(timeout);
            this.sessions.add(session);

            try {
                keyCreated(key, session);
               
View Full Code Here

            }
        }
    }

    private void processClosedSessions() {
        IOSession session;
        while ((session = this.closedSessions.poll()) != null) {
            if (this.sessions.remove(session)) {
                sessionClosed(session);
            }
        }
View Full Code Here

    }

    protected void closeSessions() {
        synchronized (this.sessions) {
            for (Iterator<IOSession> it = this.sessions.iterator(); it.hasNext(); ) {
                IOSession session = it.next();
                session.close();
            }
        }
    }
View Full Code Here

    private OperatedAsyncClientConnection getConnection() {
        HttpPoolEntry local = this.poolEntry;
        if (local == null) {
            return null;
        }
        IOSession session = local.getConnection();
        return (OperatedAsyncClientConnection) session.getAttribute(
                ExecutionContext.HTTP_CONNECTION);
    }
View Full Code Here

    private OperatedAsyncClientConnection ensureConnection() {
        HttpPoolEntry local = this.poolEntry;
        if (local == null) {
            throw new ConnectionShutdownException();
        }
        IOSession session = local.getConnection();
        return (OperatedAsyncClientConnection) session.getAttribute(
                ExecutionContext.HTTP_CONNECTION);
    }
View Full Code Here

TOP

Related Classes of org.apache.http.nio.reactor.IOSession

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.