org.nanocontainer.deployer
Class NanoContainerDeployer

java.lang.Object
  extended byorg.nanocontainer.deployer.NanoContainerDeployer
All Implemented Interfaces:
Deployer

public class NanoContainerDeployer
extends java.lang.Object
implements Deployer

This class is capable of deploying an application from any kind of file system supported by Jakarta VFS. (Like local files, zip files etc.) - following the ScriptedContainerBuilderFactory scripting model. The root folder to deploy must have the following file structure:

 +-someapp/
   +-META-INF/
   | +-nanocontainer.[py|js|xml|bsh]
   +-com/
     +-blablah/
       +-Hip.class
       +-Hop.class
 
For those familiar with J2EE containers (or other containers for that matter), the META-INF/picocontainer script is the ScriptedContainerBuilderFactory composition script. It plays the same role as more classical "deployment descriptors", except that deploying via a full blown scripting language is a lot more powerful! A new class loader (which will be a child of parentClassLoader) will be created. This classloader will make the classes under the root folder available to the deployment script. IMPORTANT NOTE: The scripting engine (rhino, jython, groovy etc.) should be loaded by the same classLoader as the appliacation classes, i.e. the VFSClassLoader pointing to the app directory.
    +-------------------+
    | xxx               |  <-- parent app loader (must not contain classes from app builder classloader)
    +-------------------+
              |
    +-------------------+
    | someapp           | <-- app classloader (must not contain classes from app builder classloader)
    +-------------------+
              |
    +-------------------+
    | picocontainer     |
    | nanocontainer     |  <-- app builder classloader
    | rhino             |
    | jython            |
    | groovy            |
    +-------------------+
 
This means that these scripting engines should *not* be accessible by any of the app classloader, since this may prevent the scripting engine from seeing the classes loaded by the VFSClassLoader. In other words, the scripting engine classed may be loaded several times by different class loaders - once for each deployed application.

Author:
Aslak Hellesøy

Constructor Summary
NanoContainerDeployer()
          Default constructor that makes sensible defaults.
NanoContainerDeployer(org.apache.commons.vfs.FileSystemManager fileSystemManager)
          Constructs a nanocontainer deployer with the specified file system manager.
NanoContainerDeployer(org.apache.commons.vfs.FileSystemManager fileSystemManager, org.nanocontainer.script.ScriptBuilderResolver builderResolver)
          Constructs this object with both a VFS file system manager, and
NanoContainerDeployer(org.apache.commons.vfs.FileSystemManager fileSystemManager, java.lang.String baseFileName)
          Constructs a nanocontainer deployer with the specified file system manager and specifies a 'base name' for the configuration file that will be loaded.
 
Method Summary
 org.picocontainer.defaults.ObjectReference deploy(org.apache.commons.vfs.FileObject applicationFolder, java.lang.ClassLoader parentClassLoader, org.picocontainer.defaults.ObjectReference parentContainerRef)
          Deploys an application.
 org.picocontainer.defaults.ObjectReference deploy(org.apache.commons.vfs.FileObject applicationFolder, java.lang.ClassLoader parentClassLoader, org.picocontainer.defaults.ObjectReference parentContainerRef, java.lang.Object assemblyScope)
          Deploys some sort of application folder.
protected  org.apache.commons.vfs.FileObject getDeploymentScript(org.apache.commons.vfs.FileObject applicationFolder)
          Given the base application folder, return a file object that represents the nanocontainer configuration script.
 java.lang.String getFileBasename()
          Retrieve the file base name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NanoContainerDeployer

public NanoContainerDeployer()
                      throws org.apache.commons.vfs.FileSystemException
Default constructor that makes sensible defaults.

Throws:
org.apache.commons.vfs.FileSystemException

NanoContainerDeployer

public NanoContainerDeployer(org.apache.commons.vfs.FileSystemManager fileSystemManager)
Constructs a nanocontainer deployer with the specified file system manager.

Parameters:
fileSystemManager - A VFS FileSystemManager.

NanoContainerDeployer

public NanoContainerDeployer(org.apache.commons.vfs.FileSystemManager fileSystemManager,
                             org.nanocontainer.script.ScriptBuilderResolver builderResolver)
Constructs this object with both a VFS file system manager, and

Parameters:
fileSystemManager - FileSystemManager
builderResolver - ScriptBuilderResolver

NanoContainerDeployer

public NanoContainerDeployer(org.apache.commons.vfs.FileSystemManager fileSystemManager,
                             java.lang.String baseFileName)
Constructs a nanocontainer deployer with the specified file system manager and specifies a 'base name' for the configuration file that will be loaded.

Parameters:
fileSystemManager - A VFS FileSystemManager.
Method Detail

deploy

public org.picocontainer.defaults.ObjectReference deploy(org.apache.commons.vfs.FileObject applicationFolder,
                                                         java.lang.ClassLoader parentClassLoader,
                                                         org.picocontainer.defaults.ObjectReference parentContainerRef)
                                                  throws org.apache.commons.vfs.FileSystemException,
                                                         java.lang.ClassNotFoundException
Deploys an application.

Specified by:
deploy in interface Deployer
Parameters:
applicationFolder - the root applicationFolder of the application.
parentClassLoader - the classloader that loads the application classes.
parentContainerRef - reference to the parent container (can be used to lookup components form a parent container).
Returns:
an ObjectReference holding a PicoContainer with the deployed components
Throws:
org.apache.commons.vfs.FileSystemException - if the file structure was bad.
org.nanocontainer.integrationkit.PicoCompositionException - if the deployment failed for some reason.
java.lang.ClassNotFoundException - upon class instantiation error while running the composition script.

deploy

public org.picocontainer.defaults.ObjectReference deploy(org.apache.commons.vfs.FileObject applicationFolder,
                                                         java.lang.ClassLoader parentClassLoader,
                                                         org.picocontainer.defaults.ObjectReference parentContainerRef,
                                                         java.lang.Object assemblyScope)
                                                  throws org.apache.commons.vfs.FileSystemException,
                                                         java.lang.ClassNotFoundException
Description copied from interface: Deployer
Deploys some sort of application folder. As far as NanoContainer deployment goes, there is a null assembly scope associated with this method, and

Specified by:
deploy in interface Deployer
Parameters:
applicationFolder - FileObject the base class of the 'archive'. By archive, the format depends on the deployer instance, and it may even apply to things such remote URLs. Must use Apache VFS
parentClassLoader - The parent classloader to attach this container to.
parentContainerRef - ObjectReference the parent container object reference.
assemblyScope - the assembly scope to use. This can be any object desired, (null is allowed) and when coupled with things like NanoWAR, it allows conditional assembly of different components in the script.
Returns:
ObjectReference a new object reference that container the new container.
Throws:
java.lang.ClassNotFoundException - upon class instantiation error while running the composition script.
org.apache.commons.vfs.FileSystemException - upon VFS-based errors.

getDeploymentScript

protected org.apache.commons.vfs.FileObject getDeploymentScript(org.apache.commons.vfs.FileObject applicationFolder)
                                                         throws org.apache.commons.vfs.FileSystemException
Given the base application folder, return a file object that represents the nanocontainer configuration script.

Parameters:
applicationFolder - FileObject
Returns:
FileObject
Throws:
org.apache.commons.vfs.FileSystemException

getFileBasename

public java.lang.String getFileBasename()
Retrieve the file base name.

Returns:
String


Copyright © 2003-2007 Codehaus. All Rights Reserved.