Example usage for org.apache.commons.vfs2.impl StandardFileSystemManager setClassLoader

List of usage examples for org.apache.commons.vfs2.impl StandardFileSystemManager setClassLoader

Introduction

In this page you can find the example usage for org.apache.commons.vfs2.impl StandardFileSystemManager setClassLoader.

Prototype

public void setClassLoader(final ClassLoader classLoader) 

Source Link

Document

Sets the ClassLoader to use to load the providers.

Usage

From source file:com.mirth.connect.util.VfsUtils.java

/**
 * This method is a replacement for VFS.getManager() and provides a workaround for an existing
 * bug in Commons VFS 2.0 (https://issues.apache.org/jira/browse/VFS-228). The
 * ClassNotFoundException described in apache's jira issue occurs in the CLI (works fine in the
 * administrator)./*  www.  j ava2  s  .  c o m*/
 * 
 * If/when the issue gets resolved in a future version of Commons VFS, then we can revert to
 * using VFS.getManager().
 */
public static FileSystemManager getManager() throws FileSystemException {
    if (fileSystemManager == null) {
        StandardFileSystemManager stdFileSystemManager = new StandardFileSystemManager();
        stdFileSystemManager.setClassLoader(VfsUtils.class.getClassLoader());
        stdFileSystemManager.init();
        fileSystemManager = stdFileSystemManager;
    }

    return fileSystemManager;
}

From source file:fr.cls.atoll.motu.processor.wps.TestVFS.java

public static void testBugDoReplicateFile() {

    StandardFileSystemManager standardFileSystemManager = new StandardFileSystemManager();
    standardFileSystemManager.setLogger(LogFactory.getLog(VFS.class));
    standardFileSystemManager.setClassLoader(TestVFS.class.getClassLoader());
    try {/* www.  j a v  a2  s .  c  o m*/
        URL configUrl = new URL(
                "file:/J:/dev/atoll-v2/atoll-motu/atoll-motu-library/src/main/resources/motuVFSProvider.xml");
        standardFileSystemManager.setConfiguration(configUrl);
        standardFileSystemManager.setCacheStrategy(CacheStrategy.ON_CALL);
        standardFileSystemManager.init();

        String uri = "jar:file:/C:/Documents%20and%20Settings/dearith/.m2/repository/org/jvnet/ogc/iso-19139-d_2006_05_04-schema/1.0.0-PATCH-CLS/iso-19139-d_2006_05_04-schema-1.0.0-PATCH-CLS.jar!/schema/iso19139";
        FileSystemOptions opts = new FileSystemOptions();

        FileObject fileObject = standardFileSystemManager.resolveFile(uri, opts);

    } catch (FileSystemException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

}