本文整理汇总了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);
}
}
示例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;
}
}
}
示例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;
}
示例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
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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
}
示例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);
}
}
示例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;
}
示例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;
}