-
Enhancement
-
Resolution: Done
-
Major
-
None
-
None
I would like to access JBoss CLI from a Nashorn jjs script (similar to https://developer.jboss.org/wiki/AdvancedCLIScriptingWithGroovyRhinoJythonEtc), so that I can use conditionals, error recovery, functions, etc.
To get the exactly correct version of the CLI jar, I want to get it from JBOSS_HOME as a module, which means I need to run jjs in a module environment, which I can do with a command like this:
# jjs-module.sh JBOSS_HOME=$HOME/apps/wildfly-11.0.0.Final export JBOSS_HOME java \ -Djava.util.logging.manager=org.jboss.logmanager.LogManager \ -jar $JBOSS_HOME/jboss-modules.jar \ -modulepath $JBOSS_HOME/modules \ -dependencies org.jboss.as.cli,org.jboss.logmanager,sun.scripting \ -class jdk.nashorn.tools.Shell \ -scripting \ -strict \ configureAppServer.js
// configureAppServer.js var cli = org.jboss.as.cli.scriptsupport.CLI.newInstance() cli.cmd("embed-server --std-out=echo") cli.cmd("stop-embedded-server")
Note: I had to test with WildFly 11 because of MODULES-271 (or similar)
However, the script above currently doesn't work because the package jdk.nashorn.tools is not visible in the sun.scripting module. Given that several jdk.nashorn.internal.* packages are included, it doesn't seem like much of a stretch to include jdk.nashorn.tools too.