Package org.forgerock.openig.script
Class Script
- java.lang.Object
-
- org.forgerock.openig.script.Script
-
public final class Script extends Object
A compiled script.
-
-
Field Summary
Fields Modifier and Type Field Description static StringGROOVY_MIME_TYPEThe mime-type for Groovy scripts.static StringJS_MIME_TYPEThe mime-type for Javascript scripts.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ScriptfromFile(Environment environment, String mimeType, String file)Loads a script having the provided content type and file name.static ScriptfromSource(Environment environment, String mimeType, String source)Loads a script having the provided content type and content.static ScriptfromSource(Environment environment, String mimeType, String... sourceLines)Loads a script having the provided content type and content.Objectrun(Map<String,Object> bindings)Runs this script using the provided named variable bindings.
-
-
-
Field Detail
-
GROOVY_MIME_TYPE
public static final String GROOVY_MIME_TYPE
The mime-type for Groovy scripts.- See Also:
- Constant Field Values
-
JS_MIME_TYPE
public static final String JS_MIME_TYPE
The mime-type for Javascript scripts.- See Also:
- Constant Field Values
-
-
Method Detail
-
fromFile
public static Script fromFile(Environment environment, String mimeType, String file) throws ScriptException
Loads a script having the provided content type and file name.- Parameters:
environment- The application environment.mimeType- The script language mime-type.file- The location of the script to be loaded.- Returns:
- The script.
- Throws:
ScriptException- If the script could not be loaded.
-
fromSource
public static Script fromSource(Environment environment, String mimeType, String... sourceLines) throws ScriptException
Loads a script having the provided content type and content.- Parameters:
environment- The application environment.mimeType- The script language mime-type.sourceLines- The script content.- Returns:
- The script.
- Throws:
ScriptException- If the script could not be loaded.
-
fromSource
public static Script fromSource(Environment environment, String mimeType, String source) throws ScriptException
Loads a script having the provided content type and content.- Parameters:
environment- The application environment.mimeType- The script language mime-type.source- The script content.- Returns:
- The script.
- Throws:
ScriptException- If the script could not be loaded.
-
run
public Object run(Map<String,Object> bindings) throws ScriptException
Runs this script using the provided named variable bindings.- Parameters:
bindings- The set of bindings to inject into the script.- Returns:
- The result returned by the script.
- Throws:
ScriptException- If the script failed to execute.
-
-