@Transactional(readOnly=true) @Service public class ScriptService extends Object
scriptService.executeScript("script name", ScriptService.createContext("var1",
value1, "var2", value2));
| Constructor and Description |
|---|
ScriptService() |
| Modifier and Type | Method and Description |
|---|---|
void |
clearScriptCache()
Clears the script cache
|
static ScriptContext |
createContext(Object... args)
Takes an even number of arguments, and creates a
ScriptContext object, with ith argument as the key and
(i+1)th argument as the value. |
Object |
executeFunction(ScriptEngine engine,
String functionName,
Object... args)
Executes given function using given script engine
|
Object |
executeFunctionNoArgs(ScriptEngine engine,
String functionName)
Executes given function using given script engine
|
Object |
executeScript(Script script,
ScriptContext context)
Executes the given script with context as the ScriptContext.
|
Object |
executeScript(String scriptName,
ScriptContext context)
Executes the given script with context as the ScriptContext.
|
Object |
executeScript(String scriptName,
ScriptContext context,
Date asOnDate)
Executes the given script with context as the ScriptContext as on given
date.
|
Script |
findByNameAndPeriod(String name,
Date period) |
Script |
getByName(String name) |
void |
loadFunctionsFromScript(String scriptName)
Loads all functions from given script.
|
public static ScriptContext createContext(Object... args)
ScriptContext object, with ith argument as the key and
(i+1)th argument as the value. This is why this method expects an even
number of arguments.args - Arguments from which the context will be createdexecuteScript(String, ScriptContext)public void loadFunctionsFromScript(String scriptName)
scriptName - Script which is to be loadedpublic Object executeFunctionNoArgs(ScriptEngine engine, String functionName)
engine - Script engine to be used for executing the functionfunctionName - Name of function to be executedpublic Object executeFunction(ScriptEngine engine, String functionName, Object... args)
engine - Script engine to be used for executing the functionfunctionName - Name of function to be executedargs - Arguments to be passed to the functionpublic Object executeScript(Script script, ScriptContext context)
script - Script to be executedcontext - The script context - attributes in this context can be used as
variables inside the scriptValidationException - if the script returns a list of ValidationErrorspublic Object executeScript(String scriptName, ScriptContext context)
scriptName - Name of script to be executedcontext - ValidationException - , if the script returns a list of ValidationErrorspublic Object executeScript(String scriptName, ScriptContext context, Date asOnDate)
scriptName - Name of script to be executedcontext - asOnDate - The date as on which the script is to be executedValidationException - , if the script returns a list of ValidationErrorspublic void clearScriptCache()
Copyright © 2015–2016 eGovernments Foundation. All rights reserved.