org.jboss.embedded
Class Bootstrap

java.lang.Object
  extended by org.jboss.embedded.Bootstrap
Direct Known Subclasses:
BinaryBootstrap

public class Bootstrap
extends java.lang.Object

Basic bootstrap class for embeddable JBoss

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

Field Summary
static java.lang.String BOOTSTRAP_RESOURCE_FILE
           
static java.lang.String BOOTSTRAP_RESOURCE_PATH
           
protected  boolean ignoreShutdownErrors
           
protected  org.jboss.kernel.Kernel kernel
           
protected  java.lang.ClassLoader loader
           
protected  org.jboss.deployers.client.spi.main.MainDeployer mainDeployer
           
protected  boolean started
           
 
Constructor Summary
Bootstrap()
           
Bootstrap(org.jboss.kernel.Kernel kernel)
           
 
Method Summary
 void bootstrap()
          Will obtain resource path from jboss.embedded.bootstrap.resource.path System Property.
 void bootstrap(java.lang.String bootstrapResourcePath)
          Specify top classpath resource directory where base JBoss Embedded directory structure is.
protected  void bootstrapURL(java.net.URL url)
           
 DeploymentGroup createDeploymentGroup()
           
protected static org.jboss.kernel.Kernel createKernel()
           
 void deploy(java.net.URL url)
           
 void deploy(VirtualFile file)
           
protected  void deployBaseBootstrapUrl(java.net.URL url)
           
 void deployDirectory(java.net.URL url, boolean recurse)
          Define a deploy directory and deploy all files within it.
 void deployDirectoryFromResource(java.lang.String resource, boolean recurse)
          Find a deploy directory from a base resource
 void deployResource(java.lang.String resource)
          Deploy a resource found by getResource() on the kernel's classloader
 void deployResourceBase(java.lang.Class baseResource)
          Find the .class resource of the given class Deploy a URL pointing to the classpath the resource is located in.
 void deployResourceBase(java.lang.String baseResource)
          Deploy the classpath directories or .jar files a classloader resource is located in.
 void deployResourceBases(java.lang.String baseResource)
           
static Bootstrap getInstance()
          For those applications that need a singelton Bootstrap instance
 org.jboss.kernel.Kernel getKernel()
           
 java.lang.ClassLoader getLoader()
           
 boolean isIgnoreShutdownErrors()
           
 boolean isStarted()
           
static void main(java.lang.String[] args)
           
 void scanClasspath(java.lang.String path)
          Look in java.class.path for any .jar or class directories whose base file/dir match any base file/dir names in the comma delimited path parameter If classpath is: /home/wburke/jars/foo.jar and path is: "foo.jar" This will be a match and that .jar file will be deployed
 void setIgnoreShutdownErrors(boolean ignoreShutdownErrors)
           
 void setKernel(org.jboss.kernel.Kernel kernel)
           
 void setLoader(java.lang.ClassLoader loader)
           
 void shutdown()
          Shutdown the kernel and all deployments
 void undeploy(java.net.URL url)
           
 void undeploy(VirtualFile vf)
           
 void undeployClasspath(java.lang.String path)
          Undeploy something deployed via scanSclasspath()
 void undeployDirectory(java.net.URL url, boolean recurse)
           
 void undeployDirectoryFromResource(java.lang.String resource, boolean recurse)
           
 void undeployResource(java.lang.String resource)
          opposite of deployResource
 void undeployResourceBase(java.lang.Class baseResource)
          opposite of deployResourceBase()
 void undeployResourceBase(java.lang.String baseResource)
          opposite of deployResourceBase()
 void undeployResourceBases(java.lang.String baseResource)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOOTSTRAP_RESOURCE_PATH

public static final java.lang.String BOOTSTRAP_RESOURCE_PATH
See Also:
Constant Field Values

BOOTSTRAP_RESOURCE_FILE

public static final java.lang.String BOOTSTRAP_RESOURCE_FILE
See Also:
Constant Field Values

kernel

protected org.jboss.kernel.Kernel kernel

loader

protected java.lang.ClassLoader loader

mainDeployer

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

started

protected boolean started

ignoreShutdownErrors

protected boolean ignoreShutdownErrors
Constructor Detail

Bootstrap

public Bootstrap()

Bootstrap

public Bootstrap(org.jboss.kernel.Kernel kernel)
Method Detail

getInstance

public static Bootstrap getInstance()
For those applications that need a singelton Bootstrap instance

Returns:
the bootstrap

isIgnoreShutdownErrors

public boolean isIgnoreShutdownErrors()

setIgnoreShutdownErrors

public void setIgnoreShutdownErrors(boolean ignoreShutdownErrors)

isStarted

public boolean isStarted()

getKernel

public org.jboss.kernel.Kernel getKernel()

setKernel

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

getLoader

public java.lang.ClassLoader getLoader()

setLoader

public void setLoader(java.lang.ClassLoader loader)

createKernel

