当前位置: 首页>>代码示例>>Java>>正文


Java GenericFileName类代码示例

本文整理汇总了Java中org.apache.commons.vfs2.provider.GenericFileName的典型用法代码示例。如果您正苦于以下问题:Java GenericFileName类的具体用法?Java GenericFileName怎么用?Java GenericFileName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GenericFileName类属于org.apache.commons.vfs2.provider包,在下文中一共展示了GenericFileName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createClient

import org.apache.commons.vfs2.provider.GenericFileName; //导入依赖的package包/类
/**
 * Creates the client.
 * 
 * @return the grid ftp client
 * 
 * @throws FileSystemException the file system exception
 */
protected GridFTPClient createClient() throws FileSystemException {
    final GenericFileName rootName = getRoot();

    UserAuthenticationData authData = null;
    try {
        authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, GsiFtpFileProvider.AUTHENTICATOR_TYPES);

        String username = UserAuthenticatorUtils
                .getData(authData, UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(rootName.getUserName())).toString();
        String password = UserAuthenticatorUtils
                .getData(authData, UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(rootName.getPassword())).toString();
        return GsiFtpClientFactory.createConnection(rootName.getHostName(), rootName.getPort(), username, password, getFileSystemOptions());
    } finally {
        UserAuthenticatorUtils.cleanup(authData);
    }
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:24,代码来源:GridFTPClientWrapper.java

示例2: getClient

import org.apache.commons.vfs2.provider.GenericFileName; //导入依赖的package包/类
/**
 * Creates an FTP client to use.
 * 
 * @return the client
 * 
 * @throws FileSystemException the file system exception
 */
