Package net.shibboleth.shared.scripting
Class EvaluableScript
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.scripting.EvaluableScript
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent
This is a helper class that takes care of reading in, optionally compiling, and evaluating a script.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CompiledScriptThe compiled form of the script, if the script engine supports compiling.private final org.slf4j.LoggerThe log.private StringThe script to execute.private ScriptEngineThe script engine to execute the script.private StringThe scripting language. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidPerforms the initialization of the component.Evaluates this script against the given bindings.eval(ScriptContext scriptContext) Evaluates this script against the given context.Gets the script source.Gets the script language.voidsetEngineName(String what) Sets the script language.voidSets the script source.voidsetScript(InputStream scriptSource) Sets the script source.voidSets the script source.voidSets the script source.Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitialized
-
Field Details
-
scriptLanguage
The scripting language. -
script
The script to execute. -
scriptEngine
The script engine to execute the script. -
compiledScript
The compiled form of the script, if the script engine supports compiling. -
log
@Nonnull private final org.slf4j.Logger logThe log.
-
-
Constructor Details
-
EvaluableScript
public EvaluableScript()Constructor.
-
-
Method Details
-
getScript
Gets the script source.- Returns:
- the script source
-
setScript
Sets the script source.- Parameters:
what- the script source
-
setScript
Sets the script source.- Parameters:
scriptSource- how to get the script source- Throws:
IOException- if there were issues reading the script
-
setScript
Sets the script source.- Parameters:
scriptSource- how to get the script source- Throws:
IOException- if there were issues reading the script
-
getScriptLanguage
Gets the script language.- Returns:
- the script language
-
setEngineName
Sets the script language.- Parameters:
what- the script language
-
eval
Evaluates this script against the given bindings.- Parameters:
scriptBindings- the script bindings- Returns:
- the result of the script or null if the script did not return a result
- Throws:
ScriptException- thrown if there was a problem evaluating the script
-
eval
Evaluates this script against the given context.- Parameters:
scriptContext- the script context- Returns:
- the result of the script or null if the script did not return a result
- Throws:
ScriptException- thrown if there was a problem evaluating the script
-
doInitialize
Performs the initialization of the component. This method is executed within the lock on the object being initialized. The default implementation of this method is a no-op. Initializes the scripting engine and compiles the script, if possible.- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException- if the scripting engine supports compilation and the script does not compile
-