Upload
maldoreur
View
247
Download
0
Embed Size (px)
DESCRIPTION
In this part, we introduce IBM Rational Application Developer for WebSphere Software. The introduction includes packaging, product features, the Eclipse base, installation, licensing, migration, and an overview of the tools. We then discuss setting up the Workbench, the perspectives, views, and editors, the different types of projects, and introduce Unified Modeling Language.
Citation preview
ibm.com/redbooks
Draft Document for Review February 8, 2011 12:56 pm SG24-7835-00
Rational Application Developer for WebSphere Software V8 Programming Guide
Brian HaineyMartin Keen
G V Krishna KumariSylvi Lippmann
Salvatore SollamiSundaragopalVenkatraman
Lara Ziosi
Develop applications using Java EE 6 and beyond
Test, debug, and profile with local and remote servers
Deploy applications to WebSphere servers
Front cover
Steve BaberRafael Coutinho
Henry CuiCraig Fleming
Rational Application Developer for WebSphere Software V8 Programming Guide
January 2011
International Technical Support Organization
Draft Document for Review February 8, 2011 12:56 pm 7835edno.fm
SG24-7835-00
7835edno.fm Draft Document for Review February 8, 2011 12:56 pm
Copyright International Business Machines Corporation 2010. All rights reserved.Note to U.S. Government Users Restricted Rights -- Use, duplication or disclosure restricted by GSA ADPSchedule Contract with IBM Corp.
First Edition (January 2011)This edition applies to IBM Rational Application Developer for WebSphere Software Version 8.0.1 and to IBM WebSphere Application Server Version 7.0 and WebSphere Application Server V8.0 beta.
This document created or updated on February 8, 2011.
Note: Before using this information and the product it supports, read the information in Notices on page xxxi.
Draft Document for Review February 8, 2011 12:56 pm 7835TOC.fmContents
Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxiTrademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxxii
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxiiiThe team who wrote this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxiii
Residency team in Raleigh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxiiiResidency team working remotely . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxvRational Application Developer development team authors . . . . . . . . . . xxxviAdditional contributors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxviii
Now you can become a published author, too! . . . . . . . . . . . . . . . . . . . . . . . . . xlComments welcome. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xliStay connected to IBM Redbooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xli
Part 1. Introduction to Rational Application Developer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.1 Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1.1 IBM Rational Software Delivery Platform . . . . . . . . . . . . . . . . . . . . . . 41.1.2 Eclipse and IBM Rational Software Delivery Platform . . . . . . . . . . . . 71.1.3 Challenges in application development. . . . . . . . . . . . . . . . . . . . . . . . 9
1.2 Rational Application Developer supported platforms and databases . . . . . 91.2.1 Supported operating system platforms . . . . . . . . . . . . . . . . . . . . . . . 101.2.2 Supported runtime environments . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.3 New features and specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.3.1 New features in Rational Application Developer . . . . . . . . . . . . . . . . 121.3.2 Specification versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.4 Migration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141.5 Sample code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Chapter 2. Programming technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.1 Desktop applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.1.1 Simple desktop applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182.1.2 Database access. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.1.3 Graphical user interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232.1.4 Extensible Markup Language (XML). . . . . . . . . . . . . . . . . . . . . . . . . 26
2.2 Web applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272.2.1 Hypertext Transfer Protocol (HTTP) . . . . . . . . . . . . . . . . . . . . . . . . . 282.2.2 Hypertext Markup Language (HTML) . . . . . . . . . . . . . . . . . . . . . . . . 30 Copyright IBM Corp. 2010. All rights reserved. iii
7835TOC.fm Draft Document for Review February 8, 2011 12:56 pm2.2.3 Dynamic web applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312.2.4 JavaServer Faces and persistence using JPA . . . . . . . . . . . . . . . . . 392.2.5 Web 2.0 development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402.2.6 Portal applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.3 Enterprise JavaBeans and Java Persistence API . . . . . . . . . . . . . . . . . . . 462.3.1 EJB 3.1 specification: What is new . . . . . . . . . . . . . . . . . . . . . . . . . . 472.3.2 Types of EJB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482.3.3 Java Persistence API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492.3.4 Other EJB and JPA features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
2.4 Web services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522.4.1 Interoperatility considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532.4.2 Web services in Java EE 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
2.5 Messaging systems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582.5.1 Java Message Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592.5.2 Message-driven beans (MDBs). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592.5.3 Requirements for the development environment . . . . . . . . . . . . . . . 60
2.6 OSGi applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612.6.1 OSGi features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612.6.2 Benefits of OSGi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
2.7 Other applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 622.7.1 Java EE application clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632.7.2 Enterprise information system applications. . . . . . . . . . . . . . . . . . . . 662.7.3 Service Component Architecture applications . . . . . . . . . . . . . . . . . 662.7.4 Session Initiation Protocol applications. . . . . . . . . . . . . . . . . . . . . . . 672.7.5 Communications Enabled Applications (CEA) . . . . . . . . . . . . . . . . . 67
Chapter 3. Workbench setup and preferences . . . . . . . . . . . . . . . . . . . . . . 693.1 Workbench basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3.1.1 Workbench basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733.2 Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
3.2.1 Automatic builds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803.2.2 Manual builds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 813.2.3 File associations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 813.2.4 Content types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 833.2.5 Local history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 833.2.6 Perspective preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 853.2.7 Web browser preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 863.2.8 Internet preference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Chapter 4. Perspectives, views, and editors. . . . . . . . . . . . . . . . . . . . . . . . 894.1 Integrated development environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
4.1.1 Perspectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 904.1.2 Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90iv Rational Application Developer for WebSphere Software V8 Programming Guide
Draft Document for Review February 8, 2011 12:56 pm 7835TOC.fm4.1.3 Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 914.1.4 Perspective layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 924.1.5 Switching perspectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 934.1.6 Specifying the default perspective . . . . . . . . . . . . . . . . . . . . . . . . . . 954.1.7 Organizing and customizing perspectives. . . . . . . . . . . . . . . . . . . . . 96
4.2 Help system for Rational Application Developer . . . . . . . . . . . . . . . . . . . . 984.2.1 Context sensitive help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
4.3 Available perspectives. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1024.3.1 CVS Repository Exploring perspective . . . . . . . . . . . . . . . . . . . . . . 1044.3.2 Data perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1054.3.3 Database Debug perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1084.3.4 Database Development perspective . . . . . . . . . . . . . . . . . . . . . . . . 1094.3.5 Debug perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1104.3.6 Java perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1124.3.7 Java Browsing perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1134.3.8 Java EE perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1154.3.9 Java Type Hierarchy perspective . . . . . . . . . . . . . . . . . . . . . . . . . . 1164.3.10 JavaScript perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1184.3.11 JPA perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1194.3.12 Modeling perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1214.3.13 Plug-in Development perspective . . . . . . . . . . . . . . . . . . . . . . . . . 1224.3.14 Profiling and Logging perspective . . . . . . . . . . . . . . . . . . . . . . . . . 1244.3.15 Report Design perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1254.3.16 Resource perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1264.3.17 Team Synchronizing perspective . . . . . . . . . . . . . . . . . . . . . . . . . 1274.3.18 Test perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1294.3.19 Web perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1304.3.20 XML perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1344.3.21 Progress view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
4.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Chapter 5. Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1395.1 Java Enterprise Edition 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
5.1.1 Enterprise application modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1425.1.2 Web modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1435.1.3 EJB modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1435.1.4 Application client modules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1445.1.5 Resource adapter modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1445.1.6 Java utility libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
5.2 Project basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1445.2.1 Creating a new project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1455.2.2 Project properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1535.2.3 Deleting projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 Contents v
7835TOC.fm Draft Document for Review February 8, 2011 12:56 pm5.2.4 Transferring projects between workspaces. . . . . . . . . . . . . . . . . . . 1545.2.5 Closing projects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
5.3 Java EE 6 project types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1555.3.1 Enterprise application project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1565.3.2 Application client project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1575.3.3 Dynamic web project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1575.3.4 EJB project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1585.3.5 Connector project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1595.3.6 Utility project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
5.4 Project wizards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1605.5 Sample projects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
5.5.1 Help system samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1655.5.2 Example projects wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
5.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Chapter 6. Unified Modeling Language . . . . . . . . . . . . . . . . . . . . . . . . . . . 1716.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1726.2 Constructing and visualizing applications using UML . . . . . . . . . . . . . . . 172
6.2.1 UML visualization capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1746.2.2 Unified Modeling Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
6.3 Working with UML class diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1786.3.1 Creating class diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1796.3.2 Creating, editing, viewing Java elements in UML class diagrams . 1826.3.3 Creating, editing, and viewing EJB components in UML class diagrams
1866.3.4 Creating, editing, and viewing WSDL elements in UML class diagrams
1926.3.5 Class diagram preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
6.4 Exploring relationships in applications . . . . . . . . . . . . . . . . . . . . . . . . . . 2046.4.1 Browse diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2046.4.2 Topic diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
6.5 Describing interactions with UML sequence diagrams . . . . . . . . . . . . . . 2106.5.1 Creating sequence diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2126.5.2 Creating lifelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2136.5.3 Creating messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2146.5.4 Creating combined fragments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2166.5.5 Creating references to external diagrams . . . . . . . . . . . . . . . . . . . . 2196.5.6 Exploring Java methods with static method sequence diagrams . . 2206.5.7 Sequence diagram preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
6.6 More information about UML. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
Part 2. Basic Java and XML development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Chapter 7. Developing Java applications . . . . . . . . . . . . . . . . . . . . . . . . . 227vi Rational Application Developer for WebSphere Software V8 Programming Guide
Draft Document for Review February 8, 2011 12:56 pm 7835TOC.fm7.1 Java perspectives, views, and editor overview . . . . . . . . . . . . . . . . . . . . 2287.2 Java perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
7.2.1 Package Explorer view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2307.2.2 Hierarchy view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2317.2.3 Outline view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2317.2.4 Problems view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2327.2.5 Declaration view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2347.2.6 Console view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2357.2.7 Call Hierarchy view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
7.3 Java Browsing perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2377.4 Java Type Hierarchy perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2377.5 Developing the ITSO Bank application . . . . . . . . . . . . . . . . . . . . . . . . . . 238
7.5.1 ITSO Bank application overview . . . . . . . . . . . . . . . . . . . . . . . . . . . 2387.5.2 Packaging structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2387.5.3 Interfaces and classes overview . . . . . . . . . . . . . . . . . . . . . . . . . . . 2397.5.4 Interfaces and classes structure . . . . . . . . . . . . . . . . . . . . . . . . . . . 2407.5.5 Interface and class fields and getter and setter methods . . . . . . . . 2417.5.6 Interface methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2427.5.7 Class constructors and methods. . . . . . . . . . . . . . . . . . . . . . . . . . . 2447.5.8 Class diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
7.6 ITSO Bank application step-by-step development guide . . . . . . . . . . . . 2487.6.1 Creating a Java project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2487.6.2 Creating a UML class diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2527.6.3 Creating Java packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2537.6.4 Creating Java interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2557.6.5 Creating Java classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2567.6.6 Creating Java attributes (fields) and getter and setter methods . . . 2607.6.7 Adding method declarations to an interface . . . . . . . . . . . . . . . . . . 2667.6.8 Adding constructors and Java methods to a class . . . . . . . . . . . . . 2687.6.9 Creating relationships between Java types. . . . . . . . . . . . . . . . . . . 2697.6.10 Implementing the classes and methods . . . . . . . . . . . . . . . . . . . . 2737.6.11 Running the ITSO Bank application . . . . . . . . . . . . . . . . . . . . . . . 2747.6.12 Creating a run configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2757.6.13 Understanding the sample code . . . . . . . . . . . . . . . . . . . . . . . . . . 2777.6.14 Additional features used for Java applications . . . . . . . . . . . . . . . 2817.6.15 Using scripting inside the JRE . . . . . . . . . . . . . . . . . . . . . . . . . . . 2827.6.16 Analyzing the source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2847.6.17 Debugging a Java application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
7.7 Using the Java scrapbook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2887.7.1 Pluggable Java Runtime Environment . . . . . . . . . . . . . . . . . . . . . . 2907.7.2 Exporting Java applications to a JAR file . . . . . . . . . . . . . . . . . . . . 2917.7.3 Running Java applications external to Rational Application Developer
294 Contents vii
7835TOC.fm Draft Document for Review February 8, 2011 12:56 pm7.7.4 Importing Java resources from a JAR file into a project . . . . . . . . . 2957.7.5 Javadoc tooling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
7.8 Generating the Javadoc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2977.8.1 Generating the Javadoc from an existing project . . . . . . . . . . . . . . 2977.8.2 Generating Javadoc from an Ant script . . . . . . . . . . . . . . . . . . . . . . 2997.8.3 Generating the Javadoc with diagrams from existing tags . . . . . . . 2997.8.4 Generating Javadoc with diagrams automatically . . . . . . . . . . . . . . 301
7.9 Java editor and rapid application development . . . . . . . . . . . . . . . . . . . . 3027.9.1 Navigating through the code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3037.9.2 Source folding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3057.9.3 Type hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3077.9.4 Smart insert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3077.9.5 Marking occurrences. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3077.9.6 Smart compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3087.9.7 Java and file search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3087.9.8 Working sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3127.9.9 Quick fix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3137.9.10 Quick assist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3147.9.11 Content assist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3157.9.12 Import generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3167.9.13 Adding constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3177.9.14 Using the delegate method generator. . . . . . . . . . . . . . . . . . . . . . 3207.9.15 Refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
7.10 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
Chapter 8. Developing XML applications . . . . . . . . . . . . . . . . . . . . . . . . . 3298.1 XML overview and associated technologies . . . . . . . . . . . . . . . . . . . . . . 330
8.1.1 XML processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3308.1.2 DTDs and XML schemas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3318.1.3 XSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3328.1.4 XML namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3338.1.5 XPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3338.1.6 XML Catalog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
8.2 Rational Application Developer XML tools . . . . . . . . . . . . . . . . . . . . . . . 3348.2.1 Creating an XML schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3358.2.2 Generating HTML documentation from an XML schema file . . . . . 3478.2.3 Generating an XML file from an XML schema . . . . . . . . . . . . . . . . 3488.2.4 Editing an XML file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3498.2.5 Working with XSL transformation files . . . . . . . . . . . . . . . . . . . . . . 3518.2.6 Transforming an XML file into an HTML file . . . . . . . . . . . . . . . . . . 3558.2.7 XML mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
8.3 Service Data Objects and XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3678.3.1 Generating SDOs from an XML schema. . . . . . . . . . . . . . . . . . . . . 368viii Rational Application Developer for WebSphere Software V8 Programming Guide
Draft Document for Review February 8, 2011 12:56 pm 7835TOC.fm8.3.2 Marshal SDO objects to XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3698.3.3 Unmarshal XML to an SDO data graph . . . . . . . . . . . . . . . . . . . . . 372
8.4 JAXB and XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3758.4.1 Generating JAXB classes from an XML schema . . . . . . . . . . . . . . 3768.4.2 Marshal JAXB objects to XML. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3788.4.3 Unmarshal the XML file to JAXB objects . . . . . . . . . . . . . . . . . . . . 3808.4.4 JAXB customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
8.5 Feature Pack for XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3848.6 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
Part 3. Persistence and enterprise information system integration development . . . . . 387
Chapter 9. Developing database applications . . . . . . . . . . . . . . . . . . . . . 3899.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3909.2 Connecting to the ITSOBANK database . . . . . . . . . . . . . . . . . . . . . . . . . 390
9.2.1 Connecting to databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3919.2.2 Creating a connection to the ITSOBANK database . . . . . . . . . . . . 3919.2.3 Browsing a database with the Data Source Explorer . . . . . . . . . . . 395
9.3 Creating SQL statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3979.3.1 Creating a Data Development project . . . . . . . . . . . . . . . . . . . . . . . 3989.3.2 Populating the transactions table . . . . . . . . . . . . . . . . . . . . . . . . . . 3999.3.3 Creating a select statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4009.3.4 Running the SQL query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
9.4 Developing Java stored procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4099.4.1 Creating a Java stored procedure. . . . . . . . . . . . . . . . . . . . . . . . . . 4099.4.2 Deploying a Java stored procedure . . . . . . . . . . . . . . . . . . . . . . . . 4139.4.3 Running the stored procedure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
9.5 Developing SQLJ applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4159.5.1 Creating SQLJ files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4169.5.2 Examining the generated SQLJ file. . . . . . . . . . . . . . . . . . . . . . . . . 4209.5.3 Testing the SQLJ program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
9.6 Data modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4229.6.1 Creating a Data Design project . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4239.6.2 Creating a physical data model. . . . . . . . . . . . . . . . . . . . . . . . . . . . 4249.6.3 Modeling with diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4289.6.4 Generating DDL from physical data model and deploy. . . . . . . . . . 4319.6.5 Analyzing the data model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
9.7 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
Chapter 10. Persistence using the Java Persistence API . . . . . . . . . . . . 43710.1 Introducing the Java Persistence API . . . . . . . . . . . . . . . . . . . . . . . . . . 438
10.1.1 JPA entity object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43910.1.2 Object-rational mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44010.1.3 Entity inheritance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447 Contents ix
7835TOC.fm Draft Document for Review February 8, 2011 12:56 pm10.1.4 Persistence units. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44810.1.5 Entity manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44910.1.6 JPA Manager Bean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45110.1.7 Java Persistence Query Language . . . . . . . . . . . . . . . . . . . . . . . . 45310.1.8 Criteria API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45710.1.9 Persistence provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45910.1.10 JPA 2.0 enhancements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
10.2 Create a JPA project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46210.2.1 Setting up the ITSOBANK database . . . . . . . . . . . . . . . . . . . . . . . 46310.2.2 Create a new JPA project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46310.2.3 Add JPA support to an existing project . . . . . . . . . . . . . . . . . . . . . 46710.2.4 Convert a Java project to a JPA project . . . . . . . . . . . . . . . . . . . . 468
10.3 Create JPA entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46910.3.1 Create a new JPA entity with the wizard. . . . . . . . . . . . . . . . . . . . 47010.3.2 Create a JPA entity when adding persistence to a POJO. . . . . . . 47310.3.3 Generating database tables from JPA entities . . . . . . . . . . . . . . . 47610.3.4 Generating JPA entities from database tables . . . . . . . . . . . . . . . 47610.3.5 Adding business logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48510.3.6 Adding named queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486
10.4 Create a JPA Manager Bean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48810.5 Visualizing JPA entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49110.6 Testing JPA entities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494
10.6.1 Creating the Java project for entity testing . . . . . . . . . . . . . . . . . . 49510.6.2 Creating a Java class for entity testing . . . . . . . . . . . . . . . . . . . . . 49510.6.3 Setting up the build path for OpenJPA . . . . . . . . . . . . . . . . . . . . . 49610.6.4 Setting up the persistence.xml file . . . . . . . . . . . . . . . . . . . . . . . . 50210.6.5 Creating the test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50310.6.6 Running the JPA entity test. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50710.6.7 Displaying the SQL statements. . . . . . . . . . . . . . . . . . . . . . . . . . . 51110.6.8 Adding inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
10.7 Preparing the entities for deployment in the server. . . . . . . . . . . . . . . . 51810.8 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
Chapter 11. Developing applications to connect to enterprise information systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
11.1 Introduction to Java EE Connector Architecture . . . . . . . . . . . . . . . . . . 52411.1.1 System contracts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52411.1.2 Resource adapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52611.1.3 Common Client Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52711.1.4 WebSphere Adapters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527
11.2 Application development for EIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52811.2.1 Importers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52911.2.2 J2C wizards. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529x Rational Application Developer for WebSphere Software V8 Programming Guide
Draft Document for Review February 8, 2011 12:56 pm 7835TOC.fm11.3 Sample application overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53011.4 CICS outbound scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
11.4.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53111.4.2 Creating the Java data binding class . . . . . . . . . . . . . . . . . . . . . . 53111.4.3 Creating the J2C bean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53211.4.4 Deploying the J2C bean as an EJB 3.0 session bean . . . . . . . . . 53611.4.5 Generating a JSF client. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53811.4.6 Running the JSF client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
11.5 CICS channel outbound scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54211.5.1 Creating the Java data binding for the channel and containers . . 54311.5.2 Creating the J2C bean that accesses the channel . . . . . . . . . . . . 54711.5.3 Developing a web service to invoke the COBOL program . . . . . . 54911.5.4 Testing the web service with CICS access . . . . . . . . . . . . . . . . . . 554
11.6 SAP outbound scenario. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55611.6.1 Required software and configuration . . . . . . . . . . . . . . . . . . . . . . 55611.6.2 Creating a connector project and J2C bean . . . . . . . . . . . . . . . . . 55711.6.3 Generating the sample web application . . . . . . . . . . . . . . . . . . . . 56211.6.4 Testing the web application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564
11.7 Monitoring inbound events for resource adapters . . . . . . . . . . . . . . . . . 56411.7.1 Monitoring inbound events using WebSphere Business Monitor . 56411.7.2 Monitoring inbound events using WebSphere Business Events. . 565
11.8 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
Part 4. Enterprise and SOA application development . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567
Chapter 12. Developing EJB applications. . . . . . . . . . . . . . . . . . . . . . . . . 56912.1 Introduction to Enterprise JavaBeans . . . . . . . . . . . . . . . . . . . . . . . . . . 570
12.1.1 EJB 3.1 specification. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57012.1.2 EJB component types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57112.1.3 EJB services and annotations. . . . . . . . . . . . . . . . . . . . . . . . . . . . 58212.1.4 EJB 3.1 application packaging . . . . . . . . . . . . . . . . . . . . . . . . . . . 59212.1.5 EJB 3.1 Lite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59212.1.6 EJB 3.1 features in Rational Application Developer . . . . . . . . . . . 593
12.2 Developing an EJB module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59312.2.1 Sample application overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59412.2.2 Creating an EJB project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59712.2.3 Make the JPA entities available to the EJB project . . . . . . . . . . . . 60012.2.4 Setting up the ITSOBANK database . . . . . . . . . . . . . . . . . . . . . . . 60112.2.5 Implementing the session facade . . . . . . . . . . . . . . . . . . . . . . . . . 604
12.3 Testing the session EJB and the JPA entities. . . . . . . . . . . . . . . . . . . . 61512.3.1 Testing with the Universal Test Client . . . . . . . . . . . . . . . . . . . . . . 61612.3.2 Creating a web application to test the session bean. . . . . . . . . . . 61812.3.3 Testing the sample web application . . . . . . . . . . . . . . . . . . . . . . . 624 Contents xi
7835TOC.fm Draft Document for Review February 8, 2011 12:56 pm12.3.4 Visualizing the test application . . . . . . . . . . . . . . . . . . . . . . . . . . . 62512.4 Invoking EJBs from web applications . . . . . . . . . . . . . . . . . . . . . . . . . . 626
12.4.1 Implementing the RAD8EJBWeb application . . . . . . . . . . . . . . . . 62712.4.2 Running the web application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62912.4.3 Cleanup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63612.4.4 Adding a remote interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636
12.5 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638
Chapter 13. Developing Java EE application clients . . . . . . . . . . . . . . . . 63913.1 Introduction to Java EE application clients . . . . . . . . . . . . . . . . . . . . . . 64013.2 Overview of the sample application. . . . . . . . . . . . . . . . . . . . . . . . . . . . 64213.3 Preparing the sample application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644
13.3.1 Importing the enterprise application sample . . . . . . . . . . . . . . . . . 64413.3.2 Setting up the sample database . . . . . . . . . . . . . . . . . . . . . . . . . . 646
13.4 Developing the Java EE application client . . . . . . . . . . . . . . . . . . . . . . 64913.4.1 Creating the Java EE application client projects . . . . . . . . . . . . . . 65013.4.2 Configuring the Java EE application client projects . . . . . . . . . . . 65313.4.3 Importing the graphical user interface and control classes . . . . . . 65613.4.4 Creating the BankDesktopController class . . . . . . . . . . . . . . . . . . 65813.4.5 Completing the BankDesktopController class. . . . . . . . . . . . . . . . 65913.4.6 Creating an EJB reference and binding . . . . . . . . . . . . . . . . . . . . 66113.4.7 Registering the BankDesktopController class as the main class . 663
13.5 Testing the Java EE application client. . . . . . . . . . . . . . . . . . . . . . . . . . 66513.6 Packaging the Java EE application client . . . . . . . . . . . . . . . . . . . . . . . 669
13.6.1 Packaging the application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66913.6.2 Running the deployed application client . . . . . . . . . . . . . . . . . . . . 670
Chapter 14. Developing web services applications . . . . . . . . . . . . . . . . . 67114.1 Introduction to web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672
14.1.1 SOA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67214.1.2 Web services as an SOA implementation. . . . . . . . . . . . . . . . . . . 674
14.2 What is new in Java EE 6 for web services. . . . . . . . . . . . . . . . . . . . . . 67514.2.1 Java API for XML-Based Web Services (JAX-WS) 2.2 - JSR-224 67614.2.2 Java Architecture for XML Binding (JAXB) 2.2 - JSR-222 . . . . . . 67714.2.3 Implementing Enterprise Web Services JSR-109 . . . . . . . . . . . 67814.2.4 Related web services standards . . . . . . . . . . . . . . . . . . . . . . . . . . 678
14.3 JAX-WS programming model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67914.3.1 Better platform independence for Java applications . . . . . . . . . . . 68014.3.2 Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68014.3.3 Invoking web services asynchronously . . . . . . . . . . . . . . . . . . . . . 68114.3.4 Dynamic and static clients. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68214.3.5 MTOM support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68314.3.6 Multiple payload structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683xii Rational Application Developer for WebSphere Software V8 Programming Guide
Draft Document for Review February 8, 2011 12:56 pm 7835TOC.fm14.3.7 SOAP 1.2 support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68314.4 Web services development approaches . . . . . . . . . . . . . . . . . . . . . . . . 68314.5 Web services tools in Rational Application Developer . . . . . . . . . . . . . 684
14.5.1 Creating a web service from existing resources . . . . . . . . . . . . . . 68414.5.2 Creating a skeleton web service . . . . . . . . . . . . . . . . . . . . . . . . . . 68414.5.3 Client development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68514.5.4 Testing tools for web services. . . . . . . . . . . . . . . . . . . . . . . . . . . . 685
14.6 Preparing for the JAX-WS samples. . . . . . . . . . . . . . . . . . . . . . . . . . . . 68614.6.1 Importing the sample. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68614.6.2 Testing the application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 687
14.7 Creating bottom-up web services from a JavaBean . . . . . . . . . . . . . . . 68814.7.1 Creating a web service using annotations . . . . . . . . . . . . . . . . . . 68814.7.2 Creating web services using the Web Service wizard . . . . . . . . . 69714.7.3 Resources generated by the Web Service wizard . . . . . . . . . . . . 706
14.8 Creating a synchronous web service JSP client . . . . . . . . . . . . . . . . . . 70714.8.1 Generating and testing the web service client . . . . . . . . . . . . . . . 707
14.9 Creating a web service JavaServer Faces client . . . . . . . . . . . . . . . . . 71514.10 Creating a web service thin client . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72314.11 Creating asynchronous web service clients . . . . . . . . . . . . . . . . . . . . 726
14.11.1 Polling client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72614.11.2 Callback client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72914.11.3 Asynchronous message exchange client . . . . . . . . . . . . . . . . . . 732
14.12 Creating web services from an EJB . . . . . . . . . . . . . . . . . . . . . . . . . . 73414.13 Creating a top-down web service from a WSDL . . . . . . . . . . . . . . . . . 737
14.13.1 Designing the WSDL by using the WSDL editor . . . . . . . . . . . . . 73714.13.2 Generating the skeleton JavaBean web service . . . . . . . . . . . . . 74414.13.3 Testing the generated web service . . . . . . . . . . . . . . . . . . . . . . . 745
14.14 Creating web services with Ant tasks . . . . . . . . . . . . . . . . . . . . . . . . . 74614.14.1 Creation procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74614.14.2 Running the web service Ant task. . . . . . . . . . . . . . . . . . . . . . . . 747
14.15 Sending binary data using MTOM. . . . . . . . . . . . . . . . . . . . . . . . . . . . 74814.15.1 Creating a web service project and importing the WSDL . . . . . . 74914.15.2 Generating the web service and client . . . . . . . . . . . . . . . . . . . . 75014.15.3 Implementing the JavaBean skeleton . . . . . . . . . . . . . . . . . . . . . 75314.15.4 Testing and monitoring the MTOM enabled web service . . . . . . 75614.15.5 How MTOM was enabled on the client . . . . . . . . . . . . . . . . . . . . 761
14.16 JAX-RS programming model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76214.16.1 Implementation of JAX-RS in WebSphere Application Server . . 76414.16.2 JAX-RS project setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76514.16.3 Exposing a JPA application as a RESTful service . . . . . . . . . . . 769
14.17 Web services security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78314.17.1 Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78414.17.2 Message integrity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 784 Contents xiii
7835TOC.fm Draft Document for Review February 8, 2011 12:56 pm14.17.3 Message confidentiality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78414.17.4 Policy set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78514.17.5 Applying WS-Security to a web service and client . . . . . . . . . . . 78614.17.6 WS-I Reliable Secure Profile. . . . . . . . . . . . . . . . . . . . . . . . . . . . 795
14.18 WS-Policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79614.18.1 Configuring a service provider to share its policy configuration . 79614.18.2 Configuring the client policy using a service provider policy . . . . 799
14.19 WS-MetadataExchange (WS-MEX) . . . . . . . . . . . . . . . . . . . . . . . . . . 80214.20 Security Assertion Markup Language (SAML) support . . . . . . . . . . . . 805
14.20.1 SAML assertions defined in the SAML Token Profile standard . 80514.20.2 SAML APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80614.20.3 SAML Bearer sample: prerequisites . . . . . . . . . . . . . . . . . . . . . . 80714.20.4 SAML Bearer sample: bindings. . . . . . . . . . . . . . . . . . . . . . . . . . 80814.20.5 SAML Bearer sample: programmatic token generation . . . . . . . 81514.20.6 SAML Bearer sample: testing . . . . . . . . . . . . . . . . . . . . . . . . . . . 817
14.21 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 820
Chapter 15. Developing OSGi applications. . . . . . . . . . . . . . . . . . . . . . . . 82315.1 OSGi overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 824
15.1.1 OSGi architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82515.2 Introduction to OSGi bundles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 827
15.2.1 OSGi classloading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82715.2.2 Bundle manifest file. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82815.2.3 Life cycle of a bundle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83015.2.4 Blueprint Container Specification . . . . . . . . . . . . . . . . . . . . . . . . . 83215.2.5 Types of bundle archives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83515.2.6 Relationship between bundles, application archives, and composite
archives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83615.3 Installation of the Feature Pack for OSGi . . . . . . . . . . . . . . . . . . . . . . . 83615.4 Tools for OSGi application development. . . . . . . . . . . . . . . . . . . . . . . . 83815.5 Creating OSGi Bundle Projects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 840
15.5.1 How to create OSGi Bundle Projects . . . . . . . . . . . . . . . . . . . . . . 84015.5.2 Create an OSGi Application Project . . . . . . . . . . . . . . . . . . . . . . . 84215.5.3 Create Composite Bundle Project . . . . . . . . . . . . . . . . . . . . . . . . . 84415.5.4 Working with the Composite Bundle Manifest. . . . . . . . . . . . . . . . 845
15.6 Developing OSGi applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84615.6.1 API Bundle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84715.6.2 Persistence Bundle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84915.6.3 Business Logic Bundle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85515.6.4 Web interface bundle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85915.6.5 Application OSGi. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86215.6.6 Deploying the OSGi application . . . . . . . . . . . . . . . . . . . . . . . . . . 864
15.7 Further information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 868xiv Rational Application Developer for WebSphere Software V8 Programming Guide
Draft Document for Review February 8, 2011 12:56 pm 7835TOC.fmChapter 16. Developing Service Component Architecture (SCA) applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 869
16.1 Introduction to SCA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87016.1.1 Basic concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87016.1.2 Runtime support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 879
16.2 SCA project creation or augmentation . . . . . . . . . . . . . . . . . . . . . . . . . 88016.3 Top down scenario to develop a Java Component from a WSDL interface
88216.3.1 Creating a Composite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88416.3.2 Creating a Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88516.3.3 Implementing the Java Component . . . . . . . . . . . . . . . . . . . . . . . 887
16.4 Creating a contribution to include the deployable composites . . . . . . . 88816.5 Deploying the contribution to WebSphere Application Server. . . . . . . . 89016.6 Testing the services provided by the SCA application . . . . . . . . . . . . . 89116.7 Wiring a component to a service on another component . . . . . . . . . . . 895
16.7.1 Creating a reference to an external Atom feed provider . . . . . . . . 89616.7.2 Exposing a service with an Atom binding . . . . . . . . . . . . . . . . . . . 90416.7.3 Adding a Contribution and testing the initial implementation . . . . 90816.7.4 Adding a second Component to the Composite . . . . . . . . . . . . . . 91016.7.5 Wiring the reference on one component to the service on the other .
91316.7.6 Using a Property defined in a component and in a composite . . . 91616.7.7 Testing the implementation by exporting the Contribution . . . . . . 918
16.8 Reusing an existing asset (a Java EE application), to create a component 920
16.8.1 Explore the existing EAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92116.8.2 Create a new SCA Enhanced EAR file to hold the Web Project . . 92216.8.3 Create a new SCA Project with a Contribution . . . . . . . . . . . . . . . 92916.8.4 Testing the completed application. . . . . . . . . . . . . . . . . . . . . . . . . 934
16.9 Adding intents and policies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93616.10 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 936
Chapter 17. Developing Modern Batch jobs on Computing Grids . . . . . 93917.1 Introduction to Modern Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94017.2 New Modern Batch job tools in Rational Application Developer . . . . . . 94017.3 Working with the Compute-Intensive sample . . . . . . . . . . . . . . . . . . . . 941
17.3.1 Installing the sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94117.3.2 Understanding the sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94317.3.3 Deploying the sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94717.3.4 Running the sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 948
17.4 Overview of the Transactional capabilities . . . . . . . . . . . . . . . . . . . . . . 95317.4.1 Sequence diagram for the Transactional Batch pattern . . . . . . . . 95417.4.2 Available patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 957 Contents xv
7835TOC.fm Draft Document for Review February 8, 2011 12:56 pm17.5 Additional information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 959
Part 5. Web application development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 961
Chapter 18. Developing web applications using JSP and servlets . . . . 96318.1 Introduction to Java EE web applications . . . . . . . . . . . . . . . . . . . . . . . 964
18.1.1 Java EE applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96518.1.2 Model-view-controller pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . 970
18.2 Web development tooling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97118.2.1 Web perspective and views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97118.2.2 Page Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97418.2.3 Page templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97618.2.4 CSS Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97718.2.5 Security Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97718.2.6 File creation wizards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 979
18.3 Summary of new features in Rational Application Developer . . . . . . . . 98018.4 RedBank application design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 982
18.4.1 Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98218.4.2 View layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98318.4.3 Controller layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 983
18.5 Implementing the RedBank application. . . . . . . . . . . . . . . . . . . . . . . . . 98618.5.1 Creating the web project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98618.5.2 Importing the Java RedBank model . . . . . . . . . . . . . . . . . . . . . . . 99318.5.3 Defining the empty web pages . . . . . . . . . . . . . . . . . . . . . . . . . . . 99318.5.4 Creating frameset pages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99518.5.5 Customizing frameset web page areas. . . . . . . . . . . . . . . . . . . . . 99818.5.6 Customizing a style sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100018.5.7 Verifying the site navigation and page templates . . . . . . . . . . . . 100118.5.8 Developing the static web resources . . . . . . . . . . . . . . . . . . . . . 100318.5.9 Developing the dynamic web resources . . . . . . . . . . . . . . . . . . . 100718.5.10 Working with JSPs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1017
18.6 Web application testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103118.6.1 Prerequisites to run the sample web application. . . . . . . . . . . . . 103118.6.2 Running the sample web application . . . . . . . . . . . . . . . . . . . . . 103118.6.3 Verifying the RedBank web application. . . . . . . . . . . . . . . . . . . . 1032
18.7 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1036
Chapter 19. Developing web applications using JSF . . . . . . . . . . . . . . 103919.1 Introduction to JSF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1040
19.1.1 JSF 1.x features and benefits . . . . . . . . . . . . . . . . . . . . . . . . . . . 104019.1.2 JSF 2.0 features and benefits . . . . . . . . . . . . . . . . . . . . . . . . . . . 104119.1.3 JSF 2.0 application architecture . . . . . . . . . . . . . . . . . . . . . . . . . 104219.1.4 JSF features in Rational Application Developer . . . . . . . . . . . . . 1044
19.2 Developing a web application using JSF and JPA . . . . . . . . . . . . . . . 1045xvi Rational Application Developer for WebSphere Software V8 Programming Guide
Draft Document for Review February 8, 2011 12:56 pm 7835TOC.fm19.2.1 Setting up the ITSOBANK database . . . . . . . . . . . . . . . . . . . . . . 104619.2.2 Creating the JSF Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104719.2.3 Creating Facelet templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105219.2.4 Creating Facelets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105819.2.5 Creating JPA manager beans . . . . . . . . . . . . . . . . . . . . . . . . . . . 105919.2.6 Creating JPA page data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106519.2.7 Editing the login page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106519.2.8 Editing the customer details page . . . . . . . . . . . . . . . . . . . . . . . . 107119.2.9 Using Ajax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107519.2.10 Running the JSF application . . . . . . . . . . . . . . . . . . . . . . . . . . . 107719.2.11 Final code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1079
19.3 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1079
Chapter 20. Developing web applications using Web 2.0 . . . . . . . . . . . 108120.1 Introduction to Web 2.0 architecture and development practices . . . . 1082
20.1.1 The Web 2.0 architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108220.1.2 Technologies used in Web 2.0 applications . . . . . . . . . . . . . . . . 1084
20.2 Overview of Web 2.0 tooling features . . . . . . . . . . . . . . . . . . . . . . . . . 108720.2.1 JavaScript editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108720.2.2 Dojo development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108820.2.3 Testing and debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108920.2.4 JAX-RS services development . . . . . . . . . . . . . . . . . . . . . . . . . . 108920.2.5 Using other server-side technologies . . . . . . . . . . . . . . . . . . . . . 1089
20.3 Developing the Web 2.0 sample application . . . . . . . . . . . . . . . . . . . . 109020.3.1 Project setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109020.3.2 Create the web page. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109520.3.3 Build a custom Dojo widget. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110020.3.4 Adding to a page and testing a custom Dojo widget . . . . . . . . . . 110520.3.5 Adding a Dojo DataGrid to your web page . . . . . . . . . . . . . . . . . 1109
Chapter 21. Developing portal applications . . . . . . . . . . . . . . . . . . . . . . 111521.1 Introduction to portal technology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1116
21.1.1 Portal concepts and definitions . . . . . . . . . . . . . . . . . . . . . . . . . . 111621.1.2 IBM WebSphere Portal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111921.1.3 Portal and portlet development features in Rational Application
Developer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112021.1.4 Setting up Rational Application Developer with the Portal test
environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112221.2 Developing applications for WebSphere Portal . . . . . . . . . . . . . . . . . . 1122
21.2.1 Portal samples and tutorials . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112321.2.2 Development strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112421.2.3 Portal tools for developing portals. . . . . . . . . . . . . . . . . . . . . . . . 1127
21.3 New WebSphere portal development tools in Rational Application Developer Contents xvii
7835TOC.fm Draft Document for Review February 8, 2011 12:56 pm113421.3.1 Support for WebSphere Portal Server V7 . . . . . . . . . . . . . . . . . . 113421.3.2 Site Designing Portlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113421.3.3 New portlet project features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113421.3.4 RPC tooling for portlet projects . . . . . . . . . . . . . . . . . . . . . . . . . . 1135
21.4 Developing portal solutions using portal tools . . . . . . . . . . . . . . . . . . . 113521.4.1 Developing eventing portlets. . . . . . . . . . . . . . . . . . . . . . . . . . . . 113521.4.2 Creating Ajax and Web 2.0 portlets . . . . . . . . . . . . . . . . . . . . . . 114221.4.3 Deploying and running the application . . . . . . . . . . . . . . . . . . . . 114621.4.4 Creating a Portal Site with the Site Designing Portlet feature. . . 114721.4.5 Developing Dojo based inter-portlet communication. . . . . . . . . . 115121.4.6 Consuming RPC Adapter services . . . . . . . . . . . . . . . . . . . . . . . 115621.4.7 Creating iWidget projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115721.4.8 JPA tooling support for Portlet projects. . . . . . . . . . . . . . . . . . . . 1159
21.5 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1165
Chapter 22. Developing Lotus iWidgets . . . . . . . . . . . . . . . . . . . . . . . . . 116722.1 Introduction to iWidgets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1168
22.1.1 Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116822.1.2 Events and Event Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . 116922.1.3 Itemsets and Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116922.1.4 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1170
22.2 Developing iWidgets in Rational Application Developer . . . . . . . . . . . 117022.2.1 Accessing the tutorials and samples. . . . . . . . . . . . . . . . . . . . . . 117022.2.2 Configuring Rational Application Developer for iWidget development
117122.3 Working with the sample iWidget application . . . . . . . . . . . . . . . . . . . 1171
22.3.1 Preparing the sample iWidget application. . . . . . . . . . . . . . . . . . 117122.3.2 Developing the sample iWidget application . . . . . . . . . . . . . . . . 117322.3.3 Testing the sample iWidget application. . . . . . . . . . . . . . . . . . . . 117722.3.4 Deploying into WebSphere Portal v7 . . . . . . . . . . . . . . . . . . . . . 1180
22.4 Additional resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118222.4.1 Further information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1183
Part 6. Deploying, testing, profiling, and debugging applications . . . . . . . . . . . . . . . . . 1185
Chapter 23. Cloud environment and servers configuration . . . . . . . . . 118723.1 Introduction to server configurations . . . . . . . . . . . . . . . . . . . . . . . . . . 1188
23.1.1 Application servers supported by Rational Application Developer118823.1.2 Local and remote test environments . . . . . . . . . . . . . . . . . . . . . . 1191
23.2 Cloud extensions: developing and testing applications on the IBM Smart Business, Development and Test Cloud . . . . . . . . . . . . . . . . . . . . . . . 1191
23.2.1 Installing IBM Rational Desktop Connection Toolkit for Cloud Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1192xviii Rational Application Developer for WebSphere Software V8 Programming Guide
Draft Document for Review February 8, 2011 12:56 pm 7835TOC.fm23.2.2 Working with the IBM Development and Test Cloud . . . . . . . . . 119523.2.3 Working with the Cloud Client for Eclipse . . . . . . . . . . . . . . . . . . 121123.2.4 Requesting instances from the web client. . . . . . . . . . . . . . . . . . 121523.2.5 Resources for additional information. . . . . . . . . . . . . . . . . . . . . . 1218
23.3 Understanding WebSphere Application Server v8.0 profiles . . . . . . . 121923.3.1 Types of profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122023.3.2 Using the profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1220
23.4 WebSphere Application Server v8.0 Beta installation . . . . . . . . . . . . . 122123.5 Using WebSphere Application Server profiles . . . . . . . . . . . . . . . . . . 1222
23.5.1 Creating a new profile using the WebSphere Profile wizard . . . . 122223.5.2 Deleting a WebSphere profile . . . . . . . . . . . . . . . . . . . . . . . . . . . 122823.5.3 Defining the new server in Rational Application Developer . . . . 122923.5.4 Customizing a server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123223.5.5 Sharing a WebSphere profile between developers. . . . . . . . . . . 123523.5.6 Defining a server for each workspace. . . . . . . . . . . . . . . . . . . . . 1237
23.6 Migrating the server resources from Rational Application Developer V7.0 or V7.5 to V8.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1237
23.7 Adding and removing applications to and from a server . . . . . . . . . . . 123823.7.1 Adding an application to the server. . . . . . . . . . . . . . . . . . . . . . . 123823.7.2 Removing an application from a server. . . . . . . . . . . . . . . . . . . . 1239
23.8 Configuring application and server resources . . . . . . . . . . . . . . . . . . . 124023.8.1 Creating a data source in the Enhanced EAR editor . . . . . . . . . 124423.8.2 Setting substitution variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125023.8.3 Configuring server resources . . . . . . . . . . . . . . . . . . . . . . . . . . . 1251
23.9 Configuring security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125123.9.1 Configuring security in the server . . . . . . . . . . . . . . . . . . . . . . . . 125123.9.2 Configuring security in the Workbench . . . . . . . . . . . . . . . . . . . . 1253
23.10 AJAX Test Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125423.10.1 AJAX Test Server Configuration . . . . . . . . . . . . . . . . . . . . . . . . 125423.10.2 AJAX Proxy configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1256
23.11 Developing automation scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125823.12 Tips: enhance server interaction performance . . . . . . . . . . . . . . . . . 1258
23.12.1 Server start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125923.12.2 Application publishing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1259
23.13 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1259
Chapter 24. Building applications with Ant . . . . . . . . . . . . . . . . . . . . . . 126124.1 Introduction to Ant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1262
24.1.1 Ant build files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126224.1.2 Ant tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1263
24.2 Ant features in Rational Application Developer . . . . . . . . . . . . . . . . . . 126424.2.1 Preparing for the sample. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126424.2.2 Creating a build file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1265 Contents xix
7835TOC.fm Draft Document for Review February 8, 2011 12:56 pm24.2.3 Project definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126624.2.4 Global properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126724.2.5 Building targets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126724.2.6 Content assist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126924.2.7 Code snippets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127024.2.8 Formatting an Ant script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127224.2.9 Defining the format of an Ant script . . . . . . . . . . . . . . . . . . . . . . . 127224.2.10 Problems view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1274
24.3 New Ant features in Rational Application Developer. . . . . . . . . . . . . . 127524.3.1 SCA Ant task. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127524.3.2 OSGi Ant tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127624.3.3 Other new Ant tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1277
24.4 Building a Java EE application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127824.4.1 Java EE application deployment packaging . . . . . . . . . . . . . . . . 127824.4.2 Preparing for the sample. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127924.4.3 Creating the build script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127924.4.4 Running the Ant Java EE application build . . . . . . . . . . . . . . . . . 1282
24.5 Running Ant outside of Rational Application Developer . . . . . . . . . . . 128324.5.1 Preparing for the headless build . . . . . . . . . . . . . . . . . . . . . . . . . 128324.5.2 Running the headless Ant build script . . . . . . . . . . . . . . . . . . . . . 1284
24.6 Using the Rational Application Developer Build Utility . . . . . . . . . . . . 128424.6.1 Overview of the build utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128524.6.2 Example of using the build utility. . . . . . . . . . . . . . . . . . . . . . . . . 1285
24.7 More information about Ant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1288
Chapter 25. Deploying enterprise applications . . . . . . . . . . . . . . . . . . . 128925.1 Introduction to application deployment . . . . . . . . . . . . . . . . . . . . . . . . 1291
25.1.1 Common deployment considerations . . . . . . . . . . . . . . . . . . . . . 129125.1.2 Java EE application components and deployment modules. . . . 129225.1.3 Deployment descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129225.1.4 WebSphere deployment architecture . . . . . . . . . . . . . . . . . . . . . 129625.1.5 Java and WebSphere class loader . . . . . . . . . . . . . . . . . . . . . . . 1301
25.2 Preparing for the deployment of the EJB application . . . . . . . . . . . . . 130525.2.1 Reviewing the deployment scenarios . . . . . . . . . . . . . . . . . . . . . 130525.2.2 Installing the prerequisite software . . . . . . . . . . . . . . . . . . . . . . . 130625.2.3 Importing the sample application archive files . . . . . . . . . . . . . . 130725.2.4 Sample database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1308
25.3 Packaging the application for deployment. . . . . . . . . . . . . . . . . . . . . . 130825.3.1 Removing the enhanced EAR data source . . . . . . . . . . . . . . . . . 130925.3.2 Generating the deployment code . . . . . . . . . . . . . . . . . . . . . . . . 130925.3.3 Exporting the EAR files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1310
25.4 Manual deployment of enterprise applications . . . . . . . . . . . . . . . . . . 131125.4.1 Configuring the data source in the application server . . . . . . . . . 1311xx Rational Application Developer for WebSphere Software V8 Programming Guide
Draft Document for Review February 8, 2011 12:56 pm 7835TOC.fm25.4.2 Installing the enterprise applications . . . . . . . . . . . . . . . . . . . . . . 131825.4.3 Starting the enterprise applications. . . . . . . . . . . . . . . . . . . . . . . 132225.4.4 Verifying the application after manual installation . . . . . . . . . . . . 132325.4.5 Uninstalling the application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1325
25.5 Automated deployment using Jython-based wsadmin scripting . . . . . 132525.5.1 Overview of wsadmin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132625.5.2 Overview of Jython . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132725.5.3 Developing a Jython script to deploy the ITSO Bank . . . . . . . . . 132825.5.4 Executing the Jython script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133725.5.5 Verifying the application after automatic installation . . . . . . . . . . 134025.5.6 Generating WebSphere admin commands for Jython scripts . . . 134025.5.7 Debugging Jython scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1343
25.6 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1344
Chapter 26. Testing using JUnit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134526.1 Introduction to application testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1346
26.1.1 Test concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134626.1.2 Test phases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134626.1.3 Test environments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134826.1.4 Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134926.1.5 Test case execution and recording results . . . . . . . . . . . . . . . . . 134926.1.6 Benefits of unit and component testing . . . . . . . . . . . . . . . . . . . . 134926.1.7 Benefits of testing frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . 1350
26.2 JUnit testing without TPTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135126.2.1 JUnit fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135126.2.2 Test and Performance Tools Platform (TPTP) . . . . . . . . . . . . . . 135126.2.3 New in JUnit 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1352
26.3 Preparing the JUnit sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135726.3.1 Creating a JUnit test case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135726.3.2 Creating a JUnit test suite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136326.3.3 Running the JUnit test case or JUnit test suite . . . . . . . . . . . . . . 136426.3.4 Launch individual test methods. . . . . . . . . . . . . . . . . . . . . . . . . . 136626.3.5 Using the JUnit view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1368
26.4 JUnit testing of JPA entities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136826.4.1 Preparing the JPA unit testing sample . . . . . . . . . . . . . . . . . . . . 136926.4.2 Setting up the ITSOBANK database . . . . . . . . . . . . . . . . . . . . . . 136926.4.3 Configuring the RAD8JUnit project . . . . . . . . . . . . . . . . . . . . . . . 136926.4.4 Creating a JUnit test case for a JPA entity . . . . . . . . . . . . . . . . . 137026.4.5 Setting up the persistence.xml file . . . . . . . . . . . . . . . . . . . . . . . 137226.4.6 Running the JPA unit test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1373
26.5 JUnit testing using TPTP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137526.5.1 Running the TPTP JUnit test. . . . . . . . . . . . . . . . . . . . . . . . . . . . 138026.5.2 Analyzing the test results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1380 Contents xxi
7835TOC.fm Draft Document for Review February 8, 2011 12:56 pm26.6 Web application testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138326.6.1 Preparing for the sample. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138426.6.2 Recording a test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138526.6.3 Editing the test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138726.6.4 Generating an executable test . . . . . . . . . . . . . . . . . . . . . . . . . . 138926.6.5 Running the test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138926.6.6 Analyzing the test results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139026.6.7 Generating test reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1393
26.7 Cleaning the workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1396
Chapter 27. Profiling applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139727.1 Introduction to profiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1398
27.1.1 Profiling features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139927.1.2 Profiling architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140127.1.3 Profiling and Logging perspective . . . . . . . . . . . . . . . . . . . . . . . . 1404
27.2 Preparing for the profiling sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140527.2.1 Installing the prerequisite software . . . . . . . . . . . . . . . . . . . . . . . 140527.2.2 Enabling the Profiling and Logging capability . . . . . . . . . . . . . . . 1406
27.3 Profiling a Java application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140727.3.1 Importing the sample project archive file. . . . . . . . . . . . . . . . . . . 140727.3.2 Creating a profiling configuration . . . . . . . . . . . . . . . . . . . . . . . . 140827.3.3 Running the EntityTester application . . . . . . . . . . . . . . . . . . . . . 141227.3.4 Analyzing profiling data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141327.3.5 Execution statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141327.3.6 Execution flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141827.3.7 UML sequence diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141927.3.8 Memory analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142227.3.9 Thread analysis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142327.3.10 Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142527.3.11 Clean up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1425
27.4 Profiling a web application running on the server . . . . . . . . . . . . . . . . 142527.4.1 Importing the sample project archive file. . . . . . . . . . . . . . . . . . . 142527.4.2 Setting up environment variables to profile a server . . . . . . . . . . 142527.4.3 Publishing and running sample application. . . . . . . . . . . . . . . . . 142627.4.4 Starting server in profiling mode . . . . . . . . . . . . . . . . . . . . . . . . . 142627.4.5 Running the sample application to collect profiling data . . . . . . . 142827.4.6 Statistic views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142827.4.7 Execution statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142927.4.8 Execution flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143227.4.9 UML sequence diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143427.4.10 Refreshing the views and resetting data . . . . . . . . . . . . . . . . . . 143727.4.11 Ending the profiling session . . . . . . . . . . . . . . . . . . . . . . . . . . . 143727.4.12 Profile on server: Memory and thread analysis. . . . . . . . . . . . . 1437xxii Rational Application Developer for WebSphere Software V8 Programming Guide
Draft Document for Review February 8, 2011 12:56 pm 7835TOC.fm27.5 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1438
Chapter 28. Debugging local and remote applications . . . . . . . . . . . . . 143928.1 Summary of new features in Rational Application Developer . . . . . . . 144028.2 Overview of Rational Application Developer debugging tools. . . . . . . 1440
28.2.1 Supported languages and environments . . . . . . . . . . . . . . . . . . 144028.2.2 Basic Java debugging features . . . . . . . . . . . . . . . . . . . . . . . . . . 144128.2.3 XSLT debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144628.2.4 Stored procedure debugging for DB2 V9 . . . . . . . . . . . . . . . . . . 144828.2.5 Service Component Architecture debugger . . . . . . . . . . . . . . . . 144928.2.6 Java tracepoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144928.2.7 Collaborative debugging using Rational Team Concert client . . 1450
28.3 Debugging a web application on a local server. . . . . . . . . . . . . . . . . . 145128.3.1 Importing the sample application . . . . . . . . . . . . . . . . . . . . . . . . 145128.3.2 Running the sample application in debug mode . . . . . . . . . . . . . 145228.3.3 Setting breakpoints in a Java class. . . . . . . . . . . . . . . . . . . . . . . 145328.3.4 Debug perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145628.3.5 Watching variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145728.3.6 Evaluating and watching expressions . . . . . . . . . . . . . . . . . . . . . 145828.3.7 Using the Display view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145928.3.8 Working with breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146028.3.9 Setting breakpoints in a JSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146128.3.10 Debugging a JSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1462
28.4 Debugging a web application on a remote server . . . . . . . . . . . . . . . . 146428.4.1 Removing the WebSphere configuration from the workspace . . 146528.4.2 Configuring debug on a remote WebSphere Application Server 146528.4.3 Attaching to the remote server in Rational Application Developer146728.4.4 Debugging a remote application . . . . . . . . . . . . . . . . . . . . . . . . . 1469
28.5 Jython debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146928.5.1 Considerations for the Jython debugger . . . . . . . . . . . . . . . . . . . 147028.5.2 Debugging a sample Jython script . . . . . . . . . . . . . . . . . . . . . . . 1470
28.6 JavaScript debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147328.6.1 Setting the default browser to Firefox . . . . . . . . . . . . . . . . . . . . . 147328.6.2 JavaScript debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1474
28.7 Dojo Debug Extension for Firebug . . . . . . . . . . . . . . . . . . . . . . . . . . . 147928.7.1 Launching the Dojo Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . 147928.7.2 Exploring the All widgets view. . . . . . . . . . . . . . . . . . . . . . . . . . . 148028.7.3 Exploring the All connections view . . . . . . . . . . . . . . . . . . . . . . . 148628.7.4 Exploring the All Subscriptions view . . . . . . . . . . . . . . . . . . . . . . 149028.7.5 Exploring the Info side panel. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1492
28.8 Debug extension for Rational Team Concert client (Team Debug). . . 149328.8.1 Supported environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149428.8.2 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1495 Contents xxiii
7835TOC.fm Draft Document for Review February 8, 2011 12:56 pm28.8.3 Sharing a Java debug session by transferring it to another user 149628.9 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1506
Part 7. Management and team development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1509
Chapter 29. CVS integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151129.1 Introduction to CVS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1512
29.1.1 CVS features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151229.1.2 CVS support within Rational Application Developer . . . . . . . . . . 1513
29.2 Configuring the CVS client for Rational Application Developer. . . . . . 151529.2.1 CVS Server Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151529.2.2 Configuring the CVS team capability . . . . . . . . . . . . . . . . . . . . . 151529.2.3 Accessing the CVS repository. . . . . . . . . . . . . . . . . . . . . . . . . . . 1516
29.3 Configuring CVS in Rational Application Developer . . . . . . . . . . . . . . 151829.3.1 Label decorations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151829.3.2 File content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151929.3.3 Ignored resources . . . . . . . . . . . . . . .