commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Shifman <mark.shif...@yale.edu>
Subject Re:[VFS]how to programmatically create an instance of DefaultFileSystemManager
Date Wed, 18 Feb 2009 13:30:34 GMT
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


Mime
View raw message