Package java.nio.channels

Examples of java.nio.channels.SelectionKey.attachment()


                            launch = true;
                        }
                    } else if (handshake == -1 ) {
                        KeyAttachment ka = null;
                        if (key!=null) {
                            ka = (KeyAttachment) key.attachment();
                            socket.getPoller().cancelledKey(key, SocketStatus.DISCONNECT, false);
                        }
                        if (socket!=null) nioChannels.offer(socket);
                        socket = null;
                        if ( ka!=null ) keyCache.offer(ka);
View Full Code Here


                        if ( ka!=null ) keyCache.offer(ka);
                        ka = null;
                    } else {
                        final SelectionKey fk = key;
                        final int intops = handshake;
                        final KeyAttachment ka = (KeyAttachment)fk.attachment();
                        ka.getPoller().add(socket,intops);
                    }
                }catch(CancelledKeyException cx) {
                    socket.getPoller().cancelledKey(key,null,false);
                } catch (OutOfMemoryError oom) {
View Full Code Here

                                statusDropsConnection(response.getStatus());
                    }
                    // Comet support
                    SelectionKey key = socket.getIOChannel().keyFor(socket.getPoller().getSelector());
                    if (key != null) {
                        NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment) key.attachment();
                        if (attach != null)  {
                            attach.setComet(comet);
                            if (comet) {
                                Integer comettimeout = (Integer) request.getAttribute("org.apache.tomcat.comet.timeout");
                                if (comettimeout != null) attach.setTimeout(comettimeout.longValue());
View Full Code Here

            comet = false;
            cometClose = true;
            SelectionKey key = socket.getIOChannel().keyFor(socket.getPoller().getSelector());
            if ( key != null ) {
                NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment) key.attachment();
                if ( attach!=null && attach.getComet()) {
                    //if this is a comet connection
                    //then execute the connection closure at the next selector loop
                    //request.getAttributes().remove("org.apache.tomcat.comet.timeout");
                    //attach.setTimeout(5000); //force a cleanup in 5 seconds
View Full Code Here

            return i.hasNext();
        }

        public NioSession next() {
            SelectionKey key = i.next();
            return (NioSession) key.attachment();
        }

        public void remove() {
            i.remove();
        }
View Full Code Here

            // key was cancelled. can also happen if we timeout a method, which
            // results in a channel close.
            // just skip
            continue;
          }
          TAsyncMethodCall methodCall = (TAsyncMethodCall)key.attachment();
          methodCall.transition(key);

          // If done or error occurred, remove from timeout watch set
          if (methodCall.isFinished() || methodCall.getClient().hasError()) {
            timeoutWatchSet.remove(methodCall);
View Full Code Here

                    try
                    {
                        if (!key.isValid())
                        {
                            key.cancel();
                            SelectChannelEndPoint endpoint = (SelectChannelEndPoint)key.attachment();
                            if (endpoint != null)
                                endpoint.doUpdateKey();
                            continue;
                        }
View Full Code Here

                            if (endpoint != null)
                                endpoint.doUpdateKey();
                            continue;
                        }

                        Object att = key.attachment();
                        if (att instanceof SelectChannelEndPoint)
                        {
                            SelectChannelEndPoint endpoint = (SelectChannelEndPoint)att;
                            endpoint.dispatch();
                        }
View Full Code Here

            while (iter.hasNext())
            {
                SelectionKey key = (SelectionKey)iter.next();
                if (key==null)
                    continue;
                EndPoint endpoint = (EndPoint)key.attachment();
                if (endpoint!=null)
                {
                    try
                    {
                        endpoint.close();
View Full Code Here

                    }
                    // Comet support
                    SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor(
                            socketWrapper.getSocket().getPoller().getSelector());
                    if (key != null) {
                        NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment) key.attachment();
                        if (attach != null)  {
                            attach.setComet(comet);
                            if (comet) {
                                Integer comettimeout = (Integer) request.getAttribute("org.apache.tomcat.comet.timeout");
                                if (comettimeout != null) attach.setTimeout(comettimeout.longValue());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.