| Method from org.jboss.embedded.Bootstrap Detail: |
public void bootstrap() throws DeploymentException {
String path = System.getProperty(BOOTSTRAP_RESOURCE_PATH, "");
bootstrap(path);
}
Will obtain resource path from jboss.embedded.bootstrap.resource.path System Property.
Otherwise it just invoked bootstrap(String bootstrapResourcePath) with "" |
public void bootstrap(String bootstrapResourcePath) throws DeploymentException {
if (bootstrapResourcePath == null)
{
bootstrapResourcePath = "";
}
else if (!bootstrapResourcePath.equals("") && !bootstrapResourcePath.endsWith("/"))
{
bootstrapResourcePath += "/";
}
System.setProperty(BOOTSTRAP_RESOURCE_PATH, bootstrapResourcePath);
bootstrapResourcePath += BOOTSTRAP_RESOURCE_FILE;
URL url = loader.getResource(bootstrapResourcePath);
if (url == null)
throw new DeploymentException("Unable to find bootstrap file: " + bootstrapResourcePath + " in classpath");
bootstrapURL(url);
}
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") |
protected void bootstrapURL(URL url) throws DeploymentException {
try
{
// ServerConfig has to be created and installed before boostrap as we may want to use
// system properties set up in ServerConfig
ServerConfig config = new ServerConfig();
AbstractBeanMetaData bmd = new AbstractBeanMetaData("ServerConfig", ServerConfig.class.getName());
kernel.getController().install(bmd, config);
deployBaseBootstrapUrl(url);
mainDeployer = (MainDeployer)kernel.getRegistry().getEntry("MainDeployer").getTarget();
}
catch (Throwable throwable)
{
throw new RuntimeException("Unable to bootstrap: ", throwable);
}
mainDeployer.checkComplete();
started = true;
}
|
public DeploymentGroup createDeploymentGroup() {
DeploymentGroup group = new DeploymentGroup();
group.setClassLoader(loader);
group.setMainDeployer(mainDeployer);
group.setKernel(kernel);
return group;
}
|
protected static Kernel createKernel() {
BasicBootstrap bootstrap1 = new BasicBootstrap();
bootstrap1.run();
return bootstrap1.getKernel();
}
|
public void deploy(URL url) throws DeploymentException {
DeploymentGroup group = createDeploymentGroup();
group.add(url);
group.process();
}
|
public void deploy(VirtualFile file) throws DeploymentException {
DeploymentGroup group = createDeploymentGroup();
group.add(file);
group.process();
}
|
protected void deployBaseBootstrapUrl(URL url) throws Throwable {
BeanXMLDeployer deployer = new BeanXMLDeployer(kernel);
deployer.deploy(url);
}
|
public void deployDirectory(URL url,
boolean recurse) throws DeploymentException, IOException {
DeploymentGroup group = createDeploymentGroup();
group.addDirectory(url, recurse);
group.process();
}
Define a deploy directory and deploy all files within it. The recurse parameter tells whether to recurse into
sub directories for deployments |
public void deployDirectoryFromResource(String resource,
boolean recurse) throws DeploymentException, IOException {
DeploymentGroup group = createDeploymentGroup();
group.addDirectoryByResource(resource, recurse);
group.process();
}
Find a deploy directory from a base resource |
public void deployResource(String resource) throws DeploymentException {
DeploymentGroup group = createDeploymentGroup();
group.addResource(resource);
group.process();
}
Deploy a resource found by getResource() on the kernel's classloader |
public void deployResourceBase(String baseResource) throws DeploymentException {
DeploymentGroup group = createDeploymentGroup();
group.addResourceBase(baseResource);
group.process();
}
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. |
public void deployResourceBase(Class baseResource) throws DeploymentException {
DeploymentGroup group = createDeploymentGroup();
group.addResourceBase(baseResource);
group.process();
}
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 |
public void deployResourceBases(String baseResource) throws DeploymentException {
DeploymentGroup group = createDeploymentGroup();
group.addResourceBases(baseResource);
group.process();
}
|
public static synchronized Bootstrap getInstance() {
if (instance == null)
instance = new Bootstrap(createKernel());
return instance;
}
For those applications that need a singelton Bootstrap instance |
public Kernel getKernel() {
return kernel;
}
|
public ClassLoader getLoader() {
return loader;
}
|
public boolean isIgnoreShutdownErrors() {
return ignoreShutdownErrors;
}
|
public boolean isStarted() {
return started;
}
|
public static void main(String[] args) throws Exception {
getInstance().bootstrap();
for (String arg : args)
{
getInstance().scanClasspath(arg);
}
System.out.println("Running...");
Thread t = new Thread();
t.setDaemon(false);
t.start();
}
|
public void scanClasspath(String path) throws DeploymentException {
DeploymentGroup group = createDeploymentGroup();
group.addClasspath(path);
group.process();
}
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 |
public void setIgnoreShutdownErrors(boolean ignoreShutdownErrors) {
this.ignoreShutdownErrors = ignoreShutdownErrors;
}
|
public void setKernel(Kernel kernel) {
this.kernel = kernel;
}
|
public void setLoader(ClassLoader loader) {
this.loader = loader;
}
|
public void shutdown() {
try
{
mainDeployer.shutdown();
}
catch (Exception e)
{
if (!ignoreShutdownErrors)
throw new RuntimeException(e);
else
log.error("Failed to shutdown Bootstrap", e);
}
}
Shutdown the kernel and all deployments |
public void undeploy(URL url) throws DeploymentException {
VirtualFile vf = DeploymentGroup.getVirtualFile(url);
undeploy(vf);
}
|
public void undeploy(VirtualFile vf) throws DeploymentException {
mainDeployer.removeDeployment(vf.getName());
mainDeployer.process();
}
|
public void undeployClasspath(String path) throws DeploymentException {
List< URL > paths = DeploymentGroup.getClassPaths(path);
for (URL url : paths)
{
undeploy(url);
}
}
Undeploy something deployed via scanSclasspath() |
public void undeployDirectory(URL url,
boolean recurse) throws DeploymentException, IOException {
List< VirtualFile > files = DeploymentGroup.getDeployerDirUrls(null, url, recurse);
for (VirtualFile vf : files)
mainDeployer.removeDeployment(vf.getName());
mainDeployer.process();
}
|
public void undeployDirectoryFromResource(String resource,
boolean recurse) throws DeploymentException, IOException {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (loader != null) classLoader = loader;
List< VirtualFile > files = DeploymentGroup.getDeployerDirUrlsFromResource(null, classLoader, resource, recurse);
for (VirtualFile vf : files)
mainDeployer.removeDeployment(vf.getName());
mainDeployer.process();
}
|
public void undeployResource(String resource) throws DeploymentException {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (loader != null)
classLoader = loader;
URL url = classLoader.getResource(resource);
if (url == null)
throw new NullPointerException("Resource was null: " + resource);
undeploy(url);
}
opposite of deployResource |
public void undeployResourceBase(String baseResource) throws DeploymentException {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (loader != null)
classLoader = loader;
URL url = classLoader.getResource(baseResource);
if (url == null)
throw new RuntimeException("Could not find baseResource: " + baseResource);
undeployResourceBase(url, baseResource);
}
opposite of deployResourceBase() |
public void undeployResourceBase(Class baseResource) throws DeploymentException {
String resource = baseResource.getName().replace('.", '/") + ".class";
undeployResourceBase(resource);
}
opposite of deployResourceBase() |
public void undeployResourceBases(String baseResource) throws DeploymentException {
try
{
Enumeration< URL > urls = loader.getResources(baseResource);
while (urls.hasMoreElements())
{
URL url = urls.nextElement();
undeployResourceBase(url, baseResource);
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
|