public abstract class AbstractScriptEvaluator extends Object
EvaluableScript against a set of inputs
and returns the result.| Modifier and Type | Field and Description |
|---|---|
private Object |
customObject
A custom object to inject into the script.
|
static String |
DEFAULT_ENGINE
The default language is Javascript.
|
private boolean |
hideExceptions
Whether to raise runtime exceptions if a script fails.
|
private org.slf4j.Logger |
log
Class logger.
|
private String |
logPrefix
Debugging info.
|
private Class |
outputType
The output type to validate.
|
private Object |
returnOnError
Value to return from script if an error occurs.
|
private EvaluableScript |
script
The script we care about.
|
| Constructor and Description |
|---|
AbstractScriptEvaluator(EvaluableScript theScript)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected Object |
evaluate(Object... input)
Evaluate the script.
|
protected Object |
finalizeContext(ScriptContext scriptContext,
Object scriptResult)
Complete processing by evaluating the result of the script and returning the final result to the caller.
|
protected Object |
getCustomObject()
Return the custom (externally provided) object.
|
protected boolean |
getHideExceptions()
Get whether to hide exceptions in script execution.
|
protected String |
getLogPrefix()
Get log prefix for debugging.
|
protected Class |
getOutputType()
Get the output type to be enforced.
|
protected Object |
getReturnOnError()
Get value to return if an error occurs.
|
protected abstract void |
prepareContext(ScriptContext scriptContext,
Object... input)
Pre-process the script context before execution.
|
void |
setCustomObject(Object object)
Set the custom (externally provided) object.
|
void |
setHideExceptions(boolean flag)
Set whether to hide exceptions in script execution (default is false).
|
void |
setLogPrefix(String prefix)
Set log prefix for debugging.
|
protected void |
setOutputType(Class type)
Set the output type to be enforced.
|
protected void |
setReturnOnError(Object value)
Set value to return if an error occurs.
|
@Nonnull @NotEmpty public static final String DEFAULT_ENGINE
@Nonnull private final org.slf4j.Logger log
@Nonnull private final EvaluableScript script
private boolean hideExceptions
public AbstractScriptEvaluator(@Nonnull@ParameterName(name="theScript") EvaluableScript theScript)
theScript - the script we will evaluate.@Nullable protected String getLogPrefix()
public void setLogPrefix(@Nullable String prefix)
prefix - log prefix@Nullable protected Class getOutputType()
protected void setOutputType(@Nullable Class type)
type - output type@Nullable protected Object getCustomObject()
public void setCustomObject(@Nullable Object object)
object - the custom objectprotected boolean getHideExceptions()
public void setHideExceptions(boolean flag)
flag - flag to set@Nullable protected Object getReturnOnError()
protected void setReturnOnError(@Nullable Object value)
value - value to return@Nullable protected Object evaluate(@Nullable Object... input)
input - input parametersprotected abstract void prepareContext(@Nonnull ScriptContext scriptContext, @Nullable Object... input)
scriptContext - the script contextinput - the input@Nullable protected Object finalizeContext(@Nonnull ScriptContext scriptContext, @Nullable Object scriptResult) throws ScriptException
The default implementation just returns the result.
scriptContext - the context after executionscriptResult - the result of script executionScriptException - to signal a failure after script executionCopyright © 1999–2019 Shibboleth Consortium. All rights reserved.