Package org.apache.sshd.sftp.client.fs
Class SftpFileSystem
- java.lang.Object
-
- java.nio.file.FileSystem
-
- org.apache.sshd.common.file.util.BaseFileSystem<SftpPath>
-
- org.apache.sshd.sftp.client.fs.SftpFileSystem
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,ClientSessionHolder
,SessionContextHolder
,SessionHolder<ClientSession>
- Direct Known Subclasses:
SftpFileSystemAutomatic
public class SftpFileSystem extends BaseFileSystem<SftpPath> implements SessionHolder<ClientSession>, ClientSessionHolder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SftpFileSystem.DefaultGroupPrincipal
static class
SftpFileSystem.DefaultUserPrincipal
static class
SftpFileSystem.DefaultUserPrincipalLookupService
protected static class
SftpFileSystem.SftpClientHandle
TheSftpFileSystem.SftpClientPool
storesSftpClient
s not directly but via handles in its channel pool.protected class
SftpFileSystem.SftpClientPool
A pool ofSftpClient
s.private class
SftpFileSystem.Wrapper
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicReference<ClientSession>
clientSession
private SftpPath
defaultDir
private SftpErrorDataHandler
errorDataHandler
private SftpClientFactory
factory
private java.lang.String
id
private java.util.concurrent.atomic.AtomicBoolean
open
static AttributeRepository.AttributeKey<java.lang.Boolean>
OWNED_SESSION
AnAttributeRepository.AttributeKey
that can be set toBoolean.TRUE
on theClientSession
to tell theSftpFileSystem
that it owns that session and should close it when theSftpFileSystem
itself is closed.private SftpFileSystem.SftpClientPool
pool
private int
readBufferSize
private SftpVersionSelector
selector
private java.util.List<java.nio.file.FileStore>
stores
private java.util.Set<java.lang.String>
supportedViews
static java.util.NavigableSet<java.lang.String>
UNIVERSAL_SUPPORTED_VIEWS
private int
version
private int
writeBufferSize
-
Fields inherited from class org.apache.sshd.common.file.util.BaseFileSystem
log
-
-
Constructor Summary
Constructors Modifier Constructor Description SftpFileSystem(SftpFileSystemProvider provider, java.lang.String id, ClientSession session, SftpClientFactory factory, SftpVersionSelector selector, SftpErrorDataHandler errorDataHandler)
protected
SftpFileSystem(SftpFileSystemProvider provider, java.lang.String id, SftpClientFactory factory, SftpVersionSelector selector, SftpErrorDataHandler errorDataHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
protected SftpPath
create(java.lang.String root, java.util.List<java.lang.String> names)
SftpClient
getClient()
ClientSession
getClientSession()
SftpPath
getDefaultDir()
java.util.List<java.nio.file.FileStore>
getFileStores()
java.lang.String
getId()
int
getReadBufferSize()
ClientSession
getSession()
SftpErrorDataHandler
getSftpErrorDataHandler()
SftpVersionSelector
getSftpVersionSelector()
java.nio.file.attribute.UserPrincipalLookupService
getUserPrincipalLookupService()
int
getVersion()
int
getWriteBufferSize()
protected void
init()
boolean
isOpen()
SftpFileSystemProvider
provider()
protected ClientSession
sessionForSftpClient()
protected void
setClientSession(ClientSession newSession)
void
setReadBufferSize(int size)
void
setWriteBufferSize(int size)
java.util.Set<java.lang.String>
supportedFileAttributeViews()
java.lang.String
toString()
-
Methods inherited from class org.apache.sshd.common.file.util.BaseFileSystem
appendDedupSep, create, create, getPath, getPathMatcher, getRootDirectories, getSeparator, globToRegex, handleWindowsSeparator, hostFsHasWindowsSeparator, isReadOnly, newWatchService
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.session.SessionHolder
getSessionContext
-
-
-
-
Field Detail
-
UNIVERSAL_SUPPORTED_VIEWS
public static final java.util.NavigableSet<java.lang.String> UNIVERSAL_SUPPORTED_VIEWS
-
OWNED_SESSION
public static final AttributeRepository.AttributeKey<java.lang.Boolean> OWNED_SESSION
AnAttributeRepository.AttributeKey
that can be set toBoolean.TRUE
on theClientSession
to tell theSftpFileSystem
that it owns that session and should close it when theSftpFileSystem
itself is closed.
-
id
private final java.lang.String id
-
factory
private final SftpClientFactory factory
-
selector
private final SftpVersionSelector selector
-
errorDataHandler
private final SftpErrorDataHandler errorDataHandler
-
pool
private SftpFileSystem.SftpClientPool pool
-
version
private int version
-
supportedViews
private java.util.Set<java.lang.String> supportedViews
-
defaultDir
private SftpPath defaultDir
-
readBufferSize
private int readBufferSize
-
writeBufferSize
private int writeBufferSize
-
stores
private final java.util.List<java.nio.file.FileStore> stores
-
open
private final java.util.concurrent.atomic.AtomicBoolean open
-
clientSession
private java.util.concurrent.atomic.AtomicReference<ClientSession> clientSession
-
-
Constructor Detail
-
SftpFileSystem
public SftpFileSystem(SftpFileSystemProvider provider, java.lang.String id, ClientSession session, SftpClientFactory factory, SftpVersionSelector selector, SftpErrorDataHandler errorDataHandler) throws java.io.IOException
- Throws:
java.io.IOException
-
SftpFileSystem
protected SftpFileSystem(SftpFileSystemProvider provider, java.lang.String id, SftpClientFactory factory, SftpVersionSelector selector, SftpErrorDataHandler errorDataHandler)
-
-
Method Detail
-
init
protected void init() throws java.io.IOException
- Throws:
java.io.IOException
-
getSftpVersionSelector
public final SftpVersionSelector getSftpVersionSelector()
-
getSftpErrorDataHandler
public SftpErrorDataHandler getSftpErrorDataHandler()
-
getId
public final java.lang.String getId()
-
getVersion
public final int getVersion()
-
provider
public SftpFileSystemProvider provider()
- Overrides:
provider
in classBaseFileSystem<SftpPath>
-
getFileStores
public java.util.List<java.nio.file.FileStore> getFileStores()
- Overrides:
getFileStores
in classBaseFileSystem<SftpPath>
-
getReadBufferSize
public int getReadBufferSize()
-
setReadBufferSize
public void setReadBufferSize(int size)
-
getWriteBufferSize
public int getWriteBufferSize()
-
setWriteBufferSize
public void setWriteBufferSize(int size)
-
create
protected SftpPath create(java.lang.String root, java.util.List<java.lang.String> names)
- Specified by:
create
in classBaseFileSystem<SftpPath>
-
getClientSession
public ClientSession getClientSession()
- Specified by:
getClientSession
in interfaceClientSessionHolder
- Returns:
- The underlying
ClientSession
used
-
getSession
public ClientSession getSession()
- Specified by:
getSession
in interfaceSessionHolder<ClientSession>
-
setClientSession
protected void setClientSession(ClientSession newSession)
-
sessionForSftpClient
protected ClientSession sessionForSftpClient() throws java.io.IOException
- Throws:
java.io.IOException
-
getClient
public SftpClient getClient() throws java.io.IOException
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.nio.file.FileSystem
- Throws:
java.io.IOException
-
isOpen
public boolean isOpen()
- Specified by:
isOpen
in classjava.nio.file.FileSystem
-
supportedFileAttributeViews
public java.util.Set<java.lang.String> supportedFileAttributeViews()
- Specified by:
supportedFileAttributeViews
in classjava.nio.file.FileSystem
-
getUserPrincipalLookupService
public java.nio.file.attribute.UserPrincipalLookupService getUserPrincipalLookupService()
- Specified by:
getUserPrincipalLookupService
in classjava.nio.file.FileSystem
-
getDefaultDir
public SftpPath getDefaultDir()
- Overrides:
getDefaultDir
in classBaseFileSystem<SftpPath>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-