Monday, 17 March 2014

What is Data Control Scopes and Data Control Frame

ADF transactions are defined by the business service implementation used in the application (Application Modules). Application Modules provides the connections and transaction to commit the data into the DB. The AM are exposed to the ViewController layer through an abstraction called Data Control.
By default AM provides transaction for the application to commit the data into the DB. But the developer has the ability to change the transaction flow. Each bounded task flow provides its own transaction and data control scopes, example each bounded task flow can commit data separately or use the default transaction.

In the below image you can see simple bounded taskflow with transaction options.




For a given btf (Bounded Task Flow) there are 4 transaction options.
I)                    No Controller Transaction (btf use the existing default transaction)
II)                  Always Begin New Transaction (btf creates new transaction)
III)                Always Use the Existing Transaction (btf uses the existing transaction)
IV)               Use the Existing Transaction If Possible.
Each btf data control scopes provides option to share the transaction with the other btf or not. It provides 2 options
i)                    Shared
ii)                   Isolated
“Shared”: will try to share any instance of a data control with the task flow's caller if the data controls have the same definition, rather than creating a new instance.


“Isolated”: Even if both task flows use the same design time data control definition, at runtime
 each task flow will have their own instance of the data control.

There is something called Data Control Frame which handles all the data control scopes. Each task flow has its own data control frame and containing list of data control scopes.
A data control frame is created at run-time for the application’s unbounded task flow and for each isolated data control scoped bounded task flow. When bounded task flow specified the shared data control scope and the current task flow uses the data control frame and the instances attached to it.

Alternatively if the bounded task flow specifies an isolated data control scope, a new
frame will be created and a new instance of any data controls used by the bounded task flow will
be attached to this new frame.

The below image shows when the new Data Control Frame is created





As you can see in the above diagram there are three Data Control Frame gets created. The red arrow shows that when the data control scope of the BTF is selected as isolated new Data Control Frame gets created. And when the BTF is Shared, the called BTF uses the dame Data Control Frame and instances attached the same.