How to implement Universal Binding
We demonstrate 2 alternatives for defining LSC with equivalent semantics to universal binding.
We want to specify the requirement: After event A occurred, for each instance of ClassB event B must occur.
Using concrete LSC
Define your specification using lifelines of type 'Universal Binding' as required. For example:
When playing out the specification, check the 'Concrete LSC' checkbox:
As a result when play out starts, PlayGo transforms the specification into specification with no dynamic lifelines. Instead of each dynamic lifeline it creates multiple LSCs, each containing only static lifelines. PlayGo translates the dynamic lifelines into concrete/static lifelines, based on the objects, of the type defined by the lifeline, in the system model. For example:
Combining LSC with Java code
Define an LSC in which after event A occurs, a Java method that iterates all ClassB instances is triggered. The ClassB iterate method should iterate ClassB objects, and trigger a certain event D on each object.
Here is an example for an 'iterate' method:
Now define an LSC that monitors that event D and executes even B.
When event D is monitored, a new live copy is created for the concrete object allowing execution of event B and any other required behavior for this object.
Similarly, one can implement the iterate method to trigger event B on a subset of ClassB objects, subject to a certain condition. This is equivalent to defining a lifeline of type Universal Binding having a binding expression.