You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Mark Shifman <ma...@yale.edu> on 2009/02/18 14:30:34 UTC

Re:[VFS]how to programmatically create an instance of DefaultFileSystemManager

I made my own manager to do my own services.  This might help you.

package org.VFSManagers;

import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.FileSystemManager;
import org.apache.commons.vfs.impl.DefaultFileSystemManager;
import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
import org.apache.commons.vfs.provider.sftp.SftpFileProvider;
import org.apache.commons.vfs.provider.smb.SmbFileProvider;

public class VFS_YPED {
	private static FileSystemManager instance;

	private VFS_YPED()
    {
    }

	 public static synchronized FileSystemManager getManager() throws FileSystemException{
		 if (instance == null){
		     DefaultFileSystemManager dfs = new DefaultFileSystemManager();
		     dfs.addProvider("sftp", new SftpFileProvider());
		     dfs.addProvider("smb",new SmbFileProvider());
		     //dfs.addProvider("zip",new ZipFileProvider());
		     dfs.addProvider("local", new DefaultLocalFileProvider());
		     //dfs.setCacheStrategy(CacheStrategy.ON_RESOLVE);
		     dfs.init();
		     instance=dfs;
		 }
		 return instance;
	 }
	 public static void close(){
		 if (instance != null)
		 ((DefaultFileSystemManager)instance).close();
		 instance=null;
	 }
}


Suresh Pendap wrote:
> Hi,
> 
>          I would like to programmatically create an instance of DefaultFileSystemManager by setting all the providers, rather than use the singleton instance using the VFS.getManager(). 
> 
> Can some one provide me the sample code which depicts how to achieve that?
> 
> I just want to make sure that I do not miss any important step.
> 
>  
> 
>  
> 
> Regards
> 
> Suresh
> 
>  
> 


-- 
 Mark Shifman MD. Ph.D.
 Yale Center for Medical Informatics
 Phone (203)737-5219
 mark.shifman@yale.edu

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org