[jboss-jira] [JBoss JIRA] (WFCORE-3686) Allow Nashorn Shell (jjs) in sun.scripting module

Sean Flanigan (JIRA) issues at jboss.org
Thu Mar 15 04:07:00 EDT 2018


Sean Flanigan created WFCORE-3686:
-------------------------------------

             Summary: Allow Nashorn Shell (jjs) in sun.scripting module
                 Key: WFCORE-3686
                 URL: https://issues.jboss.org/browse/WFCORE-3686
             Project: WildFly Core
          Issue Type: Enhancement
          Components: Modules
            Reporter: Sean Flanigan
            Assignee: David Lloyd


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:

{code:bash}
# 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
{code}

{code:javascript}
// configureAppServer.js
var cli = org.jboss.as.cli.scriptsupport.CLI.newInstance()
cli.cmd("embed-server --std-out=echo")
cli.cmd("stop-embedded-server")
{code}

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.



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the jboss-jira mailing list