Calling a specific behavior
You can use the following APIs to call any Behavior by its name or its qualified name.
| Code Block |
|---|
|
object ALH.callBehavior(String "name")
object ALH.callBehavior(String "name", List<?>List arguments)
object ALH.callBehavior(String "name", List<?>List arguments, boolean isSynchronous) |
The following example shows how to call the "test" specified Behavior in ALH API.
| Code Block |
|---|
|
value = ALH.callBehavior("test"); |
You can also give initial parameter values in which the arguments lists argument list must be created.
| Code Block |
|---|
|
arguments = ALH.createList();
arguments.add("value1");
arguments.add("value2");
value = ALH.callBehavior("test", arguments); |
If a found Behavior value is null or an argument's size is not equal to the in or inout input parameter's size of the found Behavior, an IllegalArgumentException will be thrown.
Calling a specific operation
You can use the following APIs to call an operation
by its name or its qualified name.
| Code Block |
|---|
|
object ALH.callOperation(String "name")
object ALH.callOperation(String "name", List<?>List arguments)
object ALH.callOperation(Object_ object, String "name")
object ALH.callOperation(Object_ object, String "name", List<?>List arguments)
object ALH.callOperation(Object_ object, String "name", List<?>List arguments, boolean isSynchronous)
object ALH.callOperation(Object_ object, String "name", String "portName")
object ALH.callOperation(Object_ object, String "name", String "portName", List<?>List arguments)
|
| Note |
|---|
If the object is omitted then context (self) is used automatically. |
The following examples show In the following example, you can learn how to call a specified operation in ALH API by passing the operation's name and portoperation "test" and return its value to variable "result".
| Code Block |
|---|
|
value result= ALH.callOperation("test"); |
In the following example, you can learn how to call a specified operation in ALH API by passing the operation's name and source port.
| Code Block |
|---|
ALH.callOperation("start", "p1") |
You can also give initial parameter values in which the arguments lists must be created by executing the following code.
| Code Block |
|---|
|
arguments = ALH.createList();
arguments.add("value1");
arguments.add("value2");
value = ALH.callOperation("test", arguments); |
If a found Behavior value is null or an argument's size is not equal to the in or inout parameter's size of the found Behavior, an IllegalArgumentException will be thrown.
Creating list of arguments
A Java List will be required under certain circumstances, e.g., if you want to create Argument values that will be passed to some calling Behaviors or Operations.
The following code fragment shows how to create the Java ArrayList in the scripting language with ALH:
| Code Block |
|---|
arguments = ALH.createList();
arguemnts.add(20); |
Alternatively, you can use an initial value as the constructor's parameter.
| Code Block |
|---|
|
arguments = ALH.createList(20); |
| Note |
|---|
|
- Only one initial value of the list is allowed.
- Variable-length argument lists are not supported.
|