List of usage examples for org.apache.commons.vfs2.impl DefaultFileSystemManager addExtensionMap
public void addExtensionMap(final String extension, final String scheme)
From source file:org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader.java
public static FileSystemManager generateVfs() throws FileSystemException { DefaultFileSystemManager vfs = new DefaultFileSystemManager(); vfs.addProvider("res", new org.apache.commons.vfs2.provider.res.ResourceFileProvider()); vfs.addProvider("zip", new org.apache.commons.vfs2.provider.zip.ZipFileProvider()); vfs.addProvider("gz", new org.apache.commons.vfs2.provider.gzip.GzipFileProvider()); vfs.addProvider("ram", new org.apache.commons.vfs2.provider.ram.RamFileProvider()); vfs.addProvider("file", new org.apache.commons.vfs2.provider.local.DefaultLocalFileProvider()); vfs.addProvider("jar", new org.apache.commons.vfs2.provider.jar.JarFileProvider()); vfs.addProvider("http", new org.apache.commons.vfs2.provider.http.HttpFileProvider()); vfs.addProvider("https", new org.apache.commons.vfs2.provider.https.HttpsFileProvider()); vfs.addProvider("ftp", new org.apache.commons.vfs2.provider.ftp.FtpFileProvider()); vfs.addProvider("ftps", new org.apache.commons.vfs2.provider.ftps.FtpsFileProvider()); vfs.addProvider("war", new org.apache.commons.vfs2.provider.jar.JarFileProvider()); vfs.addProvider("par", new org.apache.commons.vfs2.provider.jar.JarFileProvider()); vfs.addProvider("ear", new org.apache.commons.vfs2.provider.jar.JarFileProvider()); vfs.addProvider("sar", new org.apache.commons.vfs2.provider.jar.JarFileProvider()); vfs.addProvider("ejb3", new org.apache.commons.vfs2.provider.jar.JarFileProvider()); vfs.addProvider("tmp", new org.apache.commons.vfs2.provider.temp.TemporaryFileProvider()); vfs.addProvider("tar", new org.apache.commons.vfs2.provider.tar.TarFileProvider()); vfs.addProvider("tbz2", new org.apache.commons.vfs2.provider.tar.TarFileProvider()); vfs.addProvider("tgz", new org.apache.commons.vfs2.provider.tar.TarFileProvider()); vfs.addProvider("bz2", new org.apache.commons.vfs2.provider.bzip2.Bzip2FileProvider()); vfs.addProvider("hdfs", new HdfsFileProvider()); vfs.addExtensionMap("jar", "jar"); vfs.addExtensionMap("zip", "zip"); vfs.addExtensionMap("gz", "gz"); vfs.addExtensionMap("tar", "tar"); vfs.addExtensionMap("tbz2", "tar"); vfs.addExtensionMap("tgz", "tar"); vfs.addExtensionMap("bz2", "bz2"); vfs.addMimeTypeMap("application/x-tar", "tar"); vfs.addMimeTypeMap("application/x-gzip", "gz"); vfs.addMimeTypeMap("application/zip", "zip"); vfs.setFileContentInfoFactory(new FileContentInfoFilenameFactory()); vfs.setFilesCache(new SoftRefFilesCache()); File cacheDir = computeTopCacheDir(); vfs.setReplicator(new UniqueFileReplicator(cacheDir)); vfs.setCacheStrategy(CacheStrategy.ON_RESOLVE); vfs.init();/* w w w. ja v a 2s.c om*/ vfsInstances.add(new WeakReference<DefaultFileSystemManager>(vfs)); return vfs; }
From source file:org.apache.metron.common.utils.VFSClassloaderUtil.java
/** * Create a FileSystem manager suitable for our purposes. * This manager supports files of the following types: * * res - resource files/* ww w .j av a2s . c o m*/ * * jar * * tar * * bz2 * * tgz * * zip * * HDFS * * FTP * * HTTP/S * * file * @return * @throws FileSystemException */ public static FileSystemManager generateVfs() throws FileSystemException { DefaultFileSystemManager vfs = new DefaultFileSystemManager(); vfs.addProvider("res", new org.apache.commons.vfs2.provider.res.ResourceFileProvider()); vfs.addProvider("zip", new org.apache.commons.vfs2.provider.zip.ZipFileProvider()); vfs.addProvider("gz", new org.apache.commons.vfs2.provider.gzip.GzipFileProvider()); vfs.addProvider("ram", new org.apache.commons.vfs2.provider.ram.RamFileProvider()); vfs.addProvider("file", new org.apache.commons.vfs2.provider.local.DefaultLocalFileProvider()); vfs.addProvider("jar", new org.apache.commons.vfs2.provider.jar.JarFileProvider()); vfs.addProvider("http", new org.apache.commons.vfs2.provider.http.HttpFileProvider()); vfs.addProvider("https", new org.apache.commons.vfs2.provider.https.HttpsFileProvider()); vfs.addProvider("ftp", new org.apache.commons.vfs2.provider.ftp.FtpFileProvider()); vfs.addProvider("ftps", new org.apache.commons.vfs2.provider.ftps.FtpsFileProvider()); vfs.addProvider("war", new org.apache.commons.vfs2.provider.jar.JarFileProvider()); vfs.addProvider("par", new org.apache.commons.vfs2.provider.jar.JarFileProvider()); vfs.addProvider("ear", new org.apache.commons.vfs2.provider.jar.JarFileProvider()); vfs.addProvider("sar", new org.apache.commons.vfs2.provider.jar.JarFileProvider()); vfs.addProvider("ejb3", new org.apache.commons.vfs2.provider.jar.JarFileProvider()); vfs.addProvider("tmp", new org.apache.commons.vfs2.provider.temp.TemporaryFileProvider()); vfs.addProvider("tar", new org.apache.commons.vfs2.provider.tar.TarFileProvider()); vfs.addProvider("tbz2", new org.apache.commons.vfs2.provider.tar.TarFileProvider()); vfs.addProvider("tgz", new org.apache.commons.vfs2.provider.tar.TarFileProvider()); vfs.addProvider("bz2", new org.apache.commons.vfs2.provider.bzip2.Bzip2FileProvider()); vfs.addProvider("hdfs", new HdfsFileProvider()); vfs.addExtensionMap("jar", "jar"); vfs.addExtensionMap("zip", "zip"); vfs.addExtensionMap("gz", "gz"); vfs.addExtensionMap("tar", "tar"); vfs.addExtensionMap("tbz2", "tar"); vfs.addExtensionMap("tgz", "tar"); vfs.addExtensionMap("bz2", "bz2"); vfs.addMimeTypeMap("application/x-tar", "tar"); vfs.addMimeTypeMap("application/x-gzip", "gz"); vfs.addMimeTypeMap("application/zip", "zip"); vfs.setFileContentInfoFactory(new FileContentInfoFilenameFactory()); vfs.setFilesCache(new SoftRefFilesCache()); vfs.setReplicator(new UniqueFileReplicator(new File(System.getProperty("java.io.tmpdir")))); vfs.setCacheStrategy(CacheStrategy.ON_RESOLVE); vfs.init(); return vfs; }
From source file:org.renjin.appengine.AppEngineContextFactory.java
@VisibleForTesting static FileSystemManager createFileSystemManager(LocalFileProvider localFileProvider) throws FileSystemException { try {/*from ww w .j av a 2 s . c om*/ FastJarFileProvider jarFileProvider = new FastJarFileProvider(); // this provides a fake local file system rooted in the servlet context root. // this is necessary because on the actual appengine platform, any queries to the ancestors // of the servlet context (e.g. /base) will throw a security exception DefaultFileSystemManager dfsm = new DefaultFileSystemManager(); dfsm.addProvider("jar", jarFileProvider); dfsm.addProvider("file", localFileProvider); dfsm.addExtensionMap("jar", "jar"); dfsm.setDefaultProvider(new UrlFileProvider()); dfsm.setFilesCache(new NullFilesCache()); dfsm.setCacheStrategy(CacheStrategy.ON_RESOLVE); dfsm.setBaseFile(new File("/")); dfsm.init(); return dfsm; } catch (FileSystemException e) { LOG.log(Level.SEVERE, "Failed to initialize file system for development server", e); throw new RuntimeException(e); } }