當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultLocalFileProvider類代碼示例

本文整理匯總了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;
	}
}
 
開發者ID:pentaho,項目名稱:pdi-vfs,代碼行數:23,代碼來源:RamProviderTestCase.java

示例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);
}
 
開發者ID:pentaho,項目名稱:pdi-vfs,代碼行數:14,代碼來源:LargeTarTestCase.java

示例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;
}
 
開發者ID:pentaho,項目名稱:pdi-vfs,代碼行數:16,代碼來源:AbstractProviderTestCase.java

示例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;
}
 
開發者ID:mnip91,項目名稱:proactive-component-monitoring,代碼行數:51,代碼來源:VFSFactory.java

示例5: getCapabilities

import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider; //導入依賴的package包/類
public Collection getCapabilities()
{
    return DefaultLocalFileProvider.capabilities;
}
 
開發者ID:pentaho,項目名稱:pdi-vfs,代碼行數:5,代碼來源:TemporaryFileProvider.java

示例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);
        }
    }
}
 
開發者ID:pentaho,項目名稱:pdi-vfs,代碼行數:47,代碼來源:AbstractTestSuite.java

示例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"));

}
 
開發者ID:eGovFrame,項目名稱:egovframework.rte.root,代碼行數:53,代碼來源:FilehandlingServiceTest.java

示例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();
    }
 
開發者ID:eGovFrame,項目名稱:egovframework.rte.root,代碼行數:61,代碼來源:FilehandlingServiceTest.java


注:本文中的org.apache.commons.vfs.provider.local.DefaultLocalFileProvider類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。