rational app dev 7.5

1436
ibm.com/redbooks Draft Document for Review May 8, 2009 6:53 pm SG24-7672-00 Rational Application Developer V7.5 Programming Guide Ueli Wahli Miguel Gomes Brian Hainey Ahmed Moharram Juan Pablo Napoli Marco Rohr Develop application using Java EE 5 Test, debug, and profile with local and remote servers Deploy applications to WebSphere servers Henry Cui Patrick Gan Celso Gonzalez Pinar Ugurlu Lara Ziosi This is the final draft

Upload: api-19920690

Post on 29-Dec-2014

962 views

Category:

Documents


12 download

TRANSCRIPT

Front coverDraft Document for Review May 8, 2009 6:53 pm SG24-7672-00

Rational Application Developer V7.5 Programming GuideDevelop application using Java EE 5 Test, debug, and profile with local and remote servers Deploy applications to WebSphere servers

Henry Cui Patrick Gan Celso Gonzalez Pinar Ugurlu Lara ZiosiThis is the final draft

Ueli Wahli Miguel Gomes Brian Hainey Ahmed Moharram Juan Pablo Napoli Marco Rohr

ibm.com/redbooks

Draft Document for Review May 9, 2009 12:19 am

7672edno.fm

International Technical Support Organization Rational Application Developer V7.5 Programming Guide May 2009

SG24-7672-00

7672edno.fm

Draft Document for Review May 9, 2009 12:19 am

Note: Before using this information and the product it supports, read the information in Notices on page liii.

First Edition (May 2009) This edition applies to IBM Rational Application Developer for WebSphere Software Version 7.5 and to IBM WebSphere Application Server Version 7.0. This document created or updated on May 9, 2009.

Copyright International Business Machines Corporation 2008. All rights reserved. Note to U.S. Government Users Restricted Rights -- Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

Draft Document for Review May 9, 2009 12:19 am

7672TOC.fm

ContentsFigures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxvii Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xlvii Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xlix Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . liii Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . liv Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . lv The team that wrote this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . lvi Become a published author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . lix Comments welcome. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . lx Summary of changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . lxi April 2009, First Edition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . lxi Part 1. Introduction to Rational Application Developer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Chapter 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 IBM Rational Software Delivery Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Eclipse and IBM Rational Software Delivery Platform . . . . . . . . . . . . . . . . . 7 Eclipse Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Eclipse Software Developer Kit (SDK) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Application development challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Product packaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Rational Developer supported platforms and databases . . . . . . . . . . . . . . 10 Application Developer v7.5 eAssembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Product tools and features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Summary of new features in Application Developer v7.5 . . . . . . . . . . . . . . 14 Specification versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Installation and licensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Licensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Updates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Uninstall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Migration and coexistence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

Copyright IBM Corp. 2008. All rights reserved.

iii

7672TOC.fm

Draft Document for Review May 9, 2009 12:19 am

