Class RexxCompiledScript
- All Implemented Interfaces:
Invocable
javax.script.CompiledScript class and implements
the javax.script.Invocable interface as this only makes sense in this
class for getInterface(Class clasz). Therefore the author
(Rony G. Flatscher) who served on the JSR-223 specification committee) thinks that the documentation
in javax.script.Invocable is false, as it states that Invocable gets implemented by a
ScriptEngine, somehow indicating it has to operate on some "state" of the script engine.
Please note: the JSR-223 specification does not imply that ScriptEngine should implement this interface!
The [oo]Rexx implementation of JSR-223 tries to be as flexible as possible and also implements this interface in its implementation of
ScriptEngine sharing as much code between
the tow (and caching compiled scripts for invoking the aforementioned method in a sensible way.- Since:
- 2015-05-11
- Version:
- 100.20200128
- Author:
- Rony G. Flatscher
-
Method Summary
Modifier and TypeMethodDescriptioneval(ScriptContext sc) Evaluates (executes, runs) the Rexx program stored in thisRexxCompiledScriptobject.Getter for the Rexx edited script source code which got compiled (tokenized), it will have injected code, if any of the Rexx script annotations @GET, @GET("attribute list") or @SET("attribute list") was found inscriptSource.Returns theScriptEnginewhose compile method created this CompiledScript.Getter method to return the current value offilename.<T> TgetInterface(Class<T> clasz) Returns an implementation of a Java interface where the Java method invocations will be carried out by the public Rexx routines in the script.<T> TgetInterface(Object thiz, Class<T> clasz) Returns an implementation of a Java interface where the Java method invocations will be implemented by the methods of the supplied Rexx object (aRexxProxy.Getter for theRexxProxyrepresenting the Rexx routine object the script got compiled (tokenized) into.Getter to retrieve the RexxScriptEngine used to create this compiled script.Getter for theRexxProxyrepresenting the Rexx routine object the script got compiled (tokenized) to.Getter for the Rexx script source code.booleanGetter for the Rexx script which got compiled (tokenized).invokeFunction(String name, Object... args) Invokes (calls) a public Rexx routine defined in this compiled script.invokeMethod(Object thiz, String name, Object... args) Sends a Rexx message to the Rexx object contained in the addressedRexxProxyobject.voidsetSupplyBSFExceptionObject(boolean newValue) Setter for the Rexx script which got compiled (tokenized).Methods inherited from class javax.script.CompiledScript
eval, eval
-
Method Details
-
getRexxScriptEngine
Getter to retrieve the RexxScriptEngine used to create this compiled script.- Returns:
- the RexxScriptEngine that created this RexxCompiledScript object
-
getSupplyBSFExceptionObject
public boolean getSupplyBSFExceptionObject()Getter for the Rexx script which got compiled (tokenized).- Returns:
- the current value of
bSupplyBSFExceptionObject
-
setSupplyBSFExceptionObject
public void setSupplyBSFExceptionObject(boolean newValue) Setter for the Rexx script which got compiled (tokenized).- Parameters:
newValue- the value to be used for the fieldbSupplyBSFExceptionObject
-
getFilename
Getter method to return the current value offilename.- Returns:
- the current value of
filename
-
getScriptSource
Getter for the Rexx script source code. If there are no Rexx script annotations present, then this code got compiled (tokenized), else the edited code stored in the fieldeditedScriptSource. .- Returns:
- the string representing the Rexx script program
-
getEditedScriptSource
Getter for the Rexx edited script source code which got compiled (tokenized), it will have injected code, if any of the Rexx script annotations @GET, @GET("attribute list") or @SET("attribute list") was found inscriptSource. If this version exists, it got compiled instead ofscriptSource.- Returns:
- the string representing of the edited Rexx script program
-
getScriptObject
Getter for theRexxProxyrepresenting the Rexx routine object the script got compiled (tokenized) to.- Returns:
- a
RexxProxyrepresenting the Rexx routine object
-
getPackageObject
Getter for theRexxProxyrepresenting the Rexx routine object the script got compiled (tokenized) into.- Returns:
- a
RexxProxyrepresenting the Rexx package object of this compiled script
-
eval
Evaluates (executes, runs) the Rexx program stored in thisRexxCompiledScriptobject. Thescparameter will always be passed on to the Rexx routine by storing it in aRexxDirectoryunder the index"SCRIPTCONTEXT"and appending it as the last argument to the Rexx script. This way any Rexx routine is able to access and manipulate theScriptContext.- Specified by:
evalin classCompiledScript- Parameters:
sc- - AScriptContextobject, which will be supplied to the Rexx routine in aRexxDirectoryunder the index"SCRIPTCONTEXT", by appending it to the Rexx argument list. (Hint: one can always access this object from Rexx code with the statementscriptcontext=arg('A')~lastItem~scriptContext).)If this parameter contains a
ScriptEngine.ARGV(the String"javax.script.argv") entry (a JavaObjectarray), then these objects are used as arguments for the Rexx routine in the supplied order. Javanullvalues will be represented as ooRexx.nilvalues.
Note: If any argument is of typeRexxProxy, then the Rexx routine will receive the contained Rexx object instead.Note # 2: This method will append an additional Rexx directory object argument with an entry named
If this parameter contains a
ScriptEngine.FILENAME(the String"javax.script.filename") entry (a string), then this is used as the filename for the Rexx routine to execute and can be fetched from Rexx with the statementparse source . . thisFilename.- Returns:
- the object the Rexx routine returns. In the case that a Rexx object gets returned it will
be wrapped (boxed) in a
RexxProxy. Supplying aRexxProxyas an argument to a Rexx routine will cause the contained Rexx object to be used in Rexx instead.
Hint: one can interact with the contained Rexx object of aRexxProxyby sending it messages from Java using itssendMessagemethods. - Throws:
ScriptException
-
getEngine
Returns theScriptEnginewhose compile method created this CompiledScript.- Specified by:
getEnginein classCompiledScript
-
getInterface
Returns an implementation of a Java interface where the Java method invocations will be carried out by the public Rexx routines in the script. Therefore there must be a public Rexx routine defined for each Java interface method.Hint: when an interface method gets invoked, the Rexx routine gets all its arguments in the same order supplied to, plus an appended
RexxDirectory"slot directory" object, which contains information about this particular method invocation. This slot directory will also contain an entry, named"SCRIPTCONTEXT", which allows the Rexx routine to fully interact with theScriptContextused for its invocation.
(Hint: one can always access this object from Rexx code with the statementscriptcontext=arg('A')~lastItem~scriptContext).)- Specified by:
getInterfacein interfaceInvocable- Parameters:
clasz- - The Java interface class object<T>, whose methods are implemented as public Rexx routines.- Returns:
- a Java object of type
<T>
-
getInterface
Returns an implementation of a Java interface where the Java method invocations will be implemented by the methods of the supplied Rexx object (aRexxProxy.Note: Uses the implementation in
RexxScriptEngine.getInterface(Object thiz, Class clasz).Hint #1: the external
BSF4ooRexxexternal Rexx functionBSFCreateRexxProxy(...)is much more versatile and among other things allows for implementing multiple Java interface classes in a single Rexx class.Hint #2: when an interface method gets invoked, the Rexx method routine gets all its arguments in the same order supplied to, plus an appended
RexxDirectory"slot directory" object, which contains information about this particular method invocation. This slot directory will also contain an entry, named"SCRIPTCONTEXT", which allows the Rexx routine to fully interact with theScriptContextused for its invocation.
(Hint: one can always access this object from Rexx code with the statementscriptcontext=arg('A')~lastItem~scriptContext).)- Specified by:
getInterfacein interfaceInvocable- Parameters:
thiz- - The Java object (must be aRexxProxy) that implements the Java interface methodsclasz- - The Java interface class object<T>, whose methods are implemented in thethizobject- Returns:
- a Java object of type
<T>
-
invokeFunction
public Object invokeFunction(String name, Object... args) throws ScriptException, NoSuchMethodException Invokes (calls) a public Rexx routine defined in this compiled script.- Specified by:
invokeFunctionin interfaceInvocable- Parameters:
name- - The name of the public routine to invoke.args- - The arguments (a Java array of typeObject) for the routine.Note # 1: If any argument is of type
RexxProxy, then the Rexx routine will receive the contained Rexx object instead.Note # 2: This method will append an additional Rexx directory object argument with an entry named
"SCRIPTCONTEXT", which allows the Rexx routine to fully interact with theScriptContextused for its invocation.
(Hint: one can always access this object from Rexx code with the statementscriptcontext=arg('A')~lastItem~scriptContext).)- Returns:
- the object the Rexx routine returns. In the case that a Rexx object gets returned it will
be wrapped (boxed) in a
RexxProxy. Supplying aRexxProxyas an argument to a Rexx routine will cause the contained Rexx object to be used in Rexx instead.
Hint: one can interact with the contained Rexx object of aRexxProxyby sending it messages from Java using itssendMessagemethods or theinvokeMethod(Object thiz, String name, Object...args)method. - Throws:
ScriptExceptionNoSuchMethodException
-
invokeMethod
public Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException Sends a Rexx message to the Rexx object contained in the addressedRexxProxyobject.Note: Uses the implementation in
RexxScriptEngine.invokeMethod(Object thiz, String name, Object...args)where this method belongs to.- Specified by:
invokeMethodin interfaceInvocable- Parameters:
thiz- - The wrapped (as aRexxProxy) Rexx object to receive the messagename- - The Rexx message (method) name.args- - The arguments (a Java array of typeObject) for the Rexx method.Note # 1: If any argument is of type
RexxProxy, then the Rexx routine will receive the contained Rexx object instead.Note # 2: This method will append an additional Rexx directory object argument with an entry named
"SCRIPTCONTEXT", which allows the Rexx routine to fully interact with theScriptContextused for its invocation.
(Hint: one can always access this object from Rexx code with the statementscriptcontext=arg('A')~lastItem~scriptContext).)- Returns:
- the object the Rexx routine returns. In the case that a Rexx object gets returned it will
be wrapped (boxed) in a
RexxProxy. Supplying aRexxProxyas an argument to a Rexx routine will cause the contained Rexx object to be used in Rexx instead.
Hint: one can interact with the contained Rexx object of aRexxProxyby sending it messages from Java using itssendMessagemethods or theinvokeMethod(Object thiz, String name, Object...args)method. - Throws:
ScriptExceptionNoSuchMethodException
-