Is there a way to check before adding module to JBoss using CLI?

若如初见. 提交于 2019-12-21 12:58:35

问题


Is there a way to check module hasn't already been added before calling adding using JBoss CLI?

e.g.

module add --name=org.mysql --resources=/home/abc/drivers/mysql/MySQL5.jar



# Want to do similar check for module add
if (outcome != success) of /subsystem=datasources/jdbc-driver=org.mysql:read-resource
   # Add it...
end-if

Reason is trying to add a module that already exists causes an error.


回答1:


When in domain mode, you can do that.

Here's how you can check a module's existence:

if (outcome != success) of /host=master/core-service=module-loading/:list-resource-loader-paths(module=your.module.name)
    echo install your.module.name ...   
    module add --name=your.module.name --dependencies=.. --resources=....jar
else 
    echo module your.module.name already installed
end-if



回答2:


There are only two options "add" and "remove". They fail when they are set in an "if" statement, so as far as I know the existence of the module cannot be checked. If the module does exist and "add" is executed it fails, the same happens if we try to remove a non-existing module. So finally I have created two scripts, one to add the modules and another one to delete them. You can check the "module" command documentation here: cli command to add/remove AS modules



来源:https://stackoverflow.com/questions/22477353/is-there-a-way-to-check-before-adding-module-to-jboss-using-cli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!