org.jboss.embedded
Class DeploymentGroup

java.lang.Object
  extended by org.jboss.embedded.DeploymentGroup
Direct Known Subclasses:
DeploymentScanner

public class DeploymentGroup
extends java.lang.Object

comment

Version:
$Revision: 1.1 $
Author:
Bill Burke, adrian@jboss.org

Field Summary
protected  org.jboss.kernel.Kernel kernel
           
protected  org.jboss.deployers.client.spi.main.MainDeployer mainDeployer
           
 
Constructor Summary
DeploymentGroup()
           
 
Method Summary
 void add(java.net.URL url)
          schedules a URL to be deployed
 void add(VirtualFile vf)
          Schedule a VirtualFile to be deployed
protected  void addBaseResource(java.net.URL url, java.lang.String baseResource)
           
 void addClasspath()
          Scan all paths/jars in Java CLasspath (found with java.class.path System Property) schedule these jars to be deployed
 void addClasspath(java.lang.String paths)
          Scan Java Classpath (found with java.class.path) for a specified list of files you want to deploy The files listed should be only the filename.
 void addDirectory(java.net.URL directory, boolean recurse)
           
 void addDirectoryByResource(java.lang.String resource, boolean recurse)
          Searches for a directory as described in the getDirFromResource() method of this class.
 void addFileByResource(java.lang.String resource)
          Searches for a file based on the location of an existing classloader resource as described in the getDirFromResource() method of this class.
 void addMultipleResources(java.lang.String resource)
          Search for resources using the group's configured classloader if no classloader, then Thread.currentThread().getContextClassLoader() is used.
 void addResource(java.lang.String resource)
          Search for the resource using the group's configured classloader if no classloader, then Thread.currentThread().getContextClassLoader() is used.
 void addResourceBase(java.lang.Class baseResource)
          Find the .class file resource of provided class Return a URL pointing to the classpath the resource is located in.
 void addResourceBase(java.lang.String baseResource)
          Deploy the classpath directory or .jar file a classloader resource is located in.
 void addResourceBases(java.lang.String baseResource)
          Deploy the classpath directories or .jar files a classloader resource is located in.
 void addUrls(java.util.List<java.net.URL> urls)
          schedules a list of urls to be deployed
 void addVirtualFiles(java.util.List<VirtualFile> vfs)
          schedules a list of virtual files to be deployed
static java.util.List<java.net.URL> getClassPaths()
           
static java.util.List<java.net.URL> getClassPaths(java.lang.String paths)
           
static java.util.List<VirtualFile> getDeployerDirUrls(VirtualFileFilter filter, java.net.URL url, boolean recurse)
           
static java.util.List<VirtualFile> getDeployerDirUrlsFromResource(VirtualFileFilter filter, java.lang.ClassLoader loader, java.lang.String resource, boolean recurse)
           
 java.util.List<org.jboss.deployers.vfs.spi.client.VFSDeployment> getDeployments()
           
 java.util.List<org.jboss.deployers.structure.spi.DeploymentUnit> getDeploymentUnits()
          Get the deployment units
static java.net.URL getDirFromResource(java.lang.ClassLoader loader, java.lang.String resource)
          Find the directory that contains a given resource.
static VirtualFile getVirtualFile(java.net.URL url)
           
 void process()
          Ask the mainDeployer to process the set of files you added to the group this will also check the processing
 void setClassLoader(java.lang.ClassLoader classLoader)
           
 void setFilter(VirtualFileFilter filter)
          File filter that will be used when scanning a directory
 void setKernel(org.jboss.kernel.Kernel kernel)
           
 void setMainDeployer(org.jboss.deployers.client.spi.main.MainDeployer mainDeployer)
           
 void undeploy()
          Ask the mainDeployer to undeploy the set of files in the group
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mainDeployer

protected org.jboss.deployers.client.spi.main.MainDeployer mainDeployer

kernel

protected org.jboss.kernel.Kernel kernel
Constructor Detail

DeploymentGroup

public DeploymentGroup()
Method Detail

setMainDeployer

public void setMainDeployer(org.jboss.deployers.client.spi.main.MainDeployer mainDeployer)

setKernel

public void setKernel(org.jboss.kernel.Kernel kernel)

setFilter

public void setFilter(VirtualFileFilter filter)
File filter that will be used when scanning a directory

