This content has been marked as final.
Show 2 replies
-
1. Re: Add module via Management API in AS 7.2
jaysensharma Mar 20, 2013 6:11 PM (in response to andrewwinter77)1 of 1 people found this helpfulHi,
No, I do not think Creation of Module is possible via Management API.
However you can use CLI based java API to achieve the same:
import java.io.IOException; import java.util.Map; import org.jboss.as.cli.CommandContext; import org.jboss.as.cli.CommandContextFactory; import org.jboss.as.cli.CommandLineException; public class ModuleAdd { public static void main(String[] args) throws CommandLineException, IOException { String host = "localhost"; int port = 9999; ModuleAdd moduleAdd=new ModuleAdd(); CommandContext ctx = CommandContextFactory.getInstance().newCommandContext("admin","admin123".toCharArray()); ctx.connectController(host, port); moduleAdd.createSecurityDoModuleAdd(ctx); ctx.disconnectController(); } public void createSecurityDoModuleAdd(CommandContext ctx) { System.out.println("Setting up the module with CLI"); try { String command="module add --name=aaa.bbb --resources=/NotBackedUp/DELETE/ojdbc6.jar --dependencies=javax.api,javax.transaction.api"; ctx.handle(command); } catch (CommandLineException e) { e.printStackTrace(); } finally { ctx.terminateSession(); } } }
For example when you open a Terminal and export JBOSS_HOME in the terminal and then when you run the above code you wil see a Module is added in JBoss AS7.1.3 or higher version of it as following:
AS7.1.3/modules
/aaa/
└── bbb
└── main
├── module.xml
└── ojdbc6.jar
module.xml as following:
=================
<?xml version="1.0" ?> <module xmlns="urn:jboss:module:1.1" name="aaa.bbb"> <resources> <resource-root path="ojdbc6.jar"/> </resources> <dependencies> <module name="javax.api"/> <module name="javax.transaction.api"/> </dependencies> </module>
-
2. Re: Add module via Management API in AS 7.2
andrewwinter77 Mar 21, 2013 6:04 AM (in response to jaysensharma)Thanks for the tip, Jay. Having to rely on the filesystem isn't ideal but it's a good-enough workaround for me for now.
Thanks!
Andrew.