protected static org.jboss.kernel.Kernel createKernel()

deployBaseBootstrapUrl

protected void deployBaseBootstrapUrl(java.net.URL url)
                               throws java.lang.Throwable
Throws:
java.lang.Throwable

bootstrapURL

protected void bootstrapURL(java.net.URL url)
                     throws org.jboss.deployers.spi.DeploymentException
Throws:
org.jboss.deployers.spi.DeploymentException

bootstrap

public void bootstrap(java.lang.String bootstrapResourcePath)
               throws org.jboss.deployers.spi.DeploymentException
Specify top classpath resource directory where base JBoss Embedded directory structure is. The Embedded JBoss directory structure is determined by extrapolating a directory from a base classpath resource. The absolute directory will be determined by doing classloader.getResource(bootstrapResourcePath + "conf/bootstrap-beans.xml")

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

bootstrap

public void bootstrap()
               throws org.jboss.deployers.spi.DeploymentException
Will obtain resource path from jboss.embedded.bootstrap.resource.path System Property. Otherwise it just invoked bootstrap(String bootstrapResourcePath) with ""

Throws:
org.jboss.deployers.spi.DeploymentException

shutdown

public void shutdown()
Shutdown the kernel and all deployments


scanClasspath

public void scanClasspath(java.lang.String path)
                   throws org.jboss.deployers.spi.DeploymentException
Look in java.class.path for any .jar or class directories whose base file/dir match any base file/dir names in the comma delimited path parameter If classpath is: /home/wburke/jars/foo.jar and path is: "foo.jar" This will be a match and that .jar file will be deployed

Parameters:
path - can be comma delimited
Throws:
org.jboss.deployers.spi.DeploymentException

undeployClasspath

public void undeployClasspath(java.lang.String path)
                       throws org.jboss.deployers.spi.DeploymentException
Undeploy something deployed via scanSclasspath()

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

deployResourceBase

public void deployResourceBase(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

deployResourceBases

public void deployResourceBases(java.lang.String baseResource)
                         throws org.jboss.deployers.spi.DeploymentException
Parameters:
baseResource -
Throws:
org.jboss.deployers.spi.DeploymentException

deployResourceBase

public void deployResourceBase(java.lang.Class baseResource)
                        throws org.jboss.deployers.spi.DeploymentException
Find the .class resource of the given class Deploy 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 classloader.getResource("META-INF/persistence.xml") is used to determine the base location

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

deploy

public void deploy(java.net.URL url)
            throws org.jboss.deployers.spi.DeploymentException
Throws:
org.jboss.deployers.spi.DeploymentException

deploy

public void deploy(VirtualFile file)
            throws org.jboss.deployers.spi.DeploymentException
Throws:
org.jboss.deployers.spi.DeploymentException

deployResource

public void deployResource(java.lang.String resource)
                    throws org.jboss.deployers.spi.DeploymentException
Deploy a resource found by getResource() on the kernel's classloader

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

deployDirectory

public void deployDirectory(java.net.URL url,
                            boolean recurse)
                     throws org.jboss.deployers.spi.DeploymentException,
                            java.io.IOException
Define a deploy directory and deploy all files within it. The recurse parameter tells whether to recurse into sub directories for deployments

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

deployDirectoryFromResource

public void deployDirectoryFromResource(java.lang.String resource,
                                        boolean recurse)
                                 throws org.jboss.deployers.spi.DeploymentException,
                                        java.io.IOException
Find a deploy directory from a base resource

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

undeployResourceBase

public void undeployResourceBase(java.lang.String baseResource)
                          throws org.jboss.deployers.spi.DeploymentException
opposite of deployResourceBase()

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

undeployResourceBases

public void undeployResourceBases(java.lang.String baseResource)
                           throws org.jboss.deployers.spi.DeploymentException
Throws:
org.jboss.deployers.spi.DeploymentException

undeployResourceBase

public void undeployResourceBase(java.lang.Class baseResource)
                          throws org.jboss.deployers.spi.DeploymentException
opposite of deployResourceBase()

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

undeployResource

public void undeployResource(java.lang.String resource)
                      throws org.jboss.deployers.spi.DeploymentException
opposite of deployResource

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

undeploy

public void undeploy(java.net.URL url)
              throws org.jboss.deployers.spi.DeploymentException
Throws:
org.jboss.deployers.spi.DeploymentException

undeploy

public void undeploy(VirtualFile vf)
              throws org.jboss.deployers.spi.DeploymentException
Throws:
org.jboss.deployers.spi.DeploymentException

undeployDirectory

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

undeployDirectoryFromResource

public void undeployDirectoryFromResource(java.lang.String resource,
                                          boolean recurse)
                                   throws org.jboss.deployers.spi.DeploymentException,
                                          java.io.IOException
Throws:
org.jboss.deployers.spi.DeploymentException
java.io.IOException

createDeploymentGroup

public DeploymentGroup createDeploymentGroup()

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception