Function definitions are part of the module: however, only if they are implemented in the Expression Language is the implementation part of the Module as well. If you decide to implement your function in Java, you will need to upload the implementation to the LSPS server as part of you application.
The definition of functions are stored in Function Definition files.
Function definition editor with a function definition file of the Standard Library
Defining Functions
To create a function, do the following:
- In the Modeling perspective, create or open a function definition file.
- Add a new function and define the function details:
- Name: name used to call the function
- Return type: data type of the return value
Type parameters: comma-separated list of abstractions of data types used in parameters
Type parameters allow functions to operate over a parameter that can be of various data types, not only a single data type, in different calls. The concept is based on generics as used in Java. You can also make a generic data type extend another data type with the extends keyword. The syntax is then <type_param_1> extends <type1>
, <type_param_2> extends <type2>
(for details, refer to the Expression Language User Guide).
- Public: function visibility
- Variadic: function arity A function is variadic if its last parameter can be declared variadic, that is, zero or more occurrences of that last parameter are allowed.
- Has side effects: if true, on validation, the info notification about the function having a side effect is suppressed A function is considered to have side effects if one of the following is true:
- The function modifies a variable outside of the function scope.
- The function creates a shared record.
- The function modifies a record field.
- The function calls a function that causes a side effect.
- Deprecated: if true, on validation, a notification about that the called function is deprecated is displayed
- Define the input parameters. For every parameter you need to define the following:
- Name: parameter name unique within the function declaration
- Type: data type of the parameter
- Required: if checked, every function calls must define the parameter. The Required property does not provide any additional runtime check of the parameter value.
- Description: optional description of the parameter Functions can be overloaded: functions with the same name but different parameters are considered different functions.
- Define the implementation:
- Select Expression and define the implementation.
Name -> &newEmployee.name,
Birthdate -> &newEmployee.birthdate,
Salary -> "You need to set the salary",
CurrentPosition -> getPosition(newEmployee);
return true)
- Select Java and enter the path to the method that implements the function, such as
org.example.example.TimeUtils.getWeekday
, and include the implementation in the ejb project of your LSPS Application. For further information on how to develop a custom LSPS Application, refer to the Software Development Kit Guide.
- Enter the Description of the function in the Description field.
Function definition
Calling Functions
Functions are called by their name followed by function parameters in brackets:
<FUNCTION_NAME>(<FUNCTION_PARAM1>, <FUNCTION_PARAM2>)