1 22 package org.jboss.kernel.plugins.bootstrap.standalone; 23 24 import java.net.URL ; 25 import java.util.Enumeration ; 26 27 import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap; 28 import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer; 29 30 37 public class StandaloneBootstrap extends BasicBootstrap 38 { 39 40 protected BasicXMLDeployer deployer; 41 42 43 protected String [] args; 44 45 51 public static void main(String [] args) throws Exception 52 { 53 StandaloneBootstrap bootstrap = new StandaloneBootstrap(args); 54 bootstrap.run(); 55 } 56 57 63 public StandaloneBootstrap(String [] args) throws Exception 64 { 65 super(); 66 this.args = args; 67 } 68 69 public void bootstrap() throws Throwable 70 { 71 super.bootstrap(); 72 73 deployer = new BasicXMLDeployer(getKernel()); 74 75 Runtime.getRuntime().addShutdownHook(new Shutdown ()); 76 77 ClassLoader cl = Thread.currentThread().getContextClassLoader(); 78 for (Enumeration e = cl.getResources(StandaloneKernelConstants.DEPLOYMENT_XML_NAME); e.hasMoreElements(); ) 79 { 80 URL url = (URL ) e.nextElement(); 81 deploy(url); 82 } 83 for (Enumeration e = cl.getResources("META-INF/" + StandaloneKernelConstants.DEPLOYMENT_XML_NAME); e.hasMoreElements(); ) 84 { 85 URL url = (URL ) e.nextElement(); 86 deploy(url); 87 } 88 89 deployer.validate(); 91 } 92 93 99 protected void deploy(URL url) throws Throwable 100 { 101 deployer.deploy(url); 102 } 103 104 109 protected void undeploy(URL url) 110 { 111 try 112 { 113 deployer.undeploy(url); 114 } 115 catch (Throwable t) 116 { 117 log.warn("Error during undeployment: " + url, t); 118 } 119 } 120 121 protected class Shutdown extends Thread 122 { 123 public void run() 124 { 125 log.info("Shutting down"); 126 deployer.shutdown(); 127 } 128 } 129 } 130 | Popular Tags |