Interface Session<F>
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
CachingSessionFactory.CachedSession,FtpSession,SftpSession
public interface Session<F> extends Closeable
Common abstraction for a Session with a remote File system.
- Since:
- 2.0
- Author:
- Josh Long, Mario Gray, Mark Fisher, Oleg Zhurakousky, Gary Russell, Alen Turkovic
-
Method Summary
Modifier and Type Method Description voidappend(InputStream inputStream, String destination)Append to a file.voidclose()default voiddirty()Mark this session as dirty, indicating that it should not be reused and any delegated sessions should be taken care of before closing.booleanexists(String path)Check if the remote file or directory exists.booleanfinalizeRaw()Invoke after closing the InputStream fromreadRaw(String).ObjectgetClientInstance()Get the underlying client library's client instance for this session.StringgetHostPort()Return the host:port pair this session is connected to.booleanisOpen()F[]list(String path)String[]listNames(String path)booleanmkdir(String directory)voidread(String source, OutputStream outputStream)InputStreamreadRaw(String source)Retrieve a remote file as a rawInputStream.booleanremove(String path)voidrename(String pathFrom, String pathTo)booleanrmdir(String directory)Remove a remote directory.default booleantest()Test the session is still alive, e.g.voidwrite(InputStream inputStream, String destination)
-
Method Details
-
remove
- Throws:
IOException
-
list
- Throws:
IOException
-
read
- Throws:
IOException
-
write
- Throws:
IOException
-
append
Append to a file.- Parameters:
inputStream- the stream.destination- the destination.- Throws:
IOException- an IO Exception.- Since:
- 4.1
-
mkdir
- Throws:
IOException
-
rmdir
Remove a remote directory.- Parameters:
directory- The directory.- Returns:
- True if the directory was removed.
- Throws:
IOException- an IO exception.- Since:
- 4.1
-
rename
- Throws:
IOException
-
close
void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
isOpen
boolean isOpen() -
exists
Check if the remote file or directory exists.- Parameters:
path- the remote path.- Returns:
trueorfalseif remote path exists or not.- Throws:
IOException- an IO exception during remote interaction.
-
listNames
- Throws:
IOException
-
readRaw
Retrieve a remote file as a rawInputStream.- Parameters:
source- The path of the remote file.- Returns:
- The raw inputStream.
- Throws:
IOException- Any IOException.- Since:
- 3.0
-
finalizeRaw
Invoke after closing the InputStream fromreadRaw(String). Required by some session providers.- Returns:
- true if successful.
- Throws:
IOException- Any IOException.- Since:
- 3.0
-
getClientInstance
Object getClientInstance()Get the underlying client library's client instance for this session. Returns anObjectto avoid significant changes to -file, -ftp, -sftp modules, which would be required if we added another generic parameter. Implementations should narrow the return type.- Returns:
- The client instance.
- Since:
- 4.1
-
getHostPort
String getHostPort()Return the host:port pair this session is connected to.- Returns:
- the host:port pair this session is connected to.
- Since:
- 5.2
-
test
default boolean test()Test the session is still alive, e.g. when checking out from a pool. The default implementation simply delegates toisOpen().- Returns:
- true if the test is successful.
- Since:
- 5.1
-
dirty
default void dirty()Mark this session as dirty, indicating that it should not be reused and any delegated sessions should be taken care of before closing.- Since:
- 5.1.2
- See Also:
CachingSessionFactory.CachedSession.close()
-