问题
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