RMA: a Pattern Based J2EE Development Tool
Total Page:16
File Type:pdf, Size:1020Kb
RMA: A Pattern Based J2EE Development Tool by Jun Chen A thesis presented to the University of Waterloo in ful¯lment of the thesis requirement for the degree of Master of Mathematics in Computer Science Waterloo, Ontario, Canada, 2004 °c Jun Chen 2004 AUTHOR'S DECLARATION FOR ELECTRONIC SUBMISSION OF A THESIS I hereby declare that I am the sole author of this thesis. This is a true copy of the thesis, including any required ¯nal revisions, as accepted by my examiners. I understand that my thesis may be made electronically available to the public. ii Abstract The development process for creating J2EE web applications is complex and tedious, and is thus error prone. The quality of a J2EE web application depends on correctness of code as well as the e±ciency and flexibility of its architecture. Although the J2EE speci¯cation has promised to hide the distributed nature of the application, application developers still have to be aware of this fact in both the design (architecture) and implementation (code) perspectives. In this thesis, we present the detailed design of our pattern-based J2EE development tool, RoadMapAssembler (RMA). RMA demonstrates how patterns can be used to generate e±cient architectural code while also hiding the deployment logic and distributed nature of J2EE applications in the implementation perspective. Furthermore, it shows the generation of a J2EE framework as a process of assembling patterns in an incremental fashion using known inter-pattern relationships. iii Acknowledgement I would like to express my deepest gratitude to my supervisor, Professor Steve MacDonald. His guidance, insight and expressive clarity have served as an inspiration and have helped me tremen- dously during these past two years. This thesis would not be possible without his patience and advice. I would also like to thank my readers, Professor Tim Brecht and Professor Richard Trefler for taking the time to review my thesis. Also, I like to thank my friends who had helped me so much in the past two years. A special thank you to my parents for their endless love, support and encouragement during my studies away from home. iv Contents 1 Introduction 1 1.1 Introduction . 1 1.1.1 The Development Process . 1 1.1.2 The Deployment Process . 3 1.2 Contribution . 3 1.2.1 RoadMapAssembler . 4 1.3 Outline . 4 2 Background 7 2.1 J2EE . 7 2.1.1 Presentation Tier Technologies . 8 2.1.2 EJBs . 9 2.1.3 Data Access Technologies . 10 2.1.4 Deployment Tools . 11 2.2 Eclipse . 13 3 J2EE Framework and Patterns 16 3.1 Data Access Object . 18 3.2 Transfer Value Object . 20 3.3 Session Fa»cade . 21 3.4 Service Locator . 23 3.5 Transfer Object Assembler . 25 3.6 Value List Handler . 27 v 3.7 Business Delegate . 28 3.8 Summary . 29 4 Pattern Relationships And Pattern Assembly 31 4.1 Pattern Relationships . 31 4.1.1 Transfer Value Object + Data Access Object . 33 4.1.2 Transfer Object Assembler + Data Access Object Subcomponent . 34 4.1.3 Value List Handler + Data Access Object Subcomponent . 37 4.1.4 Session Fa»cade+ Business Components . 39 4.1.5 Service Locator + Business Delegate + Session Fa»cadeSubcomponent . 42 4.1.6 Discussion on Pattern Relationships . 44 4.2 Pattern Assembly . 45 4.2.1 Assembly Processes . 46 4.2.2 Writing Application Code . 58 4.3 A Sample Application . 60 4.3.1 Assembling a Sample Application . 62 4.3.2 Discussion . 68 4.4 Summary . 68 5 Isolation of Deployment Logic 70 5.1 Removing Deployment Logic at the Code Level . 72 5.1.1 Generating Access Interfaces . 72 5.1.2 Re¯ned Service Locator . 74 5.1.3 Proxy for EJBs . 78 5.1.4 Discussion . 79 5.2 Generating Deployment Files . 81 5.2.1 Generating Deployment Descriptor Files . 82 5.2.2 Packaging the EAR File . 83 5.3 Summary . 84 6 Analysis 85 vi 7 Related Work 89 7.1 COPS for Parallel Programming . 89 7.2 Tools for J2EE Development . 90 7.2.1 JBuilder and WebSphere . 91 7.2.2 Struts . 92 7.2.3 Pattern Transformation based JAFAR . 92 7.2.4 Model Transformation based OptimalJ . 94 7.2.5 Role/Constraint based Fred . 97 7.3 Summary . 99 8 Future Work and Conclusion 100 8.1 Future Work . 100 8.2 Conclusion . 101 A Acronyms 106 B UML Legends 108 vii List of Figures 1.1 RMA Architecture . 5 2.1 J2EE Container Architecture . 8 2.2 Hierarchy of a J2EE Application Archive . 12 3.1 Sun's J2EE framework . 17 3.2 Data Access Object . 19 3.3 Transfer Value Object Class Diagram . 21 3.4 Session Fa»cadeClass Diagram . 23 3.5 Service Locator . 24 3.6 Transfer Object Assembler . 26 3.7 Value List Handler . 28 3.8 Business Delegate . 29 4.1 Transfer Value Object and Data Access Object . 35 4.2 Transfer Value Object, Transfer Object Assembler and Data Access Object . 37 4.3 Transfer Value Object, Data Access Object and Value List Handler . 38 4.4 Session Fa»cadeand EJBs . 41 4.5 Service Locator + Business Delegate . 43 4.6 Sample Code for the Transfer Value Object . 48 4.7 Sample Code for the Data Access Object-1 . 49 4.8 Sample Code for the Data Access Object-2 . 50 4.9 Sample Code for the Assembler . 53 4.10 Sample Code for the Value List Handler . 55 viii 4.11 Sample Code for the Session Fa»cade . 57 4.12 Sample Code for the Business Delegate . 59 4.13 Use Cases for Sample Application . 60 4.14 Simpli¯ed Architecture for Sample Application . 61 4.15 Wizard Pages for Generating DAO . 63 4.16 Wizard Pages for Generating the Transfer Object Assembler . 64 4.17 Wizard Pages for Generating Session Facade . 66 4.18 Wizard Page for Generating Value List Handler . 67 5.1 Code for Accessing an EJB . 71 5.2 Code for Re¯ned Service Locator-1 . 76 5.3 Code for Re¯ned Service Locator-2 . 77 5.4 Class Diagram for EJB Proxy . 78 5.5 Layers for Generated Code of Hiding Distributed Computing . 80 B.1 UML Legend-Class Symbols . 108 B.2 UML Legends-Association Symbols . 109 ix List of Tables 4.1 The Categorization of Roles in the Relationships . 45 6.1 Code Distribution on Generated Code for Architecture . ..