## 5 Model Transformations
### Transformation from the E1 Model into the E2 Model  
We construct the E2 model from the E1 model using a model transformation. Figure 11 shows the E2 model that results from the E1 model shown in Figure 8. The transformation from the E1 model into the E2 model involves performing the following steps for each enhanced connector found in the E1 model:  
* Let us call the class which contains the enhanced connector the _container class_ (e.g., the class ECls shown in Figures 8 and 11). A class with the name _ConnectorCls_<_ConnectorName_> is created as a nested class of the container class. We call this class the _connector class_.
* An object of the connector class is created under the container class.
* Let _XIfc_ be the interface required or provided by the ports connected by the enhanced connector. Two ports are added to the connector class with the names _reqPort_ and _proPort_, which require and provide the interface XIfc, respectively.
* Connectors that connect the requesters to the prvPort of the connector class are created.
* Connectors that connect the providers to the reqPort of the connector class are created.
* A class with the name _RequestPortCls_ is created as a nested class of the connector class. An object of this class with the name _InPort_ is also created as a _Property_ of the connector class.
* A port with the name _prvPort_ is created in RequestPortCls, which provides the interface XIfc.
* Properties of the OpaqueBehavior that represent the enhanced connector behavior, except the properties denoting the request buffers, are moved under the connector class. Properties that denote the request buffers are moved under RequestPortCls.
* A property named _ownerConnector_ is created in RequestPortCls. The type of ownerConnector is set to the connector class.  
Figure 10: Enhanced connector transformation process.  
* A _constructor_ with a single argument is created for RequestPortCls. The type of the argument is the connector class. Implementation for the constructor is added as an OpaqueBehavior using ALF. The implementation sets the ownerConnector property to the argument of the constructor. This way, RequestPortCls knows the connector class, which owns itself.
* An operation that implements the operation declared by the interface XIfc is created under RequestPortCls. An OpaqueBehavior that acts as the _method_ of this operation is also added. Implementation of the operation performs the following actions:
* If a request buffer is defined, it stores the incoming request in the buffer allocated for the requester.
* It forwards the request to the connector class using the ownerPort property. The connector then executes the actual coordination behavior.
* A _constructor_ is created under the connector class, and an OpaqueBehavior using ALF is added as its method. The behavior of this constructor instantiates the InPort property of the connector class.
* Multiplicities of the port prvPort and the property InPort inside the connector class are set to the number of requesters.
* Multiplicities of the port reqPort and the property OutPort inside the connector class are set to the number of providers.  
Behavior specifications of the created constructors and operations are specified using ALF. The E2 model contains all the structural and behavioral artifacts required to define the coordination behavior for the enhanced connector. In the next transformations,  
Figure 11: E2 model for the example shown in Figure 8: (**a**) Composite structure diagram that contains the requester, providers, and the object of the connector class. (**b**) Composite structure diagram for the connector class. (**c**) UML model showing the connector behavior and other behaviors generated by the model transformation.  
we transform the OpaqueBehaviors specified using ALF into behaviors specified using fUML activities.