public GridFTPClient getClient() throws FileSystemException {
    synchronized (idleClientSync) {
        if (idleClient == null) {
            final GenericFileName rootName = (GenericFileName) getRoot().getName();

            LOG.debug("Creating connection to GSIFTP Host: " + rootName.getHostName() + " Port:" + rootName.getPort() + " User:"
                    + rootName.getUserName() + " Path: " + rootName.getPath());

            return GsiFtpClientFactory.createConnection(rootName.getHostName(),
                                                        rootName.getPort(),
                                                        rootName.getUserName(),
                                                        rootName.getPassword(),
                                                        // rootName.getPath(),
                                                        getFileSystemOptions());
        } else {
            final GridFTPClient client = idleClient;
            idleClient = null;
            return client;
        }
    }
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:29,代码来源:GsiFtpFileSystem.java

示例3: getHDFSFileSystem

import org.apache.commons.vfs2.provider.GenericFileName; //导入依赖的package包/类
@Override
public HadoopFileSystem getHDFSFileSystem() throws FileSystemException {
  if (fs == null) {
    Configuration conf = new Configuration();
    conf.set("fs.maprfs.impl", MapRFileProvider.FS_MAPR_IMPL);

    GenericFileName rootName = (GenericFileName) getRootName();
    String url = rootName.getScheme() + "://" + rootName.getHostName().trim();
    if (rootName.getPort() != MapRFileNameParser.DEFAULT_PORT) {
      url += ":" + rootName.getPort();
    }
    url += "/";
    conf.set("fs.default.name", url);
    setFileSystemOptions( getFileSystemOptions(), conf );
    try {
      fs = new HadoopFileSystemImpl( org.apache.hadoop.fs.FileSystem.get(conf) );
    } catch (Throwable t) {
      throw new FileSystemException("Could not get MapR FileSystem for " + url, t);
    }
  }
  return fs;
}
 
开发者ID:pentaho,项目名称:pentaho-hdfs-vfs,代码行数:23,代码来源:MapRFileSystem.java

示例4: FTPClientWrapper

import org.apache.commons.vfs2.provider.GenericFileName; //导入依赖的package包/类
FTPClientWrapper(final GenericFileName root, final FileSystemOptions fileSystemOptions, Integer defaultTimeout)
        throws FileSystemException {
    this.root = root;
    this.fileSystemOptions = fileSystemOptions;
    this.defaultTimeout = defaultTimeout;
    getFtpClient(); // fail-fast
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:8,代码来源:FTPClientWrapper.java

示例5: createClient

import org.apache.commons.vfs2.provider.GenericFileName; //导入依赖的package包/类
private FTPClient createClient() throws FileSystemException
{
    final GenericFileName rootName = getRoot();
    Map<String,String>mParams = null;
    if(rootName instanceof URLFileName){
    	mParams = getQueryParams((URLFileName)rootName);
    }
    UserAuthenticationData authData = null;
    try
    {
     authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, FtpFileProvider.AUTHENTICATOR_TYPES);

     char[] username = UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME,
                                                      UserAuthenticatorUtils.toChar(rootName.getUserName()));

     char[] password = UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD,
                                                      UserAuthenticatorUtils.toChar(rootName.getPassword()));

        if (mParams == null) {

            return FtpClientFactory.createConnection(rootName.getHostName(), rootName.getPort(), username, password,
                                                     rootName.getPath(), getFileSystemOptions(), defaultTimeout);
        } else {

            return FtpClientFactory.createConnection(rootName.getHostName(), rootName.getPort(), username, password,
                                                     rootName.getPath(), getFileSystemOptions(),
                                                     mParams.get(SftpConstants.PROXY_SERVER),
                                                     mParams.get(SftpConstants.PROXY_PORT),
                                                     mParams.get(SftpConstants.PROXY_USERNAME),
                                                     mParams.get(SftpConstants.PROXY_PASSWORD),
                                                     mParams.get(SftpConstants.TIMEOUT),
                                                     mParams.get(SftpConstants.RETRY_COUNT), defaultTimeout);
        }
    }
    finally
    {
        UserAuthenticatorUtils.cleanup(authData);
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:40,代码来源:FTPClientWrapper.java

示例6: FtpFileSystem

import org.apache.commons.vfs2.provider.GenericFileName; //导入依赖的package包/类
/**
 * @param rootName The root of the file system.
 * @param ftpClient The FtpClient.
 * @param fileSystemOptions The FileSystemOptions.
 * @since 2.0 (was protected)
 * */
public FtpFileSystem(final GenericFileName rootName, final FtpClient ftpClient,
                     final FileSystemOptions fileSystemOptions)
{
    super(rootName, null, fileSystemOptions);
    // hostname = rootName.getHostName();
    // port = rootName.getPort();

    idleClient.set(ftpClient);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:16,代码来源:FtpFileSystem.java

示例7: getClient

import org.apache.commons.vfs2.provider.GenericFileName; //导入依赖的package包/类
/**
 * Creates an FTP client to use.
 * @return An FTPCleint.
 * @throws FileSystemException if an error occurs.
 */
public FtpClient getClient() throws FileSystemException
{
    FtpClient client = idleClient.getAndSet(null);

    if (client == null || !client.isConnected())
    {
        client = new FTPClientWrapper((GenericFileName) getRoot().getName(), getFileSystemOptions());
    }

    return client;
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:17,代码来源:FtpFileSystem.java

示例8: doCreateFileSystem

import org.apache.commons.vfs2.provider.GenericFileName; //导入依赖的package包/类
/**
 * Creates a {@link FileSystem}.
 */
@Override
protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions)
    throws FileSystemException
{
    // JSch jsch = createJSch(fileSystemOptions);

    // Create the file system
    final GenericFileName rootName = (GenericFileName) name;

    Session session;
    UserAuthenticationData authData = null;
    try
    {
        authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, AUTHENTICATOR_TYPES);

        session = SftpClientFactory.createConnection(
            rootName.getHostName(),
            rootName.getPort(),
            UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME,
                UserAuthenticatorUtils.toChar(rootName.getUserName())),
            UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD,
                UserAuthenticatorUtils.toChar(rootName.getPassword())),
            fileSystemOptions);
    }
    catch (final Exception e)
    {
        throw new FileSystemException("vfs.provider.sftp/connect.error",
            name,
            e);
    }
    finally
    {
        UserAuthenticatorUtils.cleanup(authData);
    }

    return new SftpFileSystem(rootName, session, fileSystemOptions);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:41,代码来源:SftpFileProvider.java

