Package org.apache.sshd.common
Interface Closeable
-
- All Superinterfaces:
java.lang.AutoCloseable,java.nio.channels.Channel,java.io.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,AbstractClientChannel.NullIoInputStream,AbstractClientSession,AbstractCloseable,AbstractConnectionService,AbstractFactoryManager,AbstractInnerCloseable,AbstractIoServiceFactory,AbstractKexFactoryManager,AbstractServerChannel,AbstractServerSession,AbstractSession,AgentForwardedChannel,AgentForwardedChannel,AsyncCapableClientChannel,BufferedIoOutputStream,ChannelAgentForwarding,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 java.nio.channels.ChannelACloseableis 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 Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddCloseFutureListener(SshFutureListener<CloseFuture> listener)Pre-register a listener to be informed when resource is closed.default voidclose()CloseFutureclose(boolean immediately)Close this resource asynchronously and return a future.static voidclose(Closeable closeable)static java.time.DurationgetMaxCloseWaitTime(PropertyResolver resolver)booleanisClosed()Returnstrueif this object has been closed.booleanisClosing()Returnstrueif theclose(boolean)method has been called.default booleanisOpen()voidremoveCloseFutureListener(SshFutureListener<CloseFuture> listener)Remove a pre-registered close event listener
-
-
-
Method Detail
-
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-trueif the resource should be shut down abruptly,falsefor a graceful close- Returns:
- a
CloseFuturerepresenting 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 notificationSshFutureListener- nevernull
-
removeCloseFutureListener
void removeCloseFutureListener(SshFutureListener<CloseFuture> listener)
Remove a pre-registered close event listener- Parameters:
listener- The registerSshFutureListener- nevernull. Ignored if not registered or resource already closed
-
isClosed
boolean isClosed()
Returnstrueif this object has been closed.- Returns:
trueif closing
-
isClosing
boolean isClosing()
Returnstrueif theclose(boolean)method has been called. Note that this method will returntrueeven if thisisClosed()returnstrue.- Returns:
trueif closing
-
isOpen
default boolean isOpen()
- Specified by:
isOpenin interfacejava.nio.channels.Channel
-
close
default void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.nio.channels.Channel- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
getMaxCloseWaitTime
static java.time.Duration getMaxCloseWaitTime(PropertyResolver resolver)
-
close
static void close(Closeable closeable) throws java.io.IOException
- Throws:
java.io.IOException
-
-