Example usage for org.apache.commons.vfs2.impl VFSClassLoader VFSClassLoader

List of usage examples for org.apache.commons.vfs2.impl VFSClassLoader VFSClassLoader

Introduction

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

Prototype

public VFSClassLoader(final FileObject[] files, final FileSystemManager manager) throws FileSystemException 

Source Link

Document

Constructors a new VFSClassLoader for the given files.

Usage

From source file:org.apache.accumulo.start.classloader.vfs.ContextManagerTest.java

@Test
public void testPostDelegation() throws Exception {
    final VFSClassLoader parent = new VFSClassLoader(new FileObject[] { vfs.resolveFile(uri1) }, vfs);

    Class<?> pclass = parent.loadClass("test.HelloWorld");

    ContextManager cm = new ContextManager(vfs, new ReloadingClassLoader() {
        @Override/*from ww w  .ja  va 2 s .  c o m*/
        public ClassLoader getClassLoader() {
            return parent;
        }
    });

    cm.setContextConfig(new ContextsConfig() {
        @Override
        public ContextConfig getContextConfig(String context) {
            if (context.equals("CX1")) {
                return new ContextConfig(uri2.toString(), true);
            } else if (context.equals("CX2")) {
                return new ContextConfig(uri2.toString(), false);
            }
            return null;
        }
    });

    Assert.assertTrue(cm.getClassLoader("CX1").loadClass("test.HelloWorld") == pclass);
    Assert.assertFalse(cm.getClassLoader("CX2").loadClass("test.HelloWorld") == pclass);
}

From source file:org.apache.accumulo.start.classloader.vfs.providers.VfsClassLoaderTest.java

@Before
public void setup() throws Exception {

    this.hdfs = cluster.getFileSystem();
    this.hdfs.mkdirs(TEST_DIR);

    // Copy jar file to TEST_DIR
    URL jarPath = this.getClass().getResource("/HelloWorld.jar");
    Path src = new Path(jarPath.toURI().toString());
    Path dst = new Path(TEST_DIR, src.getName());
    this.hdfs.copyFromLocalFile(src, dst);

    FileObject testDir = vfs.resolveFile(TEST_DIR.toUri().toString());
    FileObject[] dirContents = testDir.getChildren();

    // Point the VFSClassLoader to all of the objects in TEST_DIR
    this.cl = new VFSClassLoader(dirContents, vfs);
}