org.apache.commons.vfs2.FileSystemConfigBuilder Java Examples

The following examples show how to use org.apache.commons.vfs2.FileSystemConfigBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VFSFileSystem.java    From commons-configuration with Apache License 2.0 6 votes vote down vote up
private void setProperty(final FileSystemConfigBuilder builder, final FileSystemOptions options,
                         final String key, final Object value)
{
    final String methodName = "set" + key.substring(0, 1).toUpperCase() + key.substring(1);
    final Class<?>[] paramTypes = new Class<?>[2];
    paramTypes[0] = FileSystemOptions.class;
    paramTypes[1] = value.getClass();

    try
    {
        final Method method = builder.getClass().getMethod(methodName, paramTypes);
        final Object[] params = new Object[2];
        params[0] = options;
        params[1] = value;
        method.invoke(builder, params);
    }
    catch (final Exception ex)
    {
        log.warn("Cannot access property '" + key + "'! Ignoring.", ex);
    }

}
 
Example #2
Source File: ConcurrentFileSystemManager.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
public FileSystemConfigBuilder getFileSystemConfigBuilder( String scheme ) throws FileSystemException {
  lock.readLock().lock();
  try {
    return super.getFileSystemConfigBuilder( scheme );
  } finally {
    lock.readLock().unlock();
  }
}
 
Example #3
Source File: DelegatingFileSystemOptionsBuilder.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the list of all set*() methods for the given scheme
 */
private Map<String, List<Method>> createSchemeMethods(final String scheme) throws FileSystemException {
    final FileSystemConfigBuilder fscb = getManager().getFileSystemConfigBuilder(scheme);
    FileSystemException.requireNonNull(fscb, "vfs.provider/no-config-builder.error", scheme);

    final Map<String, List<Method>> schemeMethods = new TreeMap<>();

    final Method[] methods = fscb.getClass().getMethods();
    for (final Method method : methods) {
        if (!Modifier.isPublic(method.getModifiers())) {
            continue;
        }

        final String methodName = method.getName();
        if (!methodName.startsWith("set")) {
            // not a setter
            continue;
        }

        final String key = methodName.substring(3).toLowerCase();

        List<Method> configSetter = schemeMethods.get(key);
        if (configSetter == null) {
            configSetter = new ArrayList<>(2);
            schemeMethods.put(key, configSetter);
        }
        configSetter.add(method);
    }

    return schemeMethods;
}
 
Example #4
Source File: AbstractFileSystem.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
protected AbstractFileSystem(final FileName rootName, final FileObject parentLayer,
        final FileSystemOptions fileSystemOptions) {
    this.parentLayer = parentLayer;
    this.rootName = rootName;
    this.fileSystemOptions = fileSystemOptions;
    final FileSystemConfigBuilder builder = DefaultFileSystemConfigBuilder.getInstance();
    String uri = builder.getRootURI(fileSystemOptions);
    if (uri == null) {
        uri = rootName.getURI();
    }
    this.rootURI = uri;
}
 
Example #5
Source File: PentahoMapReduceJobBuilderImpl.java    From pentaho-hadoop-shims with Apache License 2.0 5 votes vote down vote up
private void snapshotMetaStore( String metaStoreSnapshotDir ) throws MetaStoreException {
  IMetaStore snapshot = new XmlMetaStore( metaStoreSnapshotDir );
  try {
    FileSystemConfigBuilder nc = KettleVFS.getInstance().getFileSystemManager().getFileSystemConfigBuilder( "hc" );
    Method snapshotMethod = nc.getClass().getMethod( "snapshotNamedClusterToMetaStore", IMetaStore.class );
    snapshotMethod.invoke( nc, snapshot );

    stageConfigurationFiles( metaStoreSnapshotDir );
  } catch ( FileSystemException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e ) {
    log.logError( "Error in snapshotNamedClusterToMetaStore.", e );
  }
}
 
Example #6
Source File: ResourceFileProvider.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
public FileSystemConfigBuilder getConfigBuilder() {
    return org.apache.commons.vfs2.provider.res.ResourceFileSystemConfigBuilder.getInstance();
}
 
Example #7
Source File: RepositoryVfsProvider.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
public FileSystemConfigBuilder getConfigBuilder() {
  throw new NotImplementedException();
}
 
