Package com.avoka.core.groovy.runtime
Class GroovyScriptRuntime
java.lang.Object
com.avoka.core.groovy.runtime.GroovyScriptRuntime
Provides Groovy Script execution utility methods.
-
Constructor Summary
ConstructorDescriptionCreate a new GroovyScript runtime.GroovyScriptRuntime
(ClassLoader classLoader) Create a new GroovyScript runtime with the given class loader. -
Method Summary
Modifier and TypeMethodDescriptionexecuteScript
(String script, Map<String, Object> parameters) Execute the provided Groovy Script content, binding the given parameters and returning the result object.int
boolean
Return true if the runtime will capture the script output for running in shell mode.boolean
setBindable
(IBindable bindable) Set an bindable object to bind to the Groovy script object before it is invoked.setCaptureOutput
(boolean captureOutput) Specify whether the runtime should capture the script output for running in shell mode.setClassLoader
(ClassLoader classLoader) Set the GroovyScript class loader.setExecutionTimeout
(int timeout) Set the GroovyScript execution timeout in milliseconds, a value of 0 means the script will run indefinitely.setParseOnly
(boolean parseOnly) setSecureGroovyAPI
(boolean secureGroovyAPI) setSecurityContext
(String securityContext) Set the security context of the class loader.setThreadListener
(IGroovyThreadListener threadListener) validateScript
(String script) Validates the provided Groovy script, and return a validation error message if errors are found.
-
Constructor Details
-
GroovyScriptRuntime
public GroovyScriptRuntime()Create a new GroovyScript runtime.- Since:
- 17.10.0
-
GroovyScriptRuntime
Create a new GroovyScript runtime with the given class loader.- Parameters:
classLoader
- the script class loader- Since:
- 4.2.0
-
-
Method Details
-
executeScript
Execute the provided Groovy Script content, binding the given parameters and returning the result object.- Parameters:
script
- the Groovy script content to executeparameters
- the input parameter to bind into the script- Returns:
- the result the result from the executed Groovy script
-
validateScript
Validates the provided Groovy script, and return a validation error message if errors are found.- Parameters:
script
- the Groovy script (required)- Returns:
- null if the script validated successfully, an error message otherwise
-
setBindable
Set an bindable object to bind to the Groovy script object before it is invoked.- Parameters:
bindable
- the object to bind to the Groovy script object to be invoked (optional)- Returns:
- the groovy script runtime
- Since:
- 17.10.0
-
isCaptureOutput
public boolean isCaptureOutput()Return true if the runtime will capture the script output for running in shell mode.- Returns:
- true if the runtime will capture the script output for running in shell mode
- Since:
- 4.0.0
-
setCaptureOutput
Specify whether the runtime should capture the script output for running in shell mode.- Parameters:
captureOutput
- the captureOutput to set- Returns:
- the groovy script runtime
- Since:
- 4.0.0
-
setClassLoader
Set the GroovyScript class loader.- Parameters:
classLoader
- the groovy script class loader- Returns:
- the groovy script runtime
- Since:
- 17.10.0
-
setSecurityContext
Set the security context of the class loader.- Parameters:
securityContext
- the class loader security context- Returns:
- the groovy script runtime
- Since:
- 17.10.0
-
setExecutionTimeout
Set the GroovyScript execution timeout in milliseconds, a value of 0 means the script will run indefinitely.- Parameters:
timeout
- the GroovyScript execution timeout in milliseconds- Returns:
- the groovy script runtime
- Since:
- 4.2.0
-
getExcutionTimeout
public int getExcutionTimeout()- Returns:
- the GroovyScript execution timeout in milliseconds.
- Since:
- 4.2.0
-
isSecureGroovyAPI
public boolean isSecureGroovyAPI()- Returns:
- true if using the Secure Groovy API
- Since:
- 5.0.0
-
setSecureGroovyAPI
- Parameters:
secureGroovyAPI
- the secureGroovyAPI to set- Returns:
- the groovy script runtime
- Since:
- 5.0.0
-
setThreadListener
- Parameters:
threadListener
- the thread listener to set- Returns:
- the groovy script runtime
- Since:
- 18.5.0
-
setParseOnly
- Parameters:
parseOnly
- the parseOnly flat to specify only to parse the script and not execute it- Returns:
- the groovy script runtime
- Since:
- 5.0.0
-