How to implement Universal Binding

From WeizmannWiki
Revision as of 09:34, 29 April 2014 by Smadar (Talk | contribs)

Jump to: navigation, search

At present, the S2A Compiler, which is the mechanism used for playing out LSC specifications, does not support universal binding.

We demonstrate two alternatives for defining LSC, both with semantics equivalent 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:

UniversalBindingViaConcretization.png

When playing out the specification, check the 'Concrete LSC' checkbox:

ConcreteLSC.png

As a result, when play-out starts, PlayGo transforms the specification into one 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, which appear in the system model. For example:

ConcreteLSCSpec.png

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.

UniversalBindingViaCode1.png

Here is an example for an 'iterate' method:

UniversalBindingViaCode3.png

Now define an LSC that monitors that event D and executes event 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.

UniversalBindingViaCode2.png


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.