MDA-Based Modeling and Transformation to Generate N-Tiers Web Models
Total Page:16
File Type:pdf, Size:1020Kb
Journal of Software MDA-Based Modeling and Transformation to Generate N-Tiers Web Models M'hamed Rahmouni*, Samir Mbarki Department of Computer Science, Faculty of Science, Ibn Tofail University, Kenitra, BP 133, Morocco. Corresponding author. Tel.: +212 664 79 94 44; email: [email protected] Manuscript submitted: August 8, 2014; accepted March 20, 2015. doi: 10.17706/jsw.10.3.222-238 Abstract: Data interchanges between companies are increasing. To improve this interchange and meet the increasing user needs, various frameworks and patterns are integrated for producing stable, maintainable and testable code. Some of the design patterns that will be used in the applications design and development are the MVC model, the DAO and DI (Dependency Injection) patterns. In this paper, we integrate these patterns to generate the N-tiers web model and thereafter generate the N-tiers application web code from this model. To obtain this, we start by modeling the Spring IoC, Struts2 and Hibernate frameworks for establishing their meta-models. Each framework from these is based on a pattern from the cited above. After establishing the different meta-models, we lead a model transformation process to generate N-tiers web model from the integrated meta-models. The model-to-model transformations are also clearly and formally established by using ATL transformation language. The model-to-code transformation will be the subject of the future work. Finally, a case study is provided to exemplify the generated PSM model respecting the architecture overview of MVC 2, DI and DAO patterns. Key words: MDA, hibernate DAO, spring IoC, struts, ATL transformation, n-tiers architecture. 1. Introduction Data interchanges between companies are increasing. To improve this interchange and meet the increasing user demands, various frameworks and patterns are integrated for producing stable, maintainable and testable code. Some of the design patterns that will be used in our application design and development are the MVC (Model-View-Controller) model, the DAO (Data Access Object) and DI (Dependency Injection) patterns. To have the different patterns cited above, we will integrate many frameworks based on these patterns like: Struts2 [1], Hibernate [2] and Spring IoC [3], [4]. At the same time, the traditional mode has been changed greatly by the frameworks integration. Struts 2, Spring and Hibernate can be integrated to develop web sites. The goal is to reuse existing application services and minimize data duplication in different information systems. In technical terms, Struts 2 is a framework based on MVC 2 architecture. This framework is built for designing web applications. Using such architecture provides a separation code between views that display, the data store and pure logic part. This separation provides better maintainability and scalability of the application. Spring provides an abstraction layer to access data, including JPA, Hibernate, iBATIS, or JDBC directly. Working with a Spring service will allow the developer to ignore the technical properties of the data store underlying. The Hibernate framework is the most powerful and popular Object Relational Mapping (ORM) that can be used 222 Volume 10, Number 3, March 2015 Journal of Software with J2EE. All access to data or schema of the system is done using hibernate. The application development architecture precisely the Web systems development [5], is as well focusing on the model driven engineering approach. The approach used in this work is the Model-Driven Architecture (MDA) [6]-[7].Most of the current Web Engineering approaches (WebML [8], OO-H [9], OOWS [10], UWE [11], WebSA [12]) already propose to build different views of Web systems following a horizontal separation of concerns. The objective of this work is to generate automatically an N-tiers web model that is a PSM model. This model respects the architecture of MVC2, DI and DAO patterns. To meet this objective, we elaborate the PIM and PSM meta-models then we establish the traceability links between the components of these meta-models and thereafter we define the different rules by ATL transformation language. Finally, we demonstrate and exemplify these rules by a case study. The remainder of this paper is organized in eight sections as follows: Section II describes the process and methodology. Section III presents the MDA approach. Section IV explains N-tiers system architecture. Section V is dedicated to the UML and N-tiers architecture meta-models. The transformation rules implementation is the subject of Section VI. Section VII presents the transformation rules execution and the result of the execution process. The related work is the objective of Section VIII. Finally, Section VIX concludes the work and gives hints about future work. 2. Process and Methodology In this work, the process starts by meta-modeling Spring IoC, Struts 2 and Hibernate DAO frameworks allow implementing the different CIM, PIM, and PSM meta-models. The CIM model of this work is an UML class diagram of a case study of an Employee management. The functional model (PIM) is a simplified UML meta-model. The PSM meta-model is composed of the meta-models of Spring IoC, Struts 2 and Hibernate DAO frameworks. The PSM meta-models are presented in the Fig. 3, -Fig. 5. The next step is to define the ATL transformation rules. This step starts by the implementation of KM3 models corresponding to each meta-model and the Ecore models corresponding to each KM3. The last step is to establish the traceability links between the components of source and target meta-models then, we define the different transformation rules in ATL transformation language. The result of this work is the n-tiers web model represented in EMF model. This is the configuration file of the proposed application. From the generated PSM model, we can generate the application code of the case study by applied an M2C transformation. The M2C transformation is neglected in this work. It will be the subject of future work. The tools support of this work is the UML, ATL transformation language, MOF, XMI, KM3, OCL and EMF Project. 3. MDA (Model-Driven Architecture) One of the main aims of MDA [13] (Model-Driven Architecture) approach is to separate design from architecture. The basic principle of this approach is the development of different models. Those models are the heart of MDA. This latter defines the requirement model (Computation Independent Model, CIM), then given the analysis and design model (Platform Independent Model, PIM) corresponding to its and finally the transformation of the PIM model into a PSM (Platform Specific Model) model specific to the target platform for the concrete implementation of the system. The techniques used in the MDA context are mainly the techniques of modeling and model transformations. MDA is related to multiple standards including UML [14], MOF [15], XMI [16], OCL [17] and many others. This work is depicted to develop N-tiers application architecture. In the following section, we present the n-tiers system architecture of our application. 223 Volume 10, Number 3, March 2015 Journal of Software 4. N-Tiers System Architecture In this paper, we will integrate the Spring IoC, Struts 2 and Hibernate DAO frameworks in order to implement n-tiers web application. This application is composed from three layers. Each layer is managed by a framework through the frameworks cited above. 4.1. Web Presentation Layer / Ui Tier with Struts 2 The presentation layer allows display the data and the interaction of the application with the user. The separation of this layer permits in particular proposing several presentations for the same application: the same treatment layer can then be used for heavy duty application and a lightweight application. In this work, this layer will be managed by Struts 2 framework. 4.2. Business Layer with Spring IoC The Business layer contains all business whose module components. These business components are responsible for managing the lifecycle of business objects managed by the module. This layer is now provided by Spring IoC. 4.3. Persistence Layer with Hibernate DAO This layer is responsible for data access and their handling, regardless of the DBMS. All CRUD operations are implemented in this layer component. This layer can be handled by Hibernate Framework. Fig. 1 shows the different layers which will be developed in this work. Fig. 1. N-tiers layers. To achieve each implementation layer, we conduct a development method based on MDA approach. In this method, we begin by meta-modeling the frameworks and thereafter given the meta-model corresponding of each framework. The meta-modeling is the subject of the following section. 5. UML and N-Tiers Architecture Meta-Models In this section, we present the various meta-classes forming the UML source and N-tiers target meta-models. 5.1. UML Source Meta-Model Fig. 2 shows the source meta-model which is a simplified UML class diagram. UMLPackage represents the notion of UML package. The UMLPackage meta-class is linked to the Classifier meta-class. This latter represents as well the concept of UML class and the concept of data type. The Property meta-class 224 Volume 10, Number 3, March 2015 Journal of Software expresses the notion of an UML class properties or references to other classes (uni and bidirectional associations). The Operation meta-class presents the concept of the method in the UML context. This meta-class is composed of a set of Parameter. Also the Parameter meta-class represents the attributes and method parameters. class UMLDiagr... UmlPackage - name: String 1 +elements * Classifier 1 - name: String 1 +type +type * DataType Class Property +property - name: String 1 * - upper: Integer - lower: Integer 1 +operation * Operation Parameter +parameter - name: String - name: String 1 * * Fig. 2. Simplified UML meta-model. 5.2. N-Tiers Target Meta-Model This meta-model is composed of a various meta-models.