日期:2014-05-16 浏览次数:20992 次
public static synchronized FileSystemManager getManager() throws FileSystemException { if (instance == null) { instance = createManager("org.apache.commons.vfs.impl.StandardFileSystemManager"); } return instance; }
private static FileSystemManager createManager(final String managerClassName) throws FileSystemException { try { // Create instance final Class mgrClass = Class.forName(managerClassName); final FileSystemManager mgr = (FileSystemManager) mgrClass.newInstance(); /* try { // Set the logger final Method setLogMethod = mgrClass.getMethod("setLogger", new Class[]{Log.class}); final Log logger = LogFactory.getLog(VFS.class); setLogMethod.invoke(mgr, new Object[]{logger}); } catch (final NoSuchMethodException e) { // Ignore; don't set the logger } */ try { // Initialise final Method initMethod = mgrClass.getMethod("init", (Class[]) null); initMethod.invoke(mgr, (Object[]) null); } catch (final NoSuchMethodException e) { // Ignore; don't initialize } return mgr; } catch (final InvocationTargetException e) { throw new FileSystemException("vfs/create-manager.error", managerClassName, e.getTargetException()); } catch (final Exception e) { throw new FileSystemException("vfs/create-manager.error", managerClassName, e); } }
FileSystemManager fsm = VFS.getManager();