2 Replies Latest reply on Feb 27, 2008 6:18 AM by Gavin Ellis

    Deploying applications programmatically

    Gavin Ellis Newbie

      I am currently working on a j2ee application which will essentially act as a container for other sub-applications. The main application will provide an admin front end which allows an administrator to manage the lifecycle of each sub-application, and also provide a set of services the sub-application can utilise. A sub-application defines a set of handlers that are used by a remote client, so for each new remote-client that is created a new sub-application jar is required to be built and deployed through the main application.

      What I am looking to be able to do is manage the deployment lifecycle for each of these sub-application jars programmatically and currently investigating how this might be achieved through jboss. I have found some information on the Jboss deployer architecture but this seems to be quite sparse. Any pointers on how one might go about doing this or any links to relevant information would be greatly appreciated.

        • 1. Re: Deploying applications programmatically
          jaikiran pai Master

          There's a MBean named MainDeployer which you could use to deploy the applications programatically. Access you jmx-console (http://localhost:8080/jmx-console) and on that page look for service=MainDeployer under the jboss.system domain. If you click on that link you will be forwarded to a page which shows you all the available APIs (one of which is the deploy method) on this MBean. The JBossJMX FAQ at http://wiki.jboss.org/wiki/Wiki.jsp?page=FAQJBossJMX will help you in using the MBean programatically.

          • 2. Re: Deploying applications programmatically
            Gavin Ellis Newbie

            Thanks for your reply! Following your advice I have now successfully deployed a jar and custom archive using the MainDeployer and a custom deployer. For anyone interested here is a code snippet demonstrating looking up the MainDeployer mbean and using this to deploy an archive:

            
            ObjectName objectName = new ObjectName("jboss.system:service=MainDeployer");
            
            MBeanServer server = MBeanServerLocator.locateJBoss();
            
            MainDeployerMBean deployerMBean =
             (MainDeployerMBean)MBeanServerInvocationHandler.newProxyInstance(
             server,
             objectName,
             MainDeployerMBean.class,
             false);
            
            deployerMBean.deploy("file://C:/archives/myArchive.jar");