示例9: SftpFileSystem

import org.apache.commons.vfs2.provider.GenericFileName; //导入依赖的package包/类
protected SftpFileSystem(final GenericFileName rootName,
                         final Session session,
                         final FileSystemOptions fileSystemOptions)
{
    super(rootName, null, fileSystemOptions);
    this.session = session;
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:8,代码来源:SftpFileSystem.java

示例10: doCreateFileSystem

import org.apache.commons.vfs2.provider.GenericFileName; //导入依赖的package包/类
/**
 * Creates a {@link FileSystem}.
 */
@Override
protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions)
    throws FileSystemException
{
    // Create the file system
    final GenericFileName rootName = (GenericFileName) name;

    UserAuthenticationData authData = null;
    HttpClient httpClient;
    try
    {
        authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, AUTHENTICATOR_TYPES);

        httpClient = HttpClientFactory.createConnection(
            rootName.getScheme(),
            rootName.getHostName(),
            rootName.getPort(),
            UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData,
                UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(rootName.getUserName()))),
            UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData,
                UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(rootName.getPassword()))),
            fileSystemOptions);
    }
    finally
    {
        UserAuthenticatorUtils.cleanup(authData);
    }

    return new HttpFileSystem(rootName, httpClient, fileSystemOptions);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:34,代码来源:HttpFileProvider.java

示例11: doCreateFileSystem

import org.apache.commons.vfs2.provider.GenericFileName; //导入依赖的package包/类
/**
 * Creates a {@link FileSystem}.  If you're looking at this method and wondering how to
 * get a FileSystemOptions object bearing the proxy host and credentials configuration through
 * to this method so it's used for resolving a {@link FileObject} in the FileSystem, then be sure
 * to use correct signature of the {@link FileSystemManager} resolveFile method.
 * @see org.apache.commons.vfs2.impl.DefaultFileSystemManager#resolveFile(FileObject, String, FileSystemOptions)
 */
@Override
protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions)
    throws FileSystemException
{
    // Create the file system
    final GenericFileName rootName = (GenericFileName) name;
    FileSystemOptions fsOpts = (fileSystemOptions == null) ? new FileSystemOptions() : fileSystemOptions;

    UserAuthenticationData authData = null;
    HttpClient httpClient;
    try
    {
        authData = UserAuthenticatorUtils.authenticate(fsOpts, AUTHENTICATOR_TYPES);

        httpClient = HttpClientFactory.createConnection(
            WebdavFileSystemConfigBuilder.getInstance(),
            "http",
            rootName.getHostName(),
            rootName.getPort(),
            UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData,
                    UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(rootName.getUserName()))),
            UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData,
                    UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(rootName.getPassword()))),
            fsOpts);
    }
    finally
    {
        UserAuthenticatorUtils.cleanup(authData);
    }

    return new WebdavFileSystem(rootName, httpClient, fsOpts);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:40,代码来源:WebdavFileProvider.java

示例12: FtpsClientWrapper