Example #8
Source File: Webdav4FileProvider.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
public FileSystemConfigBuilder getConfigBuilder() {
    return Webdav4FileSystemConfigBuilder.getInstance();
}
 
Example #9
Source File: Webdav4sFileProvider.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
public FileSystemConfigBuilder getConfigBuilder() {
    return Webdav4FileSystemConfigBuilder.getInstance();
}
 
Example #10
Source File: FtpsFileProvider.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
public FileSystemConfigBuilder getConfigBuilder() {
    return FtpsFileSystemConfigBuilder.getInstance();
}
 
Example #11
Source File: Http4FileProvider.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
public FileSystemConfigBuilder getConfigBuilder() {
    return Http4FileSystemConfigBuilder.getInstance();
}
 
Example #12
Source File: UrlFileProvider.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
public FileSystemConfigBuilder getConfigBuilder() {
    return org.apache.commons.vfs2.provider.res.ResourceFileSystemConfigBuilder.getInstance();
}
 
Example #13
Source File: HttpFileProvider.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
public FileSystemConfigBuilder getConfigBuilder() {
    return HttpFileSystemConfigBuilder.getInstance();
}
 
Example #14
Source File: SftpFileProvider.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
public FileSystemConfigBuilder getConfigBuilder() {
    return SftpFileSystemConfigBuilder.getInstance();
}
 
Example #15
Source File: FtpFileProvider.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
public FileSystemConfigBuilder getConfigBuilder() {
    return FtpFileSystemConfigBuilder.getInstance();
}
 
Example #16
Source File: Http5FileProvider.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
public FileSystemConfigBuilder getConfigBuilder() {
    return Http5FileSystemConfigBuilder.getInstance();
}
 
Example #17
Source File: WebdavFileProvider.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
public FileSystemConfigBuilder getConfigBuilder() {
    return WebdavFileSystemConfigBuilder.getInstance();
}
 
Example #18
Source File: MockFileProvider.java    From pentaho-hadoop-shims with Apache License 2.0 4 votes vote down vote up
@Override
public FileSystemConfigBuilder getConfigBuilder() {
  // TODO Auto-generated method stub
  return null;
}
 
Example #19
Source File: DefaultFileSystemManager.java    From commons-vfs with Apache License 2.0 3 votes vote down vote up
/**
 * Get the configuration builder for the given scheme.
 *
 * @param scheme The scheme to locate.
 * @return The FileSystemConfigBuilder for the scheme.
 * @throws FileSystemException if the given scheme is not konwn
 */
@Override
public FileSystemConfigBuilder getFileSystemConfigBuilder(final String scheme) throws FileSystemException {
    final FileProvider provider = providers.get(scheme);
    FileSystemException.requireNonNull(provider, "vfs.impl/unknown-scheme.error", scheme);
    return provider.getConfigBuilder();
}
 
Example #20
Source File: AbstractFileProvider.java    From commons-vfs with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the FileSystemConfigBuidler.
 *
 * @return the FileSystemConfigBuilder.
 */
@Override
public FileSystemConfigBuilder getConfigBuilder() {
    return null;
}
 
Example #21
Source File: FileProvider.java    From commons-vfs with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the configbuilder useable to collect the needed fileSystemOptions.
 *
 * @return a FileSystemConfigBuilder for the particular file system.
 */
FileSystemConfigBuilder getConfigBuilder();
 
Example #22
Source File: HdfsFileProvider.java    From commons-vfs with Apache License 2.0 2 votes vote down vote up
/**
 * Return config builder.
 *
 * @return A config builder for HdfsFileSystems.
 * @see org.apache.commons.vfs2.provider.AbstractFileProvider#getConfigBuilder()
 */
@Override
public FileSystemConfigBuilder getConfigBuilder() {
    return HdfsFileSystemConfigBuilder.getInstance();
}
 
Example #23
Source File: ZipFileProvider.java    From commons-vfs with Apache License 2.0 2 votes vote down vote up
/**
 * Return config builder.
 *
 * @return A config builder for ZipFileProvider.
 * @see org.apache.commons.vfs2.provider.AbstractFileProvider#getConfigBuilder()
 */
@Override
public FileSystemConfigBuilder getConfigBuilder() {
    return ZipFileSystemConfigBuilder.getInstance();
}