Parameters:
filter -

setClassLoader

public void setClassLoader(java.lang.ClassLoader classLoader)

process

public void process()
             throws org.jboss.deployers.spi.DeploymentException
Ask the mainDeployer to process the set of files you added to the group this will also check the processing

Throws:
org.jboss.deployers.spi.DeploymentException

undeploy

public void undeploy()
              throws org.jboss.deployers.spi.DeploymentException
Ask the mainDeployer to undeploy the set of files in the group

Throws:
org.jboss.deployers.spi.DeploymentException

add

public void add(VirtualFile vf)
         throws org.jboss.deployers.spi.DeploymentException
Schedule a VirtualFile to be deployed

Parameters:
vf -
Throws:
org.jboss.deployers.spi.DeploymentException

add

public void add(java.net.URL url)
         throws org.jboss.deployers.spi.DeploymentException
schedules a URL to be deployed

Parameters:
url -
Throws:
org.jboss.deployers.spi.DeploymentException

getVirtualFile

public static VirtualFile getVirtualFile(java.net.URL url)
                                  throws org.jboss.deployers.spi.DeploymentException
Throws:
org.jboss.deployers.spi.DeploymentException

addVirtualFiles

public void addVirtualFiles(java.util.List<VirtualFile> vfs)
                     throws org.jboss.deployers.spi.DeploymentException
schedules a list of virtual files to be deployed

Parameters:
vfs -
Throws:
org.jboss.deployers.spi.DeploymentException

addUrls

public void addUrls(java.util.List<java.net.URL> urls)
             throws org.jboss.deployers.spi.DeploymentException
schedules a list of urls to be deployed

Parameters:
urls -
Throws:
org.jboss.deployers.spi.DeploymentException

addClasspath

public void addClasspath()
                  throws org.jboss.deployers.spi.DeploymentException
Scan all paths/jars in Java CLasspath (found with java.class.path System Property) schedule these jars to be deployed

Throws:
org.jboss.deployers.spi.DeploymentException

getClassPaths

public static java.util.List<java.net.URL> getClassPaths()
                                                  throws org.jboss.deployers.spi.DeploymentException
Throws:
org.jboss.deployers.spi.DeploymentException

addClasspath

public void addClasspath(java.lang.String paths)
                  throws org.jboss.deployers.spi.DeploymentException
Scan Java Classpath (found with java.class.path) for a specified list of files you want to deploy The files listed should be only the filename. Do not put relative or absolute paths in filenames. i.e. "myejbs.jar, my-beans.xml"

Parameters:
paths - comma delimited list of files
Throws:
org.jboss.deployers.spi.DeploymentException

getClassPaths

public static java.util.List<java.net.URL> getClassPaths(java.lang.String paths)
                                                  throws org.jboss.deployers.spi.DeploymentException
Throws:
org.jboss.deployers.spi.DeploymentException

addResource

public void addResource(java.lang.String resource)
                 throws org.jboss.deployers.spi.DeploymentException,
                        java.lang.NullPointerException
Search for the resource using the group's configured classloader if no classloader, then Thread.currentThread().getContextClassLoader() is used. classLoader.getResource(String resource) Schedule the resource to be deployed.

Parameters:
resource -
Throws:
org.jboss.deployers.spi.DeploymentException
java.lang.NullPointerException

addResourceBase

public void addResourceBase(java.lang.String baseResource)
                     throws org.jboss.deployers.spi.DeploymentException
Deploy the classpath directory or .jar file a classloader resource is located in. i.e. classpath is "/home/wburke/lib/tutorial.jar" tutorial.jar has "META-INF/persistence.xml" resource within it. addResourceBase("META-INF/persistence.xml") will try and deploy tutorial.jar

Parameters:
baseResource -
Throws:
org.jboss.deployers.spi.DeploymentException

addBaseResource

protected void addBaseResource(java.net.URL url,
                               java.lang.String baseResource)
                        throws org.jboss.deployers.spi.DeploymentException
Throws:
org.jboss.deployers.spi.DeploymentException

addResourceBases

public void addResourceBases(java.lang.String baseResource)
                      throws org.jboss.deployers.spi.DeploymentException
