简体   繁体   中英

How to add a module programmatically in Wildfly?

In Wildfly-CLI jboss-cli.sh it is possible to add a module like this

module add --name=org.postgres
           --resources=postgresql-42.2.5.jar
           --dependencies=javax.api,javax.transaction.api

This adds the file postgresql-42.2.5.jar and creates module.xml with the following structure in /modules/org/postgres/main :

<?xml version='1.0' encoding='UTF-8'?>
<module xmlns="urn:jboss:module:1.1" name="org.postgres">
    <resources>
        <resource-root path="postgresql-42.5.1.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>

How can this be done programmatically with ModelControllerClient (available in org.wildfly.core:wildfly-controller-client:19.0.1.Final )?

ModelControllerClient client = ModelControllerClient.Factory.create(InetAddress.getByName("localhost"), 9990);

It cannot be done with the ModelControllerClient . The module command is a high level CLI command and not what is referred to as an operation.

You could launch a CLI process and send the command. The other option would be to copy the JAR and create the module.xml programmatically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM