Package org.pentaho.di.core.vfs
Class SftpFileSystemWindowsProvider
java.lang.Object
org.apache.commons.vfs2.provider.AbstractVfsComponent
org.apache.commons.vfs2.provider.AbstractVfsContainer
org.apache.commons.vfs2.provider.AbstractFileProvider
org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider
org.apache.commons.vfs2.provider.sftp.SftpFileProvider
org.pentaho.di.core.vfs.SftpFileSystemWindowsProvider
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.apache.commons.vfs2.provider.FileProvider
,org.apache.commons.vfs2.provider.VfsComponent
public class SftpFileSystemWindowsProvider
extends org.apache.commons.vfs2.provider.sftp.SftpFileProvider
This class serves two main purposes.
-
To provide a correct way of running sftp commands on Windows server.
Current implementation of commons-vfs calls
id -G
orid -u
, which is incorrect for Windows. -
To provide a way to release sftp connections, when we're done.
commons-vfs says we do not close fileSystemManager until application shutdown
(see VFS-454).
Thus, we need to close the connections.
There isAbstractFileProvider.freeUnusedResources()
, which we can use to achieve this. But, unfortunately, original SftpFileSystem only releases them when all file objects it's associated with are garbage collected. This is too restrictive and inconvenient. Here we make the sftp file system object releasable when there are open file objects, we only need i/o streams to be closed.
This is pretty safe to do. Even a file object would want to open a stream once again (currently wouldn't), the file system object re-creates session and opens a new connection.
SftpFileProvider
in FileSystemManager (see overridden providers.xml).
And then used to spawn SftpFileSystemWindows and SftpFileObjectWithWindowsSupport.-
Field Summary
Fields inherited from class org.apache.commons.vfs2.provider.sftp.SftpFileProvider
ATTR_USER_INFO, AUTHENTICATOR_TYPES, capabilities
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.commons.vfs2.FileSystem
doCreateFileSystem
(org.apache.commons.vfs2.FileName name, org.apache.commons.vfs2.FileSystemOptions fileSystemOptions) Methods inherited from class org.apache.commons.vfs2.provider.sftp.SftpFileProvider
getCapabilities, getConfigBuilder
Methods inherited from class org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider
findFile, findFile, getFileSystem
Methods inherited from class org.apache.commons.vfs2.provider.AbstractFileProvider
addFileSystem, close, closeFileSystem, createFileSystem, findFileSystem, freeUnusedResources, getFileNameParser, parseUri, setFileNameParser
Methods inherited from class org.apache.commons.vfs2.provider.AbstractVfsContainer
addComponent, removeComponent
Methods inherited from class org.apache.commons.vfs2.provider.AbstractVfsComponent
getContext, getLogger, init, setContext, setLogger
-
Constructor Details
-
SftpFileSystemWindowsProvider
public SftpFileSystemWindowsProvider()
-
-
Method Details
-
doCreateFileSystem
protected org.apache.commons.vfs2.FileSystem doCreateFileSystem(org.apache.commons.vfs2.FileName name, org.apache.commons.vfs2.FileSystemOptions fileSystemOptions) throws org.apache.commons.vfs2.FileSystemException - Overrides:
doCreateFileSystem
in classorg.apache.commons.vfs2.provider.sftp.SftpFileProvider
- Throws:
org.apache.commons.vfs2.FileSystemException
-