Class GroovyEngineFactory
- java.lang.Object
-
- org.codehaus.groovy.jsr223.GroovyScriptEngineFactory
-
- org.forgerock.openam.scripting.factories.GroovyEngineFactory
-
- All Implemented Interfaces:
ScriptEngineFactory
public class GroovyEngineFactory extends org.codehaus.groovy.jsr223.GroovyScriptEngineFactoryThis factory overrides the default getScriptEngine implementation, and ensures that we use the AST Transformation Customizer to provide interruption checks at the beginning of closures, loops, etc. in the executed script. This allows us to monitor the thread running the script and trigger an interrupt if the script's allowed running time is up.
-
-
Constructor Summary
Constructors Constructor Description GroovyEngineFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ScriptEnginegetScriptEngine()Instantiates and returns an instance ofGroovyScriptEngineImplpassing in a newGroovyClassLoaderwith an AST transformation customizer that will ensure that interrupt checks are inserted into the compiled code (at the start of closures, loops, etc.).voidsetSandbox(org.kohsuke.groovy.sandbox.GroovyValueFilter sandbox)Sets the Groovy value filter to use for sandboxing scripts.
-
-
-
Method Detail
-
getScriptEngine
public ScriptEngine getScriptEngine()
Instantiates and returns an instance ofGroovyScriptEngineImplpassing in a newGroovyClassLoaderwith an AST transformation customizer that will ensure that interrupt checks are inserted into the compiled code (at the start of closures, loops, etc.). Scripts run through engines provided by this function will be interruptable.- Specified by:
getScriptEnginein interfaceScriptEngineFactory- Overrides:
getScriptEnginein classorg.codehaus.groovy.jsr223.GroovyScriptEngineFactory- Returns:
- an interruptable groovy script engine implementation.
-
setSandbox
public void setSandbox(org.kohsuke.groovy.sandbox.GroovyValueFilter sandbox)
Sets the Groovy value filter to use for sandboxing scripts. The filter is called every time an object is accessed by the script to verify that the access is allowed.- Parameters:
sandbox- the new sandbox to use.
-
-