Difference between revisions of "How to implement Universal Binding"

From WeizmannWiki
Jump to: navigation, search
(New page: At present [http://www.wisdom.weizmann.ac.il/~maozs/s2a/ S2A Compiler], which is the mechanism used for playing out LSC specification, does not support [[LSC Reference#Universal_Binding|un...)
 
Line 1: Line 1:
 
At present [http://www.wisdom.weizmann.ac.il/~maozs/s2a/ S2A Compiler], which is the mechanism used for playing out LSC specification, does not support [[LSC Reference#Universal_Binding|universal binding]].
 
At present [http://www.wisdom.weizmann.ac.il/~maozs/s2a/ S2A Compiler], which is the mechanism used for playing out LSC specification, does not support [[LSC Reference#Universal_Binding|universal binding]].
  
We demonstrate 2 alternatives for defining LSC with equivalent semantics to universal binding.<br> We want to specify the requirement: After event A occurred, for each instance of ClassB event B must occur.
+
We demonstrate two alternatives for defining LSC, both with semantics equivalent to universal binding.<br> We want to specify the requirement: After event A occurred, for each instance of ClassB event B must occur.
  
 
== Using concrete LSC  ==
 
== Using concrete LSC  ==

Revision as of 10:13, 23 March 2014

At present S2A Compiler, which is the mechanism used for playing out LSC specification, 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 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:

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

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.