Package org.apache.sshd.common.future

Examples of org.apache.sshd.common.future.DefaultCloseFuture


    public static Closeable sequential(final Object lock, final Closeable... closeables) {
        if (closeables.length == 0) {
            return new Closeable() {
                public CloseFuture close(boolean immediately) {
                    final CloseFuture future = new DefaultCloseFuture(lock);
                    future.setClosed();
                    return future;
                }
            };
        } else if (closeables.length == 1) {
            return closeables[0];
        } else {
            return new Closeable() {
                public CloseFuture close(final boolean immediately) {
                    final DefaultCloseFuture future = new DefaultCloseFuture(lock);
                    final Iterator<Closeable> iterator = Arrays.asList(closeables).iterator();
                    SshFutureListener<CloseFuture> listener = new SshFutureListener<CloseFuture>() {
                        public void operationComplete(CloseFuture previousFuture) {
                            if (iterator.hasNext()) {
                                Closeable c = iterator.next();
                                CloseFuture nextFuture = c.close(immediately);
                                nextFuture.addListener(this);
                            } else {
                                future.setClosed();
                            }
                        }
                    };
                    listener.operationComplete(null);
                    return future;
View Full Code Here


            future.setValue(true);
            return future;
        } else if (futures.length == 1) {
            return futures[0];
        } else {
            final CloseFuture future = new DefaultCloseFuture(null);
            final AtomicInteger count = new AtomicInteger(futures.length);
            SshFutureListener<?> listener = new SshFutureListener<SshFuture>() {
                public void operationComplete(SshFuture f) {
                    if (count.decrementAndGet() == 0) {
                        future.setClosed();
                    }
                }
            };
            for (SshFuture f : futures) {
                f.addListener(listener);
View Full Code Here

            out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.Message.SSH_MSG_CHANNEL_DATA);
        }

        @Override
        protected synchronized CloseFuture preClose(boolean immediately) {
            final CloseFuture future = new DefaultCloseFuture(null);
            serverSession.close(immediately).addListener(new SshFutureListener<IoCloseFuture>() {
                public void operationComplete(IoCloseFuture f) {
                    future.setClosed();
                }
            });
            return future;
        }
View Full Code Here

        out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.Message.SSH_MSG_CHANNEL_DATA);
    }

    @Override
    protected synchronized CloseFuture preClose(boolean immediately) {
        final CloseFuture future = new DefaultCloseFuture(null);
        serverSession.close(immediately).addListener(new SshFutureListener<IoCloseFuture>() {
            public void operationComplete(IoCloseFuture f) {
                future.setClosed();
            }
        });
        return future;
    }
View Full Code Here

TOP

Related Classes of org.apache.sshd.common.future.DefaultCloseFuture

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.