Interface Closeable

All Superinterfaces:
AutoCloseable, Channel, Closeable
All Known Subinterfaces:
AgentForwardSupport, Channel, ClientChannel, ClientSession, CloseableExecutorService, ConnectionService, Forwarder, IoAcceptor, IoConnector, IoInputStream, IoOutputStream, IoService, IoServiceFactory, IoSession, ServerChannel, ServerSession, Service, Session, SessionContext, X11ForwardSupport
All Known Implementing Classes:
AbstractChannel, AbstractChannel.GracefulChannelCloseable, AbstractClientChannel, AbstractClientSession, AbstractCloseable, AbstractConnectionService, AbstractFactoryManager, AbstractInnerCloseable, AbstractIoServiceFactory, AbstractKexFactoryManager, AbstractServerChannel, AbstractServerSession, AbstractSession, AgentForwardedChannel, BufferedIoOutputStream, ChannelAgentForwarding, ChannelAsyncInputStream, ChannelAsyncOutputStream, ChannelDirectTcpip, ChannelExec, ChannelForwardedX11, ChannelSession, ChannelSession, ChannelSession.CommandCloseable, ChannelShell, ChannelSubsystem, ClientConnectionService, ClientSessionImpl, ClientUserAuthService, DefaultAgentForwardSupport, DefaultForwarder, DefaultSftpClient.SftpChannelSubsystem, DefaultX11ForwardSupport, FuturesCloseable, IoBaseCloseable, Nio2Acceptor, Nio2Connector, Nio2Service, Nio2ServiceFactory, Nio2Session, NoCloseExecutor, ParallelCloseable, PtyCapableChannelSession, SequentialCloseable, ServerConnectionService, ServerSessionImpl, ServerUserAuthService, SessionHelper, SimpleCloseable, SimpleIoOutputStream, SocksProxy, SshClient, SshServer, SshThreadPoolExecutor, SshThreadPoolExecutor.DelegateCloseable, TcpipClientChannel, TcpipServerChannel

public interface Closeable extends Channel
A Closeable is a resource that can be closed. The close method is invoked to release resources that the object is holding. The user can pre-register listeners to be notified when resource close is completed (successfully or otherwise)
  • Method Details

    • close

      CloseFuture close(boolean immediately)
      Close this resource asynchronously and return a future. Resources support two closing modes: a graceful mode which will cleanly close the resource and an immediate mode which will close the resources abruptly.
      Parameters:
      immediately - true if the resource should be shut down abruptly, false for a graceful close
      Returns:
      a CloseFuture representing the close request
    • addCloseFutureListener

      void addCloseFutureListener(SshFutureListener<CloseFuture> listener)
      Pre-register a listener to be informed when resource is closed. If resource is already closed, the listener will be invoked immediately and not registered for future notification
      Parameters:
      listener - The notification SshFutureListener - never null
    • removeCloseFutureListener

      void removeCloseFutureListener(SshFutureListener<CloseFuture> listener)
      Remove a pre-registered close event listener
      Parameters:
      listener - The register SshFutureListener - never null. Ignored if not registered or resource already closed
    • isClosed

      boolean isClosed()
      Returns true if this object has been closed.
      Returns:
      true if closing
    • isClosing

      boolean isClosing()
      Returns true if the close(boolean) method has been called. Note that this method will return true even if this isClosed() returns true.
      Returns:
      true if closing
    • isOpen

      default boolean isOpen()
      Specified by:
      isOpen in interface Channel
    • close

      default void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Channel
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • getMaxCloseWaitTime

      static Duration getMaxCloseWaitTime(PropertyResolver resolver)
    • close

      static void close(Closeable closeable) throws IOException
      Throws:
      IOException