Migration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Compatibility with previous versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Sample code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Chapter 2. Programming technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Desktop applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Simple desktop applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Database access. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Graphical user interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Extensible Markup Language (XML) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Static Web sites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Hypertext Transfer Protocol (HTTP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 HyperText Markup Language (HTML) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Dynamic Web applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Simple Web applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Struts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 JavaServer Faces (JSF) and persistence using SDO or JPA . . . . . . . . . . . 48 Web 2.0 Development. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Portal applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Enterprise JavaBeans and Java Persistence API (JPA) . . . . . . . . . . . . . . . . . 56 EJB 3.0 specification: What is new? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Different types of EJBs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 Java Persistence API (JPA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Other EJB and JPA features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Java EE Application Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Web services in Java EE 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Messaging systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 Java Message Service (JMS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Message-driven EJBs (MDBs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Requirements for the development environment . . . . . . . . . . . . . . . . . . . . 72 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Chapter 3. Workbench setup and preferences . . . . . . . . . . . . . . . . . . . . . . 75 Workbench basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Workspace basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Application Developer logging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Automatic builds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Manual builds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 File associations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

iv

Rational Application Developer V7.5 Programming Guide

Draft Document for Review May 9, 2009 12:19 am

7672TOC.fm

Local history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 Perspectives preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Web Browser preferences. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Internet preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Java development preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 Java classpath variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 Appearance of Java elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 Code style and formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Java editor settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 Compiler options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 Installed JREs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 Chapter 4. Perspectives, views, and editors. . . . . . . . . . . . . . . . . . . . . . . 119 Integrated development environment (IDE) . . . . . . . . . . . . . . . . . . . . . . . . . . 120 Perspectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 Perspective layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Switching perspectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Specifying the default perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 Organizing and customizing perspectives. . . . . . . . . . . . . . . . . . . . . . . . . 124 Application Developer Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 Available perspectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Crystal Reports perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 CVS Repository Exploring perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 Data perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 Database Debug perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 Database Development perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 Debug perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 Java perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 Java Browsing perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Java EE perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 Java Type Hierarchy perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 JavaScript perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 Jazz Administration perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 JPA perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 Plug-in Development perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Profiling and Logging perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 Report Design perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 Requirement perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Resource perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 Team Synchronizing perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

Contents

v

7672TOC.fm

Draft Document for Review May 9, 2009 12:19 am

Test perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 Web perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 Work items perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 Progress view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 Chapter 5. Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 Java Enterprise Edition 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 Enterprise application modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 Web modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 EJB modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Application Client modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Resource adapter modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 Java utility libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 Project basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 Creating a new project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 Project properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 Deleting projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 Project interchange files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 Closing projects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 Java EE 5 project types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 Enterprise application project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 Application client project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 Dynamic Web project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 EJB project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 Connector project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 Utility project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 Project wizards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 Sample projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 Help system samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 Example projects wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 Part 2. Architecture and modeling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 Chapter 6. RUP, patterns, and SOA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 Rational Unified Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 RUP installation in Application Developer . . . . . . . . . . . . . . . . . . . . . . . . . 191 Process Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 Process Advisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 Process Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 Process preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 GoF patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

vi

Rational Application Developer V7.5 Programming Guide

Draft Document for Review May 9, 2009 12:19 am

7672TOC.fm

Architectural patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Enterprise patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 SOA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 Web services interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 Web Service Business Process Execution Language (WS-BPEL) . . . . . . 202 Additional information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 Chapter 7. Unified Modeling Language (UML) . . . . . . . . . . . . . . . . . . . . . 205 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 Constructing and visualizing applications using UML . . . . . . . . . . . . . . . . . . 206 Unified Modeling Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 Working with UML class diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 Creating class diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 Creating, editing, and viewing Java elements in UML class diagrams . . . 213 Creating, editing, and viewing EJBs in UML class diagrams . . . . . . . . . . 218 Creating, editing, and viewing WSDL elements in UML class diagrams. . 222 Class diagram preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 Exploring relationships in applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 Browse diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 Topic diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 Describing interactions with UML sequence diagrams. . . . . . . . . . . . . . . . . . 238 Creating sequence diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 Creating lifelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 Creating messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 Creating combined fragments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 Creating references to external diagrams . . . . . . . . . . . . . . . . . . . . . . . . . 246 Exploring Java methods by using static method sequence diagrams. . . . 247 Sequence diagram preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 More information on UML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 Part 3. Basic Java and XML development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 Chapter 8. Develop Java applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 Java perspectives, views, and editor overview . . . . . . . . . . . . . . . . . . . . . . . 254 Java perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 Package Explorer view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 Hierarchy view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 Outline view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 Problems view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 Declaration view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 Console view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 Call Hierarchy view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 Java Browsing perspective. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260

Contents

vii

7672TOC.fm

Draft Document for Review May 9, 2009 12:19 am

Java Type Hierarchy perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 Developing the ITSO Bank application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 ITSO Bank application overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 Packaging structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 Interfaces and classes overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 Interfaces and classes structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 Interface and class fields and getter and setter methods . . . . . . . . . . . . . 264 Interface methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 Class constructors and methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 Class diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 ITSO Bank application step-by-step development guide . . . . . . . . . . . . . . . . 270 Creating a Java project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 Creating a UML class diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 Creating Java packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 Creating Java interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 Creating Java classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 Creating Java attributes (fields) and getter and setter methods . . . . . . . . 281 Adding method declarations to an interface . . . . . . . . . . . . . . . . . . . . . . . 285 Adding constructors and Java methods to a class . . . . . . . . . . . . . . . . . . 288 Creating relationships between Java types. . . . . . . . . . . . . . . . . . . . . . . . 289 Implementing the classes and methods . . . . . . . . . . . . . . . . . . . . . . . . . . 292 Running the ITSO Bank application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 Creating a run configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 Understanding the sample code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 Additional features used for Java applications . . . . . . . . . . . . . . . . . . . . . 300 Using scripting inside the JRE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300 Analyzing source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302 Debugging a Java application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 Using the Java scrapbook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 Plugable Java Runtime Environment (JRE) . . . . . . . . . . . . . . . . . . . . . . . 308 Exporting Java applications to a JAR file . . . . . . . . . . . . . . . . . . . . . . . . . 309 Running Java applications external to Application Developer . . . . . . . . . 310 Importing Java resources from a JAR file into a project . . . . . . . . . . . . . . 311 Javadoc tooling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312 Generating Javadoc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312 Generate Javadoc. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 Generate Javadoc from an Ant script . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 Generate Javadoc with diagrams from existing tags . . . . . . . . . . . . . . . . 315 Generate Javadoc with diagrams automatically . . . . . . . . . . . . . . . . . . . . 316 Java editor and rapid application development . . . . . . . . . . . . . . . . . . . . . . . 317 Navigating through the code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 Using the Outline view to navigate the code . . . . . . . . . . . . . . . . . . . . . . . 318 Using the Package Explorer to navigate the code . . . . . . . . . . . . . . . . . . 319

viii

Rational Application Developer V7.5 Programming Guide

Draft Document for Review May 9, 2009 12:19 am

7672TOC.fm

Using bookmarks to navigate the code . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 Source folding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 Type hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 Smart insert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 Marking occurrences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 Smart compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 Java and file search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 Working sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 Quick fix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326 Quick assist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 Content assist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 Import generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 Adding constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 Delegate method generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 Refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339 Chapter 9. Accelerate development using patterns. . . . . . . . . . . . . . . . . 341 Introduction to pattern implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342 Pattern specification and pattern implementation . . . . . . . . . . . . . . . . . . . 342 Pattern implementation and Application Developer . . . . . . . . . . . . . . . . . 342 Prepare for the sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344 Creating a pattern implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345 Create a new JET Transform project . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345 Populating the transformation model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 Adding and deriving attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350 Generate and edit templates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354 Applying the pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364 Facade pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 Importing the facade example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 Facade transformation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 Running the transformation examples . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 Chapter 10. Develop XML applications . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 XML overview and associated technologies . . . . . . . . . . . . . . . . . . . . . . . . . 370 XML processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 DTDs and XML schemas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 XSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 XML namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 XPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 Application Developer XML tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 Creating an XML schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374

Contents

ix

7672TOC.fm

Draft Document for Review May 9, 2009 12:19 am

Generating HTML documentation from an XML schema file . . . . . . . . . . 383 Generating an XML file from an XML schema . . . . . . . . . . . . . . . . . . . . . 384 Editing an XML file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384 Working with XSL transformation files . . . . . . . . . . . . . . . . . . . . . . . . . . . 386 Transforming an XML file into an HTML file . . . . . . . . . . . . . . . . . . . . . . . 391 XML mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 Generating JavaBeans from an XML schema . . . . . . . . . . . . . . . . . . . . . 400 Service Data Objects and XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408 Part 4. Persistence application development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409 Chapter 11. Develop database applications . . . . . . . . . . . . . . . . . . . . . . . 411 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412 Connecting to the ITSOBANK database . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412 Connecting to databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413 Creating a connection to the ITSOBANK database . . . . . . . . . . . . . . . . . 413 Browsing a database with the Data Source Explorer . . . . . . . . . . . . . . . . 417 Creating SQL statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419 Creating a Data Development project . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419 Populating the transactions table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420 Creating a select statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421 Running the SQL query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427 Developing Java stored procedures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428 Creating a Java stored procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428 Deploying a Java stored procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432 Running the stored procedure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433 Developing SQLJ applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433 Creating SQLJ files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434 Examining the generated SQLJ file. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437 Testing the SQLJ program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438 Data modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439 Creating a Data Design project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440 Creating a physical data model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441 Modeling with diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444 Generating DDL from physical data model and deploy. . . . . . . . . . . . . . . 447 Analyzing the data model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450 Chapter 12. Persistence using the Java Persistence API (JPA) . . . . . . . 451 Introducing the Java Persistence API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452 Entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452 Mapping the table and columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454 Relationships. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455

x

Rational Application Developer V7.5 Programming Guide

Draft Document for Review May 9, 2009 12:19 am

7672TOC.fm

Entity inheritance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459 Persistence units. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459 Object-relational mapping through orm.xml . . . . . . . . . . . . . . . . . . . . . . . 460 Persistence provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460 Entity manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461 JPA query language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462 Developing JPA entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465 Setting up the ITSOBANK database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465 Creating a JPA project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466 Generating JPA entities from database tables . . . . . . . . . . . . . . . . . . . . . 468 Generated JPA entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469 Adding business logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473 Adding named queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475 Visualizing JPA entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476 Testing JPA entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478 Creating the Java project for entity testing . . . . . . . . . . . . . . . . . . . . . . . . 478 Creating a Java class for entity testing . . . . . . . . . . . . . . . . . . . . . . . . . . . 479 Setting up the build path for OpenJPA . . . . . . . . . . . . . . . . . . . . . . . . . . . 479 Setting up the persistence.xml file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482 Creating the test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483 Running the JPA entity test. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487 Displaying the SQL statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490 Adding inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491 Preparing the entities for deployment in the server . . . . . . . . . . . . . . . . . . . . 496 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497 Part 5. Enterprise application development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499 Chapter 13. Develop Web applications using JSPs and servlets . . . . . . 501 Introduction to Java EE Web applications . . . . . . . . . . . . . . . . . . . . . . . . . . . 502 Java EE applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503 Model-view-controller (MVC) pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507 Web development tooling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508 Web perspective and views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509 Web Site Navigation Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511 Web Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512 Page Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512 Page templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514 CSS Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514 Security Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515 File creation wizards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516 Summary of new features in v7.5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518

Contents

xi

7672TOC.fm

Draft Document for Review May 9, 2009 12:19 am

RedBank application design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518 Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518 View layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519 Controller layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520 Implementing the RedBank application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522 Creating the Web project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523 Importing the Java RedBank model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528 Defining the Web site navigation and appearance . . . . . . . . . . . . . . . . . . 529 Create frameset pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534 Customize frameset Web page areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536 Customize a style sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538 Verify the site navigation and page templates . . . . . . . . . . . . . . . . . . . . . 540 Developing the static Web resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541 Developing the dynamic Web resources. . . . . . . . . . . . . . . . . . . . . . . . . . 544 Working with JSPs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552 Web application testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564 Prerequisites to run the sample Web application . . . . . . . . . . . . . . . . . . . 564 Running the sample Web application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564 Verifying the RedBank Web application . . . . . . . . . . . . . . . . . . . . . . . . . . 564 RedBank Web application conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568 Chapter 14. Develop EJB applications . . . . . . . . . . . . . . . . . . . . . . . . . . . 571 Introduction to Enterprise JavaBeans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572 EJB 3.0 specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572 EJB 3.0 simplified model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572 EJB types and their definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574 Best practices for developing session EJBs . . . . . . . . . . . . . . . . . . . . . . . 579 Message-driven EBJ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580 Web services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581 Life cycle events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581 Interceptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583 Dependency injection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584 Using deployment descriptors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589 EJB 3.0 application packaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589 EJB features in Application Developer v7.5 . . . . . . . . . . . . . . . . . . . . . . . 589 Sample application overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 590 Preparing for the sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592 Required software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592 Enabling the EJB development capability . . . . . . . . . . . . . . . . . . . . . . . . . 592 Creating and configuring the EJB projects . . . . . . . . . . . . . . . . . . . . . . . . 593 Creating an EJB project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593 Make the JPA entities available to the EJB project . . . . . . . . . . . . . . . . . . 596

xii

Rational Application Developer V7.5 Programming Guide

Draft Document for Review May 9, 2009 12:19 am

7672TOC.fm

Setting up the ITSOBANK database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597 Configuring the data source for the ITSOBANK . . . . . . . . . . . . . . . . . . . . 597 Developing an EJB application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599 Implementing the session facade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599 Preparing an exception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599 Creating the EJBBank session bean. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600 Defining the business interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601 Completing the session bean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602 Testing the session EJB and the entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609 Testing with the Universal Test Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609 Creating a test Web application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612 Visualizing the test application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 616 Writing an EJB 3.0 Web application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617 Implementing the RAD75EJBWeb application . . . . . . . . . . . . . . . . . . . . . 617 Running the Web application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620 Cleanup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624 Adding a remote interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624 Complete EJB application interchange files . . . . . . . . . . . . . . . . . . . . . . . 625 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626 Chapter 15. Develop Web applications using Struts . . . . . . . . . . . . . . . . 627 Introduction to Struts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628 Model-view-controller (MVC) pattern with Struts. . . . . . . . . . . . . . . . . . . . 629 Application Developer support for Struts. . . . . . . . . . . . . . . . . . . . . . . . . . 632 Preparing for the sample application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633 Setting up the sample database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633 Configuring the data source in the WebSphere Server v7.0 . . . . . . . . . . . 633 Activating Struts development capabilities . . . . . . . . . . . . . . . . . . . . . . . . 633 ITSO Bank Struts Web application overview . . . . . . . . . . . . . . . . . . . . . . 634 Creating a Dynamic Web project with Struts support . . . . . . . . . . . . . . . . 636 Developing a Web application using Struts . . . . . . . . . . . . . . . . . . . . . . . . . . 639 Creating the Struts components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 640 Realizing the Struts components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645 Modify application resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646 Using the Struts validation framework. . . . . . . . . . . . . . . . . . . . . . . . . . . . 647 Page Designer and the Struts tag library . . . . . . . . . . . . . . . . . . . . . . . . . 648 Completing the logon action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652 Using the Struts Configuration Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654 Completing the application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 658 Complete the Web Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 658 Completing the application resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659 Complete the form beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659 Complete the actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659

Contents

xiii

7672TOC.fm

Draft Document for Review May 9, 2009 12:19 am

Complete the JSPs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 660 Complete the Web Diagram and Struts configuration file . . . . . . . . . . . . . 661 Study the sample code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661 Running the Struts Web application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 662 Developing a Struts Web application using Tiles . . . . . . . . . . . . . . . . . . . . . . 666 Enable the Struts Tiles support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 666 Building the Tiles application extension . . . . . . . . . . . . . . . . . . . . . . . . . . 667 Running the Tiles application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 670 Importing the final sample application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672 Chapter 16. Develop Web applications using JSF . . . . . . . . . . . . . . . . . . 673 Introduction to JSF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674 JavaServer Faces (JSF) overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674 Preparing for the sample JSF application . . . . . . . . . . . . . . . . . . . . . . . . . . . 679 Setting up the sample database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679 Configuring the data source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679 Developing a Web application using JSF and JPA . . . . . . . . . . . . . . . . . . . . 680 Project setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 680 Structure of the JSF Web application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683 Editing the Faces JSP pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689 Editing the login page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689 Creating a JPA manager bean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693 Editing the customer details page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700 Editing the account details page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705 Adding navigation between the pages . . . . . . . . . . . . . . . . . . . . . . . . . . . 708 Implementing deposit and withdraw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710 Running the JSF application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 712 Web Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714 Drop-down menu for customer login . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715 Adding a deluxe pager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716 Using the data source in the server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718 Cleanup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721 Final code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721 More information on JSF and AJAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721 Chapter 17. Develop Java EE application clients . . . . . . . . . . . . . . . . . . . 723 Introduction to Java EE application clients. . . . . . . . . . . . . . . . . . . . . . . . . . . 724 Overview of the sample application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 726 Preparing for the sample application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 727 Importing the base EJB enterprise application sample . . . . . . . . . . . . . . . 727 Setting up the sample database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728 Configuring the data source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728

xiv

Rational Application Developer V7.5 Programming Guide

Draft Document for Review May 9, 2009 12:19 am

7672TOC.fm

Testing the imported code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728 Developing the Java EE Application Client . . . . . . . . . . . . . . . . . . . . . . . . . . 729 Creating the Java EE application client projects . . . . . . . . . . . . . . . . . . . . 729 Configuring the Java EE application client projects . . . . . . . . . . . . . . . . . 731 Importing the graphical user interface and control classes . . . . . . . . . . . . 731 Creating the BankDesktopController class . . . . . . . . . . . . . . . . . . . . . . . . 733 Completing the BankDesktopController class . . . . . . . . . . . . . . . . . . . . . . 734 Creating an EJB reference and binding . . . . . . . . . . . . . . . . . . . . . . . . . . 735 Registering the BankDesktopController class as the main class . . . . . . . 737 Testing the Java EE Application Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738 Packaging the Java EE Application Client . . . . . . . . . . . . . . . . . . . . . . . . . . . 741 Running the deployed application client . . . . . . . . . . . . . . . . . . . . . . . . . . 742 Chapter 18. Develop Web services applications . . . . . . . . . . . . . . . . . . . 743 Introduction to Web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744 Service-oriented architecture (SOA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744 Web services as an SOA implementation . . . . . . . . . . . . . . . . . . . . . . . . . 745 Related Web services standards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747 JAX-WS programming model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749 Better platform independence for Java applications . . . . . . . . . . . . . . . . . 749 Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 750 Invoking Web services asynchronously . . . . . . . . . . . . . . . . . . . . . . . . . . 750 Data binding with JAXB 2.0 and 2.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 752 Dynamic and static clients. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 752 MTOM support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 752 Multiple payload structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 753 SOAP 1.2 support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 753 Web services development approaches . . . . . . . . . . . . . . . . . . . . . . . . . . . . 753 Web services tools in Application Developer . . . . . . . . . . . . . . . . . . . . . . . . . 754 Creating a Web service from existing resources. . . . . . . . . . . . . . . . . . . . 754 Creating a skeleton Web service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 754 Client development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755 Testing tools for Web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755 Preparing for the samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 756 Import the sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 756 Test the application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 757 Creating bottom-up Web services from a JavaBean . . . . . . . . . . . . . . . . . . . 757 Creating a Web service using annotations . . . . . . . . . . . . . . . . . . . . . . . . 758 Creating Web services using the Web Service wizard . . . . . . . . . . . . . . . 766 Resources generated by the Web Service wizard . . . . . . . . . . . . . . . . . . 771 Creating a synchronous Web service JSP client . . . . . . . . . . . . . . . . . . . . . . 772 Resources generated by the Web Service client wizard . . . . . . . . . . . . . . 777 Creating a Web service JSF client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 778

Contents

xv

7672TOC.fm

Draft Document for Review May 9, 2009 12:19 am

Creating a Web service thin client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 783 Creating asynchronous Web service clients . . . . . . . . . . . . . . . . . . . . . . . . . 786 Polling client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 786 Callback client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 788 Asynchronous message exchange client . . . . . . . . . . . . . . . . . . . . . . . . . 790 Creating Web services from an EJB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 793 Creating a top-down Web service from a WSDL . . . . . . . . . . . . . . . . . . . . . . 794 Designing the WSDL using the WSDL editor . . . . . . . . . . . . . . . . . . . . . . 795 Generating the skeleton JavaBean Web service . . . . . . . . . . . . . . . . . . . 800 Test the generated Web service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 801 Creating Web services with Ant tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 802 Running the Web service Ant task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803 Sending binary data using MTOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803 Create a Web service project and import the WSDL . . . . . . . . . . . . . . . . 804 Generate the Web service and client . . . . . . . . . . . . . . . . . . . . . . . . . . . . 805 Implement the JavaBean skeleton . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 807 Test and monitor the MTOM enabled Web service. . . . . . . . . . . . . . . . . . 809 Enabling MTOM on the client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 811 Web services security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 813 Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 813 Message integrity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 814 Message confidentiality. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 814 Policy set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 815 Apply WS-Security to a Web service and client . . . . . . . . . . . . . . . . . . . . 815 WS-I Reliable Secure Profile. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 820 WS-Policy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 821 Configuring a service provider to share its policy configuration . . . . . . . . 822 Configuring the client policy using a service provider policy . . . . . . . . . . . 823 WS-MetadataExchange (WS-MEX) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 825 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 827 Chapter 19. Develop Web applications using Web 2.0 . . . . . . . . . . . . . . 829 Introduction to Web 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 830 Web 2.0 definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 830 Web 2.0 application architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 830 Supporting technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 833 Web 2.0 features in Application Developer v7.5 . . . . . . . . . . . . . . . . . . . . . . 836 Preparing for the sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 837 Setting up the sample database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 837 Create a database connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 837 Configuring the data source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 838 Developing a Web 2.0 using JSF, Ajax Proxy, and JPA . . . . . . . . . . . . . . . . 838 Project setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 838

xvi

Rational Application Developer V7.5 Programming Guide

Draft Document for Review May 9, 2009 12:19 am

7672TOC.fm

Structure of the Web 2.0 sample application . . . . . . . . . . . . . . . . . . . . . . 840 Adding type-ahead control to the login page. . . . . . . . . . . . . . . . . . . . . . . 841 Adding Ajax refresh submit behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . 847 Cleanup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 852 Developing a Web 2.0 application using Dojo and RPC . . . . . . . . . . . . . . . . 853 Project setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 853 Architecture of the Web 2.0 application . . . . . . . . . . . . . . . . . . . . . . . . . . 853 Exposing an RPC Adapter service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 854 RPC Adapter Configuration Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 857 Creating an RPC Converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858 Creating a service using a servlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858 Testing the services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 860 Creating the Web page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 861 Examining the Dojo components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 866 Application flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 867 Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 871 Running the application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 872 Cleanup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 874 Final code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 874 More information on Web 2.0 technologies . . . . . . . . . . . . . . . . . . . . . . . . . . 875 Chapter 20. Develop applications to connect to enterprise information systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 877 Introduction to Java EE Connector Architecture . . . . . . . . . . . . . . . . . . . . . . 878 System contracts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 878 Resource adapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 880 Common Client Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 881 WebSphere Adapters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 881 Application development for EIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 882 Importers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 882 J2C wizards. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 882 What is new in Application Developer v7.5 . . . . . . . . . . . . . . . . . . . . . . . . . . 884 Tooling for WebSphere Adapters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 884 Deployment of Websphere Adapters to WebSphere Application Server . 885 J2C Java bean deployment: EJB 2.1 and 3.0 support . . . . . . . . . . . . . . . 886 J2C Java bean deployment: Web services support . . . . . . . . . . . . . . . . . 886 CICS container link support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 887 MFS support for IMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 887 Sample application overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 887 CICS outbound scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 888 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 888 Creating the Java data binding class . . . . . . . . . . . . . . . . . . . . . . . . . . . . 889 Creating the J2C bean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 890

Contents

xvii

7672TOC.fm

Draft Document for Review May 9, 2009 12:19 am

Deploying the J2C bean as an EJB 3.0 session bean . . . . . . . . . . . . . . . 893 Generating a JSF client. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 894 Running the JSF client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 897 CICS channel outbound scenario. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 898 Creating the Java data binding for the channel and containers . . . . . . . . 898 Creating the J2C bean that accesses the channel . . . . . . . . . . . . . . . . . . 902 Develop a Web service to invoke the COBOL program . . . . . . . . . . . . . . 904 Testing the Web service with CICS access . . . . . . . . . . . . . . . . . . . . . . . 907 SAP outbound scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 909 Required software and configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 909 Creating a Connector Project and J2C bean . . . . . . . . . . . . . . . . . . . . . . 909 Generating the sample Web application . . . . . . . . . . . . . . . . . . . . . . . . . . 916 Testing the Web application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 917 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 918 Chapter 21. Develop portal applications. . . . . . . . . . . . . . . . . . . . . . . . . . 919 Introduction to portal technology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 920 Portal concepts and definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 920 IBM WebSphere Portal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 923 Portal and portlet development features in Application Developer . . . . . . 924 Setting up Application Developer with the Portal test environment. . . . . . 926 Developing applications for WebSphere Portal . . . . . . . . . . . . . . . . . . . . . . . 926 Portal samples and tutorials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 926 Development strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 927 Portal tools for developing portals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 930 New Websphere portal development tools in Application Developer v7.5 . . . 935 Developing portal solutions using portal tools . . . . . . . . . . . . . . . . . . . . . . . . 943 Developing eventing portlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 943 Deploying and running the event handling portlets . . . . . . . . . . . . . . . . . . 948 Creating Ajax and Web 2.0 portlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 951 Deploying and running the application . . . . . . . . . . . . . . . . . . . . . . . . . . . 954 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 955 Part 6. Test and debug applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 957 Chapter 22. Servers and server configuration . . . . . . . . . . . . . . . . . . . . . 959 Introduction to server configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 960 Application servers supported by Rational Application Developer 7.5 . . . 960 Local and remote test environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 962 Understanding WebSphere Application Server v7.0 profiles . . . . . . . . . . . . . 963 Types of profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 964 WebSphere Application Server v7.0 installation . . . . . . . . . . . . . . . . . . . . . . 965 Using WebSphere Application Server v7.0 profiles . . . . . . . . . . . . . . . . . . . . 966 Creating a new profile using the WebSphere Profile wizard . . . . . . . . . . . 966

xviii

Rational Application Developer V7.5 Programming Guide

Draft Document for Review May 9, 2009 12:19 am

7672TOC.fm

Verifying the new WebSphere profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . 969 Deleting a WebSphere profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 971 Defining the new server in Application Developer. . . . . . . . . . . . . . . . . . . 971 Customizing a server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 974 Sharing a WebSphere profile between developers . . . . . . . . . . . . . . . . . . 977 Defining a server for each workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . 978 Adding and removing applications to and from a server . . . . . . . . . . . . . . . . 979 Adding an application to the server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 979 Removing an application from a server. . . . . . . . . . . . . . . . . . . . . . . . . . . 980 Configuring application and server resources . . . . . . . . . . . . . . . . . . . . . . . . 981 Creating a data source in the enhanced EAR . . . . . . . . . . . . . . . . . . . . . . 983 Setting substitution variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 987 Configuring server resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 987 Configuring security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 988 Configuring security in the server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 988 Configuring security in the Workbench . . . . . . . . . . . . . . . . . . . . . . . . . . . 990 Developing automation scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 991 Creating a Jython project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 991 Creating Jython script files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 991 Editing Jython script files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 992 Running administrative script files on WebSphere Application Server . . . 992 Generating WebSphere admin commands for Jython scripts . . . . . . . . . . 994 Debugging Jython scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 997 Jython script for application deployment . . . . . . . . . . . . . . . . . . . . . . . . . . 997 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 998 Chapter 23. Test using JUnit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 999 Introduction to application testing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1000 Test concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1000 Test phases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1000 Test environments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1002 Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1003 Test case execution and recording results . . . . . . . . . . . . . . . . . . . . . . . 1003 Benefits of unit and component testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1003 Benefits of testing frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1004 Test & Performance Tools Platform (TPTP). . . . . . . . . . . . . . . . . . . . . . . . . 1005 JUnit testing without TPTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1005 JUnit fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1006 What is new in JUnit 4.x? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1006 Prepare the JUnit sample. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1010 Creating a JUnit test case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1011 Creating a JUnit test suite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1015 Running the JUnit test case or JUnit test suite . . . . . . . . . . . . . . . . . . . . 1017

Contents

xix

7672TOC.fm

Draft Document for Review May 9, 2009 12:19 am

JUnit testing of JPA entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1018 Prepare the JPA unit testing sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1018 Setting up the ITSOBANK database . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1019 Configure the RAD75JUnit project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1019 Creating a JUnit test case for a JPA entity . . . . . . . . . . . . . . . . . . . . . . . 1020 Setting up the persistence.xml file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1021 Running the JPA unit test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1022 JUnit testing using TPTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1024 Creating the TPTP JUnit sample. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1024 Running the TPTP JUnit test. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1028 Analyzing the test results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1028 Web application testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1031 Preparing for the sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1031 Recording a test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1032 Editing the test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1034 Generating an executable test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1036 Running the test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1036 Analyzing the test results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1036 Generating test reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1038 Cleaning the workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1040 Chapter 24. Debug local and remote applications . . . . . . . . . . . . . . . . . 1041 Summary of new features in v7.5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1042 Overview of Application Developer debugging tools . . . . . . . . . . . . . . . . . . 1042 Supported languages and environments . . . . . . . . . . . . . . . . . . . . . . . . 1042 Basic Java debugging features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1043 XSLT debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1047 Remote debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1049 Stored procedure debugging for DB2 V9 . . . . . . . . . . . . . . . . . . . . . . . . 1050 Collaborative debugging using Rational Team Concert Client . . . . . . . . 1050 Debugging a Web application on a local server . . . . . . . . . . . . . . . . . . . . . . 1051 Importing the sample application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1051 Running the sample application in debug mode . . . . . . . . . . . . . . . . . . . 1052 Setting breakpoints in a Java class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1053 Debug perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1055 Watching variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1056 Evaluating and watching expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . 1057 Using the Display view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1058 Working with breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1058 Set breakpoints in a JSP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1059 Debugging a JSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1060 Debugging a Web application on a remote server . . . . . . . . . . . . . . . . . . . . 1062 Exporting the RedBank as an EAR file . . . . . . . . . . . . . . . . . . . . . . . . . . 1063

xx

Rational Application Developer V7.5 Programming Guide

Draft Document for Review May 9, 2009 12:19 am

7672TOC.fm

Deploying the RedBank application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1063 Configuring debug on a remote WebSphere Application Server . . . . . . 1064 Attaching to the remote server in Application Developer . . . . . . . . . . . . 1065 Debugging a remote application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1067 Uninstalling the remote application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1067 Jython debugger. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1068 Debugging a sample Jython script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1068 Debug extension for Rational Team Concert Client (Team Debug) . . . . . . . 1071 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1071 Supported environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1072 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1072 Sharing a Java debug session by transferring it to another user . . . . . . 1073 Sharing a WebSphere Application Server debug session . . . . . . . . . . . 1077 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1079 Part 7. Deploy and profile applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1081 Chapter 25. Build applications with Ant . . . . . . . . . . . . . . . . . . . . . . . . . 1083 Introduction to Ant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1084 Ant build files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1084 Ant tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1085 Ant features in Application Developer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1085 Preparing for the sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1086 Creating a build file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1087 Project definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1088 Global properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1088 Build targets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1089 Content assist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1090 Code snippets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1091 Formatting an Ant script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1094 Defining the format of an Ant script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1094 Problems view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1095 Building a simple Java application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1096 Running Ant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1097 Ant console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1099 Rerun Ant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1099 Forced build . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1100 Classpath problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1100 Running the sample application to verify the Ant build . . . . . . . . . . . . . . 1101 Building a Java EE application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1101 Java EE application deployment packaging . . . . . . . . . . . . . . . . . . . . . . 1101 Preparing for the sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1102 Creating the build script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1103

Contents

xxi

7672TOC.fm

Draft Document for Review May 9, 2009 12:19 am

Running the Ant Java EE application build . . . . . . . . . . . . . . . . . . . . . . . 1105 Running Ant outside of Application Developer . . . . . . . . . . . . . . . . . . . . . . . 1107 Preparing for the headless build . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1107 Running the headless Ant build script . . . . . . . . . . . . . . . . . . . . . . . . . . . 1108 Using the Rational Application Developer Build Utility . . . . . . . . . . . . . . . . . 1108 Example of using the build utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1109 More information on Ant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1112 Chapter 26. Deploy enterprise applications . . . . . . . . . . . . . . . . . . . . . . 1113 Introduction to application deployment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1114 Common deployment considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . 1114 Java EE application components and deployment modules . . . . . . . . . . 1115 Deployment descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1115 WebSphere deployment architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . 1119 Java and WebSphere class loader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1126 Preparing for the deployment of the EJB application . . . . . . . . . . . . . . . . . . 1130 Reviewing the deployment scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . 1130 Installing the prerequisite software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1131 Importing the sample application project interchange files . . . . . . . . . . . 1132 Sample database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1132 Packaging the application for deployment . . . . . . . . . . . . . . . . . . . . . . . . . . 1133 Removing the enhanced EAR data source . . . . . . . . . . . . . . . . . . . . . . . 1133 Generating the deploy code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1134 Exporting the EAR files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1134 Manual deployment of enterprise applications . . . . . . . . . . . . . . . . . . . . . . . 1135 Configuring the data source in the application server . . . . . . . . . . . . . . . 1136 Installing the enterprise applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1142 Starting the enterprise applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1145 Verifying the application after manual installation . . . . . . . . . . . . . . . . . . 1146 Uninstalling the application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1147 Automated deployment using Jython based wsadmin scripting . . . . . . . . . . 1148 Overview of wsadmin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1148 Overview of Jython . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1149 Developing a Jython script to deploy the ITSO Bank . . . . . . . . . . . . . . . 1150 Executing the Jython script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1158 Verifying the application after automatic installation . . . . . . . . . . . . . . . . 1160 Generation Jython source code for wsadmin commands . . . . . . . . . . . . 1161 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1161 Chapter 27. Profile applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1163 Introduction to profiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1164 Profiling features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1164 Profiling architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1167

xxii

Rational Application Developer V7.5 Programming Guide

Draft Document for Review May 9, 2009 12:19 am

7672TOC.fm

Profiling and Logging perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1169 Preparing for the profiling sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1170 Prerequisite software installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1170 Enabling the Profiling and Logging capability . . . . . . . . . . . . . . . . . . . . . 1170 Profiling a Java application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1172 Importing the sample project interchange file . . . . . . . . . . . . . . . . . . . . . 1172 Creating a profiling configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1173 Running the EntityTester application . . . . . . . . . . . . . . . . . . . . . . . . . . . 1175 Analyzing profiling data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1175 Execution statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1176 Execution flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1180 UML sequence diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1181 Memory statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1182 Thread analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1184 Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1185 Clean up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1185 Profiling a Web application running on the server . . . . . . . . . . . . . . . . . . . . 1185 Importing the sample project interchange file . . . . . . . . . . . . . . . . . . . . . 1185 Publishing and running sample application . . . . . . . . . . . . . . . . . . . . . . . 1186 Starting the server in profiling mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1187 Profile on server: Execution Time Analysis . . . . . . . . . . . . . . . . . . . . . . . 1188 Run the sample application to collect profiling data . . . . . . . . . . . . . . . . 1189 Statistic views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1189 Execution statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1190 Execution flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1192 UML sequence diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1194 Refreshing the views and resetting data . . . . . . . . . . . . . . . . . . . . . . . . . 1194 Ending the profiling session . . . . . . . . . . . . . . . . . . . . . . . . . . . .