Java Code Examples for org.apache.commons.vfs2.impl.StandardFileSystemManager#init()

The following examples show how to use org.apache.commons.vfs2.impl.StandardFileSystemManager#init() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VFSUtils.java    From otroslogviewer with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the global filesystem manager
 *
 * @return the global filesystem manager
 */
public static FileSystemManager getFileSystemManager() {
  aLock.readLock().lock();

  try {
    if (fileSystemManager == null) {
      try {
        StandardFileSystemManager fm = new StandardFileSystemManager();
        fm.setCacheStrategy(CacheStrategy.MANUAL);
        fm.init();
        LOGGER.info("Supported schemes: {} ", Joiner.on(", ").join(fm.getSchemes()));
        fileSystemManager = fm;
      } catch (Exception exc) {
        throw new RuntimeException(exc);
      }
    }

    return fileSystemManager;
  } finally {
    aLock.readLock().unlock();
  }
}
 
Example 2
Source File: StorageObject.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private FileSystemManager getFileSystemManager() throws Exception {
	if (FILESYSTEMANAGERINSTANCE == null) {
		synchronized (StorageObject.class) {
			if (FILESYSTEMANAGERINSTANCE == null) {
				StandardFileSystemManager fs = new StandardFileSystemManager();
				fs.setFilesCache(new NullFilesCache());
				fs.setCacheStrategy(CacheStrategy.ON_RESOLVE);
				fs.init();
				FILESYSTEMANAGERINSTANCE = fs;
			}
		}
	}
	return FILESYSTEMANAGERINSTANCE;
}
 
Example 3
Source File: VfsTestHelper.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public VfsTestHelper() throws Exception {
    // setup and initialize VFS
    fsManager = new StandardFileSystemManager() {
        protected void configurePlugins() throws FileSystemException {
            // disable automatic loading of potentially unsupported extensions
        }
    };
    fsManager.setConfiguration(getClass().getResource(VFS_CONF).toString());
    fsManager.init();

    // setup and initialize ivy
    ivy = new Ivy();
    ivy.configure(new File(IVY_CONFIG_FILE));
}
 
Example 4
Source File: VfsTask.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Resolves a URI to a file, relative to the project's base directory.
 *
 * @param uri The URI to resolve.
 * @return resolved file object.
 * @throws FileSystemException If an error occurred.
 */
protected FileObject resolveFile(final String uri) throws FileSystemException {
    if (manager == null) {
        final StandardFileSystemManager mngr = new StandardFileSystemManager();
        mngr.setLogger(new AntLogger());
        mngr.init();
        manager = mngr;
        getProject().addBuildListener(new CloseListener());
    }
    return manager.resolveFile(getProject().getBaseDir(), uri);
}
 
Example 5
Source File: DelegatingFileSystemOptionsBuilderTest.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {

    // get a full blown, fully functional manager
    fsm = new StandardFileSystemManager();
    fsm.init();
}