本文整理汇总了Java中org.apache.commons.vfs.provider.local.DefaultLocalFileProvider类的典型用法代码示例。如果您正苦于以下问题:Java DefaultLocalFileProvider类的具体用法?Java DefaultLocalFileProvider怎么用?Java DefaultLocalFileProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultLocalFileProvider类属于org.apache.commons.vfs.provider.local包,在下文中一共展示了DefaultLocalFileProvider类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepare
import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider; //导入依赖的package包/类
/**
* Prepares the file system manager.
*
* Imports test data from the disk.
*
* @throws Exception
*
*/
public void prepare(final DefaultFileSystemManager manager)
throws Exception
{
try
{
manager.addProvider("ram", new RamFileProvider());
manager.addProvider("file", new DefaultLocalFileProvider());
}
catch (Exception e)
{
log.error(e);
throw e;
}
}
示例2: setup
import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider; //导入依赖的package包/类
@Before
public void setup() throws Exception {
manager = new DefaultFileSystemManager();
manager.setFilesCache(new SoftRefFilesCache());
manager.setCacheStrategy(CacheStrategy.ON_RESOLVE);
manager.addProvider("file", new DefaultLocalFileProvider());
manager.addProvider("tgz", new TarFileProvider());
manager.addProvider("tar", new TarFileProvider());
createLargeFile(largeFilePath, largeFileName);
}
示例3: createManager
import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider; //导入依赖的package包/类
/**
* creates a new uninitialized file system manager
* @throws Exception
*/
protected DefaultFileSystemManager createManager() throws Exception
{
DefaultFileSystemManager fs = getProviderConfig().getDefaultFileSystemManager();
fs.setFilesCache(getProviderConfig().getFilesCache());
getProviderConfig().prepare(fs);
if (!fs.hasProvider("file"))
{
fs.addProvider("file", new DefaultLocalFileProvider());
}
return fs;
}
示例4: createDefaultFileSystemManager
import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider; //导入依赖的package包/类
/**
* Creates new DefaultSystemManager instance with configured providers, replicator, temporary
* storage - as described in class description, and <strong>DISABLED files cache</strong>
* (NullFilesCache) .
* <p>
* Returned instance is initialized and it is a caller responsibility to close it to release
* resources.
*
* @param enableFilesCache
* when <code>true</code> DefaultFilesCache is configured for returned manager; when
* <code>false</code> file caching is disabled - NullFilesCache is configured
* @return configured and initialized DefaultFileSystemManager instance
* @throws FileSystemException
* when initialization or configuration process fails
*/
public static DefaultFileSystemManager createDefaultFileSystemManager(boolean enableFilesCache)
throws FileSystemException {
logger.debug("Creating new VFS manager");
FileSystemOptions opts = createDefaultFileSystemOptions();
final DefaultFileSystemManager manager = new DefaultOptionsFileSystemManager(opts);
manager.setLogger(logger);
final DefaultFileReplicator replicator = new DefaultFileReplicator();
manager.setReplicator(new PrivilegedFileReplicator(replicator));
manager.setTemporaryFileStore(replicator);
if (!enableFilesCache) {
// WISH: one beautiful day one may try to use FilesCache aware of AO instead of NullFilesCache
manager.setFilesCache(new NullFilesCache());
}
manager.addProvider("file", new DefaultLocalFileProvider());
manager.addProvider("http", new HttpFileProvider());
manager.addProvider("https", new HttpsFileProvider());
manager.addProvider("ftp", new FtpFileProvider());
manager.addProvider("sftp", new SftpFileProvider());
final ProActiveFileProvider proactiveProvider = new ProActiveFileProvider();
for (final String scheme : ProActiveFileName.getAllVFSSchemes()) {
manager.addProvider(scheme, proactiveProvider);
}
manager.addProvider("s3", new S3FileProvider());
manager.addOperationProvider("s3", new AclOperationsProvider());
manager.setDefaultProvider(new UrlFileProvider());
manager.init();
logger.debug("Created and initialized new VFS manager");
return manager;
}
示例5: getCapabilities
import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider; //导入依赖的package包/类
public Collection getCapabilities()
{
return DefaultLocalFileProvider.capabilities;
}
示例6: setUp
import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider; //导入依赖的package包/类
protected void setUp() throws Exception
{
startThreadSnapshot = createThreadSnapshot();
// Locate the temp directory, and clean it up
tempDir = AbstractVfsTestCase.getTestDirectory("temp");
checkTempDir("Temp dir not empty before test");
// Create the file system manager
manager = providerConfig.getDefaultFileSystemManager();
manager.setFilesCache(providerConfig.getFilesCache());
final DefaultFileReplicator replicator = new DefaultFileReplicator(tempDir);
manager.setReplicator(new PrivilegedFileReplicator(replicator));
manager.setTemporaryFileStore(replicator);
providerConfig.prepare(manager);
if (!manager.hasProvider("file"))
{
manager.addProvider("file", new DefaultLocalFileProvider());
}
manager.init();
// Locate the base folders
baseFolder = providerConfig.getBaseTestFolder(manager);
readFolder = baseFolder.resolveFile("read-tests");
writeFolder = baseFolder.resolveFile("write-tests");
// Make some assumptions about the read folder
assertTrue("Folder does not exist: " + readFolder, readFolder.exists());
assertFalse(readFolder.getName().getPath().equals(FileName.ROOT_PATH));
// Configure the tests
final Enumeration tests = testSuite.tests();
while (tests.hasMoreElements())
{
final Test test = (Test) tests.nextElement();
if (test instanceof AbstractProviderTestCase)
{
final AbstractProviderTestCase providerTestCase = (AbstractProviderTestCase) test;
providerTestCase.setConfig(manager, providerConfig, baseFolder, readFolder, writeFolder);
}
}
}
示例7: testCaching
import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider; //导入依赖的package包/类
/**
* 캐싱 기능을 사용하여, 생성하거나 수정할 파일을 메모리 상에 로딩함으로써
* 파일 접근 시에 소요되는 시간을 단축한다.
* @throws Exception
*/
@Test
public void testCaching() throws Exception {
String testFolder = "d:/workspace/java/e-gov/eGovFramework/RTE/DEV/trunk/Foundation/egovframework.rte.fdl.filehandling/testfolder";
FileSystemManager manager = VFS.getManager();
FileObject scratchFolder = manager.resolveFile(testFolder);
// testfolder 내의 모든 파일 삭제
scratchFolder.delete(Selectors.EXCLUDE_SELF);
// 캐싱 Manager 생성
DefaultFileSystemManager fs = new DefaultFileSystemManager();
fs.setFilesCache(manager.getFilesCache());
// zip, jar, tgz, tar, tbz2, file
if (!fs.hasProvider("file")) {
fs.addProvider("file", new DefaultLocalFileProvider());
}
fs.setCacheStrategy(CacheStrategy.ON_RESOLVE);
fs.init();
// 캐싱 객체 생성
FileObject foBase2 = fs.resolveFile(testFolder);
log.debug("## scratchFolder.getName().getPath() : " + scratchFolder.getName().getPath());
FileObject cachedFolder = foBase2.resolveFile(scratchFolder.getName().getPath());
// 파일이 존재하지 않음
FileObject[] fos = cachedFolder.getChildren();
assertFalse(contains(fos, "file1.txt"));
// 파일생성
scratchFolder.resolveFile("file1.txt").createFile();
// 파일 존재함
// BUT cachedFolder 에는 파일이 존재하지 않음
fos = cachedFolder.getChildren();
assertFalse(contains(fos, "file1.txt"));
// 새로고침
cachedFolder.refresh();
// 파일이 존재함
fos = cachedFolder.getChildren();
assertTrue(contains(fos, "file1.txt"));
}
示例8: testCaching1
import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider; //导入依赖的package包/类
@Test
public void testCaching1() throws Exception {
String testFolder = "d:/workspace/java/e-gov/eGovFramework/RTE/DEV/trunk/Foundation/egovframework.rte.fdl.filehandling/test";
FileSystemManager manager = VFS.getManager();
EgovFileUtil.writeFile(testFolder + "/file1.txt", text, "UTF-8");
/*
* 캐싱 Manager 생성
* CacheStrategy.MANUAL : Deal with cached data manually. Call FileObject.refresh() to refresh the object data.
* CacheStrategy.ON_RESOLVE : Refresh the data every time you request a file from FileSystemManager.resolveFile
* CacheStrategy.ON_CALL : Refresh the data every time you call a method on the fileObject. You'll use this only if you really need the latest info as this setting is a major performance loss.
*/
DefaultFileSystemManager fs = new DefaultFileSystemManager();
fs.setFilesCache(manager.getFilesCache());
// zip, jar, tgz, tar, tbz2, file
if (!fs.hasProvider("file")) {
fs.addProvider("file", new DefaultLocalFileProvider());
}
// StandardFileSystemManager fs = new StandardFileSystemManager();
fs.setCacheStrategy(CacheStrategy.ON_RESOLVE);
fs.init();
// 캐싱 객체 생성
//FileObject foBase2 = fs.resolveFile(testFolder);
log.debug("####1");
FileObject cachedFile = fs.toFileObject(new File(testFolder + "/file1.txt"));
log.debug("####2");
FilesCache filesCache = fs.getFilesCache();
log.debug("####3");
filesCache.putFile(cachedFile);
FileObject obj = filesCache.getFile(cachedFile.getFileSystem(), cachedFile.getName());
//FileObject baseFile = fs.getBaseFile();
// log.debug("### cachedFile.getContent().getSize() is " + cachedFile.getContent().getSize());
// long fileSize = cachedFile.getContent().getSize();
// log.debug("#########size is " + fileSize);
//FileObject cachedFile1 = cachedFile.resolveFile("file2.txt");
// FileObject scratchFolder = manager.resolveFile(testFolder);
// scratchFolder.delete(Selectors.EXCLUDE_SELF);
EgovFileUtil.delete(new File(testFolder + "/file1.txt"));
// obj.createFile();
// log.debug("#########obj is " + obj.toString());
// log.debug("#########size is " + obj.getContent().getSize());
log.debug("#########file is " + obj.exists());
fs.close();
}