import org.apache.commons.vfs2.provider.GenericFileName; //导入依赖的package包/类
FtpsClientWrapper(final GenericFileName root, final FileSystemOptions fileSystemOptions, Integer connectTimeout)
        throws FileSystemException {
    this.root = root;
    this.fileSystemOptions = fileSystemOptions;
    this.connectTimeout = connectTimeout;
    getFtpsClient(); // fail-fast
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:8,代码来源:FtpsClientWrapper.java

示例13: createClient

import org.apache.commons.vfs2.provider.GenericFileName; //导入依赖的package包/类
private FTPSClient createClient() throws FileSystemException
{
    final GenericFileName rootName = getRoot();

    UserAuthenticationData authData = null;
    try
    {
        authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, FtpsFileProvider.AUTHENTICATOR_TYPES);

        char[] userName = UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME,
                                                         UserAuthenticatorUtils.toChar(rootName.getUserName()));

        char[] password = UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD,
                                                         UserAuthenticatorUtils.toChar(rootName.getPassword()));

        return FtpsClientFactory.createConnection(rootName.getHostName(), rootName.getPort(), userName, password,
                                                  rootName.getPath(), getFileSystemOptions(), connectTimeout);
    }
    finally
    {
        UserAuthenticatorUtils.cleanup(authData);
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:24,代码来源:FtpsClientWrapper.java

示例14: getHDFSFileSystem

import org.apache.commons.vfs2.provider.GenericFileName; //导入依赖的package包/类
public HadoopFileSystem getHDFSFileSystem() throws FileSystemException {
  if (mockHdfs != null) {
    return mockHdfs;
  }
  if (hdfs == null) {
    Configuration conf = new Configuration();
    GenericFileName genericFileName = (GenericFileName) getRootName();
    StringBuffer urlBuffer = new StringBuffer("hdfs://");
    urlBuffer.append(genericFileName.getHostName());
    int port = genericFileName.getPort();
    if(port >= 0) {
      urlBuffer.append(":");
      urlBuffer.append(port);
    }
    String url = urlBuffer.toString();
    conf.set("fs.default.name", url);

    String replication = System.getProperty("dfs.replication", "3");
    conf.set("dfs.replication", replication);

    if (genericFileName.getUserName() != null && !"".equals(genericFileName.getUserName())) {
      conf.set("hadoop.job.ugi", genericFileName.getUserName() + ", " + genericFileName.getPassword());
    }
    setFileSystemOptions( getFileSystemOptions(), conf );
    try {
      hdfs = new HadoopFileSystemImpl( org.apache.hadoop.fs.FileSystem.get( conf ) );
    } catch (Throwable t) {
      throw new FileSystemException("Could not getHDFSFileSystem() for " + url, t);
    }
  }
  return hdfs;
}
 
开发者ID:pentaho,项目名称:pentaho-hdfs-vfs,代码行数:33,代码来源:HDFSFileSystem.java

示例15: doCreateFileSystem

import org.apache.commons.vfs2.provider.GenericFileName; //导入依赖的package包/类
/**
 * Creates a {@link FileSystem}.
 * 
 * @param name the name
 * @param fileSystemOptions the file system options
 * 
 * @return the file system
 * 
 * @throws FileSystemException the file system exception
 */
@Override
protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions) throws FileSystemException {
    // Create the file system
    final GenericFileName rootName = (GenericFileName) name;

    String attrHome;
    GridFTPClientWrapper gridFtpClient = null;
    try {
        gridFtpClient = new GridFTPClientWrapper(rootName, fileSystemOptions);
        log.debug("Creating connection to GsiFTP Host:" + gridFtpClient.getRoot().getHostName() + " Port:" + gridFtpClient.getRoot().getPort()
                + " User:" + gridFtpClient.getRoot().getUserName() + " Path:" + gridFtpClient.getRoot().getPath());
        attrHome = gridFtpClient.getCurrentDir();
        log.debug("Current directory: " + attrHome);
    } catch (Exception e) {
        throw new FileSystemException("vfs.provider.gsiftp/connect.error", name, e);
    }

    // // Session session;
    // GridFTPClient client;
    // String attrHome;
    // try {
    // log.debug("Creating connection to GsiFTP Host:" + rootName.getHostName() + " Port:" +
    // rootName.getPort() + " User:"
    // + rootName.getUserName() + " Path:" + rootName.getPath());
    //
    // client = GsiFtpClientFactory.createConnection(rootName.getHostName(),
    // rootName.getPort(),
    // rootName.getUserName(),
    // rootName.getPassword(),
    // fileSystemOptions);
    //
    // attrHome = client.getCurrentDir();
    // log.debug("Current directory: " + attrHome);
    // } catch (final Exception e) {
    // throw new FileSystemException("vfs.provider.gsiftp/connect.error", name, e);
    // }

    // set HOME dir attribute
    final GsiFtpFileSystem fs = new GsiFtpFileSystem(rootName, gridFtpClient, fileSystemOptions);
    fs.setAttribute(ATTR_HOME_DIR, attrHome);

    return fs;
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:54,代码来源:GsiFtpFileProvider.java


注:本文中的org.apache.commons.vfs2.provider.GenericFileName类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。