Package com.sun.sgs.nio.channels

Examples of com.sun.sgs.nio.channels.ClosedAsynchronousChannelException


                public Void call() throws IOException {
                    try {
                        channel.connect(remote);
                    } catch (ClosedChannelException e) {
                        throw Util.initCause(
                            new ClosedAsynchronousChannelException(), e);
                    }
                    return null;
                } })
            {
                @Override protected void done() {
                    connectionPending.set(false);
                    key.runCompletion(handler, attachment, this);
                }
            };

        if (!channel.isOpen()) {
            throw new ClosedAsynchronousChannelException();
        }

        if (!connectionPending.compareAndSet(false, true)) {
            throw new ConnectionPendingException();
        }
View Full Code Here


    {
        FutureTask<Void> task = new FutureTask<Void>(
            new Callable<Void>() {
                public Void call() throws IOException {
                    if (!channel.isOpen()) {
                        throw new ClosedAsynchronousChannelException();
                    }

                    channel.disconnect();
                    return null;
                } })
            {
                @Override protected void done() {
                    key.runCompletion(handler, attachment, this);
                }
            };

        if (!channel.isOpen()) {
            throw new ClosedAsynchronousChannelException();
        }

        key.execute(task);
        return AttachedFuture.wrap(task, attachment);
    }
View Full Code Here

            selector.wakeup();
            int interestOps;
            synchronized (asyncKey) {
                SelectionKey key = asyncKey.key;
                if (key == null || (!key.isValid())) {
                    throw new ClosedAsynchronousChannelException();
                }

    try {
        interestOps = key.interestOps();
    } catch (CancelledKeyException e) {
        throw new ClosedAsynchronousChannelException();
    }

                SelectableChannel channel = asyncKey.channel();
               
                // These precondition checks don't belong here; they
                // should be refactored to AsyncSocketChannelImpl.
                // However, they need to occur inside the asyncKey
                // lock after we know the interest ops won't change,
                // so here they are.
                // Only SocketChannel has any extra checks to do.
                if (channel instanceof SocketChannel) {
                    switch (op) {
                    case OP_READ:
                    case OP_WRITE:
                        if (!((SocketChannel) channel).isConnected()) {
                            throw new NotYetConnectedException();
                        }
                        break;
                    case OP_CONNECT:
                        if (((SocketChannel) channel).isConnected()) {
                            throw new AlreadyConnectedException();
                        }
                        break;
                    default:
                        break;
                    }
                }

                // Check that op isn't already in the interest set
                assert (interestOps & op) == 0;

                interestOps |= op;
    try {
        key.interestOps(interestOps);
    } catch (CancelledKeyException e) {
        throw new ClosedAsynchronousChannelException();
    }
            }

            if (log.isLoggable(Level.FINEST)) {
                log.log(Level.FINEST,
View Full Code Here

  ClosedWriteHandler() { }

        @Override
        void write(ByteBuffer message) {
            throw new ClosedAsynchronousChannelException();
        }
View Full Code Here

  ClosedReadHandler() { }

        @Override
        void read() {
            throw new ClosedAsynchronousChannelException();
        }
View Full Code Here

                Future<Void> result = Util.finishedFuture(null);
                key.runCompletion(handler, attachment, result);
                return AttachedFuture.wrap(result, attachment);
            }
        } catch (ClosedChannelException e) {
            throw Util.initCause(new ClosedAsynchronousChannelException(), e);
        } catch (IOException e) {
            Future<Void> result = Util.failedFuture(e);
            key.runCompletion(handler, attachment, result);
            return AttachedFuture.wrap(result, attachment);
        }
View Full Code Here

            selector.wakeup();
            int interestOps;
            synchronized (asyncKey) {
                SelectionKey key = asyncKey.key;
                if (key == null || (!key.isValid())) {
                    throw new ClosedAsynchronousChannelException();
                }

    try {
        interestOps = key.interestOps();
    } catch (CancelledKeyException e) {
        throw new ClosedAsynchronousChannelException();
    }

                SelectableChannel channel = asyncKey.channel();
               
                // These precondition checks don't belong here; they
                // should be refactored to AsyncSocketChannelImpl.
                // However, they need to occur inside the asyncKey
                // lock after we know the interest ops won't change,
                // so here they are.
                // Only SocketChannel has any extra checks to do.
                if (channel instanceof SocketChannel) {
                    switch (op) {
                    case OP_READ:
                    case OP_WRITE:
                        if (!((SocketChannel) channel).isConnected()) {
                            throw new NotYetConnectedException();
                        }
                        break;
                    case OP_CONNECT:
                        if (((SocketChannel) channel).isConnected()) {
                            throw new AlreadyConnectedException();
                        }
                        break;
                    default:
                        break;
                    }
                }

                // Check that op isn't already in the interest set
                assert (interestOps & op) == 0;

                interestOps |= op;
    try {
        key.interestOps(interestOps);
    } catch (CancelledKeyException e) {
        throw new ClosedAsynchronousChannelException();
    }
            }

            if (log.isLoggable(Level.FINEST)) {
                log.log(Level.FINEST,
View Full Code Here

  ClosedWriteHandler() { }

        @Override
        void write(ByteBuffer message) {
            throw new ClosedAsynchronousChannelException();
        }
View Full Code Here

  ClosedReadHandler() { }

        @Override
        void read() {
            throw new ClosedAsynchronousChannelException();
        }
View Full Code Here

                public Void call() throws IOException {
                    try {
                        channel.connect(remote);
                    } catch (ClosedChannelException e) {
                        throw Util.initCause(
                            new ClosedAsynchronousChannelException(), e);
                    }
                    return null;
                } })
            {
                @Override protected void done() {
                    connectionPending.set(false);
                    key.runCompletion(handler, attachment, this);
                }
            };

        if (!channel.isOpen()) {
            throw new ClosedAsynchronousChannelException();
        }

        if (!connectionPending.compareAndSet(false, true)) {
            throw new ConnectionPendingException();
        }
View Full Code Here

TOP

Related Classes of com.sun.sgs.nio.channels.ClosedAsynchronousChannelException

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.