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

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

Introduction

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

Prototype

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

Source Link

Document

Constructors a new VFSClassLoader for the given FileObjects.

Usage

From source file:org.nanocontainer.deployer.NanoContainerDeployer.java

/**
 * Deploys an application.//from w  ww  .  j a v a 2  s.c o  m
 *
 * @param applicationFolder the root applicationFolder of the application.
 * @param parentClassLoader the classloader that loads the application classes.
 * @param parentContainerRef reference to the parent container (can be used to lookup components form a parent container).
 * @return an ObjectReference holding a PicoContainer with the deployed components
 * @throws org.apache.commons.vfs.FileSystemException if the file structure was bad.
 * @throws org.nanocontainer.integrationkit.PicoCompositionException if the deployment failed for some reason.
 */
public ObjectReference deploy(FileObject applicationFolder, ClassLoader parentClassLoader,
        ObjectReference parentContainerRef) throws FileSystemException, ClassNotFoundException {
    ClassLoader applicationClassLoader = new VFSClassLoader(applicationFolder, fileSystemManager,
            parentClassLoader);

    FileObject deploymentScript = getDeploymentScript(applicationFolder);

    ObjectReference result = new SimpleReference();

    String extension = "." + deploymentScript.getName().getExtension();
    Reader scriptReader = new InputStreamReader(deploymentScript.getContent().getInputStream());
    String builderClassName = ScriptedContainerBuilderFactory.getBuilderClassName(extension);

    ScriptedContainerBuilderFactory scriptedContainerBuilderFactory = new ScriptedContainerBuilderFactory(
            scriptReader, builderClassName, applicationClassLoader);
    ContainerBuilder builder = scriptedContainerBuilderFactory.getContainerBuilder();
    builder.buildContainer(result, parentContainerRef, null, true);

    return result;
}