Interface Session<F>
- All Superinterfaces:
java.lang.AutoCloseable,java.io.Closeable
- All Known Implementing Classes:
CachingSessionFactory.CachedSession
public interface Session<F>
extends java.io.Closeable
Common abstraction for a Session with a remote File system.
- Since:
- 2.0
-
Method Summary
Modifier and Type Method Description voidappend(java.io.InputStream inputStream, java.lang.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(java.lang.String path)Check if the remote file or directory exists.booleanfinalizeRaw()Invoke after closing the InputStream fromreadRaw(String).java.lang.ObjectgetClientInstance()Get the underlying client library's client instance for this session.java.lang.StringgetHostPort()Return the host:port pair this session is connected to.booleanisOpen()F[]list(java.lang.String path)java.lang.String[]listNames(java.lang.String path)booleanmkdir(java.lang.String directory)voidread(java.lang.String source, java.io.OutputStream outputStream)java.io.InputStreamreadRaw(java.lang.String source)Retrieve a remote file as a rawInputStream.booleanremove(java.lang.String path)voidrename(java.lang.String pathFrom, java.lang.String pathTo)booleanrmdir(java.lang.String directory)Remove a remote directory.default booleantest()Test the session is still alive, e.g.voidwrite(java.io.InputStream inputStream, java.lang.String destination)
-
Method Details
-
remove
boolean remove(java.lang.String path) throws java.io.IOException- Throws:
java.io.IOException
-
list
- Throws:
java.io.IOException
-
read
void read(java.lang.String source, java.io.OutputStream outputStream) throws java.io.IOException- Throws:
java.io.IOException
-
write
void write(java.io.InputStream inputStream, java.lang.String destination) throws java.io.IOException- Throws:
java.io.IOException
-
append
void append(java.io.InputStream inputStream, java.lang.String destination) throws java.io.IOExceptionAppend to a file.- Parameters:
inputStream- the stream.destination- the destination.- Throws:
java.io.IOException- an IO Exception.- Since:
- 4.1
-
mkdir
boolean mkdir(java.lang.String directory) throws java.io.IOException- Throws:
java.io.IOException
-
rmdir
boolean rmdir(java.lang.String directory) throws java.io.IOExceptionRemove a remote directory.- Parameters:
directory- The directory.- Returns:
- True if the directory was removed.
- Throws:
java.io.IOException- an IO exception.- Since:
- 4.1
-
rename
void rename(java.lang.String pathFrom, java.lang.String pathTo) throws java.io.IOException- Throws:
java.io.IOException
-
close
void close()- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
isOpen
boolean isOpen() -
exists
boolean exists(java.lang.String path) throws java.io.IOExceptionCheck if the remote file or directory exists.- Parameters:
path- the remote path.- Returns:
trueorfalseif remote path exists or not.- Throws:
java.io.IOException- an IO exception during remote interaction.
-
listNames
java.lang.String[] listNames(java.lang.String path) throws java.io.IOException- Throws:
java.io.IOException
-
readRaw
java.io.InputStream readRaw(java.lang.String source) throws java.io.IOExceptionRetrieve a remote file as a rawInputStream.- Parameters:
source- The path of the remote file.- Returns:
- The raw inputStream.
- Throws:
java.io.IOException- Any IOException.- Since:
- 3.0
-
finalizeRaw
boolean finalizeRaw() throws java.io.IOExceptionInvoke after closing the InputStream fromreadRaw(String). Required by some session providers.- Returns:
- true if successful.
- Throws:
java.io.IOException- Any IOException.- Since:
- 3.0
-
getClientInstance
java.lang.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
java.lang.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()
-