On this page

Calling a specific behavior

You can use the following APIs to call any Behavior by its name or its qualified name.

ALH.callBehavior("name")
ALH.callBehavior("name", List arguments)
ALH.callBehavior("name", List arguments, boolean isSynchronous)

The following example shows how to call the "test" specified Behavior in ALH API.

value = ALH.callBehavior("test");

You can also give initial parameter values in which the argument list must be created.

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 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.

ALH.callOperation("name")
ALH.callOperation("name", List arguments)
ALH.callOperation(object, "name")
ALH.callOperation(object, "name", List arguments)
ALH.callOperation(object, "name", List arguments, boolean isSynchronous)
ALH.callOperation(object, "name", "portName")
ALH.callOperation(object, "name", "portName", List arguments)

If the object is omitted then context (self) is used automatically.

In the following example, you can learn how to call operation "test" and return its value to variable "result".

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.

 ALH.callOperation("start", "p1")

You can also give initial parameter values in which the arguments lists must be created by executing the following code.

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:

arguments = ALH.createList();
arguemnts.add(20);

Alternatively, you can use an initial value as the constructor's parameter.

arguments = ALH.createList(20);

Note

  • Only one initial value of the list is allowed.
  • Variable-length argument lists are not supported.