2 Replies Latest reply on Dec 4, 2014 6:13 AM by Bing-Jin Lin

    module.xml and jboss-deployment-structure.xml marshalling unmarshlling api

    Bing-Jin Lin Newbie

      Hi,

       

        Does Jboss eap provde any programming interface to read and write module.xml and jboss-deployment-structure.xml?

       

      Thanks for any responses.

        • 1. Re: module.xml and jboss-deployment-structure.xml marshalling unmarshlling api
          Jay SenSharma Master

          I do not see an option to generate jboss-deployment-structure.xml using some programming interface,  However we can add a module using jboss-cli.sh script hsing "module add" command as following, Which will create the module structure and will generate the module.xml file as well:

           

          module add --name=xyz.org.mysql --resources=/PATH/TO/mysql-connector-java-5.1.13-bin.jar --dependencies=javax.api,javax.transaction.api
          
          

           

          The same command above command can also be executed using "org.jboss.as.cli.CommandContext" based java program as well as an alternative to programmetic approach

          import java.io.IOException;
          import org.jboss.as.cli.CommandContext;
          import org.jboss.as.cli.CommandContextFactory;
          import org.jboss.as.cli.CommandLineException;
          
          public class Main {
            public static void main(String[] args) throws CommandLineException, IOException {
              String host = "localhost";   // 10.10.10.10
              int port = 9990;
              String username="admin";
              char[] password="admin@123".toCharArray();
              CommandContext ctx=null;
              try {
                ctx = CommandContextFactory.getInstance().newCommandContext(username,password);
                ctx.connectController(host, port);
                String cliCommand="module add --name=xyz.org.mysql --resources=/PATH/TO/mysql-connector-java-5.1.13-bin.jar --dependencies=javax.api,javax.transaction.api";
                ctx.handle(cliCommand);   
                ctx.disconnectController();
               } catch (CommandLineException e) {
                 e.printStackTrace();
               } finally {
                 ctx.terminateSession();
               }         
            }
          }
          
          

           

          You can also try the jboss DMR  APIs