Package net.shibboleth.shared.logic
Class ScriptedFunction<T,U>
java.lang.Object
net.shibboleth.shared.scripting.AbstractScriptEvaluator
net.shibboleth.shared.logic.ScriptedFunction<T,U>
- Type Parameters:
T- input typeU- output type
- All Implemented Interfaces:
Function<T,U>
A
Function which calls out to a supplied script.- Since:
- 7.4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionInput type.private final org.slf4j.LoggerClass logger.Fields inherited from class net.shibboleth.shared.scripting.AbstractScriptEvaluator
DEFAULT_ENGINE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedScriptedFunction(EvaluableScript theScript) Constructor.protectedScriptedFunction(EvaluableScript theScript, String extraInfo) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionGet the input type to be enforced.static <T,U> ScriptedFunction<T, U> inlineScript(String scriptSource) Factory to createScriptedFunctionfrom inline data.static <T,U> ScriptedFunction<T, U> inlineScript(String engineName, String scriptSource) Factory to createScriptedFunctionfrom inline data.protected voidprepareContext(ScriptContext scriptContext, Object... input) Pre-process the script context before execution.static <T,U> ScriptedFunction<T, U> resourceScript(String engineName, Resource resource) Factory to createScriptedFunctionfrom aResource.static <T,U> ScriptedFunction<T, U> resourceScript(Resource resource) Factory to createScriptedFunctionfrom aResource.voidsetInputType(Class<T> type) Set the input type to be enforced.voidsetOutputType(Class<?> type) Set the output type to be enforced.voidsetReturnOnError(Object value) Set value to return if an error occurs.Methods inherited from class net.shibboleth.shared.scripting.AbstractScriptEvaluator
evaluate, finalizeContext, getCustomObject, getHideExceptions, getLogPrefix, getOutputType, getReturnOnError, setContextExtenders, setCustomObject, setHideExceptions, setLogPrefix
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
inputTypeClass
Input type.
-
-
Constructor Details
-
Method Details
-
setOutputType
Set the output type to be enforced.- Overrides:
setOutputTypein classAbstractScriptEvaluator- Parameters:
type- output type
-
getInputType
Get the input type to be enforced.- Returns:
- input type
-
setInputType
Set the input type to be enforced.- Parameters:
type- input type
-
setReturnOnError
Set value to return if an error occurs.- Overrides:
setReturnOnErrorin classAbstractScriptEvaluator- Parameters:
value- value to return
-
apply
-
prepareContext
Pre-process the script context before execution.- Specified by:
prepareContextin classAbstractScriptEvaluator- Parameters:
scriptContext- the script contextinput- the input
-
inlineScript
@Nonnull public static <T,U> ScriptedFunction<T,U> inlineScript(@Nonnull @NotEmpty @ParameterName(name="engineName") String engineName, @Nonnull @NotEmpty @ParameterName(name="scriptSource") String scriptSource) throws ScriptException, ComponentInitializationException Factory to createScriptedFunctionfrom inline data.- Type Parameters:
T- input typeU- output type- Parameters:
scriptSource- the script, as a stringengineName- the language- Returns:
- the function
- Throws:
ScriptException- if the compile failsComponentInitializationException- if the scripting initialization fails
-
inlineScript
@Nonnull public static <T,U> ScriptedFunction<T,U> inlineScript(@Nonnull @NotEmpty @ParameterName(name="scriptSource") String scriptSource) throws ScriptException, ComponentInitializationException Factory to createScriptedFunctionfrom inline data.- Type Parameters:
T- input typeU- output type- Parameters:
scriptSource- the script, as a string- Returns:
- the function
- Throws:
ScriptException- if the compile failsComponentInitializationException- if the scripting initialization fails
-