@Override public void run() { if ( fsm != null ) { try { fsm.close(); } catch ( Exception ignored ) { // Exceptions can be thrown due to a closed classloader } } } } ) );
@Override public void close() { lock.writeLock().lock(); try { super.close(); } finally { lock.writeLock().unlock(); } }
@Override public String[] getSchemes() { lock.readLock().lock(); try { return super.getSchemes(); } finally { lock.readLock().unlock(); } }
public void reset() { defaultVariableSpace = new Variables(); defaultVariableSpace.initializeVariablesFrom( null ); fsm.close(); try { fsm.setFilesCache( new WeakRefFilesCache() ); fsm.init(); } catch ( FileSystemException ignored ) { } }
public SimpleJsonExtractor(WorkUnitState workUnitState) throws FileSystemException { this.workUnitState = workUnitState; // Resolve the file to pull if (workUnitState.getPropAsBoolean(ConfigurationKeys.SOURCE_CONN_USE_AUTHENTICATION, false)) { // Add authentication credential if authentication is needed UserAuthenticator auth = new StaticUserAuthenticator(workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_DOMAIN, ""), workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_USERNAME), PasswordManager.getInstance(workUnitState) .readPassword(workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_PASSWORD))); FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); this.fileObject = VFS.getManager().resolveFile(workUnitState.getProp(SOURCE_FILE_KEY), opts); } else { this.fileObject = VFS.getManager().resolveFile(workUnitState.getProp(SOURCE_FILE_KEY)); } // Open the file for reading LOGGER.info("Opening file " + this.fileObject.getURL().toString()); this.bufferedReader = this.closer.register(new BufferedReader(new InputStreamReader(this.fileObject.getContent().getInputStream(), ConfigurationKeys.DEFAULT_CHARSET_ENCODING))); }
private KettleVFS() { fsm = new ConcurrentFileSystemManager(); try { fsm.setFilesCache( new WeakRefFilesCache() ); fsm.init(); } catch ( FileSystemException e ) { e.printStackTrace(); } // Install a shutdown hook to make sure that the file system manager is closed // This will clean up temporary files in vfs_cache Runtime.getRuntime().addShutdownHook( new Thread( new Runnable() { @Override public void run() { if ( fsm != null ) { try { fsm.close(); } catch ( Exception ignored ) { // Exceptions can be thrown due to a closed classloader } } } } ) ); }
@Override Object doCall() throws Exception { while ( condition.get() ) { this.fsm.addProvider( "scheme", provider ); // to register only one provider with a given scheme condition.set( false ); } return null; } }
@After public void tearUp() { this.fileSystemManager.freeUnusedResources(); this.fileSystemManager.close(); }
@Override public boolean hasProvider( String scheme ) { lock.readLock().lock(); try { return super.hasProvider( scheme ); } finally { lock.readLock().unlock(); } }
@Override public FileObject resolveFile( FileObject baseFile, String uri, FileSystemOptions fileSystemOptions ) throws FileSystemException { lock.readLock().lock(); try { return super.resolveFile( baseFile, uri, fileSystemOptions ); } finally { lock.readLock().unlock(); } }
@Override public void addProvider( String[] urlSchemes, FileProvider provider ) throws FileSystemException { lock.writeLock().lock(); try { super.addProvider( urlSchemes, provider ); } finally { lock.writeLock().unlock(); } }
@Override Object doCall() throws Exception { while ( condition.get() ) { this.fsm.getSchemes(); } return null; } }
@Override public void freeUnusedResources() { lock.readLock().lock(); try { super.freeUnusedResources(); } finally { lock.readLock().unlock(); } }
@Override public FileName resolveURI( String uri ) throws FileSystemException { lock.readLock().lock(); try { return super.resolveURI( uri ); } finally { lock.readLock().unlock(); } }
@Override public Collection<Capability> getProviderCapabilities( String scheme ) throws FileSystemException { lock.readLock().lock(); try { return super.getProviderCapabilities( scheme ); } finally { lock.readLock().unlock(); } }
@Override public FileSystemConfigBuilder getFileSystemConfigBuilder( String scheme ) throws FileSystemException { lock.readLock().lock(); try { return super.getFileSystemConfigBuilder( scheme ); } finally { lock.readLock().unlock(); } }
@Override public FileObject createFileSystem( String scheme, FileObject file ) throws FileSystemException { lock.readLock().lock(); try { return super.createFileSystem( scheme, file ); } finally { lock.readLock().unlock(); } }
@Override public FileName resolveName( FileName base, String name, NameScope scope ) throws FileSystemException { lock.readLock().lock(); try { return super.resolveName( base, name, scope ); } finally { lock.readLock().unlock(); } }
@Override public void _closeFileSystem( FileSystem filesystem ) { lock.readLock().lock(); try { super._closeFileSystem( filesystem ); } finally { lock.readLock().unlock(); } }
/** * @see StandardFileSystemManager#freeUnusedResources() */ public static void freeUnusedResources() { ( (StandardFileSystemManager) getInstance().getFileSystemManager() ).freeUnusedResources(); }