Deploy the classpath directories or .jar files a classloader resource is located in. ClassLoader.getResources() is used to find the base resources. i.e. classpath is "/home/wburke/lib/tutorial.jar:/home/wburke/lib/pu.jar" tutorial.jar and pu.jar has "META-INF/persistence.xml" resource within it. addResourceBases("META-INF/persistence.xml") will try and deploy tutorial.jar and pu.jar because the both have the META-INF/persistence.xml resource within them.

Parameters:
baseResource -
Throws:
org.jboss.deployers.spi.DeploymentException

addResourceBase

public void addResourceBase(java.lang.Class baseResource)
                     throws org.jboss.deployers.spi.DeploymentException
Find the .class file resource of provided class Return a URL pointing to the classpath the resource is located in. i.e. classpath is "/home/wburke/lib/tutorial.jar" tutorial.jar has "META-INF/persistence.xml" resource within it. addResourceBase("META-INF/persistence.xml") will try and deploy tutorial.jar

Parameters:
baseResource -
Throws:
org.jboss.deployers.spi.DeploymentException

addMultipleResources

public void addMultipleResources(java.lang.String resource)
                          throws org.jboss.deployers.spi.DeploymentException,
                                 java.io.IOException
Search for resources using the group's configured classloader if no classloader, then Thread.currentThread().getContextClassLoader() is used. classLoader.getResources(String resource) Schedule the resource to be deployed.

Parameters:
resource -
Throws:
org.jboss.deployers.spi.DeploymentException
java.io.IOException

addDirectoryByResource

public void addDirectoryByResource(java.lang.String resource,
                                   boolean recurse)
                            throws org.jboss.deployers.spi.DeploymentException,
                                   java.io.IOException
Searches for a directory as described in the getDirFromResource() method of this class. schedules all possible files in directory to be deployed

Parameters:
resource -
recurse - whether or not to recurse child directories
Throws:
org.jboss.deployers.spi.DeploymentException
java.io.IOException

addFileByResource

public void addFileByResource(java.lang.String resource)
                       throws org.jboss.deployers.spi.DeploymentException,
                              java.io.IOException
Searches for a file based on the location of an existing classloader resource as described in the getDirFromResource() method of this class. schedules this particular file for deployment

Parameters:
resource -
Throws:
org.jboss.deployers.spi.DeploymentException
java.io.IOException

addDirectory

public void addDirectory(java.net.URL directory,
                         boolean recurse)
                  throws org.jboss.deployers.spi.DeploymentException,
                         java.io.IOException
Throws:
org.jboss.deployers.spi.DeploymentException
java.io.IOException

getDeploymentUnits

public java.util.List<org.jboss.deployers.structure.spi.DeploymentUnit> getDeploymentUnits()
Get the deployment units

Returns:
the deployment units
Throws:
java.lang.IllegalStateException - when the units cannot be located

getDeployments

public java.util.List<org.jboss.deployers.vfs.spi.client.VFSDeployment> getDeployments()

getDeployerDirUrlsFromResource

public static java.util.List<VirtualFile> getDeployerDirUrlsFromResource(VirtualFileFilter filter,
                                                                         java.lang.ClassLoader loader,
                                                                         java.lang.String resource,
                                                                         boolean recurse)
                                                                  throws org.jboss.deployers.spi.DeploymentException,
                                                                         java.io.IOException
Throws:
org.jboss.deployers.spi.DeploymentException
java.io.IOException

getDeployerDirUrls

public static java.util.List<VirtualFile> getDeployerDirUrls(VirtualFileFilter filter,
                                                             java.net.URL url,
                                                             boolean recurse)
                                                      throws org.jboss.deployers.spi.DeploymentException,
                                                             java.io.IOException
Throws:
org.jboss.deployers.spi.DeploymentException
java.io.IOException

getDirFromResource

public static java.net.URL getDirFromResource(java.lang.ClassLoader loader,
                                              java.lang.String resource)
Find the directory that contains a given resource.

The '.' character can be used to specify the current directory. The '..' string can be used to specify a higher relative path

i.e.

getDirFromResource(loader, "org/jboss/Test.class") file://org/jboss/

getDirFromResource(loader, "org/jboss/Test.class/..") file://org/

getDirFromResource(loader, "org/jboss/Test.class/../acme") file://org/acme/

getDirFromResource(loader, "org/jboss/Test.class/./embedded") file://org/jboss/embedded/

Parameters:
loader -
resource -
Returns:
the url