Package org.frankframework.javascript
Interface JavascriptEngine<E>
- Type Parameters:
E
- Specifies the type of javascript engine
public interface JavascriptEngine<E>
Javascript engine interface, allows the use of a javascript engine to execute javascript code functions.
- Since:
- 7.4
- Author:
- Jarno Huibers
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Closes the runtime for the specified engineexecuteFunction
(String name, Object... parameters) Executes a javascript function and returns the result of that functionvoid
executeScript
(String script) Read the functions of a given javascript fileGetter for the runtime of the specified enginevoid
registerCallback
(ISender sender, PipeLineSession session) Allows for senders to be called by the Javascript function.void
setGlobalAlias
(String alias) void
setResultHandler
(ResultHandler resultHandler) Registers the result and error functions to be handled by the given result handler.void
Initialize the runtime for the specified engine
-
Method Details
-
setGlobalAlias
- Parameters:
alias
- An identifier which describes the script(s) that are being executed.
-
startRuntime
Initialize the runtime for the specified engine- Throws:
JavascriptException
-
executeScript
Read the functions of a given javascript file- Parameters:
script
- String containing the contents of the javascript file in which the function(s) to be executed are specified.- Throws:
JavascriptException
-
executeFunction
Executes a javascript function and returns the result of that function- Parameters:
name
- The name of the javascript function as given in the javascript file.parameters
- An array containing the parameters for the javascript function, given in the adapter configuration- Returns:
- The result of the javascript function is returned.
- Throws:
JavascriptException
-
closeRuntime
void closeRuntime()Closes the runtime for the specified engine -
getEngine
E getEngine()Getter for the runtime of the specified engine- Returns:
- Returns the runtime instance
-
registerCallback
Allows for senders to be called by the Javascript function. Sender needs to be given in the adapter configuration, a Javascript function can call the sender, using the name of the sender as a function call.- Parameters:
sender
- The sender given in the adapter configuration
-
setResultHandler
Registers the result and error functions to be handled by the given result handler.- Parameters:
resultHandler
- Object to handle results and errors.
-