سؤال

The context is the following : I must write a javascript method that will be executed by a java application using Rhino. I cannot make any changes to the java application.

Then the question is: Would it be possible to ask Rhino to save "something" in its execution context and make it available to the javascript method for next executions of this javascript method ? and then, if yes, could this "something" be an instance of a class created on the fly by the javascript method because the java application does not contain any class that could fulfill my needs.

هل كانت مفيدة؟

المحلول

The short answer is no. Rhino doesn't have any global variables that you can use.

You will have to change the code of the Java application and add a new global variable to the execution context of Rhino. The Java code then needs to remember the value of the variable somewhere when the script is finished and put it again into the context when the scripts should run again.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top