From: <jbo...@li...> - 2006-04-24 10:19:29
|
Author: arvinder Date: 2006-04-24 06:19:24 -0400 (Mon, 24 Apr 2006) New Revision: 3940 Modified: labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBKernel.java labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBKernelConstants.java Log: Added support for main() booting and added placeholders for adding gnu getopt Modified: labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBKernel.java =================================================================== --- labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBKernel.java 2006-04-24 09:29:52 UTC (rev 3939) +++ labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBKernel.java 2006-04-24 10:19:24 UTC (rev 3940) @@ -41,26 +41,51 @@ */ public class JBossESBKernel extends BasicBootstrap { - /** The deployer */ + /** The deployer */ protected BeanXMLDeployer deployer; - /** The core deployments, ideally we want to separate - * this into core & services */ + /** The core deployments, ideally we want to separate this into core & services */ protected List deployments = CollectionsFactory.createCopyOnWriteList(); /** The arguments */ protected String[] args; + /** Set system default configuration, this can be overridden from main arguments **/ + static + { + System.setProperty(JBossESBKernelConstants.ESB_CORE_CONFIGURATION_PROPERTY, JBossESBKernelConstants.ESB_CORE_CONFIGURATION_DEPLOYMENT); + System.setProperty(JBossESBKernelConstants.ESB_CORE_SERVICE_PROPERTY, JBossESBKernelConstants.ESB_SERVICE_CONFIGURATION_DEPLOYMENT); + } + + + /** - * Bootstrap the kernel from the command line + * Bootstrap the kernel from the command line, see the original jboss + * bootstrapper class org.jboss.Main * * @param args the command line arguments * @throws Exception for any error */ - public static void main(String[] args) throws Exception + public static void main(final String[] args) throws Exception { - JBossESBKernel bootstrap = new JBossESBKernel(args); - bootstrap.run(); + Runnable worker = new Runnable() + { + public void run() + { + try + { + JBossESBKernel bootstrap = new JBossESBKernel(args); + bootstrap.run (); + } + catch (Exception e) + { + System.err.println("Failed to boot JBossESBKernel"); + e.printStackTrace(); + } + } + }; + ThreadGroup threads = new ThreadGroup("jboss"); + new Thread(threads, worker, "main").start(); } /** @@ -81,27 +106,36 @@ public JBossESBKernel(String[] args) throws Exception { super(); + // unsure if we need to keep hold of the arguments. this.args = args; + processCommandLine(args); } /** + * Parse command line arguments using gnu getopt. + * @param args + * @throws Exception + */ + private void processCommandLine(final String[] args) throws Exception + { + // override default start properties + + } + + /** * Start the bootstrap process. * @throws Throwable */ public void bootstrap() throws Throwable { super.bootstrap(); - deployer = new BeanXMLDeployer(getKernel()); - Runtime.getRuntime().addShutdownHook(new Shutdown(this)); - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - // // Core // - for (Enumeration e = cl.getResources(JBossESBKernelConstants.ESB_CORE_CONFIGURATION_DEPLOYMENT); e.hasMoreElements(); ) + for (Enumeration e = cl.getResources(System.getProperty(JBossESBKernelConstants.ESB_CORE_CONFIGURATION_PROPERTY)); e.hasMoreElements(); ) { URL url = (URL) e.nextElement(); deploy(url); @@ -109,12 +143,11 @@ // // Core Services // - for (Enumeration e = cl.getResources(JBossESBKernelConstants.ESB_SERVICE_CONFIGURATION_DEPLOYMENT); e.hasMoreElements(); ) + for (Enumeration e = cl.getResources(System.getProperty(JBossESBKernelConstants.ESB_CORE_SERVICE_PROPERTY)); e.hasMoreElements(); ) { URL url = (URL) e.nextElement(); deploy(url); } - // Validate that everything is ok deployer.validate(); } @@ -131,7 +164,8 @@ { log.info("Deploying " + url); KernelDeployment deployment = deployer.deploy(url); - if(log.isTraceEnabled()) { + if(log.isTraceEnabled()) + { //log.trace("KernelDeployment:BeanFactories=" + deployment.getBeanFactories()); log.trace("KernelDeployment:Bean =" + deployment.getBeans()); log.trace("KernelDeployment:ClassLoader =" + deployment.getClassLoader()); @@ -143,7 +177,7 @@ } /** - * Undeploy a deployment + * Undeploy a running artifact/deployment. * * @param deployment the deployment */ @@ -165,7 +199,8 @@ /** * Utility method used to undeploy and shutdown the kernel. */ - protected void shutdown() { + protected void shutdown() + { log.info("Shutting down"); // We should actually shut down services first so first deregister // them from the registry and then shutdown core services like the Modified: labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBKernelConstants.java =================================================================== --- labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBKernelConstants.java 2006-04-24 09:29:52 UTC (rev 3939) +++ labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBKernelConstants.java 2006-04-24 10:19:24 UTC (rev 3940) @@ -27,6 +27,13 @@ */ public interface JBossESBKernelConstants { + + /** Define the system property key for core **/ + static final String ESB_CORE_CONFIGURATION_PROPERTY = "jboss.soa.esb.core"; + + /** Define the system property key for core **/ + static final String ESB_CORE_SERVICE_PROPERTY = "jboss.soa.esb.services"; + /** The core xml configuration file name */ static final String ESB_CORE_CONFIGURATION_DEPLOYMENT = "jboss-esb-core.xml"; |