WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical Back Cover J2EE Development WebSphere Studio Application Developer 5.0 is about IBM's J2EE server side development tool called WebSphere ISBN:1590591208 by Igor Livshin Studio Application Developer (WSAD). The book provides a practical, step-by-step approach in teaching how to use Apress © 2003 (630 pages) the tool for developing J2EE distributed applications. This book provides a practical, step-by-step approach in teaching how to useIntegrated the WebSphere Studio Application WSAD is a new generation server-side Development Environment (IDE) that targets development of the DeveloperWSAD (WSAD) tool for developing J2EE Java enterprise applications. is tightly integrated with thedistributed WebSphere Application Server 5.0 (WAS) - the applications. runtime environment, where the WSAD-developed applications run. This tight integration between the development and the runtime environments is very important for seamless future application deployment. By being tightly integrated with WebSphere Application Server, the new tool has an important advantage over the older IBM's Java development tool - Visual Age for Java, which (in its latest release 4.0) still restricts development and testing to the Table of Contents obsolete release of WebSphere Application5.0: Server 3.5 (with future conversion to WebSphere Application WebSphere Studio Application Developer Practical J2EEnecessary Development Server 4.0). In fact, (According to IBM) Visual Age for Java 4.0 is the last supported release for this tool and it will Introduction be discontinued soon. WSAD is now considered an official tool for WebSphere-based J2EE development. Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
WebSphere Server (WAS) Chapter 1 Application - Introducing WSAD 5.0 became a dominant Java Application Server environment (currently controlling about 35% of the Java Application Server market). Thus, WSAD, as an official development tool for Chapter 2 - Setting Up the Development Environment WebSphere Application Server, should be in great demand by the J2EE development community. WSAD is a new Chapter Working the WSAD 5.0 Workbench tool, and 3 the -majority ofwith Java/J2EE developers still unfamiliar with it (not to mention a new generation of developers would needDatabase to learn Java Enterprise development in the near future). Chapter 4 who - Developing Applications Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
About the Author
Chapter 6 is- aJ2EE Development Igor Livshin J2EEEJB senior architect with extensive experience in developing large-scale distributed applications. He specializes WebSphere and WebSphere MQ (MQSeries) IBM products. He has written communication-related Chapter 7 - in J2EE Web Development articles for Web Informant and Windows Tech Journal . Igor has a master’s degree in computer science from the Chapter 8 - J2EE XML Development Institute of Technology in Odessa, Russia. Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical WebSphere Studio Application Developer 5.0: J2EE Development Igor Livshin Practicalby J2EE Development ISBN:1590591208 Apress © 2003 (630 pages) This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, applications.
Igor Livshin
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. Table of Contents
ISBN (pbk): 1-59059-120-8 Printed and bound in the United States of America Introduction 12345678910
WebSphere Studio Application Developer 5.0: Practical J2EE Development Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 - Introducing WSAD 5.0 in this book. Rather than use a trademark symbol with every occurrence Trademarked names may appear Chapter 2 - Setting Up the Environment of a trademarked name, weDevelopment use the names only in an editorial fashion and to the benefit of the trademark Chapter Working withofthe WSAD 5.0 Workbench owner, 3with- no intention infringement of the trademark. Chapter 4
- Developing Database Applications
Technical Reviewer: Miller Directors: DanFramework Appleman, Part Two - Working with Jeff J2EE: The Editorial Distributed Application
Gary Cornell, Martin Streicher, Jim
Sumser, Watterson, John Zukowski Chapter 5 Karen - J2EE Development Assistant Publisher: Grace Wong Chapter 6 - J2EE EJB Development Project Manager: Sofia Marchant Chapter 7 - J2EE Web Development Development Editor: Tracy Brown Chapter 8 - J2EE XML Development Production Editor: Janet Vail Part Three - Working with Enterprise Messaging Proofreader: Lori Bring Chapter 9 - J2EE Enterprise Messaging Compositor: Diana Van Winkle, Van Winkle Design Group Chapter 10 - Using the WSAD-Embedded JMS Provider Indexer: Ann Rogers Chapter 11 - Using WebSphere MQ as the JMS Provider Artist and Cover Designer: Kurt Krames Appendix A - Manager: Deploying This Production KariBook's BrooksJ2EE Examples Index Manufacturing Manager: Tom Debolski List of Figures
Distributed List of Tables to the book trade in the United States by Springer-Verlag New York, Inc., 175 Fifth Avenue, New NY, 10010 and outside the United States by Springer-Verlag GmbH & Co. KG, Tiergartenstr. List of York, Code Examples 17,of69112 Heidelberg, Germany. List Sidebars In the United States: phone 1-800-SPRINGER, email
[email protected],or visit http://www.springer-ny.com.Outside the United States: fax +49 6221 345229, email
[email protected],or visit http://www.springer.de. For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710. Phone 510-549-5930, fax 510-549-5939, email
[email protected], or visit http://www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.comin the Downloads section. To my family, Bella, Julia, and Ethan About the Author Igor Livshin is a J2EE senior architect with extensive experience in developing large-scale distributed applications. He specializes in WebSphere and WebSphere MQ (MQSeries) IBM products. He has written communication-related articles for Web Informant andWindows Tech Journal. Igor has a master’s degree
in computer science from the Institute of Technology in Odessa, Russia.
WebSphere Studio Application Developer 5.0: Practical
J2EE Reviewer Development About the Technical by Igor Livshin
ISBN:1590591208
Jeff Miller is an e-business Apress © 2003 architect (630 pages) and member of the dragonslayers team with IBM Developer Relations Technical Consulting. He has more than 20 yearsapproach of software This book provides a practical, step-by-step in development experience as an teaching howdeveloper, to use the and WebSphere Studio electrical engineer, software architect. Jeff Application has worked for MultiMate, Ashton-Tate, and Developer (WSAD) tool forpartner developing Lotus, among others, and was a founding andJ2EE vice distributed president of international development at applications. Software By Design, a software consulting company. His current focus at IBM is Web and enterprise application architecture, design, development, and particularly security. He works with partners and customers, consulting, mentoring, coding, and teaching. Jeff is an IBM-certified e-business solution Table of Contents designer and solution technologist and5.0: is IBM certified onDevelopment WebSphere Application Server and WebSphere WebSphere Studio Application Developer Practical J2EE Studio Application Developer. He received his master’s degree in computer science from Rensselaer Introduction Polytechnic Institute. Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0 Acknowledgments
Chapter 2
- Setting Up the Development Environment
Chapter I would3like- toWorking thank John with the Zukowski WSAD 5.0 andWorkbench Gary Cornell, Apress editorial directors, for helping me make this
project 4a reality. Chapter - Developing Database Applications Part Two - Working with J2EE: The Distributed Application Framework
Special thanks to Ryan Cox, IBM WebSphere WebSpeed (SWAT) team; Sree A. Ratnasinghe, IBM - J2EE Development advisory software engineer; Jeff Miller, e-business architect for IBM Developer Relations; Roland Barcia, Chapter 6 - J2EE EJB Development IBM Software Services for WebSphere; Willy Farrell, IBM Developer Relations Technical Consulting; and Chapter 7 - J2EE Web Development Sheldon Wosnick, IBM WebSphere advisory software developer. All were generous with sharing their Chapter 8 - J2EE XML Development knowledge. Chapter 5
Part Three - Working with Enterprise Messaging
Chapter - J2EE Lots of 9thanks to aEnterprise wonderfulMessaging Apress team: Grace Wong, assistant publisher; Sofia Marchant, project Chapter 10 Jeff - Using thetechnical WSAD-Embedded JMS Provider manager; Miller, editor; Tracy Brown, development editor; and Janet Vail, production editor. Chapter All contributed 11 - Using greatly WebSphere to the technical MQ as the accuracy JMS Provider and style of the book. Appendix A - Deploying This Book's J2EE Examples
My thanks also go to Lori Doherty, CNA insurance company, and Debbie Cabell, Kemper Insurance, for their help and encouragement.
Index
List of Figures List of Tables
List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical Introduction J2EE Development
Overview
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in
Several years ago, teaching my jobhow requirements to use the WebSphere changed and Studio I hadApplication to switch from Borland JBuilder to IBM Developer (WSAD) tool for (WSAD). developing WebSphere Studio Application Developer AtJ2EE that distributed time, WSAD was a new product, and I was applications. pleased with the elegance of its design and the power it provided to Java 2 Enterprise Edition (J2EE) developers. At the same time, I was amazed by the absence of detailed documentation about the product. The of online help was simply inadequate for learning how to use the product (and was not intended for that Table Contents purpose). Several WebSphere-related books available that time targeted WebSphere Application WebSphere Studio Application Developer 5.0: Practical J2EEatDevelopment Server (WAS), but they included little or no information about WSAD. Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Thus, I started researching and eventually was able to collect a lot of valuable information about WSAD
Chapter 1 it- took Introducing WSAD 5.0and effort). The process of collecting different pieces of information (although substantial time Chapter 2 my - Setting Development Environment swamped office Up withthe numerous folders, and soon it became a challenge to find what I needed among Chapter - Working withthe theneed WSAD them. I3began to realize for5.0 an Workbench organized repository of WSAD information. Chapter 4 - Developing Database Applications
Now, several yearswith later, WebSphere is one Application of the industry-dominant Part Two - Working J2EE: The Distributed Framework
J2EE development/runtime tools.
However, lackDevelopment of WSAD documentation has not changed much. With the exception of several IBM Chapter 5 the - J2EE Redbooks about narrow topics, no retail book has been specifically written for WebSphere Chapter 6 -written J2EE EJB Development developers— untilWeb now.Development This book teaches you how to use the latest version of WSAD 5.0 for developing Chapter 7 - J2EE J2EE 1.3–compliant enterprise applications. - J2EE XML Development
Chapter 8
Part Three - Working with Enterprise Messaging
This practical, how-to book documents many types of J2EE development tasks with WebSphere 5.0. The
Chapter 9 - J2EE Enterprise Messaging step-by-step approach includes plenty of examples, screen shots, and explanations to facilitate your Chapter 10 Using the WSAD-Embedded JMS Provider learning experience. I hope that this book eases your WebSphere learning process and helps you quickly Chapter 11more - Using WebSphere MQ as the JMS Provider become productive. Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical What This Book Covers J2EE Development
ISBN:1590591208 Livshin This book coversby theIgor latest release of WSAD-version 5.0-and shows how to use it for developing J2EE Apress © enterprise 2003 (630 pages) 1.3-compliant distributed applications. It also shows how to deploy J2EE 1.3 applications on WAS 5.0. J2EE isThis a large relatively complex technologyapproach that handles many different aspects of bookand provides a practical, step-by-step in teaching how to useItthe WebSphere Studio Application developing distributed applications. is practically impossible to cover the entire J2EE technology in one tool for J2EE distributed book without just Developer scratching(WSAD) the surface of developing each aspect. Rather than doing that, this book concentrates on applications. several important topics that are applicable to any large J2EE development project:
Enterprise JavaBean (EJB) 2.0 development, including Container Managed Persistence (CMP) and Bean Managed Persistence (BMP) entity beans and stateless and stateful session beans
Table of Contents
WebSphere Studio Application Developer 5.0: Practical J2EE Development
Introduction Web development, including servlets 2.3 and JavaServer Pages (JSP) 1.2 Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Extensible Markup Language Chapter 1 - Introducing WSAD 5.0 (XML) development, including XML namespaces, Document Type Definitions (DTDs), XML schema, and XML transformations Chapter 2 - Setting Up the Development Environment Chapter 3
- Working with the WSAD 5.0 Workbench
Asynchronous communication, including Java Message Service (JMS) and Message Driven Beans - Developing Database Applications (MDBs), and the integration of the WebSphere and WebSphere MQ products
Chapter 4
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 - J2EEof Development Deployment J2EE 1.3-compliant applications on WAS 5.0 Chapter 6 - J2EE EJB Development
No learning can be successful (regardless of how detailed the information provided) without Chapter 7 - process J2EE Web Development practice. each topic discussed in this book comes with corresponding examples of practical Chapter 8 Therefore, - J2EE XML Development development, debugging, and selective application Part Three - Working with Enterprise Messaging
installation (deployment) on WAS 5.0. Many development steps include screen shots to make the learning process easier and more productive. The Chapter 9 - J2EE Enterprise Messaging source code for all examples and the exported applications' EAR files are available for download on the Chapter 10 - Using the WSAD-Embedded JMS Provider Apress Web site (http://www.apress.com) in the Downloads section. (For more information, see the next Chapter 11 - Using WebSphere MQ as the JMS Provider section.) Appendix A - Deploying This Book's J2EE Examples
IndexNote All examples in this book were developed on the Windows 2000 platform. All software packages List of Figures necessary to follow the book examples are available for free download (and 60-day evaluation) List of Tables from the Internet. All software packages are resource intensive and require a decently equipped List of CodeWindows Examples2000 machine. I recommend 768MB of RAM (minimum 512MB), a 1.5MHz processor,
and about 30GB of disk space. List of Sidebars
WebSphere Studio Application Downloading the Book's SampleDeveloper Code 5.0: Practical J2EE Development
ISBN:1590591208 Igor Livshin All of the code forbythis book is available in the Downloads section of the Apress Web site Apress © 2003 (630 pages) (http://www.apress.com). It is broken up into chapters, and each chapter contains three folders. The Source folder includes all the source code files,step-by-step the This book provides a practical, approach in
teaching how to use the WebSphere Studio Application Developer (WSAD) toolapplications, for developing J2EE Export folder contains all the exported and thedistributed Server folder contains the exported server applications. project. If additional information is necessary, a readme.txt file will be present in the chapter folder. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical Who This Book Is For J2EE Development
by Igor Livshin This book is for professional Java developers who are familiar ISBN:1590591208 with the basic aspects of the J2EE Apress © 2003 (630much pages) practical experience. The book is also for experienced J2EE technology but who do not have developers who would like provides to quicklya learn the step-by-step WSAD 5.0 development This book practical, approach in environment and see how to use it teaching to use the WebSphere Studio Application to develop the latest J2EEhow 1.3-compliant applications. Developer (WSAD) tool for developing J2EE distributed applications. The book does not teach J2EE, but it covers many of the new features introduced in the latest J2EE 1.3
specification and explains how to use these new features when working with the WebSphere family of products. The book also discusses several advanced topics of J2EE 1.3 development. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Studio Application Developer 5.0: Practical ContactingWebSphere the Author J2EE Development
ISBN:1590591208 Igor Livshin This book shouldby facilitate your WebSphere learning process and help you become more productive. I © 2003 pages) hope that you findApress it useful and(630 that it serves as an essential part of your WebSphere toolkit. If you have any questions or This comments related atopractical, the book, you can contact me in at
[email protected]. book provides step-by-step approach
teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Studio Application Developer 5.0: Practical Part One:WebSphere Getting Started with WebSphere Studio J2EE Development ISBN:1590591208 by Igor Livshin Application Developer (WSAD) 5.0 Apress © 2003 (630 pages) This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Chapter List Developer (WSAD) tool for developing J2EE distributed applications.
Chapter 1: Introducing WSAD 5.0
Table of Contents
WebSphere Chapter Studio 2: Setting Application Up the Developer Development 5.0: Practical Environment J2EE Development Introduction
Chapter 3: Working WSAD 5.0 Workbench Part One - Getting Started with withthe WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0 Chapter 4: Developing Database Applications
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Studio Application Developer 5.0: Practical Chapter WebSphere 1: Introducing WSAD 5.0 J2EE Development
Overview
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in
IBM WebSphere teaching Studio Application how to useDeveloper the WebSphere (WSAD) Studio is an Application Integrated Development Environment (IDE) Developer tool forEdition developing J2EE distributed for building and testing Java(WSAD) 2 Enterprise (J2EE) distributed applications. Being a member of the applications. WebSphere family of products, WSAD is tightly integrated with IBM WebSphere Application Server (WAS), which is the runtime environment for J2EE applications. Table of Contents
Although it is possible to run non-WSAD-developed applications on WAS and to run WSAD-developed applications on other J2EE application servers, running WSAD-developed applications on WAS is the Introduction easiest and the most straightforward way of deploying and running J2EE applications because the Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 products are so tightly integrated. WebSphere Studio Application Developer 5.0: Practical J2EE Development
Chapter 1
- Introducing WSAD 5.0
Chapter WSAD 2is a-relatively Setting Up new theJ2EE Development development Environment tool that replaces the IBM VisualAge for Java package.
WSAD 3is built on top with of Eclipse-an Java-based framework for building Java application Chapter - Working the WSADopen-source, 5.0 Workbench development tools. Originally developed by IBM, Eclipse was released to the open-source development Chapter 4 - Developing Database Applications community, which with includes vendors as Fujitsu, Serena Part Two - Working J2EE:such The software Distributed Application Framework
Software, Sybase, Borland, Merant,
Rational Red Hat, and many others. The Eclipse plugin architecture allows software vendors to Chapter 5 Software, - J2EE Development develop6 their products as plug-ins to Eclipse. Chapter - J2EE EJB Development Chapter 7
- J2EE Web Development
WSAD runs on a variety of operating systems including different flavors of Windows and Linux. This book Chapter 8 - J2EE XML Development covers the recently released 5.0 versions of both the WSAD and WAS packages. This chapter introduces Part Three - Working with Enterprise Messaging WSAD 5.0 and its major features: role-based architecture, the Workbench and workspaces, perspectives, Chapter 9 -soJ2EE Messaging views, and on. Enterprise This chapter also introduces the features new to WSAD 5.0. In addition, the chapter Chapter 10 Using the WSAD-Embedded JMS Provider explores the WebSphere Studio family of products. Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Why Learn WebSphere WSAD? Studio Application Developer 5.0: Practical J2EE Development
ISBN:1590591208 Igor Livshinas a development and runtime J2EE The popularity of by WebSphere environment has grown rapidly. In Apressfamily © 2003of (630 pages) won numerous awards from various magazines, awarded by 2002, the WebSphere products readers and editors, the provides categories of Enterprise, Web Services, and Extensible Markup Thisin book a practical, step-by-step approachJava, in how tomore use the WebSphere Studio Application Language (XML).teaching Furthermore, than 11,000 readers cast their votes in 2002 in the first annual Web (WSAD)Awards, tool for developing J2EE distributed Services Journal Developer Readers' Choice naming WebSphere products as the winner in four categories applications. and the first runner-up in 11 more. Together with WAS, WSAD is quickly becoming the dominant J2EE development tool. According to IBM, WebSphere has become the most successful software development product in the history of IBM, and it continues to gain market share faster than any other J2EE-related Table of Contents commercial product. Some of the largest sitesJ2EE on the Internet are developed and hosted by WebSphere Studio Application Developer 5.0:Web Practical Development WebSphere products. The use of the WebSphere family of products has increased about 500 percent in Introduction 2002. Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 7
- J2EE Web Development
By learning WSAD, you equip yourself with an extremely powerful development tool and make yourself Chapter 2 - Setting Up the Development Environment more marketable as a J2EE specialist. Consider that about 50,000 companies and about one million Chapter 3 - are Working withusing the WSAD 5.0 Workbench developers currently WebSphere technology. Another important reason for selecting WSAD as Chapter 4 Developing Database Applications your development tool is the product integration. When developing distributed enterprise applications in Part Two - Working Distributed Application Framework Java, you typicallywith workJ2EE: with aThe variety of products that facilitate access to legacy data and integration of Chapter 5 J2EE Development legacy applications (such as the J2EE application server runtime environment, databases, communication Chapter 6 - J2EE EJBon). Development middleware, and so IBM is the only vendor capable of proving the entire supporting infrastructure. Imagine8 that all the products you need for developing and running your J2EE applications come from Chapter - J2EE XML Development different vendors. At your first serious production problem, you will need to communicate with different Part Three - Working with Enterprise Messaging vendors, each blaming the others for your problem. On top of this, software releases coming from different Chapter 9 - J2EE Enterprise Messaging vendors are uncoordinated and are not necessarily able to work together. Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter - Using WebSphere as the JMS Provider WSAD 11 distinguishes itself fromMQ other development tools with its elegant and innovated design, which is Appendix A Deploying This Book's J2EE Examples based on role-based architecture. J2EE development is a complex process that involves specialists in Index many different professions such as Java, servlets, and JavaServer Pages (JSP) developers; graphic List of Figures artists; Enterprise JavaBean (EJB), Java Database Connectivity (JDBC), Java Naming and Directory List of Tables Interface (JNDI), and Java Message Service (JMS) developers; and application assemblers and List deployers. of Code Examples By incorporating a role-based architecture, WSAD adjusts its development environment by
optimizing it for each developer's role and, therefore, increasing development productivity. List of Sidebars
WebSphere Developer 5.0: Practical Understanding the Studio MajorApplication Features of WSAD 5.0 J2EE Development
ISBN:1590591208 by Igor Livshin WSAD 5.0 is a major product release that introduces two important features and includes a multitude of © 2003 (630 pages) equally importantApress enhancements. The two new features are as follows:
This book provides a practical, step-by-step approach in
WSAD 5.0 supports J2EE 1.3the and EJB 2.0 specifications, including the EJB component's new teachingthe how to use WebSphere Studio Application Developer (WSAD) for developing distributed local interface in addition to thetool traditional remoteJ2EE interface; it also supports a new persistence model applications. for entity beans. WSAD 5.0 supports JMS Message Driven Beans (MDBs).
Table of Contents
WebSphere Studio Application Developer 5.0: Practical J2EEadditions Development The following sections explain the significance of these and enhancements. Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Supporting the J2EE 1.3 and EJB 2.0 Specifications
Chapter 1
- Introducing WSAD 5.0
Chapter 2 - Setting Up the Development Until release 5.0, WSAD supported onlyEnvironment a remote interface mechanism, which provided invocation of EJB Chapter 3 - Working the WSAD 5.0 Workbench components over thewith network. The remote interface is a foundation of distributed applications that allows Chapter processing 4 -toDeveloping be spreadDatabase betweenApplications multiple platforms, which in turn facilitates scalability and reliability. Part Two - Working with J2EE: The Distributed Application Framework
However, theDevelopment remote interface, communication over the network is slow, which negatively impacts Chapter 5 with - J2EE
application-performance. Many best-practice patterns can somewhat minimize this negative impact. The J2EE EJB Development EJB 2.0 specification introduced the local interface mechanism with the main goal of substantially Chapter 7 - J2EE Web Development improving the performance and responsiveness of J2EE applications. For EJB components and their Chapter 8 - J2EE XML Development clients that run in the same address space-that is, in the same Java Virtual Machine (JVM)-the local Part Three - Working with Enterprise Messaging interface allows local component invocation that is substantially faster than network-based component Chapter 9 - J2EE Enterprise Messaging invocation. Chapter 6
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter - Using WebSphere MQ as the JMS Provider Another11important difference between remote and local interfaces is the way in which method parameters Appendix are passed. A - In Deploying the remote Thisinterface, Book's J2EE parameters Examples are passed by value. In other words, remote methods
work with a local copy of passed parameters, so the original parameters are not modified even if the Index remote method changes their values. It also takes longer and requires more network resources to copy List of Figures andofpass large parameters over the network. In contrast, the local interface passes parameters by List Tables reference. It is faster, and the called methods can directly modify the original parameters. List of Code Examples List of Sidebars
WSAD 5.0 supports both remote and local interfaces. EJB components can provide remote interfaces, local interfaces, or both. In the case when an EJB component supports both local and remote interfaces, it is up to the EJB client to decide how to invoke the EJB component. Chapter 5 covers this WSAD 5.0 feature; you will develop several EJB components that use local and remote interfaces.
Supporting JMS Message-Driven Beans The J2EE 1.2 specification originally introduced Java Message Service (JMS), which is now included as a default in J2EE 1.3. To support JMS, J2EE 1.3 introduced a new type of EJB: the MDB that is part of the EJB 2.0 specification. WSAD 5.0 now fully supports JMS. JMS is a vendor-neutral Java messaging Application Programming Interface (API) that supports J2EE asynchronous communication. It is similar in concept to JNDI or JDBC, which are vendor-neutral APIs for accessing different naming and directory servers and various databases. Before the introduction of MDBs, there was a major technical issue with EJB components executing JMS on the receiving side of communication. Specifically, the problem was with using the Send/Receive mode of JMS communication. EJB components never have problems just sending asynchronous messages. In the Send/Receive mode, an EJB component sends a message and then waits for a response. Because of the nature of the asynchronous communication, there is no reasonable time limit for when the response should be expected. The EJB component can continue sending messages even when the opposite side of communication is not running. A J2EE application server is an object-based, distributed, transactionprocessing monitor developed and tuned for processing a large number of short tasks-conceptually
similar to the Custom Information Control System (CICS). An EJB component that has sent a message WebSphere Studio Application Developer 5.0: Practical cannot afford to stay active for a long time waiting for a response and monitoring a queue for the arrival of J2EE Development an expected response message. ISBN:1590591208 by Igor Livshin Apress © 2003 (630 pages) This message listening service should be removed from the component and delegated to a server. That This purpose book provides practical, step-by-step was the main design of theaMDBs introduced in theapproach EJB 2.0 in specifications. In WSAD and WAS howato use the WebSphere Studio Application versions 4.0x,IBMteaching supported proprietary listener; however, starting from release 5.0, it fully supports Developer (WSAD) tool for developing J2EE distributed JMS. This is an advanced part of J2EE development, covered in Chapters 9,10, and 11. Again, this book applications.
uses a practical, step-by-step approach to explain the intricate details of developing JMS applications with WSAD 5.0. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development
Understanding Other Significant WSAD 5.0 Enhancements
Introduction
Part One -5.0 Getting Started with WebSphere Studio Application Version includes other important enhancements, most ofDeveloper which are(WSAD) covered5.0 in
more detail throughout
Chapter 1 - Introducing WSAD 5.0 this book: Chapter 2
- Setting Up the Development Environment A new editor forthe Java that5.0 supports the Abstract Window Toolkit (AWT) and Swing-based Chapter 3 -visual Working with WSAD Workbench
graphical user interface for applets and applications. Chapter 4 - Developing Database Applications Part Two - Working with J2EE: The Distributed Application Framework
Support for J2EE 1.3, servlets 2.3, and JSP 1.2 (Filters, Listeners, Events, etc). This part is covered in - J2EE Development Chapter 5 with practical development examples in Chapters 6 and 7.
Chapter 5 Chapter 6
- J2EE EJB Development
Chapter Full 7 support - J2EEfor Web Struts-based Development Web application development. Chapter 8
- J2EE XML Development
Support for Enterprise JavaBean Query Language Part Three - Working with Enterprise Messaging
(EJB QL)-covered in Chapter 5.
Chapter 9
- J2EE Enterprise Messaging Simplified build and runtime CLASSPATH support (see Chapter 3).
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter A new 11 -Java Using Archive WebSphere (JAR)MQ generation as the JMS utility Provider and support for Javadoc. Appendix A - Deploying This Book's J2EE Examples Index
Pluggable runtime support for the Java Runtime Environment (JRE) and multiple runtime environments switching (see Chapter 3).
List of Figures
List ofThe Tables ability to run code with errors in methods. List of Code Examples
template support. List ofJava Sidebars Enhanced Web Service support. Enhanced XML support-covered in Chapter 8. New support for views, a stored procedure builder, a Data Definition Language (DDL) remote export, and DDL commitment to the database. Support for additional databases (Cloudscape 5.0 and Informix 9.3) and new database releases (Sybase Adaptive Server Enterprise 12.5 and Oracle 9i). New server support tools (WebSphere Log Analyzer). Extensible HTML (XHTML) support and custom JSP tags (taglib) support for JSP 1.2 (see Chapter 5). A new library view to catalog reusable objects. A TCP/IP monitoring server. Enhanced integration with Rational ClearCase LT and support for namespace and project versioning. New Web page designer (implemented in Java). See Chapter 7 for more information. The EJB 1.1 (J2EE 1.2) internal project structure in WSAD 5.0 is different from it was in WSAD 4.0x. This simplifies the tool's usability and is not related to J2EE 1.2 vs. J2EE 1.3. See Chapter 6 for more
information.
WebSphere Studio Application Developer 5.0: Practical
J2EE Development Enhanced Java Testing Framework (JUnit) and Apache Java-based build tool (ANT) integration. by Igor Livshin
ISBN:1590591208
The Database Apress Web©Pages 2003 (630 Wizard pages) now allows development of Web pages that perform update, edit, and delete database operations supportedapproach only the in read operations). See Chapter 6 for This book provides a (version practical,4.0x step-by-step teaching how to use the WebSphere Studio Application more information. Developer (WSAD) tool for developing J2EE distributed applications. Enhanced profiling and log analyzing.
In addition to supporting the standard EJB QL specification (EJB 2.0), Web-Sphere also provides
Table of Contents numerous extensions to the EJB QL language (such as ORDER BY, date/time expressions, subqueries, WebSphere Studio Application Developer 5.0: Practical J2EEfor Development GROUP BY, HAVING, EXISTS, and multiple elements the SELECT clauses) that make the EJB QL Introduction language much more powerful. WebSphere also introduces the new dynamic queries, which are query Part One accepted - Getting Started with WebSphere Studioaccepted Application Developer (WSAD) 5.0 strings at runtime rather than queries statically at development
Chapter 1
time.
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment Exploring the WebSphere Studio Family of Products - Working with the WSAD 5.0 Workbench
Chapter 3
Chapter 4 - Developing Database Applications WebSphere Studio comes in several flavors, discussed in the following sections. This book covers WSAD. Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 - J2EE Development WebSphere Studio Site Chapter 6
Developer (WSSD)
- J2EE EJB Development
WSSD 7is a-subset of WSAD; it provides tools for building Web and Struts applications but does not support Chapter J2EE Web Development EJBs. WSSD includes the integrated WAS software (versions 4 and 5) used for unit testing. Also, you can Chapter 8 - J2EE XML Development integrate Tomcat and use itMessaging for testing. Part Three Apache - Working with Enterprise Chapter 9
- J2EE Enterprise Messaging
WebSphere Studio Application Developer (WSAD)
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter - Using as the JMS(including Provider WAS) and provides full support for J2EE WSAD 11 contains allWebSphere the WSSD MQ functionality Appendix A Deploying This Book's J2EE Examples development: servlets, JSPs, EJBs, Web Services, major database access, XML, JMS, and other J2EE Index technologies. List of Figures
WebSphere List of Tables
Studio Application Developer Integration Edition (WSAD IE)
List of Code Examples
WSAD IE includes all the functionality in WSAD plus the following:
List of Sidebars
J2EE connector architecture support Visual editing of service-oriented architecture workflows A wizard for complex Web Services and EJBs WebSphere Application Server Enterprise Edition (WAS EE) support
WebSphere Studio Enterprise Developer (WSAD EE) WSAD EE includes all the functionality of WSAD IE plus the following: Enterprise Generation Language z/OS and OS/390 support WebSphere Studio Asset Analyzer Developer resource portal
WebSphere Studio Application Developer 5.0: Practical Understanding the Resource Requirements J2EE Development
ISBN:1590591208 by Igor WSAD is a powerful toolLivshin that requires substantial machine resources to run:
Apress © 2003 (630 pages)
Intel PentiumThis II processor minimum (Pentium III 500MHz or faster book provides a practical, step-by-step approach in recommended) teaching how to use the WebSphere Studio Application
512MB RAMDeveloper minimum (WSAD) (768MBtool recommended) for developing J2EE distributed applications.
800MB available disk space Table of Contents
Referring to the WSAD 5.0 Migration Guide
WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction WSAD 5.0 supports WSAD 4.0x and VisualAge for Java migration. The WSAD 5.0 Migration Guide Part One - detailed Getting Started with for WebSphere Studio Application Developer (WSAD) 5.0 Be contains information various product versions and operating systems.
aware that migration
Chapter 1 - Introducing WSAD from version 4.0x to version 5.05.0 does not automatically change the project level. To change the Web Chapter - Setting Up the the project Development Environment project 2level, rightclick and select Properties > Web > J2EE Level. Chapter 3
- Working with the WSAD 5.0 Workbench Changing EJB project level isApplications more involved. You need to create a new EAR project, open the METAChapter 4 the - Developing Database
INF/Application.xml deployment Modules, and then Part Two - Working with J2EE: The descriptor, Distributedselect Application Framework
select Add > myModules. You can find the WSAD 5.0 Migration Guide at Chapter 5 - J2EE Development http://www.ibm.com/websphere/developer/zones/studio/transition.html. In addition, Chapter 6 - J2EE EJB Development you can refer to the IBM Redbook Migrating to WebSphere V5.0: An End-to-End Migration Guide at Chapter 7 - J2EE Web Development http://www.redbooks.ibm.com/redbooks/SG246910.html. Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Targeting WAS 4.0x, WAS 5.0, and WAS Express - J2EE Enterprise Messaging
Chapter 9
Chapter 10 - Using the WSAD-Embedded JMS Provider
Most applications that have been developed and subsequently tested on WAS 4.0x will run unchanged on WAS 5.0. However, if the application uses newer specificationlevel features (J2EE 1.3, servlets 2.3, Appendix A - Deploying This Book's J2EE Examples JSP1.2, and so on), then that application will only run on WAS 5.0. Chapter 11 - Using WebSphere MQ as the JMS Provider Index
List of Figures If you develop applications with WSAD 5.0 that you want to deploy and run on WAS 4.0x,you should be List of Tables aware that some WSAD 5.0 wizards create projects and resources that default to J2EE 1.3. To change List theofdefault Code Examples to J2EE 1.2, select Windows > Preferences > J2EE. Then select the highest J2EE 1.2 version. List of Sidebars
The WAS Express environment is the only test environment included in the WAS Express development product. WAS Express is similar to WAS 5.0 but does not support EJBs. After this brief introduction to the relevant WebSphere products, you are ready to start building your development environment.
Summary
WebSphere Studio Application Developer 5.0: Practical J2EE Development
ISBN:1590591208 by introduced Igor Livshinyou to WSAD 5.0-one of the most This chapter briefly popular J2EE development tools from © 2003 5.0 (630 is pages) IBM. You learnedApress that WSAD fully compliant with the J2EE 1.3 specification and provides full support for EJB 2.0, servlets JSP 1.2. The chapter also described new features and This2.3, bookand provides a practical, step-by-step approachnumerous in to use the WebSphere Studio Application enhancements ofteaching version how 5.0 and highlighted the most important ones: local interfaces, a new CMP entity (WSAD) tool for developing J2EE distributed bean model, andDeveloper JMS MDBs.
applications.
The following chapters explore many of these features in detail by building step-by-step examples. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Studio Application Developer 5.0: Practical Chapter WebSphere 2: Setting Up the Development Environment J2EE Development
Overview
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in
The developmentteaching environment how torequires use the the WebSphere installation Studio of WebSphere Application Studio Application Developer (WSAD) tool for developing J2EE distributed (WSAD) 5.0 and Developer the DB2 Universal Database (UDB) 7.2 with Fixpack 6 database. You will install applications. WebSphere MQ (MQSeries 5.3.1) in Chapter 9 where enterprise messaging is covered. This chapter covers how to set up the development environment for the Windows 2000 platform (other platforms require a similar installation process). The Windows 2000 platform requires Service Pack 2 or later to be Table of Contents installed. WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction
Note At the time of this book’s publication, Service Pack 3 is currently available for download from the Microsoft Web site (http://www.microsoft.com).The cumulative update includes Chapter 1 Service - Introducing WSAD 5.0 Pack 2, so Service Pack 3 is all you need to download and install. Please check the Chapter 2 documentation - Setting Up thefor Development Environment other Windows platforms. Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 3
- Working with the WSAD 5.0 Workbench In this chapter, you will first download and install the DB2 database and then download and install the Chapter 4 - Developing Database Applications
WSAD files. with J2EE: The Distributed Application Framework Part Two5.0 - Working Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical Downloading and Installing the DB2 Database J2EE Development
ISBN:1590591208 Igor Livshin If you do not havebythe DB2 installation CD-ROM, you can download a trial version of the DB2 UDB © 2003 pages)At the time of this book’s publication, you can download the Personal Edition Apress 7.2 from the (630 Internet. package from theThis IBMbook Webprovides site at http://www.software.ibm.com/data/db2. a practical, step-by-step approach in
teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Setting Up Your System for DB2 Installation
The trial version is a single-user version of the DB2 product. Once you download the latest available Table of Contents version of DB2 and read the installation instructions, create a temporary directory and unzip the WebSphere Studio Application Developer Practical Development downloaded file in this directory. Follow5.0: these stepsJ2EE before starting the DB2 installation: Introduction 1. Log on as an administrator on the local machine. Create a new local user account called Part Onedb2admin - Getting Started withitWebSphere Application Developer (WSAD) 5.0 and make a member Studio of the Administrators group. The password
must be DB2
Chapter compatible. 1 - Introducing WSAD 5.0 it should be eight characters or fewer, and it should not include the < or (In other words, Chapter > 2 characters.) - Setting Up the Development Environment Chapter 3
- Working with the WSAD 5.0 Workbench 2. Next, assign special rights Applications to this account by selecting Start > Control Panel > Chapter 4 - Developing Database
> Local Application SecurityFramework Policy > Part TwoAdministrative - Working with J2EE:Tools The Distributed
Local Policies > User Rights
Chapter Assignment. 5 - J2EE Development Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- Act J2EE asXML partDevelopment of the operating system.
3. Assign the following special rights to this account:
Part Three - Working with Enterprise Messaging
Chapter 9
as a service. - Log J2EEon Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
Create a token object.
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Increase Deployingquotas. This Book's J2EE Examples Index List of FiguresReplace a process-level token. List of 4.Tables Log off and log in again locally as db2admin.Launch setup.exeto begin the DB2 package List of Code ExamplesFinally, follow the installation instructions. installation. List of Sidebars
Note Avoid installing DB2 in the subdirectory of the \Program Files directory for two reasons. First, writing in this directory (or its subdirectory) requires the user to have an account with administrative rights. In addition, try to avoid a long-name installation directory because the CLASSPATH and PATH environment variables have a length limit. On my development machine, I installed the DB2 package in the g:\sqllibdirectory. When prompted to enter a username and password, enter db2adminand the corresponding password for this account. When the DB2 setup is complete, the First Steps window will appear. Close it and reboot the machine. When the system restarts, log in locally again as db2adminto configure DB2 as explained in the next section.
Configuring DB2 to Use JDBC 2.0 Drivers DB2 (by default) supports Java Database Connectivity (JDBC) 1.0 drivers, which is not acceptable for Java 2 Enterprise Edition (J2EE) development. You need to change the DB2 configuration to support JDBC 2.0 drivers. You must make this configuration change when the DB2 JDBC Applet Server is not running. To stop the DB2 JDBC Applet Server (it runs as a Windows service), enter the following command: net stop DB2 JDBC Applet Server Now, you can switch DB2 to the mode that supports JDBC 2.0 drivers. In the command-line window, switch to the directory g:\sqllib\java12.Enter the following command:
usejdbc2.bat WebSphere Studio Application Developer 5.0: Practical J2EE Development Next, verify that you receive the “file copied” message. Finally, start the DB2 JDBC Applet Server by ISBN:1590591208 by Igor Livshin entering the following command: Apress © 2003 (630 pages)
net start "DB2 JDBC Applet Server"
This book provides a practical, step-by-step approach in
teaching to use the WebSphere Studio Application To make your work more how convenient, create a DB2 shortcut. Right-click Start> Explore, expand All Developer (WSAD) tool for developing J2EE distributed Usersin the Document and Settings directory, expand Start Menu, and click Programs. Rightapplications. click IBM DB2 and drag it onto your desktop. This creates the DB2 shortcut for easy DB2 invocations. Finally, log in as a network user and build a DB2 shortcut for the network user account using the same Table of Contents steps. WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical Downloading the WSAD 5.0 Installation Files J2EE Development
Igor Livshin If you do not havebythe WSAD 5.0 installation CD-ROM, you canISBN:1590591208 download a trial version for free 60-day Apress 2003 (630 pages) evaluation from the IBM©WebSphere Developer Domain site at http://www7b.software.ibm.com/wsdd/downloads/WSsupport.html. This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Picking the Files to Download
From the same site, you can also get 30-day free-trial support with installation, configuration, and Table of Contents deployment. For the current WSAD 5.0 release, you need to download nine required core files. The rest of WebSphere Studioparts) Application Developer 5.0: Practicalor J2EE Development the files (called are optional. You download ignore them depending on your specific development Introduction environment. Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
The following parts are optional: Chapter 1 - Introducing WSAD 5.0 Chapter 2
- Setting Up the Development Environment Part 10: This contains the remote Agent Controller installation. Agent Controller is no longer installed
Chapter 3 - Working with WSAD4.0x). 5.0 Workbench automatically (as it was forthe WSAD Agent Controller is a daemon process that helps the client Chapter 4 Developing Database Applications application launch new host processes or attach to agents that exist within existing host processes. You Part Two Working with J2EE: Theif Distributed need to -install Agent Controller you plan toApplication perform theFramework following tasks:
profile your applications, use
Chapter - J2EE Development logging5tools to import remote WebSphere activity log files, or remotely debug your applications. I Chapter 6 J2EE EJB recommend you installDevelopment this part. Chapter 7
- J2EE Web Development
Part 11: contains the Rational ClearCase LT Source Configuration Management (SCM) package. Chapter 8 This - J2EE XML Development Download this file if you to use ClearCase LT for your SCM. Currently, WSAD comes with support Part Three - Working with intend Enterprise Messaging for two source-control management packages that allow developers to work as a team: Concurrent Chapter 9 - J2EE Enterprise Messaging Versions System (CVS) and ClearCase LT. Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter - Using WebSphere as the JMS Provider CVS is 11 an open-source controlMQ management package from Concurrent Versions System. It is available for Appendix A Deploying This Book's J2EE ClearCase Examples LT is a limited release of the full ClearCase version free from http://www.cvsnt.org. Index from Rational Software. The LT version comes with WSAD (on CD-ROM) or is downloadable from the List of Figures Internet as a part of the WSAD trial version. CVS is a simple SCM package. Its main problem is the lack of List of Tables change-control mechanisms (mechanisms that allow a developer to lock the source in the repository for List theofduration Code Examples of source modification). ClearCase LT is a more sophisticated package that supports source
locking in local streams, but it still lacks source locking in external streams. List of Sidebars Note You can postpone this decision by selecting Otherwhen prompted for the SCM package during installation. Keep in mind that selecting the CVS,ClearCase, or Otheroption merely installs the WSAD support for the corresponding package. You must install the actual package separately. You also need to be aware that selecting the Otheroption is compatible with CVS. You do not need to reinstall WSAD should you decide later to use the CVS package. On the other hand, you have to reinstall WSAD to use ClearCase LT if you did not select this option during installation. Tip With WSAD 4.x, there was an easier way to switch between SCM packages and avoid WSAD reinstallation. However, at the time of publication, this facility was not included in WSAD 5.0. In case this facility does become available again, I've included this tip. Be sure to check availability before using the tip. There are two procedures located in the \plugins\com.rational.clearcasedirectory called enable_clearcase.batandenable_vcm.bat(you need to close WSAD before executing either of these procedures). Part 12: This contains the embedded messaging client and server. You do not need this part if any of the following are true: You do not plan to build Java Message Service (JMS) applications. You plan to test your JMS application on WAS.
You plan to use WebSphere MQ Application as a WSAD Developer 5.0 JMS provider. WebSphere Studio 5.0: Practical J2EE Development
Should you decide need the messaging support, download this part. ISBN:1590591208 bythat Igoryou Livshin Apress © 2003 (630 pages)
Download the nine required files (plus any optional files that you need) and unzip them in the same provides a practical, step-by-step approach in directory. All filesThis are book self-extracting, so click each file and specify the same target directory for extraction. teaching how to use the WebSphere Studio Application Before installing WSAD 5.0,(WSAD) you may want to print twoJ2EE files:distributed install.pdfandreadme.html.Both Developer tool for developing documents provide useful installation information. applications. Starting from this point, the installation process is identical to the CD-ROM installation. The only difference Table is that of the Contents CD-ROM installation has the autorun feature, which automatically launches the setup.exe
program (with theApplication image files, you need to Practical launch the setup.exe program manually). WebSphere Studio Developer 5.0: J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Understanding the Installation Requirements
Chapter 1
- Introducing WSAD 5.0
Chapter Setting Up theWSAD Development Environment Before 2you-start installing on Windows 2000, you need to understand the following installation Chapter requirements. 3 - Working with the WSAD 5.0 Workbench Chapter 4
- Developing Database Applications
WSAD’s is aJ2EE: directory where WSAD keeps all user development Part Two - workspace Working with The Distributed Application Framework
activity organized in the form of projects. WSAD is capable of working with multiple workspaces. When first started after installation, Chapter 5 - J2EE Development WSAD 5.0 creates a new workspace in the Windows Document and Settings directory. You can Chapter 6 - J2EE EJB Development change the location of this first workplace. In addition, if you check the Use This Workspace as a Chapter 7 - J2EE Web Development Default and Do Not Show This Dialog Again box, this workspace will become the default Chapter 8 - J2EE XML Development workspace, and it will be used any time you start WSAD. In this case, to start WSAD with another Part Three - Working with Enterprise Messaging workspace, create another shortcut for starting WSAD and modify the command that invokes WSAD. Add Chapter 9 -WSAD_workspace J2EE Enterprise Messaging the-data parameter to this command. For example: Chapter 10 - Using the WSAD-Embedded JMS Provider
G:\WSAD\wsappdev.exe -data WSAD_workplace
Chapter 11 - Using WebSphere MQ as the JMS Provider
Appendix A - Deploying This Book's J2EE Examples directory to be used by WSAD. where WSAD_workplace indicates the workspace Index
Figure 2-1 shows the WSAD Windows shortcut that has been set to use the workspace_Developer1 List of Figures directory as the default workspace. List of Tables List of Code Examples List of Sidebars
Figure 2-1: WSAD shortcut specifying the workspace directory On the other hand, if you uncheck the Use This Workspace as a Default and Do Not Show This Dialog Again option, WSAD will always prompt you at startup for the workspace location. WSAD will create a new workspace directory if the directory you specified does not exist. If you start WSAD with a new (nonexisting) workspace directory defined as a subdirectory of the \Program Files directory, the user starting WSAD needs to have an WebSphere Studio Application Developer 5.0: Practical account with administrative rights. J2EE Development
ISBN:1590591208 by is Igor Livshinin the \ProgramFiles WSAD (by default) installed directory, Apress © 2003 (630 pages) which (again) requires the user installing WSAD to have an account with administrative rights. In addition, This book Your provides a practical,environment, step-by-step approach be aware of the following: development especiallyinif you are going to use JMS, will teaching howof toJAR use the Studio Application require a substantial number filesWebSphere to be included in your CLASSPATH environment variable. The Developer (WSAD) tool for developing J2EE distributed CLASSPATH environment variable in the Windows environment has a length restricted to 256 bytes. I applications. strongly recommend you install WSAD in a directory with a shorter name (say, g:\WSAD).Otherwise, you will end up with a CLASSPATH environment variable that exceeds 256 bytes. This way of installation Table Contents also of helps deal with another Windows 2000 problem—the value of the PATH environment variable must WebSphere be fewer than Studio 820 Application characters. Developer 5.0: Practical J2EE Development
Introduction
Considering all options, best way to install WSAD (and any other software Part One - Getting Startedthe with WebSphere Studio Application Developer (WSAD) packages) 5.0
is by logging in locally as an administrator, installing the package outside the Program Files directory, and using a Chapter 1 - Introducing WSAD 5.0 relatively short name for the installation directory (such as g:\WSAD).SelectCustomized(when Chapter 2 - Setting Up the Development Environment prompted) to install WSAD in a nonstandard directory. Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4 - Developing After WSAD installation,Database log in asApplications a network user, right-click Start> Explore, expand All Users in Part Two - Working with J2EE: The Distributed Document and Settings, expand StartApplication Menu, andFramework click Programs.
Finally, right-click the icon for
Chapter 5 - J2EE and Development IBM WebSphere drag it onto your desktop. This will create a shortcut for easy WSAD invocation. Chapter 6 - J2EE EJB Development
Tip7Specifying different workspace locations for different WSAD shortcuts allows a developer to Chapter - J2EE Web Development on different WSAD projects. This is a useful option for organizing your work. Chapter 8conveniently - J2EE XMLwork Development Part Three - Working with Enterprise Messaging
If you have already used WSAD 4.0x and have projects that need to be converted to WSAD 5.0, you can - J2EE Enterprise Messaging use two methods to migrate your projects to WSAD 5.0:
Chapter 9
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter Use 11one - Using of theWebSphere available SCM MQ as systems, the JMS such Provider as CVS or Rational ClearCase LT. This is the
recommended way. Appendix A - Deploying This Book's J2EE Examples Index
Export your projects from the WSAD 4.0x workspace and import them to the WSAD 5.0 workspace. This method migrates everything except the Project BuildPath, which needs to be entered List of Tables manually. List of Figures
List of Code Examples
List Sidebars the migration from version 4.0x to version 5.0 does not automatically change the project As of mentioned,
level. To change the Web project level, right-click the project and select Properties> Web> J2EE Level. Changing the EJB project level is more involved. You need to create a new EAR project and then open the META-INF/Application.xmlDeployment Descriptor, select Modules, and then select Add > myModules. Once in WSAD 5.0, you can migrate a J2EE 1.2 project to J2EE 1.3 using the Migration wizard. Right-click the project and select Migrate> J2EE Migration Wizard to start the wizard. Do not install WSAD on High Performance File System (HPFS) files because Windows 2000 has a problem handling long filenames on HPFS files. You are now ready for WSAD installation.
WebSphere Installing WSAD 5.0Studio Application Developer 5.0: Practical J2EE Development
ISBN:1590591208 With all the files extracted, by Igor Livshin start the WSAD installation by executing setup.exe,which is located in the Apress © 2003 (630been pages)extracted. You will see the screen shown in Figure 2-2. directory where all the files have
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three Figure - Working 2-2: WSAD withinstallation Enterprise screen Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
From the screen shown in Figure 2-2, you can select several installation options (from the full WSAD installation to the installation of several optional parts of WSAD). Several additional options allow you to Appendix - Deploying Book's J2EE Examples display, A read, and printThis certain parts of the WSAD documentation. To install the WSAD package, follow Index these steps: Chapter 11 - Using WebSphere MQ as the JMS Provider
List of Figures
1. Click Install IBM WebSphere Studio Application Developer. Select Custom Installationand indicate a short-named WSAD installation directory (on my machine, I installed WSAD in the List of Code Examples g:\WSAD directory). Follow the installation instructions. After successful WSAD installation, reboot List of Sidebars the machine. List of Tables
2. Runsetup.exeagain. This time, select Install IBM Agent Controller. Specify the installation directory (on my machine I installed it in the g:\WSAD\AgentControllerdirectory). When prompted to indicate the Java runtime, click Browseand navigate to the \eclipse\jre\bindirectory. When prompted, select Disable Security. Optionally, repeat the same steps to install ClearCase LT. (Chapter 9 discusses the installation of the embedded messaging client and server.) Finally, start WSAD. The first screen will prompt you for the location of WSAD’s workspace directory (see Figure 2-3).
Figure 2-3: Setting the WSAD workspace On my machine, I specified: g:\WSAD\workspace.I also checked the box (making this the default
workspace directory and requesting not to show this dialog box again). If you need to use another WebSphere Studio Application Developer 5.0: Practical workspace, you can build a separate WSAD shortcut. The last installation screen should indicate that J2EE Development WSAD has been successfully installed. by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
Installing WSAD on the Server
This book provides a practical, step-by-step approach in how to use therequire WebSphere Studio Application Large WSADteaching installations typically installing WSAD executables on the server but storing the Developer (WSAD) tool for developing J2EE distributed workspace on a local drive or on a mapped home directory. Assuming that all the company software applications.
packages are installed on a server drive locally mapped to the s: drive, use the following command for the shortcut to start WSAD from the server: Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction S:\wsad\wsappdev.exe -data g:\local_workspace_directory Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
This concludes setting upWSAD the development environment. Chapter 9 covers additional development Chapter 1 - Introducing 5.0 environment setup that is necessary for processing Chapter 2 - Setting Up the Development EnvironmentJMS applications. Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Summary
WebSphere Studio Application Developer 5.0: Practical J2EE Development
by Igor This chapter covered theLivshin process of building the development ISBN:1590591208 environment necessary to follow the book Apress © 2003to(630 pages) examples. You learned how download and install the DB2 database and the WSAD 5.0 J2EE development toolThis from IBM.provides a practical, step-by-step approach in book teaching how to use the WebSphere Studio Application Developer tool for the developing distributedDevelopment Environment (IDE), so In the next chapter, you will(WSAD) start exploring WSAD J2EE 5.0 Integrated applications. make sure your development environment is ready. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Studio Application Developer 5.0: Practical Chapter WebSphere 3: Working with the WSAD 5.0 Workbench J2EE Development
Overview
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in
This chapter introduces teachingyou how toto theuse WebSphere the WebSphere Studio Studio Application Application Developer (WSAD) 5.0 Workbench, tool for This developing J2EE distributed which is WSAD'sDeveloper graphical (WSAD) user interface. chapter explores a rich set of features, tools, and wizards applications. that simplifies Java 2 Enterprise Edition (J2EE) development and substantially increases your productivity as a developer. Table of Contents
In this chapter, you will learn about the role-based development architecture of WSAD. Specifically, the chapter covers the following topics:
WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction
Part One - Getting Startedand withViews WebSphere Studio Application Developer (WSAD) 5.0 Using Perspectives
Chapter 1
- Introducing WSAD 5.0
Creating projects Chapter 2 - Setting Upand the folders Development Environment Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Developing and debugging programs
Part Two - Working J2EE: wizards The Distributed Application Framework Exporting andwith importing
Chapter 5
- J2EE Development
Customizing Chapter 6 - J2EE the EJB Workbench Development Chapter 7
- J2EE Web Development
Chapter 9
- J2EE Enterprise Messaging
You will also develop your first project with WSAD in this chapter; specifically, you will create a 'Hello Chapter 8 - J2EE XML Development World' Java application. The chapter begins by exploring the Workbench, which is the main graphical user Part Three - Working with Enterprise Messaging interface window. Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio ApplicationWindow Developer 5.0: Practical Understanding the Workbench Layout J2EE Development
ISBN:1590591208 You can invoke the by Workbench Igor Livshin by selecting Start> Programs > IBM WebSphere Studio > Application Developer Apress © 2003 (630 5.0. pages)
This book provides a practical, step-by-step approach in
However, this method is ahow littletobituse involved. You probably teaching the WebSphere Studioremember Applicationthat during the WSAD 5.0 installation (WSAD) tool for developing J2EE distributed you developed a Developer shortcut for fast WSAD activation. Double-click the shortcut now to start WSAD. The applications. screen that appears is the main interface of the WSAD Workbench (see Figure 3-1). Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider
Figure 3-1: The WSAD Workbench
Appendix A - Deploying This Book's J2EE Examples Index You will see the main menu and toolbar at the top of the Workbench window. The vertical bar on the left is List theofPerspective Figures Bar. It contains buttons that are shortcuts for the quick activation of already opened
Perspectives List of Tables (you will learn about Perspectives in a moment). List of Code Examples
You can divide the Workbench layout roughly into two areas. The area on the left is the Navigation Pane, which presents a hierarchical view of the workspace. A more detailed discussion of the workspace follows, but for now it is important to understand that the workspace is a directory where WSAD keeps all of your development projects.
List of Sidebars
The area on the right is the Content Pane, which displays different content depending on the type of development work being done. In Figure 3-1, a welcome screen for the Help Perspective appears in this area. The bar on top of the Content Pane shows mini-bars for files opened in the Content Pane. Each mini-bar has an X button for closing the corresponding window. These windows are Editor Views. Although you can open multiple windows in the Content Pane, only one window is visible at a time (with the rest being hidden behind it). The visible window is the active window and its bar is highlighted. You can click the X button on the active window’s mini-bar to close the window. On the top of the WSAD Workbench is the main window title bar. To the left of the program’s title, you should see the name of the currently active Perspective; in Figure 3-1, it is J2EE. The active Perspective's name is always displayed in the left part of the title bar. The next section discusses Perspectives and Views—two fundamental parts of the Workbench.
WebSphere Studio Application Developer 5.0: Practical Using WSAD Perspectives and Views J2EE Development
ISBN:1590591208 by Igor A WSAD Perspective is aLivshin set of tools made available for a particular type of development. For example, Apress © 2003 (630Java pages)application, you do not need the Web development tools (such as when you develop a stand-alone the Art Editor, HTML and so aon). Therefore, the Javaapproach Perspective This Editor, book provides practical, step-by-step in displays only the tools you need how to use the WebSphere Studio Application for effective Javateaching development.
Developer (WSAD) tool for developing J2EE distributed applications. You can use Perspectives to adjust the WSAD development environment for a particular development role
in accordance with the main notion of the WSAD architecture—as a role-based development tool. Switching to a certain Perspective causes the corresponding changes to occur in the Workbench internal Table of Contents configuration (together with visible changes of the Workbench content). WebSphere Studio Application Developer 5.0: Practical J2EE Development
Introduction J2EE is a complex technology that requires the involvement of many specialists, such as Web developers, Part One - Getting Started JavaBean with WebSphere Studio Application Developer (WSAD) and 5.0 Java coders, Enterprise (EJB) developers, application assemblers,
so on. The WSAD
Chapter 1 - architecture Introducing WSAD Perspective allows5.0 WSAD to adjust its development setting and the layout of its main window Chapter 2 the - Setting Up the Development Environment to provide best combination of tools for each developer’s role. Chapter 3
- Working with the WSAD 5.0 Workbench Each WSAD tool appears inside the WSAD Workbench as a View. Each Viewdisplays the data that a Chapter 4 - Developing Database Applications
specific visually presents to the developer. One tool Framework can be presented Part Two -tool Working with J2EE: The Distributed Application
by multiple Views, such as the Java Editor tool being presented by the Editor View, Outline View, Tasks View, and Properties View. You Chapter 5 - J2EE Development will learn more about Perspectives and Views shortly, but for now you should get an idea of how they look. Chapter 6 - J2EE EJB Development Chapter 7 a- particular J2EE WebPerspective, Developmentclick Window > Open Perspective from the main menu. Then, select To select Chapter 8 - J2EE XML Development the Perspective you want to open; for example, select Window > Open Perspective > Java. Part Three - Working with Enterprise Messaging
If the Perspective you need is not in the menu list, select Other. You will see a full list of Perspectives (see Chapter 9 - J2EE Enterprise Messaging Figure 10 3-2).- Using the WSAD-Embedded JMS Provider Chapter Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 3-2: Perspective selection list Select the Perspective from the list and click OK. Figure 3-3 depicts the Web Perspective. (You can even create and name your own Perspectives by choosing and arranging a group of Views and providing a name for a new Perspective. The new Perspective will then be available from the list.)
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
Developing Database Applications Figure- 3-3: The Web Perspective
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development When the Perspective is open, an icon for the Web Perspective appears on the Perspective Bar (a Chapter 6 Web - J2EE EJB Development
vertical7bar- located on Development the left of the upper part of Workbench). In the Navigation Pane in Figure 3-3, the Chapter J2EE Web
Web project called DBProjectis expanded. The BookSearchController.javaservlet module is in - J2EE XML Development the Java Source directory (in the subdirectory that corresponds to this program’s Java package name, Part Three - Working with Enterprise Messaging apress.wsad.db). Double-clicking the BookSearchController.java module opens its source code in the Chapter 9 - J2EE Enterprise Messaging Java Editor View (in the Content Pane). Chapter 8
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 Perspective - Using WebSphere MQ asmany the JMS ProviderViews. On the left-lower part of the Workbench, the The Web also displays additional Appendix A Deploying This Book's J2EE Examples Gallery View presents a set of Web art and images that you can use when designing Web page graphics. Index Clicking the Illustration folder displays available graphics files in the Thumbnail View (see Figure 3-4). List of Figures List of Tables List of Code Examples List of Sidebars
Figure 3-4: The Thumbnail View In the same pane where the Gallery View displays, you should see several tabs at the bottom (Library, Outline, Web Structure, and Attributes). Clicking the Outline tab shows the outline of the currently displayed Java code: the package name, the import declaration, and the methods (see Figure 3-5).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
Developing Database Applications Figure- 3-5: The Outline View
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 - J2EE Development At the bottom of the Content Pane, you will see the tab for the Tasks View displayed. All error and other Chapter 6 -found J2EE in EJB messages theDevelopment entire Workbench appear in the Tasks View (see Figure 3-6). You can also filter Chapter tasks displayed 7 - J2EE in Web the Tasks Development View based on type, status, a particular set of resources, priority, or problem
severity. can also add your own tasks as reminders and optionally associate them with a set of Chapter 8 You - J2EE XML Development resources. Part Three - Working with Enterprise Messaging Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 3-6: The Tasks View Clicking any message displayed in the Tasks View highlights the corresponding line in the source code (the code this message references). If you modify some code, saving the file (by selecting Save from the main menu or clicking the icon that looks like a floppy disk) automatically triggers the Java compilation process. You can control this WSAD behavior by selecting Window > Preferences from the main menu. On the screen that appears, you can change the way the Workbench behaves in certain situations (see the“Customizing the Workbench” section for more information).
Learning Multiple Ways to SelectDeveloper Perspectives WebSphere Studio Application 5.0: Practical J2EE Development
WSAD provides several for selecting Perspectives. Say you want to switch to the Java Perspective. ISBN:1590591208 by Igor ways Livshin One way to do this is to select Window > Open Perspective from the main menu. Apress © 2003 (630 pages) provides practical, in Another way is toThis clickbook the first icon alocated on step-by-step the top of theapproach vertical Perspective Bar. If you put the cursor teaching how to use the WebSphere Studio Application on top of this icon, the help (WSAD) message displays the text J2EE Opendistributed a Perspective. Click this icon and select the Developer tool for developing Java Perspectiveapplications. from the list. The Workbench switches to the Java Perspective (see Figure 3-7).
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider
Figure The Java Appendix A - 3-7: Deploying ThisPerspective Book's J2EE Examples Index
Now, the icon of the opened Java Perspective appears on the Perspective Bar. The third way for switching the Workbench to another Perspective is to use the icons on the Perspective Bar, which displays the icons List of Tables of all the opened Perspectives. Moving a cursor over each icon displays a description of the selected List of Code Examples Perspective. Simply clicking an icon switches the Workbench to the selected Perspective. List of Figures
List of Sidebars
Tip Keeping many Perspectives concurrently opened (displayed on the Perspective Bar) is not a good idea. First, each opened Perspective consumes additional resources. Second, if several concurrently opened Views point to the same file, then all such Views must be synchronized—a process that also consumes resources. This extra processing slows down WSAD execution.
Working with Commonly Used Perspectives The following sections briefly describe the most frequently used Perspectives. The book provides more detailed Perspective-related information in later chapters.
Using the Java Perspective The Java Perspective is most useful for developing Java applications. It shows Java classes and interfaces grouped by packages. It also provides the Java Editor, Outline, and Tasks Views. In this Perspective, the Workbench toolbar contains several icons to add new packages, new Java classes, new Java interfaces, and so on. (You already saw the Java Perspective in Figure 3-7.) In Figure 3-7, the first Java Editor View displays the BookSearchController.javafile. You see only the module name on the top bar of the Java Editor View because this View is not active. The second Java Editor View displays the BookSearchDetailsViewBean.java file (the active View). Clicking the X icon of the active Java Editor View closes this View, and the pane automatically displays the next open Java Editor View that was previously hidden. Now, this View becomes the active View with its tab highlighted.
Using the Web Perspective WebSphere Studio Application Developer 5.0: Practical J2EE Development
The Web Perspective is preconfigured for developing static pages—consisting of Hypertext Markup ISBN:1590591208 by Igor Livshin Language (HTML) and images—and dynamic pages—consisting of servlets and JavaServer Pages Apress © 2003 (630 pages) (JSPs).Figure 3-8 depicts the Web Perspective with the HTML Editor View previewing the file being edited. This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 - 3-8: Introducing WSAD 5.0 Figure The Web Perspective’s Preview View Chapter 2 - Setting Up the Development Environment
The HTML View can display file content in three different Views: Design (shows the page Chapter 3 -Editor Working with the WSADthe 5.0HTML Workbench as a set4 of -HTML controls), Source (shows the HTML code), and Preview (shows how the page looks in a Chapter Developing Database Applications browser). Clicking with one of three tabs at the bottom of the Framework HTML Editor Part Two - Working J2EE: The Distributed Application
View switches the pane to the corresponding View. Figure 3-8 shows the Preview View (how the user will see the page at runtime). Chapter 5 - J2EE Development Chapter 6
- J2EE EJB Development At the bottom of the Workbench, several tabs show different Views that can be displayed (depending on
Chapter J2EE Web Development the type7 of -file displayed in the upper pane). Clicking one of these tabs will display a Tasks, Links, Chapter 8 - Styles, J2EE XML Development Thumbnail, Colors, or Servers View. Part Three - Working with Enterprise Messaging
As you 9can- see, Links View is displayed in Figure 3-8. It shows the relationship between different files Chapter J2EEthe Enterprise Messaging that comprise the Web project. If a file refers to an HTML page that the Workbench is unable to locate, the Chapter 10 - Using the WSAD-Embedded JMS Provider link will11 appear as broken. Chapter - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
Using the J2EE Perspective
Index
List of Figures
You use the J2EE Perspective for developing the EJB components (entity and session beans). The toolbar
List of Tables displays the icons for building enterprise applications; building entity, session, and Message Driven Beans List of Code Examples EJB deployed code; mapping Container Managed Persistence (CMP) entity bean (MDBs); generating List of Sidebars properties to the database record fields; and so on. Double-clicking a bean file in the Navigation Pane
opens it in the Java Editor View. Also displayed are the Outline and Property Views (for working with bean properties). The J2EE View shows all the J2EE modules present in the workspace. The Navigator View shows your projects as folders and files. You can also use the J2EE Perspective for packaging the J2EE applications and preparing the projects for deployment. It provides editors for editing the Deployment Descriptor files (setting transaction properties, security, and so on). You will frequently use this Perspective when developing this book’s examples. To open the project’s Deployment Descriptor, right-click the project and select OpenWith > Deployment Descriptor Editor (see Figure 3-9).
Figure 3-9: The project’s Deployment Descriptor in the J2EE Perspective Note To open the Deployment Descriptor for the Web projects, right-click the web.xmlfile and selectOpen With > Deployment Descriptor Editor, or just double-click web.xml.
The application-level Deployment Descriptor screen displays the context root of the Web module as well WebSphere Studio Application Developer 5.0: Practical as many other fields. This information determines the Uniform Resource Locator (URL) structure for J2EE Development activating the application. To construct a URL that would invoke the components of this Web module, the ISBN:1590591208 by Igor Livshin context root should be concatenated with the component filename (typically an HTML or JSP file). Chapter Apress © 2003 (630 pages) 7 shows how to do this.
Using the
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Data Perspective Developer (WSAD) tool for developing J2EE distributed applications.
You can use the Data Perspective for working with relational databases, schemas, and tables. The DB Servers View shows connections to the databases. If the plus (+) sign appears in front of the connection, Table of Contents you can expand it to show the hierarchical structure of the database, schema, tables, and fields. This View WebSphere also showsStudio remote Application procedures, Developer table views, 5.0: Practical aliases,J2EE triggers, Development and so on. To create a new connection, right-click anywhere in the DB Servers View area and select New Connection. You can use the Data Introduction Definition View forStarted building a new database, schema, table, Developer and so on.(WSAD) To do this, Part One - Getting with WebSphere Studio Application 5.0 right-click anywhere in the Data View WSAD and select Chapter 1 Definition - Introducing 5.0 New Connection (see Figure 3-10). Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 3-10: TheDatabase Connection screen
Using the XML Perspective You can use the XML Perspective for developing the XML-related applications. It presents several editors for building and modifying Extensible Markup Language (XML), Extensible Stylesheet Language (XSL), Document Type Definitions (DTDs), and XML Schema files. The Outline View displays XML tags of the open XML file. You can also use this Perspective for integrating XML with relational databases (see Figure 3-11).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
3-11: The XML Perspective Table Figure of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Using the
Debug Perspective
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 use - Introducing WSAD 5.0 for debugging Java code. It automatically opens when you run a Java You can the Debug Perspective Chapter application 2 -inSetting the debug Up the mode. Development This Perspective Environment allows you to set simple and conditional breakpoints, stop
at breakpoints, step throughout the code, examine and modify the value of Java variables, and so on. To Chapter 3 - Working with the WSAD 5.0 Workbench debug your the serverApplications needs to start in the debug mode. Next, you set the necessary Chapter 4 - application, Developing Database breakpoints and run theJ2EE: application (also in the debug mode). When Part Two - Working with The Distributed Application Framework
the executing code reaches a
breakpoint, Workbench automatically switches to the Debug Perspective (see Figure 3-12). In the Chapter 5 - the J2EE Development Debug 6View, several appear on the toolbar that allow you to perform Step Over, Step Into, Step Chapter - J2EE EJB icons Development Return,7and- other typical debugging steps. Chapter J2EE Web Development Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 3-12: The Debug Perspective
Using the Server Perspective You can use the Server Perspective to run (and optionally debug) J2EE applications and J2EE clients. This Perspective allows you to define and configure servers and server configurations and to attach your project to a specific server configuration. The Server Configuration View shows available server configurations. The Servers View shows available server instances and their status: Stopped, Started, The server should be republished, or Server is synchronized. To start the server, right-click it in the Servers View and select Start. To stop the server, right-click it and select Stop. Alternatively, just highlight the server and click the corresponding icon (Start or Stop) on the Servers View toolbar. In a similar way, you can select Profile, Restart, and Republish. Starting the server automatically republishes and synchronizes it. Starting the server in the debug mode automatically switches the Workbench to the Debug Perspective. This Debug Perspective is similar to the Debug Perspective of the regular Java application (see Figure 3-13).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3 - 3-13: Working the Perspective WSAD 5.0 Workbench Figure Thewith Server Chapter 4 - Developing Database Applications
TheTwo Workbench switches to the Debug Perspective when Part - Workingautomatically with J2EE: The Distributed Application Framework
you right-click a module within an
EJB or 5Web project and select Run on Server. Chapter - J2EE Development Chapter 6
- J2EE EJB Development
Setting the server configuration for each server instance allows you to control the runtime environment for - J2EE Web Development each executed application; it is similar to some degree to the WebSphere Application Server (WAS) Chapter 8 - J2EE XML Development setting. To open a particular server configuration file, double-click that server in the Server Configuration Part Three - Working with Enterprise Messaging View (see Figure 3-14). Chapter 7
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 3-14: The opened server configuration This Server Configuration View has many tabs at the bottom. Clicking these tabs presents screens that display different parts of the server configuration file. Click the Paths tab. The screen that appears allows you to control the ability of different Java classloaders to find your project classes and Java Archive (JAR) files. On the Pathsscreen, shown in Figure 3-15, you can control two CLASSPATH variables—the global system Java CLASSPATH variable and the ws.ext.dirsvariable (the extended CLASSPATH-like variable) that is used by the WAS 5.0 as an additional global system CLASSPATH. You can add external and internal JAR files and folders to these CLASSPATH variables. JAR libraries and files included in both of these CLASSPATH variables are not reloadable, meaning that any changes made to them require the server to be restarted for the changes to take effect.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 - 3-15: Introducing 5.0 Figure SettingWSAD the CLASSPATH and ws.ext.dirsenvironment variables Chapter 2 - Setting Up the Development Environment Chapter 3
- Working with the WSAD 5.0 Workbench
Actually, the test server is an embedded version of WAS (the base version). Click the Configuration - Developing Database Applications tab; on the screen that appears, mark the Enable Administration Console box. Save the results Part Two - Working with J2EE: The Distributed Application Framework and close the editor. Chapter 4 Chapter 5
- J2EE Development
Chapter 6 -the J2EE EJB Development Next, start server. Right-click the running server in the Servers View and select Start Admin Console. Chapter 7 J2EE Webwith Development Those of you familiar WAS will immediately recognize it (see Figure 3-16). Indeed, this is the Chapter 8 -WAS J2EE running XML Development embedded inside the WSAD environment. Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 3-16: Embedded WAS running inside the WSAD environment Enter your user ID and click OK. The Administrative Console will launch (see Figure 3-17). Having the WebSphere 5.0 test environment server implemented by the real WAS is an important advantage of WSAD as a J2EE development tool. Next, just click Logout on the main menu, close the Browser View, and stop the server.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter Figure 2 - 3-17: Setting Embedded Up the Development WAS Administrative Environment Console Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Using the Profiling Perspective
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development The Profiling Perspective allows you to preset the way of launching certain Java processes—specifically,
Chapter 6 - J2EE EJB Development the command-line parameters to be used with the launching Java process and the environment variables Chapter 7 J2EE Web that the process uses. Development Chapter 8
- J2EE XML Development
If the host-Java process on Messaging the machine Part Three Working with resides Enterprise
where the Workbench is installed, do the following to set the environment variables: Chapter 9 - J2EE Enterprise Messaging Chapter 10 - Using the WSAD-Embedded 1. Switch to the Profile Perspective JMS and Provider then click the Profile icon in the main toolbar. This opens the Chapter Launch 11 - Using WebSphere MQ as the JMS Provider Java Process wizard. Appendix A - Deploying This Book's J2EE Examples Index2. Indicate the project, the main class, and the command-line parameters and then click the
Environment Variables button. On the dialog that appears, click Add.
List of Figures
List of 3.Tables On the next dialog, enter the name and value pairs of the environment variables you want to add List of Code (seeExamples Figure 3-18). List of Sidebars
Figure 3-18: Launching a local Java process 4.
4. If the host Java process resides on the remote machine, you need to switch to the Profile WebSphere Studio Application Developer 5.0: Practical Perspective, click the List button (the arrow to the right of the Profile icon) on the main toolbar, and J2EE Development select Launch > Remote Remote Java Process wizard. ISBN:1590591208 by Igor Livshin Process. This opens the Launch Apress © 2003 (630 pages)
5. Indicate the remote machine. Any remote management requires the Agent Controllers running on This book a practical, step-by-step approach both machines. Youprovides can highlight the host and click the CheckinConnection button to check the teaching how to use the WebSphere Studio Application communication session. Then click Developer (WSAD) tool for Next. developing J2EE distributed applications.
6. On the next page, select a Java class. Then follow the same steps stated for the local process (see Figure 3-19). Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables
Figure 3-19: Launching a remote Java process List of Code Examples List of Sidebars
Using the Help Perspective The Help Perspective displays online help information. The Search tab allows you to search for a specific topic. You can invoke the Help Perspective like any other Perspective or from the main menu by clicking Help > Help Contents. Figure 3-20 shows the result of the search for Java help topics.
Figure 3-20: Results of a search for Java help topics SelectingHelp> Software Update searches the IBM WSAD-related Web site for available updates and fixes. Selecting Help> About IBM WebSphere Studio Application Developer displays the
dialog that shows the details of the installed WSAD release.
WebSphere Studio Application Developer 5.0: Practical
Selecting Help > J2EE AboutDevelopment IBM WebSphere Studio Application Developer displays the official WSAD release ISBN:1590591208 by Igorshows Livshinthe Build ID (which is currently 20021125_2118). (5.0.0); the screen also This is important Apress © 2003 (630 pages) information when communicating with the IBM WSAD technical support. The dialog also provides three This book provides a practical, step-by-step approach buttons for displaying additional information: Feature Details, Plug-in inDetails, and Configuration Details. teaching howpage, to useyou thecan WebSphere Studio Application On the Configuration Details find useful information about your WSAD environment (such Developer (WSAD) tool for developing J2EE distributed as the boot classapplications. path, the library boot path, the library path, the temp directory WSAD uses, and so on). Selecting Help > Cheat Sheets displays a menu list where the help information is organized by the type of development activity. Selecting Create a Web application from this menu list displays a concise list of Table of Contents topics that walk throughDeveloper the process ofPractical developing applications (see Figure 3-21). WebSphere Studioyou Application 5.0: J2EEWeb Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
Figure 3-21: TheCreate a Web Application help screen
Chapter 11 - Using WebSphere MQ as the JMS Provider
Appendix - Deploying J2EE Clicking Aa black arrow This icon Book's displays theExamples WSAD screen used in the topic. Clicking the icon on the right Index (which looks like a question mark in a balloon) presents a catalog of help documents relevant to the topic List ofFigure Figures3-22). (see List of Tables List of Code Examples List of Sidebars
Figure 3-22: TheWorking with the Web projects help screen Finally, WSAD provides content-sensitive help. When you need help understanding the meaning of some field on the WSAD screen, just place the cursor in the field and press the F1 key. The related help information will appear.
Customizing Perspectives You can customize the Workbench default Perspectives permanently or temporarily. If you work under some Perspective and you need to display a View that is not a part of the default Perspective, select Window > Show View and then select the View from the list of available Views.
Customizing WebSphere a Perspective Permanently Studio Application Developer 5.0: Practical J2EE Development
This section describes how to customize a Perspective permanently. Say you are working in J2EE as the ISBN:1590591208 by Igor Livshin current Perspective, and you would like to always have a Servers View as part of the J2EE Perspective. Apress © 2003 (630 pages) From the main menu, select Window > Show View and select the Servers View. The Servers View will This book provides a practical, step-by-step approach in appear on the Workbench. Next, from the main menu, click Window > Save Perspective As... and give the teaching how to use the WebSphere Studio Application modified Perspective a new(WSAD) name (say, J2EE_with_Servers_View). To get back to the original default Developer tool for developing J2EE distributed Perspective content, select Window > Perspective Reset. applications.
Making a Fine-Grained Perspective Customization Table of Contents WebSphere WSAD also Studio allows Application you to customize Developera 5.0: Perspective Practical in J2EE a fine-grained Developmentway. For any open Perspective, select
Window > Customize Perspective... from the main menu. On the screen that is displayed, select the items Introduction to be displayed the current PerspectiveStudio (see Figure 3-23).Developer (WSAD) 5.0 Part One - Gettingon Started with WebSphere Application Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures
Figure 3-23: Customizing Perspectives
List of Tables
List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical Understanding WSAD Projects J2EE Development
ISBN:1590591208 Igor Livshin A WSAD project isbyan organization structure that combines all the resources necessary for developing and 2003 (630 pages) running J2EE andApress J2EE©client applications. The J2EE specification defines the project types discussed in the following sections. This book provides a practical, step-by-step approach in
teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Web Project
You use the Web project for developing Web modules that combine HTML, servlet, JSP, JavaBean, Table of Contents JavaScript, and graphics files. It is also used for packaging the result in the Web Archive (WAR) file. WAR WebSphere Studio Application Developeruntil 5.0: they Practical J2EE Development modules are considered stand-alone are assembled into an EAR Application project. Once you Introduction have created the Web project, you can import various Web resources in the Web project. You can import Part resources One - Getting from the Started local with file system WebSphere or viaStudio HTTP/FTP Application protocols. Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
- Setting Up the Development Environment EJB Project
Chapter 2 Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter You use 4 an- EJB Developing project Database for developing Applications EJB modules that combine session, entity, and MDB files and for Part packaging Two - Working the result with in J2EE: the EJB TheJAR Distributed file. EJBApplication modules are Framework considered
stand-alone until they are
assembled anDevelopment EAR Application project. Chapter 5 - into J2EE Chapter 6
- J2EE EJB Development
- J2EE Web Development Application Client Project
Chapter 7 Chapter 8
- J2EE XML Development
Part YouThree use the - Working Application with Client Enterprise project Messaging for developing
Application Client modules that run on the client
machine WebSphere environment. They typically combine user interface presentation files that Chapter 9 outside - J2EEthe Enterprise Messaging run within clientthe container on the client Chapter 10 the - Using WSAD-Embedded JMSmachine. Provider They can also include applets. Files are packaged in the Application Client archive files (JAR) files.Provider Client archive files are assembled into an EAR Application Chapter 11 - Using WebSphere MQ as the JMS project. A - Deploying This Book's J2EE Examples Appendix Index
J2EE Project
List of Figures List of Tables
Used for developing List of Code Examples enterprise applications, the J2EE project is the top-level project that can include one or more EJB, Web, and Application Client modules. The J2EE project packages the result in the EAR file List of Sidebars suitable for application deployment.
All WAR, EJB JAR, client application JAR, and EAR files include corresponding Deployment Descriptor files that instruct WAS containers how to install and run them.
Additional Project Types WSAD defines additional project types specific to the WSAD environment, discussed in the following sections.
Java Projects Used for building Java applications, the Java project consists mostly of Java classes and interfaces. The project packages the result in a JAR file. Java applications are stand-alone tasks running outside WAS under the control of the Java Virtual Machine (JVM). Web, EJB, or J2EE projects can also use them as utility code.
Server Projects The Server project is built for setting the WSAD test server environment. Any server-side J2EE application runs on the WAS inside the appropriate container. WSAD includes WAS for creating a runtime environment that is close to the production runtime environment. WSAD allows local and remote testing using WAS as a runtime environment or only local testing using the Apache Tomcat application server as
a runtime environment. The “Creating a New Java Project” section discusses the Server project in more WebSphere Studio Application Developer 5.0: Practical detail. J2EE Development
by Igor Livshin Simple Projects
ISBN:1590591208
Apress © 2003 (630 pages)
book provides a practical, approach in a source container. For this type of A Simple project This is a Java-type project, but thestep-by-step project folder serves as how to use the Application project you have teaching no choice of placing theWebSphere source filesStudio in a different folder. Developer (WSAD) tool for developing J2EE distributed applications.
Plug-in Projects
WSAD is a plug-in-based Integrated Development Environment (IDE) in which you can develop plug-ins Table of Contents for WSAD!Studio The plug-in project is used5.0: for plug-in development and is beyond the scope of this book. WebSphere Application Developer Practical J2EE Development Introduction
Three project types (Web, EJB, and Application Client) are always added to one of the existing EAR projects. If at the time of creating a Web, EJB, or Application Client project, the EAR Enterprise project is Chapter 1 - Introducing WSAD 5.0 not present in the Workspace, you have to build a new EAR project that will contain these new Web, EJB, Chapter 2 - Setting Upprojects. the Development and Application Client You canEnvironment do this automatically by selecting New > Enterprise Application. Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical Customizing the Workbench J2EE Development
ISBN:1590591208 Livshin You can change by theIgor behavior of the Workbench and many of its tools by selecting Window > Preferences Apress © 2003 (630 pages) dialog will appear (see Figure 3-24). from the main menu. The Preferences
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - 3-24: UsingCustomizing the WSAD-Embedded JMS Provider Figure the Workbench Chapter 11 - Using WebSphere MQ as the JMS Provider
The majority of the options are self-explanatory, Appendix A - Deploying This Book's J2EE Examples so the following sections discuss only the options that require some additional information. Index List of Figures
Workbench
List of Tables
List of Code Examples
The List of following Sidebars options exist in the Workbench’s Preferences dialog: Perform Build Automatically on Resource Modification: If this box is checked, every time you save your changes, WSAD performs a build. The build is incremental and quick (only resources that have been changed since the last build are rebuilt). Save All Modified Resources Automatically Prior to Manual Build: If this box is checked, the Workbench saves all modified resources before performing the Rebuild All function. Link Navigator Selection to Active Editor: Checking this box requests the editors and the corresponding Navigator Views to interact—selecting a file that is already opened in the editor brings this Editor View in focus. The reverse is also true—selecting an editor brings the corresponding file in focus.
Perspectives The Perspectives section shows you a list of all Perspectives, including any custom Perspectives. It provides options for opening Perspectives (such as opening a new Perspective in the same window or in a new window).
External Tools/Internet If you access the Internet via a proxy server, this option allows you to set the proxy server.
Java
WebSphere Studio Application Developer 5.0: Practical J2EE Development
The following Java control the appearance of the generated Java code and the version of the ISBN:1590591208 by options Igor Livshin installed Java support environment: Apress © 2003 (630 pages) This book a practical, approach Code Formatter: Thisprovides option allows you tostep-by-step adjust the way WSADin formats the generated Java code. teaching how to use the WebSphere Studio Application All new JavaDeveloper code will be generated according to J2EE this formatter. (WSAD) tool for developing distributedHowever, if you have a Java class that is formatted differently, display it in the Editor View, right-click, and select Format. The code will applications. be reformatted in accordance with the preferences you have set. A similar formatter is available for XML code. Table of Contents
Installed JREs: This option allows5.0: youPractical to replace the Java runtime version used by WSAD. Keep in WebSphere Studio Application Developer J2EE Development mind that WSAD always uses the Java compiler with which it is shipped. Be careful if you decide to Introduction replace the Java Runtime Environment (JRE). Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0
Chapter 3
- Working with the WSAD 5.0 Workbench
Server: This option provides settings for Apache Tomcat, audio, publishing, TCP/IP monitoring, and Chapter 2 - Setting Up the Development Environment so on. Chapter 4 - Developing Applications One important option is Database J2EE. It controls the default level of the J2EE specifications that WSAD supports. Part Two - Working withyour J2EE:projects The Distributed Framework If you want to develop to followApplication the J2EE 1.3 newest specifications,
then the value of this field
Chapter - 1.3. J2EE Development should 5read Chapter 6 - J2EE EJB Development
Another7 useful feature when you are typing the Java code is Code Assist. You invoke Code Assist by Chapter - J2EE Web Development
pressing the Control+spacebar key combination. For example, type some method and press the - J2EE XML Development Control+spacebar key combination to display a list of parameters that you can use with the method. You Part Three - Working with Enterprise Messaging can select a parameter from the menu list to insert in the correct place in your code. You can control the Chapter 9 - J2EE Enterprise Messaging auto-activation of this feature by selecting Window > Preferences > Java > Editor > Code Assist. Options Chapter 10 - Using the WSAD-Embedded JMS Provider that you select under Window > Preferences are not limited to a specific Perspective but are global for the Chapter 11 - Using WebSphere MQ as the JMS Provider Workbench. You will explore the Perspectives in more detail throughout the book. Chapter 8
Appendix A - Deploying This Book's J2EE Examples Index
Web Browser
List of Figures List of Tables
This option allows you to select an external or internal Web browser. It also provides optional settings for each browser.
List of Code Examples List of Sidebars
Note If you make any changes in this section, you need to restart the Workbench for the changes to take effect.
WebSphereìHello Studio Application Developer 5.0: Practical Building a Simple Worldî Java Application J2EE Development
by the Igorindustry Livshin tradition, you will build your firstISBN:1590591208 In accordance with project as a “Hello World” application. This Apress ©to2003 (630 pages) the way applications are developed with WSAD. This first example is a simple Java project demonstrate is simple, but theThis examples that follow will gradually become more complex. book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Creating a New Java Project
To create a new project, click File > New from the main menu. A list of project types displays for your Table of Contents selection. If the type of the project you want to create is not in the list, select Project.... A new dialog WebSphere Application Developer 5.0: Practical J2EE Development displays a Studio list of all the available WSAD project types. Select Java on the left pane and Java Project on Introduction the right pane (see Figure 3-25). Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List ofFigure Sidebars 3-25: Building a Java project
Click Next. The New Project wizard displays the screen that prompts you to specify the name and the location of the project. Enter HelloWorldProject in the Project Name field and check the Use Default box (meaning the new project will be created inside the workspace), as shown in Figure 3-26.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Figure New Java Project wizard Chapter 5 - 3-26: J2EE The Development Chapter 6
- J2EE EJB Development
Click Next.-The Java Setting dialog displays. Four tabs on the top of the dialog (Source, Projects, Libraries, J2EE Web Development and Order and Export) control the active page (the page currently visible). On the Source tab, you can Chapter 8 - J2EE XML Development specify the location of the project source files. The default option is to use the project directory as a source Part Three - Working with Enterprise Messaging folder. Accept the default and click the Projects tab. Chapter 7
Chapter 9
- J2EE Enterprise Messaging
Chapter - Using the WSAD-Embedded JMS Provider On the 10 Projects tab, you can select other projects that this Java project may require. Projects marked on Chapter 11 Using WebSphere MQ as the JMS Provider this page will be included in your project’s Build Path. The Build output folder field enables you to specify Appendix A - of Deploying This Book's Examples the location the compiled sourceJ2EE files. By default, compiled files will be placed in the project folder, the Index same location where the source files are placed (see Figure 3-27). List of Figures List of Tables List of Code Examples List of Sidebars
Figure 3-27: TheProjectstab This Simple project does not require any other projects. Accept the defaults and click the Libraries tab (see Figure 3-28).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Figure Librariestab Chapter 5 - 3-28: J2EE The Development Chapter 6
- J2EE EJB Development
This page allows you to include all internal and external JAR files and folders that this project may need in - J2EE Web Development the Build Path.Your Simple project does not require an additional library to be included in the Build Path.
Chapter 7 Chapter 8
- J2EE XML Development
Part Three Working Enterprise Note -For many with frequently usedMessaging libraries, WSAD
provides environment variables. It is always
Chapter 9 preferable - J2EE Enterprise Messaging to add an environment variable to the Build Path instead of including the full path Chapter 10 to - the Using the WSAD-Embedded JMS the Provider resource location. It makes environment less location dependent. To use WSADChapter 11 provided - Using WebSphere MQ as the JMS Provider environment variables, click the Add Variable... button. Appendix A - Deploying This Book's J2EE Examples
Next, click the Order and Export tab. On this tab, you can indicate the order of libraries in the Build Path. Index WSAD builds resources sequentially. So, if there are resources that are dependent on other resources, List of Figures
the dependent resources must be included in the Build Path after the resources they depend upon (see Figure 3-29). This page allows you to reorder libraries in the Build Path.
List of Tables
List of Code Examples List of Sidebars
Figure 3-29: TheOrder and Export tab
Again, you do not need to do anything on this tab. Finally, click Finish. WSAD will generate WebSphere Studio Application Developer 5.0: Practical HelloWorldProject. You should be able to see it in the Package Explorer View. J2EE Development by Igor Livshin
ISBN:1590591208
Creating a Apress New ©Package 2003 (630 pages) This book provides a practical, step-by-step approach in
Next, you will create a Java package. Java packagesStudio combine related processing in one place within a teaching how to use the WebSphere Application project. As usual,Developer WSAD provides (WSAD)several tool for ways developing to create J2EEJava distributed packages: applications.
Right-click HelloWorldProject and select New > Package. Table of Contents From the main menu, select File > New > Package. WebSphere Studio Application Developer 5.0: Practical J2EE Development
Click the Create a Java Package toolbar icon. Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
The first way is preferable because the next screen appears with the Folderfield already populated. - Introducing WSAD 5.0 Enter apress.wsad.sample as the package name (see Figure 3-30).
Chapter 1 Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List ofFigure Code Examples 3-30: Building a Java package List of Sidebars
Click Finish. You should see the new package (apress.wsad.sample) inside your project.
Creating a New Java Class Create a new Java class by right-clicking apress.wsad.sample and selecting New > Class. Again, this is the preferable way of creating a new class because the next screen appears with a prefilled Package field. Enter HelloWorld in the Name field and request to generate the main() method and a call to a superclass constructor (see Figure 3-31).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6 - 3-31: J2EE Building EJB Development Figure Java class Chapter 7
- J2EE Web Development
Chapter Click Finish. 8 - J2EE WSAD XML willDevelopment generate the skeleton of the Java class and open it in the Java Editor View. RightPart clickThree anywhere - Working inside with theEnterprise Java Editor Messaging and select
Format. This will reformat your Java code in accordance
with the9 setting made on theMessaging Windows > Preferences dialog for Java > Code Formatter. Chapter - J2EE Enterprise Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 3-32: WSAD-generated Java class skeleton Notice the package statement on the top of the class. The Outline View displays two methods of the class: main and HelloWorld (which is the default constructor). Modify this file so that this simple program displays the current date and the “Hello World” greeting. Listing 3-1 shows the modified version of the file. Listing 3-1. HelloWorld.java package apress.wsad.sample; import java.io.*; import java.text.SimpleDateFormat; import java.util.Date; public class HelloWorld { // Constructor for HelloWorld public HelloWorld()
{ super(); WebSphere Studio Application Developer 5.0: Practical J2EE Development
} ISBN:1590591208 by Igor Livshin public static void main(String[] args) Apress © 2003 (630 pages) { This book provides a practical, step-by-step approach in Date today; teaching how to use the WebSphere Studio Application SimpleDateFormat sFormat; Developer (WSAD) tool for developing J2EE distributed String applications. currentDate = ""; HelloWorld hwInstance = new HelloWorld(); today = new Date(); Table of Contents sFormat = new SimpleDateFormat("MM-dd-yyyy"); WebSphere Studio Application Developer 5.0: Practical J2EE Development currentDate = sFormat.format(today); Introduction System.out.println("Date: " + currentDate); Part One -System.out.println("Hello Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 World!"); Chapter 1 Introducing WSAD 5.0 } Chapter } 2 - Setting Up the Development Environment Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
When modifications toThe update the JavaApplication skeleton class, you can use Part Twotyping - Working with J2EE: Distributed Framework
the auto-completion feature that WSAD provides to help build Java code. For example, say you get to the point where you want to type the Chapter 5 - J2EE Development following statement: Chapter 6 - J2EE EJB Development currentDate sFormat.format(today); Chapter 7 - J2EE=Web Development Chapter 8
- J2EE XML Development
Just type currentDate = sFormat. (stop typing after entering the dot character). Then press the Control+spacebar key combination. A pop-up window displays a list of available methods for this class Chapter 9 - J2EE Enterprise Messaging instance. Scroll this list to the point where it displays format(Date). Double-click it to insert the method in Chapter 10 - Using the WSAD-Embedded JMS Provider your source. Next, replace the parameter Date with today and you are done. Part Three - Working with Enterprise Messaging
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
Debugging the ìHello Worldî Application
Index
List of Figures
Let’s debug the program. Set a breakpoint on the line that reads “Hello World.” As always, there are several ways of doing this. The simplest way is to position the cursor on the line where the breakpoint List of Code Examples needs to be set and double-clicking the vertical bar on the left of the Editor View. A green dot appears List of Sidebars confirming the breakpoint. Another way of setting a breakpoint is to select Run> Add/RemoveMethod Breakpoint to toggle the breakpoint. You can also double-click a breakpoint to remove it. List of Tables
The Breakpoints View allows you to set conditional breakpoints. You will find the Breakpoints View in the Debugger Perspective, or you can add it yourself to the Java Perspective or another Perspective. In the Breakpoints View, right-click a breakpoint and select Hit Count, which tells the debugger to stop at the breakpoint after the specified number of hits. To launch the test, highlight the “Hello World” program and on the main toolbar click the list arrow icon (located to the right to the bug-like debug icon). From the menu list, select Debug As > Java Application. The Workbench switches to the Debug Perspective and the debugger starts. You should see your Java program stopped at the breakpoint. On the upper-left side of the Workbench, you should see the Debug View. The toolbar of the Debug View contains several icons that look like curved arrows. These are the navigation icons for debugging. They allow you to perform StepInto, Step Over, and Step Return actions. Click the Step Over icon (or press F6). You should see the cursor move down to the next line (the previous command has been executed). Click the Step Over icon three more times until the cursor is on the following line: System.out.println("Date: " + currentDate) Put the cursor over the currentDate variable and WSAD will display the variable value. On the upper-right side of the Workbench, you should see the Variables View. If it is not displayed, click the Variables tab. You can also see the value of the currentDate variable.
Press F8 to run the program to the end. The Console View displays the execution results (see Figure 3WebSphere Studio Application Developer 5.0: Practical 33). You should see the following in the Console View: J2EE Development
Date = 12-31-2002 Hello World! by Igor Livshin
ISBN:1590591208
Apress © 2003 (630 pages) This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development Figure a Java program Chapter 6 - 3-33: J2EE Debugging EJB Development Chapter 7
- J2EE Web Development
Chapter - J2EE in XML During 8execution theDevelopment debug mode, when stopped at the breakpoint, it is possible not only to examine the Part Three - Workingbut with Enterprise Messaging value of variables, also to change the value of
Chapter steps: 9
some variables and continue execution. Follow these
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
1. From the main menu, click Run > Debug Last Launched (or just press the F11 key). The program starts executing again. It stops at the same breakpoint. Click the Step Over icon until the cursor Appendix A - Deploying This Book's J2EE Examples reaches the same statement as before. Chapter 11 - Using WebSphere MQ as the JMS Provider Index
2. Figures Make sure that the Variables View is displayed (if not, click the Variablestab). Locate the List of currentDate variable in the Variables View. Right-click it and select Change Variable Value.Enter List of Tables some other data, and click outside the updated field so the change takes effect. List of Code Examples List of Sidebars
3. Press F8 to continue the program execution. You should see a different date displayed in the Console View.
Working in the WSAD Testing Environment The first Java project that you just built is a simple Java application; however, it is not the typical application that WSAD was designed to develop. All J2EE enterprise applications are server based and require an application server to run. As already mentioned, the WSAD test environment supports local and remote testing on WAS Advanced Single Server Edition 4 and WAS 5. In addition, the Apache Tomcat server supports testing, but only local testing of Web projects that contain servlets and support JSPs. Remote testing allows testing of the WebSphere applications running under WAS on a remote machine. To enable remote testing, you must have the following software installed on the remote machine: WAS Agent Controller The following software must be installed on your local machine: WSAD Agent Controller
When you test a project, you can control how the test server starts. It can be started automatically when WebSphere Studio Application Developer 5.0: Practical you right-click a module and select Run on Server. If this is the first time you are testing a project, the J2EE Development system will prompt you to select the type of server (WAS version 4.x or 5.x) to be used. After your ISBN:1590591208 by Igor Livshin selection, the server will be automatically configured and started. Apress © 2003 (630 pages)
This bookduring provides practical, approachcontrol in Click the Advance button thisa prompt tostep-by-step have more detailed of the type of server to run. In how towith use athe WebSphere Application this case, you willteaching be presented dialog that listsStudio available servers. You can select Use an Developer (WSAD) tool for developing J2EE distributed existing server. If the test server you choose has not been configured yet, it will be automatically applications. configured and started; otherwise, it will just restart. Alternatively, you can choose Create a new server. In this case, the server and server configuration will be created automatically before starting the server. Table of Contents
If your project is attached to Developer multiple servers, you can select a particular server as a preferred server for WebSphere Studio Application 5.0: Practical J2EE Development the project. To do this, you right-click the project and select Properties > Server Preferences. Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Alternatively, you can start the test server manually in the Servers View. To start the server manually,
Chapter 1 the - Introducing WSADone 5.0of the following icons located on the Servers View’s toolbar: Start the highlight server and click Chapter 2 (a -running Settingman Up the Development Environment server icon), Start the server in debug mode (a bug icon), or Start the Chapter 3 in - Working the(a WSAD 5.0 man Workbench server profilingwith mode running with the clock icon). Chapter 4 - Developing Database Applications
In the previous example, you The tested your project as a Java application by selecting Part Two - Working with J2EE: Distributed Application Framework
the project and
selecting As > Java Application from the icon bar. Chapter 5 Run - J2EE Development Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Let’s explore the steps necessary for manually starting test servers.
Chapter 8
XML Development Creating- aJ2EE New Server Project
Part Three - Working with Enterprise Messaging
Chapter 9 - a J2EE Messaging First, create newEnterprise Server project. Switch to the Server Perspective. From the main menu, select File > Chapter - Using JMS select Provider New > 10 Project. Onthe the WSAD-Embedded dialog that appears, Server > Server Project. Name the project as Chapter MyServerProject 11 - Usingand WebSphere click Finish. MQ WSAD as the JMS will Provider create a new Server project called MyServerProject. Appendix A - Deploying This Book's J2EE Examples
Right-click the new MyServerProjectand select New> Server and Server Configuration. In the resulting dialog, enter MyServer in the Server name field. Make sure you select the MyServerProject in the List of Figures Folder field. For the Server type field, select the server type you need. Figure 3-34 shows the WebSphere List of Tables version 5.0 Test Environment, which is the local WebSphere server. Index
List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Figure 3-34: Selecting the test Messaging server
Chapter 9
- J2EE Enterprise Messaging Click Next. next allows you to setProvider the port number on which the server will listen. Accept the Chapter 10 -The Using thescreen WSAD-Embedded JMS
defaults11and click Finish. WSAD a new Server in the Servers View and a new Server Chapter - Using WebSphere MQwill as generate the JMS Provider Configuration in the Server Configuration View. The server and server configurations are just XML files that Appendix A - Deploying This Book's J2EE Examples keep specific configuration data. The Server represents the typeof server—Tomcat or WebSphere 4 or 5, Index for of example—and the Server Configuration stores specific configuration information about the server, such List Figures as its name, classloader policy, data sources, and so on.
List of Tables
List of Code Finally, youExamples need to attach an existing EAR project to the server. For this example, you will attach the List of Sidebars DBEnterpriseApp EAR project. You have not built this project yet, so there is no DBEnterpriseApp in your
environment. For now we just show you how to attach an existing EAR project to the server. In the Server Configuration View, right-click MyServer and select Add Project > DBEnterpriseApp. Now, if you expand MyServer in the Server Configuration View, you should be able to see that the DBEnterpriseApp and DBProject projects have been added to the MyServer server configuration. You can attach an EAR project to many Server Configurations. Doubleclicking the Server Configuration instance opens the file in the Editor View with multiple tabs at the bottom of the View (where you can modify various attributes of the test server environment). One example of an attribute you can modify is the port number. If you want to concurrently run multiple server instances, or if WAS is installed on the same machine, there is a conflict of the same ports being used by multiple servers. You need to change the port for all concurrently running server instances. By right-clicking a project and selecting Run on Server, the default server to which the project is attached starts automatically. You will later use the Test Server environment quite frequently for testing your WAR and EJB example applications.
Importing Resources into WSAD You can import various Java resource files (Java, images, XML, JAR, WAR, EAR, and so on) into the WSAD workspace. However, there is a difference between importing simple resource files (such as Java files, images, and XML files) and importing archive files (such as WAR, EJB-JAR, and EAR files) that represent projects.
You import regular resource files into the existing projects. The WSAD Import wizard lets you indicate the Practical resource location,WebSphere the project,Studio and theApplication folder withinDeveloper the project5.0: of where to import the resource. When J2EE Development importing archive files, you enter the name of the project that you want to use for the application that you ISBN:1590591208 by Igor Livshin are going to import. To import a resource, click File > Import.... The Import screen appears (see Figure 3Apress © 2003 (630 pages) 35). This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider
Figure Importing resources the WSAD environment Appendix A - 3-35: Deploying This Book's J2EEinExamples Index
Finally, select the type of resource, click Next, and follow the Import wizard’s instructions.
List of Figures
List of Tables WSAD allows you to import regular resource files locally (select File System) or download them from the List Internet of Code (using Examples the HTTP or FTP protocols). The archive-type resources must be local to be imported. List of Sidebars
Summary
WebSphere Studio Application Developer 5.0: Practical J2EE Development
ISBN:1590591208 by Igor you Livshin This chapter introduced to the most frequently used features and tools of the WSAD 5.0 Workbench. © 2003 architecture (630 pages) It showed you theApress role-based of the Workbench, its Perspectives, Views, projects, the server test environment,This andbook otherprovides artifactsa of the Workbench. Youapproach also developed and tested a simple Java practical, step-by-step in teaching how to use the WebSphere Studio Application project.
Developer (WSAD) tool for developing J2EE distributed applications. In the chapters that follow, you will continue exploring WSAD and its rich J2EE development environment. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Studio Application Developer 5.0: Practical Chapter WebSphere 4: Developing Database Applications J2EE Development
Overview
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in
In the previous chapter, teachingyou how briefly to use learned the WebSphere about theStudio WebSphere Application Studio Application Developer (WSAD) Developer (WSAD)environment. tool for developing J2EE distributed 5.0 Workbench as a development This chapter builds on this initial knowledge and presents applications. the first J2EE development example with WSAD 5.0. The following chapters expand your knowledge of WSAD 5.0 as a development tool by discussing more specific areas of development and providing much moreofdetailed information about the WSAD 5.0 Workbench functionality that supports this type of Table Contents development. WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction
No learning process can be successful (regardless of how much detailed information is provided) without practice. Thus, each topic discussed in this book comes with the corresponding examples of practical Chapter 1 - Introducing WSAD 5.0 development as well as figures that illustrate the development process. Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 2
- Setting Up the Development Environment All examples presented thisWSAD book 5.0 are Workbench J2EE 1.3 applications (or application fragments) developed for a Chapter 3 - Working withinthe
hypothetical that Database rents technical books to its clients—software vendors. The database-related Chapter 4 - library Developing Applications examples use the with TECHBOOK that you will build in this chapter. Part Two - Working J2EE: Thedatabase Distributed Application Framework
Later chapters concentrate on
specific5aspects J2EE development. Chapter - J2EEofDevelopment Chapter 6
- J2EE EJB Development
This chapter starts with building the TECHBOOK database and its three tables: BOOK_CATALOG, - J2EE Web Development BOOK_ACTIVITY, and BOOK_NOTIFY. Next, you will develop your first example that demonstrates how Chapter 8 - J2EE XML Development to use databases in WSAD 5.0. In the appendix, you will install this example on the WebSphere Part Three - Working with Enterprise Messaging Application Server (WAS) 5.0. Now, it is time to start building the TECHBOOK database. Chapter 7
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio Application Database Developer 5.0: Practical Understanding the TECHBOOK J2EE Development
ISBN:1590591208 by Igor Livshin For this book’s examples, you will want your simple database to keep the following information:
Apress © 2003 (630 pages)
A list of all library books with a brief description of eachapproach book (theinbook title, the book author, and so This book provides a practical, step-by-step on) teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed
The book rental applications. activity (the company that rented or returned the book) Communication between the library and its clients Table of Contents
Subsequently, theApplication TECHBOOK database three tables: WebSphere Studio Developer 5.0:consists Practicalof J2EE Development Introduction
The BOOK_CATALOG table represents a library’s book catalog.
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 BOOK_ACTIVITY - Introducing WSAD 5.0records book rental and return activity. The table Chapter 2 - Setting Up the Development Environment
A librarian uses the table to communicate with the customers (informing them about Chapter 3 - Working withBOOK_NOTIFY the WSAD 5.0 Workbench new arrival and so on). Applications Chapter 4 book - Developing Database Part Two - Working with J2EE: The Distributed Application Framework
Table 4-1 describes the structure of the BOOK_CATALOG table, Table 4-2 describes the structure of the - J2EE Development BOOK_ACTIVITY table, and Table 4-3 describes the structure of the BOOK_NOTIFY table.
Chapter 5 Chapter 6
- J2EE EJB Development
Chapter 7 The - J2EE Development Note userWeb ID account c6023 is set as the Windows 2000 domain administrator, local machine Chapter 8 administrator, - J2EE XML Development and the DB2 administrator in my development environment. Part Three - Working with Enterprise Messaging
Chapter 9 Table - J2EE4-1: Enterprise The BOOK_CATALOG Messaging Table Chapter 10 - Using the WSAD-Embedded JMS Provider
DATABASE TABLE FIELD
DESCRIPTION
Chapter 11 - Using WebSphere MQ as the JMS Provider
Appendix A -CATALOG_NUMBER Deploying This Book's J2EE Examples A unique number assigned to the Index book by the library. List of Figures List of Tables
AUTHOR
FORMAT CHAR(5)
The book’s author.
VARCHAR(50)
The book’s title.
VARCHAR(100)
LOCATION
Where the book is currently located. The value Library means it is available for renting. Otherwise, the company name that has rented the book should be coded here.
VARCHAR(50)
PLATFORM
Two-digit number indicating the platform for which the book is written: 00 means cross-platform; 01 means Unix (AIX); 02 means Unix (Solaris); 03 means Unix (HP), 04 means Windows NT/2000, and 05 means Linux.
CHAR(2)
LANGUAGE
Two-digit number indicating the development language: 01 means Java, 02 means C/C++, 03 means Delphi, 04 means Cobol, 05 means PLI, and 06 means Assembler.
CHAR(2)
BOOK_TITLE List of Code Examples List of Sidebars
Table 4-2: The BOOK_ACTIVITY Table
DATABASE WebSphere TABLE Studio FIELD Application DESCRIPTION Developer 5.0: Practical
FORMAT
J2EE Development
TXN_DATE by Igor Livshin
The day of the book rental or return. ISBN:1590591208
CHAR(10)
Apress © 2003 (630 pages) TXN_TIME
The time of the book transaction.
CHAR(8)
This book provides a practical, step-by-step approach in TXN_TYPE The typeStudio of book transaction: RENT teaching how to use the WebSphere Application Developer (WSAD) tool for developing J2EE distributed means book rental, and RETR applications. means book return.
BOOK_CAT_NUM Table of Contents
A unique number assigned to the book by the library.
CHAR(4)
CHAR(5)
WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction COMPANY_NAME Part One
The name of the company that rented or returned the book. - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 Chapter 2 Chapter 3 Chapter 4
VARCHAR(50)
- Introducing WSAD 5.0 - Setting Up the Development Environment
Table 4-3: The BOOK_NOTIFY Table - Working with the WSAD 5.0 Workbench
-DATABASE Developing Database ApplicationsDESCRIPTION TABLE FIELD
FORMAT
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
-MESSAGE_KEY J2EE Development
Unique key used to look up message.
CHAR(20)
Chapter 6
-MESSAGE_BODY J2EE EJB Development
The message sent to the customer.
CHAR(250)
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical Building the TECHBOOK Database J2EE Development
by to Igor Livshin You are now ready start building the TECHBOOK database.ISBN:1590591208 First, log in locally as the database administrator (in my Apress environment, © 2003 (630 pages) it is c6023) and select Start> Programs> IBM DB2 > Command Window. Second,This youbook can provides use the file shown instep-by-step Listing 4-1 approach as input tointhe DB2 command, which builds the a practical, teaching how to tables. use the You WebSphere Application TECHBOOK database and your can findStudio the BuildTextbookDatabase.sql file on the (WSAD) tool for developing distributed Apress Web site Developer (http://www.apress.com) in theJ2EE Downloads section. applications.
Note All book titles (and their authors) used in all this book’s examples are fictitious and do not represent any published commercial books. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development
Listing 4-1. BuildTextbookDatabase.sql
Introduction
-- One Build TECHBOOK database andStudio tables -Part - Getting Started with WebSphere Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
-- Create the TECHBOOK database
DROP DB TECHBOOK; - Developing Database Applications CREATE DB TECHBOOK; Part Two - Working with J2EE: The Distributed Application Framework UPDATE DB CFG FOR TECHBOOK USING APPLHEAPSZ 256; Chapter 5 - J2EE Development -- Commit to save work Chapter 6 WORK; - J2EE EJB Development COMMIT Chapter 7 - J2EE Development GRANT ALL ON Web TECHBOOK TO PUBLIC; Chapter 8 SCHEMA - J2EE XML Development CREATE LIB; Part - Working with Enterprise Messaging -- Three Commit to save work Chapter 9 WORK; - J2EE Enterprise Messaging COMMIT Chapter 10 -RESET; Using the WSAD-Embedded JMS Provider CONNECT Chapter -- Create 11 - Using the WebSphere BOOK_CATALOG MQ as the table JMS Provider CONNECT TECHBOOK; Appendix A -to Deploying This Book's J2EE Examples Chapter 4
Index
--ofDROP TABLE LIB.BOOK_CATALOG; List Figures CREATE TABLE LIB.BOOK_CATALOG List of Tables (CATALOG_NUMBER CHARACTER(5) NOT NULL, List of Code Examples AUTHOR VARCHAR(50) NOT NULL, BOOK_TITLE VARCHAR(100) NOT NULL, LOCATION VARCHAR(50) NOT NULL, PLATFORM CHARACTER(2), LANGUAGE CHARACTER(2), PRIMARY KEY(CATALOG_NUMBER));
List of Sidebars
-- Commit to save work COMMIT WORK; -- Load BOOK_CATALOG table data INSERT INTO LIB.BOOK_CATALOG (CATALOG_NUMBER, AUTHOR, BOOK_TITLE, LOCATION, PLATFORM, LANGUAGE) VALUES('00001', 'Developer Journal', 'Windows NT Programming in Practice', 'Library', '04', '02'); INSERT INTO LIB.BOOK_CATALOG (CATALOG_NUMBER, AUTHOR, BOOK_TITLE, LOCATION, PLATFORM, LANGUAGE) VALUES('00002', 'Chris Hare', 'Inside Unix', 'AAA_Company', '00', '02'); INSERT INTO LIB.BOOK_CATALOG (CATALOG_NUMBER, AUTHOR, BOOK_TITLE, LOCATION, PLATFORM, LANGUAGE) VALUES('00003', 'David Flanagan and a team', 'Java Enterprise in a Nutshell', 'Library', '00', '01');
WebSphere Studio Application Developer 5.0: PracticalBOOK_TITLE, LOCATION, INSERT INTO LIB.BOOK_CATALOG (CATALOG_NUMBER, AUTHOR, J2EE Development PLATFORM, LANGUAGE) ISBN:1590591208 by Igor Livshin VALUES('00004', 'Danny Ayers and a team', 'Java Server Programming', Apress © 2003 (630 pages) 'BBB_Company', '00', '01'); This book provides a practical, step-by-step approach in INSERT INTO LIB.BOOK_CATALOG (CATALOG_NUMBER, AUTHOR, BOOK_TITLE, LOCATION, teaching how to use the WebSphere Studio Application PLATFORM, LANGUAGE) Developer (WSAD) tool for developing J2EE distributed VALUES('00005', 'Bill McCarty', 'Learn Red Hat Linux', 'Library', '05', '01'); applications.
INSERT INTO LIB.BOOK_CATALOG (CATALOG_NUMBER, AUTHOR, BOOK_TITLE, LOCATION, TablePLATFORM, of Contents LANGUAGE) WebSphere Studio Application Practical J2EE Development VALUES('00006', 'LisaDeveloper Donald5.0: and a team', 'MCSE Windows 2000 Professional', Introduction 'BBB_Company', '04', '02'); Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 INTO - Introducing WSAD 5.0 INSERT LIB.BOOK_CATALOG (CATALOG_NUMBER, AUTHOR, BOOK_TITLE, LOCATION, Chapter PLATFORM, 2 - Setting LANGUAGE) Up the Development Environment
VALUES('00007', 'Harry M. Brelsford', Chapter 3 - Working with the WSAD 5.0 Workbench 'Windows 2000 Server Secrets', 'BBB_Company', Chapter 4 - Developing '04', Database'02'); Applications Part Two - Working with J2EE: The Distributed Application Framework
-- Commit to Development save work Chapter 5 - J2EE COMMIT Chapter 6 WORK; - J2EE EJB Development Chapter 7
- J2EE Web Development
-- Create the BOOK_ACTIVITY table Chapter 8 - J2EE XML Development Part Three - Working with Enterprise Messaging
-- DROP TABLE LIB.BOOK_ACTIVITY;
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
CREATE TABLE LIB.BOOK_ACTIVITY (TXN_DATE CHARACTER(10) NOT NULL, Appendix A - Deploying This Book's J2EE Examples TXN_TIME CHARACTER(8) NOT NULL, Index TXN_TYPE CHARACTER(4) NOT NULL, List of Figures BOOK_CAT_NUM CHARACTER(5) NOT NULL, List of Tables COMPANY_NAME VARCHAR(50) NOT NULL, List of Code ExamplesKEY(TXN_DATE,TXN_TIME)); PRIMARY Chapter 11 - Using WebSphere MQ as the JMS Provider
List of Sidebars
-- GRANT ALL ON BOOK_ACTIVITY TO PUBLIC; -- Commit to save work COMMIT WORK; -- Load the BOOK_ACTIVITY table data INSERT INTO LIB.BOOK_ACTIVITY (TXN_DATE, TXN_TIME, TXN_TYPE , BOOK_CAT_NUM, COMPANY_NAME) VALUES('01-01-2002', '09:17:25', 'RENT', '00001', 'AAA_Company'); INSERT INTO LIB.BOOK_ACTIVITY (TXN_DATE, COMPANY_NAME) VALUES('01-10-2002', '10:11:66', 'RETR', INSERT INTO LIB.BOOK_ACTIVITY (TXN_DATE, COMPANY_NAME) VALUES('02-20-2002', '11:12:55', 'RENT',
TXN_TIME, TXN_TYPE , BOOK_CAT_NUM, '00001', 'AAA_Company'); TXN_TIME, TXN_TYPE , BOOK_CAT_NUM, '00002', 'AAA_Company');
INSERT INTO LIB.BOOK_ACTIVITY (TXN_DATE, TXN_TIME, TXN_TYPE , BOOK_CAT_NUM, COMPANY_NAME) VALUES('01-15-2002', '12:12:12', 'RENT', '00003', 'BBB_Company'); INSERT INTO LIB.BOOK_ACTIVITY (TXN_DATE, TXN_TIME, TXN_TYPE , BOOK_CAT_NUM,
COMPANY_NAME) WebSphere'13:26:33', Studio Application Developer 5.0: Practical VALUES('01-31-2002', 'RETR', '00003', 'BBB_Company'); J2EE Development by Igor Livshin
ISBN:1590591208
INSERT INTO LIB.BOOK_ACTIVITY (TXN_DATE, TXN_TIME, TXN_TYPE , BOOK_CAT_NUM, Apress © 2003 (630 pages) COMPANY_NAME) This book provides a practical,'RENT', step-by-step approach in VALUES('03-05-2002', '14:22:11', '00003', 'CCC_Company');
teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed INTO applications. LIB.BOOK_ACTIVITY (TXN_DATE, TXN_TIME, TXN_TYPE , BOOK_CAT_NUM,
INSERT COMPANY_NAME) VALUES('04-05-2002', '15:44:31', 'RETR', '00003', 'CCC_Company'); Table of Contents
WebSphere Studio LIB.BOOK_ACTIVITY Application Developer 5.0:(TXN_DATE, Practical J2EE Development INSERT INTO TXN_TIME, TXN_TYPE , BOOK_CAT_NUM, Introduction COMPANY_NAME) Part One - Getting Started with'16:32:33', WebSphere Studio Application Developer'BBB_Company'); (WSAD) 5.0 VALUES('02-11-2002', 'RENT', '00004',
Chapter 1
- Introducing WSAD 5.0
Chapter INSERT 2 INTO - Setting LIB.BOOK_ACTIVITY Up the Development Environment (TXN_DATE, TXN_TIME, TXN_TYPE , BOOK_CAT_NUM,
COMPANY_NAME) Chapter 3 - Working with the WSAD 5.0 Workbench VALUES('02-17-2002', '17:12:22', Chapter 4 - Developing Database Applications 'RENT', '00005', 'BBB_Company'); Part Two - Working with J2EE: The Distributed Application Framework
INSERT (TXN_DATE, TXN_TIME, TXN_TYPE , BOOK_CAT_NUM, Chapter 5 INTO - J2EELIB.BOOK_ACTIVITY Development COMPANY_NAME) Chapter 6 - J2EE EJB Development VALUES('03-11-2002', '18:23:44', 'RETR', '00005', 'BBB_Company'); Chapter 7 - J2EE Web Development Chapter 8
- J2EE XML Development
INSERT INTO LIB.BOOK_ACTIVITY (TXN_DATE, TXN_TIME, TXN_TYPE , BOOK_CAT_NUM, COMPANY_NAME) Chapter 9 - J2EE Enterprise Messaging VALUES('03-15-2002', '19:27:11', 'RENT', '00005', 'DDD_Company'); Part Three - Working with Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 - Using WebSphere MQ as the JMS Provider
INSERT INTO LIB.BOOK_ACTIVITY (TXN_DATE, TXN_TIME, TXN_TYPE , BOOK_CAT_NUM, COMPANY_NAME) Index VALUES('04-12-2002', '20:43:21', 'RETR', '00005', 'DDD_Company'); Appendix A - Deploying This Book's J2EE Examples List of Figures List of Tables INSERT INTO LIB.BOOK_ACTIVITY (TXN_DATE, TXN_TIME, TXN_TYPE , BOOK_CAT_NUM, List COMPANY_NAME) of Code Examples List of Sidebars VALUES('05-01-2002', '20:11:21', 'RENT', '00006', 'BBB_Company');
INSERT INTO LIB.BOOK_ACTIVITY (TXN_DATE, TXN_TIME, TXN_TYPE , BOOK_CAT_NUM, COMPANY_NAME) VALUES('05-02-2002', '21:11:21', 'RENT', '00007', 'BBB_Company'); -- Commit to save work COMMIT WORK; -- Create the BOOK_NOTIFY table -- DROP TABLE LIB.BOOK_NOTIFY; CREATE TABLE LIB.BOOK_NOTIFY (MESSAGE_KEY CHARACTER(20) NOT NULL, MESSAGE_BODY CHARACTER(250) NOT NULL, PRIMARY KEY(MESSAGE_KEY)); -- GRANT ALL ON BOOK_NOTIFY TO PUBLIC; -- Commit to save work COMMIT WORK; -- End the connection
CONNECT RESET; WebSphere Studio Application Developer 5.0: Practical J2EE Development Igorthe Livshin Download this filebyfrom Apress Web site and copy it to the ISBN:1590591208 g:\sqllib\bindirectory (where Apress © 2003 (630 pages) g:\sqllibis the DB2 installation directory in your environment). Make the appropriate adjustments if you book provides installed DB2 in aThis different location.a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed From the DB2 command line, enter the following: applications.
db2 -tf BuildTechbookDatabase.sql Table and of press Contents Enter. Listing 4-2 shows the execution results. WebSphere Studio Application Developer 5.0: Practical J2EE Development
Listing 4-2. Execution Results Introduction Part One - Getting Started with Studio Application Developer (WSAD) 5.0 G:\SQLLIB\BIN>db2 -tf WebSphere Build_Database\BuildTechbookDatabase.sql
Chapter 1
- Introducing WSAD 5.0
DB20000I The DROP completed successfully. Chapter 2 - Setting Up the DATABASE Developmentcommand Environment DB20000I The CREATE DATABASE command Chapter 3 - Working with the WSAD 5.0 Workbench completed successfully. DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. Chapter 4 - Developing Database Applications DB21026I For most configuration parameters, all applications must disconnect Part Two - Working with J2EE: The Distributed Application Framework from this database before the changes become effective. Chapter 5 - J2EE Development SQL1024N A database connection does not exist. SQLSTATE=08003 Chapter 6 - J2EE EJB Development DB21034E The command was processed as an SQL statement because it was not a Chapter 7 - J2EE Web Development valid Command Line Processor command. During SQL processing it returned: Chapter 8 - J2EE XML Development SQL1024N A database connection does not exist. SQLSTATE=08003 Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: Chapter 11 - Using WebSphere MQ as the JMS Provider SQL1024N A database connection does not exist. SQLSTATE=08003 Appendix A - Deploying This Book's J2EE Examples SQL1024N A database connection does not exist. SQLSTATE=08003 Index SQL1024N A database connection does not exist. SQLSTATE=08003 Chapter 10 - Using the WSAD-Embedded JMS Provider
List of Figures List of Tables Database Connection Information List of Code Examples List of Database Sidebars server
SQL authorization ID Local database alias DB20000I DB20000I DB20000I DB20000I DB20000I DB20000I DB20000I DB20000I DB20000I DB20000I DB20000I DB20000I DB20000I DB20000I DB20000I DB20000I DB20000I DB20000I DB20000I
The The The The The The The The The The The The The The The The The The The
SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL
= DB2/NT 7.2.3 = C6023 = TECHBOOK
command command command command command command command command command command command command command command command command command command command
completed completed completed completed completed completed completed completed completed completed completed completed completed completed completed completed completed completed completed
successfully. successfully. successfully. successfully. successfully. successfully. successfully. successfully. successfully. successfully. successfully. successfully. successfully. successfully. successfully. successfully. successfully. successfully. successfully.
DB20000I The SQL command completed successfully. Studiocompleted Application successfully. Developer 5.0: Practical DB20000I TheWebSphere SQL command J2EE Development DB20000I The SQL command completed successfully. ISBN:1590591208 by Igor Livshin DB20000I The SQL command completed successfully. Apress © 2003 (630 pages) DB20000I The SQL command completed successfully. book provides acompleted practical, step-by-step approach in DB20000I TheThis SQL command successfully. teaching how to use the WebSphere Studio Application DB20000I TheDeveloper SQL command completed successfully. (WSAD) tool for developing J2EE distributed DB20000I Theapplications. SQL command completed successfully. DB20000I The SQL command completed successfully. DB20000I The SQL command completed successfully. Table of Contents DB20000I The SQL command completed successfully. WebSphere Application Developer 5.0: Practical J2EE Development SQL1024NStudio A database connection does not exist. SQLSTATE=08003 Introduction G:\SQLLIB\BIN> Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Checking the Database and Tables in the Control Center - Working with the WSAD 5.0 Workbench
Chapter 3
Chapter 4 -aDeveloping Applications It is always good idea Database to check the execution results. To check the database and tables you have just Part Two -start Working with Control J2EE: The Distributed Application Framework created, the DB2 Center utility. This utility displays the database metadata
(the structure of
Chapter 5 tables - J2EEand Development database their keys, foreign keys, database aliases, triggers, and so on) by selecting Start> Chapter 6 J2EE EJB Programs> IBM DB2Development > Control Center. The screen shown in Figure 4-1 will appear. Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 4-1: The DB2 Control Center Note IGOR is the name of my development computer. Expand the IGORcomputer node (or whatever your computer is called) all the way down by clicking the plus (+) sign. You should see the TECHBOOK database and your three tables. To see a table structure, double-click the BOOK_CATALOGtable and click the Columnstab.Figure 4-2 shows the structure of the BOOK_CATALOG table.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development
Figure 4-2: The BOOK_CATALOG table structure Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
You can click different tabs (such as Primary Key,Foreign Keys, and so on) to see additional - Introducing WSAD 5.0 information about the table. Chapter 2 - Setting Up the Development Environment Chapter 1 Chapter 3
- Working with the WSAD 5.0 Workbench
Checking the Table Data - Developing Database Applications
Chapter 4
Part Two - Working with J2EE: The Distributed Application Framework
To see BOOK_CATALOG Chapter 5 the - J2EE Development
table records, activate the DB2 Command Center tab. Next, click the box at the end of the Database
Chapter - J2EE EJBthe Development utility6and click Interactive Chapter 7
- J2EE Web Development
field. Expand the machine node and select the TECHBOOKdatabase. The tool will connect to the database. Chapter 8 - J2EE XML Development Enter the following command in theMessaging Commandfield, as shown in Figure 4-3: Part Three - Working with Enterprise Select LIB.BOOK_CATALOG Chapter 9 *- from J2EE Enterprise Messaging Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 4-3: Entering the command Note TheLIBprefix is the database schema name. Next, highlight the entered text and select Interactive> Executefrom the main toolbar. Figure 4-4 shows the execution results.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere FigureStudio 4-4: The Application contents Developer of the BOOK_CATALOG 5.0: Practical J2EEtable Development Introduction
In the same way,Started you canwith display the content of the rest of the tables. With the 5.0 TECHBOOK Part One - Getting WebSphere Studio Application Developer (WSAD) you are1now ready to start developing your first WSAD 5.0 database-related application. Chapter - Introducing WSAD 5.0 Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
database built,
Studio Application Developer 5.0: Practical DevelopingWebSphere Your First J2EE Database Application J2EE Development
ISBN:1590591208 by will Igordevelop Livshin an application for a fictitious library As mentioned, you that lends technical books to its clients. Apress © 2003 (630 pages) You will develop this database application as a Web application (Web modulein J2EE 1.3 terminology), so you will not use any JavaBean (EJB)step-by-step development in this first ThisEnterprise book provides a practical, approach in example.
teaching how to use the WebSphere Studio Application (WSAD) tool you for developing J2EEadistributed When creating a Developer database connection, should create separate project to store the generated applications. database files, as in the following section. This facilitates deployment by making it easier to use the database in multiple projects. Table of Contents
Creating the Database Project
WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction
In this you will first create a simpleStudio project for building the TECHBOOK database. Part Onesection, - Getting Started with WebSphere Application Developer (WSAD) 5.0
Start WSAD (if it is not running yet) and switch to the Web Perspective. From the main menu, select File > New> Chapter 1 - Introducing WSAD 5.0 Project. On the New Project wizard screen, select Simpleon the left pane and Projecton the Chapter 2 - Setting Up the Development Environment right pane, as shown in Figure 4-5. Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 4-5: Creating a simple project Click Next. On the subsequent screen, name the project DBUtilityProject(see Figure 4-6).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Figure- 4-6: Naming the project J2EE Development
Chapter 5
Chapter 6 -Finish. J2EE EJBWSAD Development Next, click will create the new DBUtilityProject, and you should see it in the Chapter 7 J2EE Web Navigator View. NoticeDevelopment that the Workbench automatically switches to the Resource Perspective, and the Chapter 8 - J2EE Development Perspective’s iconXML appears on the Perspective Bar. Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Building the Database Connection
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 will - Using WebSphere MQconnection. as the JMS Provider Now, you create a database To switch to the Data Perspective, select Window> Open Appendix A Deploying This Book's J2EEmenu. Examples Perspective> Otherfrom the main In the Select Perspective dialog, select Dataand Index click OK. Right-click inside the DB Servers View and select New Connection. The Database List of Figures screen will appear. Enter Con1in the Connection name field and TECHBOOKin the Connection List Database of Tablesfield. Also, enter the user ID and password of the account capable of connecting to the List TECHBOOK of Code Examples database. The rest of the fields are already filled in correctly (see Figure 4-7). List of Sidebars
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Figure Database Connection screen Chapter 8 - 4-7: J2EEThe XML Development Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Finally, click Finish. The new connection Con1is displayed in the DB Servers View. Expand the Con1 connection in the DB Servers View to see the entire hierarchical view of the TECHBOOK database (see Chapter 11 - Using WebSphere MQ as the JMS Provider Figure 4-8). Chapter 10 - Using the WSAD-Embedded JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 4-8: The TECHBOOK database hierarchical view The main reason for developing this project is to bring the TECHBOOK database into the WSAD Workbench, so other projects can use it. Now, you need to build the project that will use the TECHBOOK
database and include the database processing logic. That is what you will do in the next section. WebSphere Studio Application Developer 5.0: Practical J2EE Development
Creating a by New Igor Web Livshin Project
ISBN:1590591208
Apress © 2003 (630 pages)
Now, you will create the Web project. Switch to the Web Perspective and select File > New > Web Project This book provides a practical, step-by-step approach in from the main menu. On the Web Project dialog, enter DBDatasourceProject in the Project teaching howCreate to use a the WebSphere Studio Application name field. Uncheck the Create a tool default CSS file box in the “Web Project features” section. Make Developer (WSAD) for developing J2EE distributed applications. sure that the J2EE Web Project box is selected (see Figure 4-9). Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables
Figure 4-9: Creating a new Web project
List of Code Examples List of Sidebars
Click Next. On the next screen, indicate that you want to create a new enterprise application project and name it DBDatasourceProjectApp. Make sure that the J2EE Level field shows 1.3(see Figure 410).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7 - 4-10: J2EE Working Web Development Figure with the J2EE settings Chapter 8 - J2EE XML Development Part Three Note -IfWorking you select with J2EE Enterprise 1.2, you Messaging will only be
able to add J2EE 1.2 modules to the application. You
deploy and run such applications on both application servers: WAS 4.0x and WAS 5.0. Chapter 9 could - J2EE Enterprise Messaging Chapter 10 - Using the WSAD-Embedded JMS Provider
Click Finish. WSAD will generate two projects: DBDatasourceProjectand DBDatasourceProjectApp. In the next section, you will import the TECHBOOK database into your Appendix A - Deploying This Book's J2EE Examples DBDatasourceProject. Chapter 11 - Using WebSphere MQ as the JMS Provider Index
List of Figures Importing
the Database in the Web Project
List of Tables List Every of Code project Examples that uses a database needs the database to be imported inside the project’s structure. That
was main reason for creating DBUtilityProject—to facilitate the import of the TECHBOOK List of the Sidebars database in the projects that use this database. To import the TECHBOOK database in your project, switch to the Data Perspective by simply clicking its icon on the Perspective Bar. In the DB Servers View, rightclick the TECHBOOK database and select Import to Folder. You should perform this step in any other project that needs to use the TECHBOOK database. That is the main reason for creating the database in a separate project and then importing it in any other project that needs it. On the next screen, click the Browsebutton and navigate to the DBDatasourceProject(see Figure 4-11).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples IndexFigure 4-11: Importing the TECHBOOK database into DBDatasourceProject List of Figures
Click OK. On the original screen, click Finish. A message will display informing you that the folder does not exist and prompting you to create the folder. Click Yes. This will import the TECHBOOK database into List of Code Examples DBDatasourceProject (see Figure 4-12). List of Tables
List of Sidebars
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - 4-12: UsingConfirming the WSAD-Embedded JMS Provider Figure the TECHBOOK import Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
Building Index
the SQL Statement
List of Figures
Next, you will build the SQL statement and the Web pages that allow the user to enter a database search request and see the database processing results. Switch to the Web Perspective, expand List of Code Examples DBDatasourceProject, and right-click Web Content. Next, select New> Other> Web Database List of > WebSidebars Pages (see Figure 4-13). List of Tables
Figure 4-13: Building database Web pages
Click Next. The Database Pages wizard Developer opens. Enter apress.wsad.db in the Java WebSphereWeb Studio Application 5.0: Practical J2EE packagefield and thenDevelopment choose Select Statement in the SQL Statement Type field and IBM ISBN:1590591208 Database Access by Igor Java Livshin BeansóMaster-Details Pattern in the Modelfield (see Figure 4-14). Apress © 2003 (630 pages) This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter Figure 9 - 4-14: J2EE Generating Enterprise Messaging the database Web pages Chapter 10 - Using the WSAD-Embedded JMS Provider
Notice the SQL Statement Type field. It allows you to select different types of SQL statements (select,update,insert, and delete). This feature is available starting with Appendix A - Deploying This Book's J2EE Examples release 5.0. In the previous releases, only one SQL type (select) was available in this field. Note Chapter 11 - Using WebSphere MQ as the JMS Provider Index
List of Figures Click Next. On the next screen, select Be guided through creating an SQL statement(you will build the List of statement Tables SQL by using the visual SQL builder tool). Also, select Use existing database model List of Codeyou Examples because already have the database and do not need to build a new one. Click the Browsebutton List andofnavigate Sidebars to the TECHBOOK database by extending DBDatasourceProject(see Figure 4-15).
Figure 4-15: Selecting an existing database model Click OK. You will return to the original screen. Notice that WSAD allows you to save the SQL statement in a file and reuse it later in other projects. Next, you want to visually construct the SQL statement. Click Next. The next screen is a graphical editor that facilitates visual construction of SQL statements.
Visually Constructing WebSphere SQL StudioStatements Application Developer 5.0: Practical J2EE Development
Expand the database schema of LIB. Next, expand Tables. For this ISBN:1590591208 by Igor Livshinby clicking the plus (+) sign in front project, you needApress to select only two out of the three available database tables, and the order of the © 2003 (630 pages) selection is important because it impacts the order of processing in the This book provides a practical, step-by-step approach in generated SQL statement. On the left pane, select the LIB.BOOK_CATALOG table first Studio and click the > button to move it to the right pane. teaching how to use the WebSphere Application Developer (WSAD) tool for developing Next, select the LIB.BOOK_ACTIVITY table and clickJ2EE the >distributed button to move it to the right pane. The SQL applications. query will be built against these two tables (by selecting certain fields from both tables). The BOOK_CATALOG table will be processed first (see Figure 4-16). Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures
Figure 4-16: Selecting tables
List of Tables
List of Code Examples
Notice that the screen has several tabs near the top (Columns,Joins,Conditions, and so on). List of Sidebars Clicking any of these tabs opens a page that helps you visually construct the corresponding part of the SQL statement. For example, clicking the Columnstab allows you to control the table’s columns that will be included in the SQL statement. That is what you want to do, so click the Columnstab, hold the Control key, and highlight the columns that need to be displayed on the output user screen. Click the > button to move them to the right pane (see Figure 4-17).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 - 4-17: J2EE Selecting Development Figure table fields Chapter 6 - J2EE EJB Development Chapter 7
- J2EE Web Development
Next, click the Conditionstab. Set the following for the first row by clicking in each column and then Chapter 8 - J2EE XML Development selecting or entering the appropriate values: Part Three - Working with Enterprise Messaging
1. In the Column field, select LIB.BOOK_CATALOG.LOCATION. - J2EE Enterprise Messaging
Chapter 9
Chapter 10 - Using the WSAD-Embedded JMS Provider
2. In the Operator field, select the not-equal () sign.
Chapter 11 - Using WebSphere MQ as the JMS Provider
Appendix 3. InAthe - Deploying Value field, This enter Book's the J2EE :location Examples variable name. Index
4. In the And/Or field, select AND.
List of Figures
List of Tables Enter the following in the second line: List of Code Examples
1. In the Column field, select LIB.BOOK_ACTIVITY.BOOK_CAT_NUM.
List of Sidebars
2. In the Operator field, select the equals (=) sign. 3. In the Value field, select LIB.BOOK_CATALOG.CATALOG_NUMBER. Your screen should look like Figure 4-18.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 - 4-18: J2EE Selecting Development Figure column values Chapter 6 - J2EE EJB Development
Click Next. screen shows the constructed SQL statement (see Figure 4-19). Chapter 7 - The J2EEsubsequent Web Development Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 4-19: The constructed SQL statement On this screen, you will search for the books that are currently not in the library possession and return certain fields from both tables. WSAD sets the value of the :locationvariable to the string Library programmatically. Click the Executebutton to test the constructed SQL statement. Click Execute again on the next screen. You will be prompted to give the value to the :locationvariable. Enter 'Library'using single quotes (see Figure 4-20).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Figure Setting value Chapter 3 - 4-20: Working with the the variable WSAD 5.0 Workbench Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Click Finish. The next screen shows the SQL processing results (see Figure 4-21).
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
Figure 4-21: The SQL processing results
Index
List of Figures
Click List of Close Tables to return to the original screen. Then click Next. The subsequent screen prompts you to configure to connect to the database at runtime. You can select Use driver manager List of Code how Examples
connection, but it is better to select Use data source connection because the Datasource automatically provides a pool of connections. Connections that are no longer used are not closed but are instead returned to the pool of connections and later reused (substantially improving application performance). Select Use data source connection (see Figure 4-22).
List of Sidebars
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 - 4-22: J2EE Selecting Development Figure the connection pool Chapter 6 - J2EE EJB Development Chapter 7
- J2EE Web Development
In this section, you visually constructed and tested the SQL statement with the help of the graphical SQL Chapter 8 - J2EE XML Development editor screens. It is also possible to just manually type the entire SQL statement in a window similar to the Part Three - Working with Enterprise Messaging one shown in Figure 4-19. To do this, you need to select Manually type an SQL statement on the Chapter 9 SQL - J2EE Enterprise Messaging Choose Method screen. Next, you want to build a Web screen that displays the processing results Chapter 10 Using the WSAD-Embedded JMS Provider to the user. You will do this in the next section. Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
Building the User Interface Screens
Index
List of next Figures The screen lets you define certain properties of building Web pages. Specifically, you can specify the List of Tables error page for displaying processing errors. You can also specify where to store the results. Leave the List of Codebox Examples Request selected because the user interaction will require a single screen (for the user multiscreen List of Sidebars conversation, you should choose the Sessionoption). Finally, select Create a new Front
Controlleroption (see Figure 4-23).
Figure 4-23: TheView Bean Data Page screen
WebSphere Studio Application Developer 5.0: Practical J2EE Development
ISBN:1590591208 Click Next. The input by Igor screen Livshin displays on the next page. The screen that WSAD automatically generates is Apress © 2003 (630 pages) really only suitable as the skeleton or the first draft of a professional-looking screen. Therefore, you need to customize the This WSAD-generated screen. Using creativity,approach you can greatly improve the crude-looking book provides a practical, step-by-step in teaching howyou to use thein WebSphere Studio Application original screen. That is what will do the next section.
Developer (WSAD) tool for developing J2EE distributed applications.
Customizing the Input Screen
Table of Contents screens are highly customizable. To go to the extreme, you can even completely WSAD-generated WebSphere StudioTypically, Application Developer 5.0: Practical J2EE Development redesign them. though, you rearrange some fields, change their titles and other attributes,
replace the screen title with an image, and so on. There are two tabs, PageandFields, located at the Introduction left One side -near the Started bottom with of theWebSphere screen. Clicking PagetabDeveloper displays the dialog5.0 that Part Getting Studio the Application (WSAD)
allows you to
customize overall screen Chapter 1 -the Introducing WSADlook 5.0 and feel (screen title, background and foreground colors, and so on). Clicking2 the- Fields tabthe displays a dialogEnvironment for customizing the screen fields. Chapter Setting Up Development Chapter 3
- Working with the WSAD 5.0 Workbench
To customize the input screen, first select the Pagetab, then click the Page Title and replace the text - Developing Database Applications Input Form with the text Enter Book Location. Click the next line for the change to take effect. Part Two - Working with J2EE: The Distributed Application Framework Next, click the Fieldstab. Select the LOCATIONfield, click the Labelfield and replace the text Chapter 5 - J2EE Development LOCATIONwith Book location. Also, increase the field size to 35 and the maximum size to 50. Your Chapter 6 - J2EE EJB Development screen should look like Figure 4-24. Chapter 4
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 4-24: The input screen design Click Next. The subsequent screen displays the output page. Notice the red stars. They mark the key fields. Click the Pagetab. Change the form title to Search Results. Click the Fieldstab and change all the column labels by removing the schema name—in other words, the table name prefix. Also, unmark two fields: TXN_DATE and TXN_TYPE (you will not display these fields here but on the Detail page). Your screen should look like Figure 4-25.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 - 4-25: J2EE The Development Figure output screen design Chapter 6 - J2EE EJB Development
Click Next. subsequent screen is for designing the Detail View output screen. Click the Pagetab. Chapter 7 -The J2EE Web Development
Change the- form title to Details View. Remove the schema and the table names coded as a suffix in J2EE XML Development the field names (see Figure 4-26). Messaging Part Three - Working with Enterprise Chapter 8 Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 4-26: TheDetails Views page design Click Next. This design will build the Model-View-Controller pattern for the Web application. It will be implemented by the several modules listed on the next screen. The system asks you to come up with a common prefix for all these modules that replaces the inconvenient LIB_BOOK_ACTIVITY prefix generated by WSAD. Change the Prefixfield to BookSearch(see Figure 4-27).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 - 4-27: J2EE Setting Development Figure the common prefix Chapter 6 - J2EE EJB Development
Click Finish. WSAD generate six modules: BookSearchController.java, Chapter 7 - J2EE Webwill Development BookSearchDetailsViewBean.java, Chapter 8 - J2EE XML Development BookSearchMasterViewBean.java,
BookSearchDetailsView.jsp, BookSearchInputForm.html, and BookSearchMasterView.jsp(see Figure 4-28).
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 4-28: The generated modules Click Finish. Your first database project is practically ready. The still-missing part is the Deployment Descriptor, which you will build in the next section.
Setting theWebSphere Application Descriptor StudioDeployment Application Developer 5.0: Practical J2EE Development
WSAD provides several of building the Deployment Descriptor. In the J2EE Perspective, you can ISBN:1590591208 by Igor ways Livshin double-click a project to have its Deployment Descriptor open in the Editor View. Alternatively, you can Apress © 2003 (630 pages) right-click a project and select Open With > Deployment Descriptor Editor. The third way is to This book provides a practical, step-by-step approach in locate the project’s Deployment file (web.xml in the WEB-INFfolder for Web teaching how to Descriptor use the WebSphere Studiolocated Application projects or ejb-jar.xml thedeveloping META-INF folder for the EJB projects) and double click it. Developerlocated (WSAD)inside tool for J2EE distributed applications.
Now, it is time to set the Deployment Descriptor for your project. In the J2EE Navigator View, right-click DBDatasourceProjectand select Open With > Deployment Descriptor Editor. Table of Contents
On the screen that appears,Developer click the References tab. Select Resourceat the top of the screen and WebSphere Studio Application 5.0: Practical J2EE Development click the Addbutton. Then click the Browsebutton next to the Typefield to display the Type Introduction Selection screen (see with Figure 4-29). Part One - Getting Started WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables
4-29: Selecting a Datasource List ofFigure Code Examples List of Sidebars
Select Datasource and click OK. On the next screen, change the Datasource name to DBDatasource. Click the Browse button and select the javax.activation.DataSource package. In the “WebSphere Bindings” section, enter jdbc/DBDatasource in the JNDI Namefield. In the “WebSphere Extensions” section, select TRANSACTION_READ_COMMITTED(no dirty reads) for the Isolation Level field (see Figure 4-30).
Figure 4-30: Configuring the Datasource Next, click the Extensions tab and check these two boxes: Automatic Request Encoding enabled and Automatic Response Encoding enabled. WSAD 5.0 no longer does this automatically (see Figure 4-31).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3 - 4-31: Working with WebSphere the WSAD 5.0 Workbench Figure Setting extensions Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Next, click -the Servletstab and select BookSearchMasterView. Make sure that the username, J2EE Development password, and dataSourceNamefields are set correctly (see Figure 4-32).
Chapter 5 Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 4-32: Setting a Datasource for BookSearchMasterView Next, select BookSearchDetailsView. Make sure that the username,password, and dataSourceNamefields are set correctly (see Figure 4-33). Save the Deployment Descriptor file and close the editor. Any project that needs to be debugged or simply executed inside the WSAD development environment requires you to set a Unit Test Server (UTS) environment. UTS is actually an embedded WAS provided here for the purpose of the WSAD project’s unit testing. Because this unit testing environment closely mimics the runtime environment, WSAD testing is performed under conditions that are close to a real production runtime environment. This close integration of WSAD and WAS also facilitates future project deployment. Setting UTS requires you to create a separate server project and server configuration. The server configuration is the place where you configure the runtime WSAD environment that is (as mentioned) close to a real production environment. In the next section, you will set the UTS environment for your project so that you will be able to run and test it.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3 - 4-33: Working with the the Datasource WSAD 5.0 Workbench Figure Setting for BookSearchDetailsView Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Setting Unit Test Server Chapter 5 the - J2EE Development Chapter 6
Environment
- J2EE EJB Development
In this section, you will create a new server project and set the server configuration (specifically, you will - J2EE Web Development set the Datasourcefor the UTS environment). Switch to the Server Perspective and select File> New Chapter 8 - J2EE XML Development > Server Project. On the next screen, enter DBDatasourceServerProjectin the Project Part Three - Working with Enterprise Messaging namefield (see Figure 4-34). Chapter 7
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 4-34: Creating the server project Finally, click Finish. WSAD will build a new server project called DBDatasourceServerProject. Next, right-click DBDatasourceServerProjectand select New> Server and Server Configuration. On the screen that appears, enter DBDatasourceServerin the Server name field. Also, expand WebSphere version 5.0 and select Test Environment in the Server type field (see Figure 4-35).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter Figure 6 - 4-35: J2EE Creating EJB Development the server project configuration Chapter 7
- J2EE Web Development
Chapter 9
- J2EE Enterprise Messaging
Finally, click Finish. WSAD will create the server instance and server configuration. In the Server Chapter 8 - J2EE XML Development Configuration View, right-click DBDatasourceServerand select Add> DBDatasourceProjectApp Part Three - Working with Enterprise Messaging to make this server the default server for the DBDatasourceProjectAppapplication. Chapter 10step - Using WSAD-Embedded JMSthe Provider The last in thethe process of configuring server environment is to build the Datasourceobject for Chapter 11 Using WebSphere MQ as the JMS the TECHBOOK database. The advantage ofProvider using the Datasourceobject (instead of directly Appendix A - Deploying This Book's manipulating the database driver) J2EE is thatExamples the Datasourceobject maintains a pool of connections to the Index underlying database that it represents. When an application that uses a Datasourceobject closes the List of Figures database connection, the connection is not physically closed but simply returned to the pool of database List connections. of Tables Conversely, when an application opens a database connection, an available connection is
taken fromExamples the pool and reused. That process substantially improves the application performance. In the List of Code next List of section, Sidebarsyou will build the Datasourceobject for your application.
Configuring the Datasource Connection Under the Server Configuration View, double-click DBDatasourceProjectAppto open the server configuration file in the Editor View. Click the Data Source tab. Highlight Default DB2 JDBC Providerin the JDBC Provider list field and click the Addbutton near the Data Source list field. On the next screen, select DB2 JDBC Provider and select Version 5.0 data source (see Figure 4-36).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Figure- 4-36: Setting server configuration J2EE Development
Chapter 5 Chapter 6
- J2EE EJB Development
Chapter Click Next. 7 - On J2EE theWeb subsequent Development screen, you can configure the Datasourcefor the server. Enter
DBDatasource the Development Namefield and enter jdbc/DBDatasourcein the JNDI name field. Also, Chapter 8 - J2EEinXML uncheck Use this data source in Part Three the - Working with Enterprise Messaging 37). 9 Chapter
container managed persistence box (see Figure 4-
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 4-37: Modifying the Datasource Click Next. On the subsequent screen, select databaseName in the Resources Propertieslist and enterTECHBOOKas the database name in the Valuefield (see Figure 4-38).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging Figure 4-38: The Modify Resource Properties
Chapter 9
screen
- J2EE Enterprise Messaging
Click Finish. WSAD create the newJMS Datasource (see Figure 4-39). Save the results (click the Chapter 10 - Using the will WSAD-Embedded Provider main toolbar icon that looks like floppy disk)Provider and click the Xbutton to close the editor. You are ready to Chapter 11 - Using WebSphere MQa as the JMS test yourAapplication. Appendix - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 4-39: TheDatasourcesetting screen
Testing the Application In the Server Perspective (the Servers View), right-click the DBDatasourceServerserver and select Start(see Figure 4-40).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed Figure 4-40:applications. Starting the server
Wait until the server displays the message “Server is ready for e-business.” In the Servers View, the ready server display the status Started. Now, switch to the Web Perspective. Right-click Table of will Contents BookSearchInputForm.html and select Run on Server. The Enter Book Location screen will WebSphere Studio Application Developer 5.0: Practical J2EE Development appear. Enter Library in the Book locationfield (see Figure 4-41). Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List ofFigure Figures4-41: Testing the project List of Tables List of Code Examples
Click Submit. The next screen shows the processing result (see Figure 4-42).
List of Sidebars
Figure 4-42: The processing results screen Next, select the first record and click Details. The subsequent screen displays the detailed record (see Figure 4-43).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Developer Practical J2EE Development FigureStudio 4-43:Application TheDetails View5.0: results screen Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Close the Web Browser View and stop the server. To learn how to deploy this application, refer to the - Introducing WSAD 5.0 appendix.
Chapter 1 Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Summary
WebSphere Studio Application Developer 5.0: Practical J2EE Development
ISBN:1590591208 by achieved Igor Livshin In this chapter, you two results. First, you built the TECHBOOK database that the rest of the book Apress © 2003 (630 pages) how to develop J2EE database-aware applications in the WSAD examples will use. Second, you learned 5.0 environment. This Thebook chapter also discussed reasons for using the provides a practical,the step-by-step approach in Datasourceinstead of directly teaching how to use the WebSphere Studio Application using the database drivers.
Developer (WSAD) tool for developing J2EE distributed applications. In the next chapter, you will start exploring the development of J2EE 1.3 applications. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical Part Two: Working with J2EE: The Distributed J2EE Development ISBN:1590591208 by Igor Livshin Application Framework Apress © 2003 (630 pages) This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Chapter List Developer (WSAD) tool for developing J2EE distributed applications.
Chapter 5: J2EE Development
Table of Contents
WebSphere Chapter Studio 6: J2EE Application EJB Development Developer 5.0: Practical J2EE Development Introduction
Chapter 7: J2EE Web Development Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0 Chapter 8: J2EE XML Development
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Studio Application Developer 5.0: Practical Chapter WebSphere 5: J2EE Development J2EE Development by Igor Livshin
ISBN:1590591208
This chapter concentrates on some of the new features of the latest Java 2 Enterprise Edition (J2EE) 1.3 Apress © 2003 (630 pages) and Enterprise JavaBean (EJB) 2.0 specifications and how you can use them in the WebSphere Studio This book provides a practical, step-by-step approach in Application Developer (WSAD) 5.0 and WebSphere Application Server (WAS) 5.0 family of tools. This teaching how to use the WebSphere Studio Application chapter also includes some(WSAD) advanced of J2EE J2EE development. Developer tooltopics for developing distributed applications.
Note You should be familiar with basic concepts of the J2EE technology. J2EE is a large topic that cannot be adequately covered in one chapter. A large number of J2EE books are available; I Table of Contents recommend Enterprise JavaBeans 2.1 (Apress, 2003). WebSphere Studio Application Developer 5.0: Practical J2EE Development
Quick Introduction to J2EE
Introduction
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 -by Introducing WSAD 5.0 J2EE is a component-based framework for developing of server-based Developed Sun Microsystems, Chapter enterprise 2 applications. - Setting Up the J2EE Development offers a multitiered Environment distributed application model that provides a multitude of
services enterprise applications: distributed component architecture, remote object Chapter 3 necessary - Workingfor with the WSAD 5.0 Workbench execution, communication, standardized access to databases and other resources, asynchronous Chapter 4 -network Developing Database Applications messaging, unifiedwith security, processing, platform independence, Part Two - Working J2EE: transaction The Distributed Application Framework Chapter 5
load balancing, and so on.
- J2EE Development
The multitiered distributed model allows developers to build highly scalable applications by dividing the - J2EE EJB Development application logic between multiple machines and executing different parts of application processing on the Chapter 7 - J2EE Web Development most suitable processing platforms. A J2EE multitiered application typically consists of four tiers: the client Chapter 8 - J2EE XML Development tier, the Web tier, the EJB (business) tier, and the enterprise tier. Chapter 6
Part Three - Working with Enterprise Messaging
Chapter 9 The - J2EE Enterprise Note enterprise tierMessaging can consist of database servers, enterprise messaging, enterprise Chapter 10 namespaces, - Using the WSAD-Embedded Custom Information JMS Provider Control System (CICS), IBM's IMS-based legacy applications,
so on. Chapter 11 and - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
J2EE applications consist of the following J2EE modules:
Index
List ofClient Figures modules of the J2EE applications typically run on the client machine in the client container and List ofdirectly Tables communicate with the EJB tier of the J2EE application. In WSAD, a client module is presented List ofas Code Examples a client project. List of Sidebars
Web modules-servlets and JavaServer Pages (JSP)-run in the Web container and are typically responsible for the application presentation logic. In WSAD, a Web module is presented as a Web project. EJB modules-session, entity, and Message Driven Beans (MDBs)-run in the EJB container and are typically responsible for the application's business processing logic. In WSAD, an EJB module is presented as an EJB project. All J2EE components (Web, EJB, and J2EE client) run inside their corresponding containers-application server software that provides a necessary interface between the J2EE components and the underlying operating system. Containers represent an environment for providing J2EE services to their components.
WebSphere Studio Application Developer 5.0: Practical Understanding JNDI J2EE Development
ISBN:1590591208 byframework Igor Livshin You use the J2EE for developing distributed enterprise Java-based applications. Components of such applica Apress © 2003 Any (630 pages) multiple tiers on the network. distributed application needs a mechanism for locating its components regardless of w Naming and Directory Interface (JNDI) facilitates locating distributed EJB components and calling their interfaces expose This book provides a practical, step-by-step approach in
teaching how to use the WebSphere Studio Application
Developer (WSAD) tool for developing J2EE distributed Many directory service packages are available from different vendors, such as Lightweight Directory Access Protocol (LD applications. Information Services (NIS+), Microsoft’s Active Directory for Windows-based networks, and so on. Each directory packag Programming Interfaces (APIs)—a situation similar to databases. JNDI is a set of standard (vendor-independent) APIs, c J2EE developer to use many proprietary (but JNDI compliant) directory service packages in a standard (vendor-indepen Table of Contents
WebSphere Studio Application Developer 5.0: enterprise Practical J2EE Development JNDI is a common framework for locating components (not only EJBs but also remote resources such as dat Introduction By using JNDI, J2EE developers should not be concerned about the underlying specifics of the directory service they use Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 migration between different packages is necessary. The same standardization is achieved
in the J2EE environment with
Chapter 1 - Introducing WSAD 5.0 Connectivity (JDBC). Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench Using JNDI for Locating EJB Components - Developing Database Applications
Chapter 4
Part - Working with components J2EE: The Distributed Application TheTwo clients of the EJB are typically anotherFramework EJB component,
a servlet, a JSP, a J2EE client application, or a
Chapter 5 several - J2EE Development There are naming and directory service software packages available. Chapter 6 - J2EE EJB Development
LDAP: a hierarchical repository of entries and attributes. Chapter 7 -This J2EEisWeb Development Chapter 8
- J2EE XML Development
NIS+: This is a naming system developed by Sun. It allows users to access systems on other hosts with a single use
Part Three - Working with Enterprise Messaging
Chapter 9 Naming - J2EE Enterprise Messaging COS Service: This is the CORBA naming service. Chapter 10 - Using the WSAD-Embedded JMS Provider
Domain Naming Service (DNS): ThisJMS is mostly used on the Internet to translate human-readable addresses into bina Chapter 11 - Using WebSphere MQ as the Provider Appendix A - Deploying This Book's J2EE Examples
All these software packages use a different set of APIs and classes. By providing standard APIs, classes, and interfaces same way as JDBC, Java Message Service (JMS), and other standard framework interfaces. All vendors of naming serv List of Figures used via JNDI. WSAD’s test server and WebSphere Application Server (WAS) provide a CORBA-based JNDI naming se List of Tables and testing examples in this chapter. development Index
List of Code Examples
There are several basic steps necessary for locating an EJB component via JNDI. Before using JNDI, the JNDI client ne List of Sidebars
properties. That helps the client to build the InitialContextpointing to the JNDI namespace. The context environme used as a parameter in the InitialContextclass constructor. The following three attributes are provided in the hasht name, location of the server where the naming service is implemented, and security preferences (YES,NO). If the securit default is NO. You use different context factory classes for different naming systems.
Listing 5-1 shows the meta-code for constructing the InitialContextfor different naming service providers. (For the s try/catchblocks that should surround this logic.) Listing 5-1. Meta-Code for Constructing the JNDI InitialContext // Import necessary packages import java.util.*; import javax.naming.*; import javax.naming.Directory*; // Create the InitialContext variable InitialContext jndiContext = null; // Create a Hashtable Property Object Hashtable prop = new Hashtable(2); // Use the following code for WebSphere-based Naming Service prop.put(INITIAL_CONTEXT_FACTORY,
com.ibm.websphere.naming.WsnInitialContextFactory); WebSphere Studio Application Developer 5.0: Practical prop.put(Context.PROVIDER_URL, "iiop://localhost/); J2EE Development by Igor Livshin
ISBN:1590591208
// Use the following code for LDAP-based Naming Service Apress © 2003 (630 pages) prop.put(Context.INITIAL_CONTEXT_FACTORY, This book provides a practical, step-by-step approach in "com.sun.jndi.ldap.LdapCtxFactory"); teaching how to use the WebSphere Studio Application prop.put(Context.PROVIDER_URL, Developer (WSAD) tool for "//polaris/o=ibm,c=us"); developing J2EE distributed applications.
// Use the following code for the File-based Naming Service prop.put(Context.INITIAL_CONTEXT_FACTORY, Table of "com.sun.jndi.fscontext.RefFSContextFactory"); Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development prop.put(.Context.PROVIDER_URL, Introduction "/C:/JNDI-Directory"); Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 - Introducing WSAD 5.0 // Construct the InitialContext object Chapter jndiContext 2 - Setting = new Up the InitialContext(prop) Development Environment Chapter 3
- Working with the WSAD 5.0 Workbench
// Look for an Database EJB remote object Chapter 4 -up Developing Applications Object obj = jndiContext.lookup(JNDI_name_of_EJB_component); Part Two - Working with J2EE: The Distributed Application Framework Chapter 5
- J2EE Development // Returned is a generic java.lang.Object that has no idea Chapter 6 - J2EEstub EJB Development
// of7 how to Web be our home interface. The narrow method allows us to Chapter - J2EE Development // cast -it to the appropriate type. J2EE XML Development
Chapter 8
Part Three - Working with Enterprise Messaging
// Get the Home Interface of the remote object - J2EE Enterprise Messaging MyEJBComponentHome componentHome = Chapter 10 - Using the WSAD-Embedded JMS Provider (MyEJBComponentHome) Chapter 11 - Using WebSphere MQ as the JMS Provider PortableRemoteObject.narrow(obj, MyEJBComponentHome.class); Appendix A - Deploying This Book's J2EE Examples // Having the Home interface we can call the create() method Index // (the container will call the corresponding ejbCreate() method List Figures //ofto create an object). List of Tables MyEJBComponent componentRemote = List of Code Examples componentHome.create([arguments]); Chapter 9
List of Sidebars
// Obtain a Remote interface of the EJB component. Having a Remote // Interface, an EJB client can call the remote // object's methods. String catalogNumber = componentRemote.getCatalog_number(); // If an EJB client calls a statefull session bean, always // clean up when the session bean is no longer needed // by calling the remove method componentHome.remove();
In the WSAD environment, the EJB client that runs inside the container (another EJB component, servlet, or JSP) does n parameters to create the InitialContextobject. WSAD takes care of this automatically. Such EJB clients create the following simplified way: jndiContext = new InitialContext();
The EJB 2.0 specification introduced the Local Interface (Local Client View) for EJB components. You will learn about it several examples that use Local Interfaces in Chapter 6. For now, I only want to mention that the lookupmethod for EJ are coded differently and the narrowmethod is not used.
Starting from EJB 1.1, it is recommended that all EJB references be bound to java:comp/env—the JNDI environment maintain. This is only a recommendation and not a requirement. The following lookupcode shows how to perform a lo the JNDI environment context:
Object objRef = jndiContext.lookup("java:comp/env/bookCatalog"); WebSphere Studio Application Developer 5.0: Practical
Applications that J2EE do notDevelopment run in the container cannot use the java: lookup namespace because it is the container tha ISBN:1590591208 by Livshin application. Instead,Igor an application of this type must look the object up directly from the name server. Each application s Apress © 2003 (630 pages) components such as EJB homes are bound relatively to the server root context in that name server. The form of the con This name book provides a practical, step-by-step in whether the qualified is a topology-based name or a approach cell-scoped-fixed name. teaching how to use the WebSphere Studio Application
Developer (WSAD) tooltopology-based for developing J2EE distributed The following example shows how the lookup name is constructed for the single server MySingleSer applications.
Java.lang.Object ejbHome = initialContext.lookup ("cell/nodes/Node1/servers/MySingleSer The of following example show how the topology-based lookupname is constructed in the cluster MyCluster: Table Contents
WebSphere Studio Application Developer 5.0: Practical J2EE Development Java.lang.Object ejbHome = initialContext.lookup ("cell/clusters/MyCluster/com/myCompan Introduction
TheOne following example shows how the cell-scoped-fixed-name lookup name is5.0 constructed: Part - Getting Started with WebSphere Studio Application Developer (WSAD)
Chapter Java.lang.Object 1 - IntroducingejbHome WSAD 5.0 = initialContext.lookup ("cell/persistent/com/myCompany/Accoun Chapter 2
- Setting Up the Development Environment For more search the WAS Info Center for the “Looking Up an EJB with JNDI” topic. Chapter 3 information, - Working with the WSAD 5.0 5.0 Workbench Chapter 4
- Developing Database Applications
Using the JNDI dumpSpace Utility
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development WAS provides a JNDI-based utility that allows you to dump the content of the InitialContextmaintained by WAS. It Chapter 6 - J2EE EJB Development
service–related problem. To run the utility, execute the following command from the command line: Chapter 7 - J2EE Web Development /bin/dumpNameSpace.bat [-keyword value] Chapter 8 - J2EE XML Development Part Three - Working with Enterprise Messaging
The keywords and values include the following: - J2EE Enterprise Messaging
Chapter 9
Chapter 10host - Using JMS whose Providernamespace you want to dump. The default is the local host. The namethe is WSAD-Embedded the WebSphere host Chapter 11 - Using WebSphere MQ as the JMS Provider
-report [short| long | help]J2EE Examples Appendix A - Deploying This Book's Index
shortmeans dump the binding name and bound object type, which is essentially what JNDI Context.listprovid
List of Figures
List oflong Tables means dump the binding name, bound object type, local object type, and string representation of the local obje List of Code Examples
prints the help information for the command. List ofhelp Sidebars
WebSphere Studio Application Developer Exploring the New Features of the J2EE5.0: 1.3Practical Framework J2EE Development
ISBN:1590591208 by Igor Livshin This section concentrates on three of the most important new features of the J2EE 1.3 release: Local Interfaces, the new © 2003 pages) several examplesApress of using the(630 Local Interface and new model of CMP entity bean. Chapters 9-11 discuss MDBs, and the
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Understanding the EJB 2.0 Tier of the J2EE 1.3 Application
The discussion starts with the EJB component Local Interface (also called Local Client View). This is a new feature intro Table of Contents Using a Local
Reference to EJB Objects
WebSphere Studio Application Developer 5.0: Practical J2EE Development
In addition to providing the Remote Interface (Remote Client View), EJB components can now provide the Local Interfac Introduction meaning they runStarted on the with sameWebSphere machine and on the same Java Virtual (WSAD) Machine5.0 (JVM). Part One - Getting Studio Application Developer
If multiple WAS instances are ins
both components run under different JVMs and they are not co-located. Chapter 1 - Introducing WSAD 5.0 Chapter 2
Setting Up the Development Environment Therefore, -the Local Interface is quite restricted. It is also sensitive to component movement from one location to anothe
Chapter Working with the WSAD 5.0 Workbench objects3do -not need to communicate over the network, a lot of processing is saved here (there is no need to marshal par Chapter 4 - Developing Database Applications Part Apart Two from - Working saving with resources J2EE: The by eliminating Distributedthe Application network communication, Framework
the Local Interface provides an additional impor
of this. 5The- first is Development that the copy of large parameter objects must be sent over the network, which is a resource-intensive Chapter J2EE Chapter 6
- J2EE EJB Development
In contrast, the Local Interface passes parameters by reference, meaning that only a reference of the object is sent to th - J2EE Web Development architectural reasons for not using the Local Interface.
Chapter 7 Chapter 8
- J2EE XML Development
Part with Enterprise Messaging OneThree of the- Working J2EE best-practice recommendations
is that an EJB client never calls entity beans directly but rather utilizes
Chapter - J2EEseveral Enterprise Messaging pattern9provides benefits. Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter Using11Session - Using WebSphere Facade MQ andasTransfer the JMS Provider Objects Appendix A - Deploying This Book's J2EE Examples
First, the Session Facade session bean is typically co-located with the entity bean it calls. Because all calls are local located client as one network call (which is much faster), and the local client can get the result over the Local Interface.
Index
List of Figures
List of Tables Second, you typically need to execute the business logic under a single transaction so that the processing results are all List of Code Examples alternative (when each entity bean runs under its own transaction context) would lead to a data integrity problem. One en List of Sidebars
Another widely used J2EE development pattern is to use transfer objects typically designed as JavaBeans. The transfer the network and other overhead and improves the application performance for the Remote Interface of communication. Interface in place.
From the EJB client point of view, the Local Interface is similar to the Remote Interface. The EJB component that expose Interface, you promote them to the Local Interface.
Understanding Local and Remote Interfaces
Still, you need to be aware of several differences. The lookupcall to locate the object with the Local Interface is slightly
Javax.naming.Context jndiContext = new InitialContext(); Book_catalogLocalHome catalogL (Book_catalogLocalHome) jndiContext.lookup("javaLcomp/env/ejb/Book_catalogLocalHome");
Notice that you do not use the PortableRemoteObject.narrowmethod. There is no need to use it here because you
Setting Local Interface and Conversational Processing
If a business function consists of several user screens, you have to design such a business function as a conversation. In that can be saved in the session are wrappers of primitive Java types (Integer,Short,Long,Float,Double, and Boo
Other Java objects must be serializable (objects that implement the Serializableinterface) to be properly saved in th Second, the session objects can be distributed over the network between multiple machines in the network cluster. The saving it on disk.
Because the remote stub itself cannot be serialized, references to the Home and Remote Interfaces cannot be put in a s WebSphere Studio Application Developer 5.0: Practical the example of using the Handleobject. Having the remote object reference, you can create a Handleto this object and J2EE Development
Handle catalogHandle = catalogRemote.getHandle(); session.putValue("Catalog_Handle", ca ISBN:1590591208 by Igor Livshin Apress © 2003 (630 pages)
To get back the remote reference to the object, get the Handleobject from the session and use the getEJBObjectme This book provides a practical, step-by-step approach in
Handle catalogHandle session.getValue("Catalog_Handle"); Catalog catalogRemo teaching how=to(Handle) use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed
applications. That is how it works with the Remote Interface. Objects that expose the Local Interface are different. Because the netwo even defined for the Local Interface (because no network is involved). You will see an example of saving references to th Table of Contents
Using EJB 2.0 Entity Beans
WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction
The EJB 2.0 specification made dramatic changes to the CMP entity bean components. The extent of these changes is s two separate types of EJB containers (one for EJB 2.0 and another for EJB 1.1 entity beans).
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment Understanding EJB 2.0 CMP Entity Bean Persistence Fields
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter - Developing Database Applications A CMP4entity bean is now an abstract class that implements the javax.ejb.EntityBeaninterface. All persistence fiel Part Two - Working with J2EE: The Distributed Application Framework CMP class:
Chapter 5
- J2EE Development
Chapter 6 abstract - J2EE EJB Development public class TechLibBook_catalogBean Chapter implements 7 - J2EE Web Development javax.ejb.EntityBean Chapter 8 {
- J2EE XML Development
Partpublic Three - Working with Enterprise abstract String Messaging getCatalog_number();
Chapter 9
- J2EE Enterprise Messaging
Chapter public 10 - abstract Using the WSAD-Embedded void setCatalog_number(String JMS Provider newCatalog_number); Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix-----------------A - Deploying This Book's J2EE Examples
----------------------------------List of Figures } List of Tables Index
List of Code Examples
--}
List of Sidebars
As you can see, a persistant field (catalog_number)is not defined in the class. It is represented by its abstract access Based on this abstract class and the information present in the Deployment Descriptor, the container generates the real from the developer).
Having full control over the CMP entity bean class allows the container to better optimize CMP processing. It no longer h entire state of the bean on the ejbLoadcallback method. By controlling the persistence fields, the container now knows
Persistant fields are called CMP fields. They can be represented by Java primitive types (int,short,long,float,byte are serializable objects and map naturally to fields in the relational databases. Again, the serialization requirement for th
Understanding EJB 2.0 CMP Entity Bean Dependent Value Classes
In addition, Java objects that implement the serializable interface can also be used as state beans. These types of beans Listing 5-2. Dependent Value Class public class Publisher implements java.io.Serializable { // Abstruct accessor methods private String publisherName; private String publisherAddress; // Constructor
public Publisher (String pubName, String pubAddress) WebSphere Studio Application Developer 5.0: Practical { J2EE Development publisherName = pubName; ISBN:1590591208 by Igor Livshin publisherAddress = pubAddress; Apress © 2003 (630 pages) } book provides a practical, step-by-step approach in public This String getPublisherName() teaching how to use the WebSphere Studio Application { Developer (WSAD) tool for developing J2EE distributed return publisherName; applications. } public String getPublisherAddress() Table of Contents { WebSphere Studio publisherAddress; Application Developer 5.0: Practical J2EE Development return Introduction } Part}One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment Listing 35-3 -shows howwith thisthe class can5.0 be Workbench set as a dependent value class for the CMP entity bean. Chapter Working WSAD Chapter 4
- Developing Database Applications
Listing 5-3. CMP Entity Bean with the Dependent Value Class
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development public class TechLibBook_catalogBean Chapter 6 abstract - J2EE EJB Development
javax.ejb.EntityBean Chapter implements 7 - J2EE Web Development { Chapter 8
- J2EE XML Development
// -Abstract accessor Part Three Working with Enterprisemethods Messaging abstract String getPublisherName(); Chapterpublic 9 - J2EE Enterprise Messaging public abstract
String getPublisherAddress();
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 - Using WebSphere MQ as the JMS Provider
// Business method public Publisher getPublisher() { Figures Publisher publisher = Tables new Publisher(getPublisherName(), getPublisherAddress()) Code Examples return publisher;
Appendix A - Deploying This Book's J2EE Examples Index List of List of List of
List of Sidebars
You should use dependent value classes as CMP fields carefully because they do not naturally match the database field the method that receives them cannot change the original object value. By not implementing the setter method, the trans
Understanding EJB 2.0 CMP Entity Bean Relationship Fields
A CMP entity bean can now maintain relationships with other CMP entity beans. Attributes coded within the CMP entity be Listing 5-4. Publisher.javaCMP Entity Bean publicabstract class Publisher implements javax.ejb.EntityBean { // Abstruct accessor methods public abstruct String getPublisherName(); public abstruct String getPublisherAddress; // Constructor public Publisher (String pubName, String pubAddress) { publisherName = pubName; publisherAddress = pubAddress; } public String getPublisherName()
{ WebSphere Studio Application Developer 5.0: Practical return publisherName; J2EE Development } ISBN:1590591208 by Igor Livshin public String getPublisherAddress() Apress © 2003 (630 pages) { This book provides a practical, step-by-step approach in return publisherAddress; teaching how to use the WebSphere Studio Application } Developer (WSAD) tool for developing J2EE distributed applications.
------------------------------------------Table of ---------------------Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development } Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
ThePublisher CMP entity bean Chapter 1 - Introducing WSAD 5.0exposes the Local Home and Local Interfaces and its getter methods are promoted to Chapter 2
- Setting Up the Development Environment
Listing 5-5 -shows how the second CMP entity bean will use the container relationship fields that point to the first CMP en Working with the WSAD 5.0 Workbench
Chapter 3
Chapter - Developing Database Applications Listing45-5. Book.java CMP Entity Bean Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
public abstract class Bookimplements javax.ejb.EntityBean - J2EE EJB Development { Chapter 7 - J2EE Web Development // Persistent relationship fields (CRP) Chapter 8 - J2EE XML Development public abstract PublisherLocal getHomeAddress(); Part Three - Working with Enterprise Messaging public abstract PublisherLocal getPublisherAddress(); Chapter 6
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
// Business method
Chapterpublic 11 - Using WebSpheregetPublisher() MQ as the JMS Provider Publisher Appendix A { - Deploying This Book's J2EE Examples Index
Publisher publisher =
List of Figures new Publisher(getPublisherName(), getPublisherAddress()) List of Tables return publisher; List } of Code Examples List of Sidebars
Note Only the Local Interface is allowed to expose the relationship fields.
Based on the abstract classes and information provided in the Deployment Descriptor, the container generates the nece The container also takes care of maintaining referential integrity.
In this section, you will see two entity beans that are set in a unidirectional relationship of one-to-many. In this example, y discuss the logic to be written to maintain these two entity beans' relationship. This chapter also discusses the WSAD too
The two entity beans are called Book_catalogandBook_activity.TheBook_catalogentity bean maintains books therefore, the Book_catalog-Book_activityrelationship is the one-to-many unidirectional relationship.
Note You won't be able to actually follow this exercise because the TechLibEJBproject is not built yet in your enviro The goal here is just to show you how it is done in WSAD.
First, you will build the container relationship field between these two entity beans. In the J2EE Perspective, right-click the screen, select Book_catalogin the left pane and Book_activityin the right pane (see Figure 5-1).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7 - 5-1: J2EESetting Web Development Figure an entity bean relationship Chapter 8 - J2EE XML Development
Click Next. On the next select Manyin the Part Three - Working withscreen, Enterprise Messaging Chapter 9
Multiplicityfield for the Book_activityentity bean and Onein t
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 5-2: Setting multiplicity for the CMP bean relationship
Note the Cascade delete field. Checking this field will set the database's Cascade Delete feature. Click Finish.Fig
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) for developing J2EE distributed Figure 5-3: Relationship set in tool the Deployment Descriptor applications.
The wizard also created the necessary EJB references. Click the Referencestab, extend Book_catalogbean, and c Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
Figure Local reference CMP bean Chapter 11 - 5-4: Using WebSphere MQtoasthe theBook_catalog JMS Provider Appendix A - Deploying This Book's J2EE Examples
Now, save the results and close the Deployment Descriptor. Next, you need to generate the deployment and Remote Me Finish.
Index
List of Figures
List of Tables Next, you need to edit the source code. Double-click TechLibBook_catalogto open it in the Java Editor View. Note th List of Code Examples
public abstract
List of Sidebars TechLibBook_activityLocal getBook_activity(); public abstract void setBook_activity(Tec
You add the addBookActivitymethod here. It allows the Book_activityentity bean to add the book activity transac // This method is used by the Book_activity bean to add a new book transaction // to the Book_catalog whenever a new book transaction is built public void addBookActivity(TechLibBook_activityLocal bookActivity) { if(bookActivity != null) { getBook_activity().add(bookActivity); } }
The second method that you add here, getAllCompanyNames, lists all companies that have this book-related transact method, and its logic is maintained by the container (see Listing 5-6). Listing 5-6. The getAllCompanyNamesMethod // list all companies that made transactions for this book public Vector getAllCompanyNames() { Vector allBookCompanyNames = new Vector(); Collection allBookActivities = getBook_activity();
Application Developer 5.0: Practical Iterator WebSphere iterator Studio = allBookActivities.iterator(); J2EE Development ISBN:1590591208 Igor Livshin while by (iterator.hasNext()) Apress © 2003 (630 pages) { This book provides a practical, step-by-step approach=in TechLibBook_activityLocal localBookActivity teaching how to use the WebSphere Studio Application (TechLibBook_activityLocal) iterator.next(); Developer (WSAD) tool for developing J2EE distributed String activityCompanyName = (String) applications. localBookActivity.getCompany_name();
Table of // Contents Form the vector to return the results
allBookCompanyNames.add(activityCompanyName); WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction } Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
allBookCompanyNames; Chapter return 1 - Introducing WSAD 5.0 Chapter}2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
You need to make these methods visible to other EJB clients; therefore, you promote these two methods to the Local Int
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 need - J2EE Next, you to Development modify the Book_activityentity bean. Double-click TechLibBook_activityto open it in the Jav Chapter 6 J2EE EJB Development method code. Chapter 7
- J2EE Web Development
Listing85-7. The ejbPostCreateMethod Chapter - J2EE XML Development Part /**Three - Working with Enterprise Messaging
Chapter 9 - J2EE Enterprise Messaging a new Book_activity bean is created * ejbPostCreate. Whenever Chapter 10 -it Using WSAD-Embedded JMSbean. Provider * add to the the Book_catalog Chapter */ 11 - Using WebSphere MQ as the JMS Provider Appendix publicA void - Deploying ejbPostCreate(String This Book's J2EE Examples txn_date, Index List of List of List of List of
String txn_time, String txn_type, Figures String book_cat_num, Tables String company_name Code Examples ) Sidebars throws javax.ejb.CreateException
{ try { // Get the LocalReference to this object // This can be done only in the ejbPostCreate method (not in // ejbCreate method) TechLibBook_activityLocal thisBean = (TechLibBook_activityLocal) getEntityContext().getEJBLocalObject(); InitialContext initContext = new InitialContext(); TechLibBook_catalogLocalHome bookCatalogLocalHome = (TechLibBook_catalogLocalHome) initContext.lookup("java:comp/env/BookCatalog"); // Get the Book_catalog bean for the specified book catalog number. TechLibBook_catalogLocal bookCatalogLocal = bookCatalogLocalHome.findByPrimaryKey(new TechLibBook_catalogKey(book_cat_num)); //Add this book transaction to the Book_catalog bean
bookCatalogLocal.addBookActivity(thisBean); WebSphere Studio Application Developer 5.0: Practical J2EE Development
} // End of try ISBN:1590591208 by Igor Livshin catch(Exception e) Apress © 2003 (630 pages) { This book provides a practical, step-by-step approach in e.printStackTrace(); teaching how to use the WebSphere Studio Application throw new CreateException(e.getMessage()); Developer (WSAD) tool for developing J2EE distributed } applications. } Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development
Introduction Let's discuss the processing logic written in this method. This method ensures that whenever a new book activity is proce Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
TechLibBook_activityLocal thisBean =
Chapter (TechLibBook_activityLocal) 1 - Introducing WSAD 5.0 Chapter getEntityContext().getEJBLocalObject(); 2 - Setting Up the Development Environment Chapter 3 - Working with the WSAD 5.0 Workbench
This can only inDatabase the ejbPostCreate Chapter 4 be- done Developing Applications method and not in the ejbCreatemethod (where the local reference to theBook_catalog bean in the bookCatalogLocalHome variable. Part Two - Working with J2EE: The Distributed Application Framework Chapter 5
- J2EE Development
With the Local Home reference, you execute the findByPrimaryKeymethod using the book_cat_numattribute of the - J2EE EJB Development you add this bean instance to the Book_catalogbean:
Chapter 6 Chapter 7
- J2EE Web Development
bookCatalogLocal.addBookActivity(thisBean); Chapter 8 - J2EE XML Development Part Three - Working with Enterprise Messaging
This is the end of this example.
Chapter 9
- J2EE Enterprise Messaging
Chapter - Using WSAD-Embedded JMS Provider Using10the FINDtheand SELECT Methods of
CMP Entity Beans
Chapter 11 - Using WebSphere MQ as the JMS Provider
You know findByPrimaryKey is aExamples mandatory method of any CMP entity bean. You can also define customer fin Appendix A that - Deploying This Book's J2EE
Index public Book_catalogLocal findByBookTitle(String bookTitle) throws javax.ejb.FinderExcep List of Figures
This List of code Tablesreturns a single reference to the Book_catalogLocal Interface object. On the other hand, the next example
List public of CodeCollection Examples findByPlatform(String bookPlatform) throws javax.ejb.FinderException, List of Sidebars
Theselectmethods are similar to findmethods, but they have several distinct features. The selectmethods are in th implementation class. They also should be declared as abstract methods. For example: public abstract String ejbSelectBookTitle(String bookTitle) throws FinderException;
This selectmethod can return the value of a single CMP field or a collection of CMP fields. Several features distinguish
Theselectmethods are not limited to the CMP fields of any specific entity bean; they can query across multiple ent
Theselectmethods execute in the transaction context of the business or callback method that invoked them, and t
Theselectmethods are private methods that can be used only inside the CMP entity bean and should never be exp
Using EJB Query Language
The EJB Query Language (EJB QL) is designed to abstract the data processing language from the relational database s now mandatory to use in implementation of the findermethods (you will see some examples of using EJB QL in the de
A QJB QL statement can consist of three clauses: the SELECTclause, the FROMclause, and the optional WHEREclause. T SELECT OBJECT(o) FROM Book_catalog AS o
In this code, the FROMclause defines that the Book_catalogtype will be processed. The identifier variable olocated afte (the Book_catalogentity bean, in this case). The OBJECToperator indicates that the single-entity bean is returned. The SELECT o.bookCatalog.bookTitle FROM Book_catalog AS o
If the CMP or container relationship fields have a complex structure, the field at the path end can be as follows: WebSphere Studio Application Developer 5.0: Practical
SELECT o.bookCatalog.bookNumber FROM Book_catalog AS o J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
In addition, for the CRM field, the path can lead to a specific CMP field within another entity bean. For example: SELECT o.bookCatalog.bookActivity.txnDate Book_catalog AS o This book provides a practical, step-by-stepFROM approach in teaching how to use the WebSphere Studio Application
The path must always end with the tool single (not a collection type). It is also illegal to navigate across the collection of Developer (WSAD) fortype developing J2EE distributed applications. SELECT o.autors.author FROM Book_catalog AS o Table of Contents
To return an element in the collection, you should use the INoperator. For example in the following::
WebSphere Studio Application Developer 5.0: Practical J2EE Development
SELECT Object(a) FROM Book_catalog AS o, IN(o.authors) AS a
Introduction
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
This statement returns all author fields in the authorscollection. You can use the DISTINCTkeyword to ensure that the
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
SELECT DISINCT Object(a) FROM Book_catalog AS o, IN(o.authors) AS a
Chapter 3 the - WHERE Working with the WSAD 5.0 Workbench You use clause to express some search condition that limits the returned results: Chapter 4 - Developing Database Applications
SELECT OBJECT(o) FROM Book_catalog AS o WHERE o.catalogNumber = "00005"
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 - J2EE Development The following is another example of the WHEREclause: Chapter 6 - J2EE EJB Development
SELECT Object(o) FROM Book_catalog AS o, IN(o.authors) AS a WHERE a.authorSalary > 5000
Chapter 7
- J2EE Web Development
Chapter 8 - J2EE XML Development Thea.authorSalary construct will iterate over all the values of the collection authors, selecting those with the indica Part Three - Working with Enterprise Messaging
Instead9of literals, you can use input parameters of the corresponding ejbSelectstatement. Say you have the following Chapter - J2EE Enterprise Messaging Chapter Public 10 abstract - Using the String WSAD-Embedded ejbSelectByBookTitleAuthor(String JMS Provider bookTitle, String bookAuthor)
Throws o.bookLocation FROM Book_catalog AS o WHERE c.bookTitle Chapter 11 FinderException; - Using WebSphere MQSELECT as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
The?1prefix indicates the first parameter, and ?2indicates the second parameter.
Index
List of let's Figures Now discuss how to set the findandselectmethods in WSAD 5.0. Say you want to set a findermethod called f List of Tables Interface) to open the module in the Java Editor View. Second, you add the findermethod (see Figure 5-5). List of Code Examples List of Sidebars
Figure 5-5: Creating a new filter in a chain
Next, you open the EJB project's Deployment Descriptor. In the J2EE Perspective, you right-click the EJB project and se that appears, check Existingand specify whether this is a findmethod or ejbSelectmethod (see Figure 5-6).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Figure 5-6: Creating a findermethod
Chapter 5
- J2EE Development
Chapter 6 - On J2EE Development Click Next. theEJB next screen, you select the type of query that most closely matches the query you want to create. Thi Chapter 7 - J2EE Web Development Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 5-7: Building the EJB QL query
Alternatively, you can indicate that the method is new on the screen depicted in Figure 5-6. Specify the method signature EJB QL language in the Chapter 6 development examples. Chapter 9 covers the new type of EJB 2.0 bean, the MDB.)
Understanding the Web Tier of the J2EE 1.3 Application
Two main blocks of any Web tier J2EE application are servlets and JSP. In contrast with the EJB 2.0 major changes, the
Understanding Filters
The servlet 2.3 specification introduced filters that are based on the old 'servlet chaining' concept. Filters are preprocess
Filters allow decoupling of some processing logic from the servlet, making it declarative. That has to do with the way filte
the filter activation.
WebSphere Studio Application Developer 5.0: Practical
J2EE Development Listing 5-8. Fragment of the Deployment Descriptor by Igor Livshin
ISBN:1590591208
Apress © 2003 (630 pages) This book provides a practical, step-by-step approach in MyFilter teaching how to use the WebSphere Studio Application MyFilter Developer (WSAD) tool for developing J2EE distributed applications. MyFilterClass Table of Contents MyFilter WebSphere Studio Application Developer 5.0: Practical J2EE Development MyFilter Introduction *.html Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1 - Introducing WSAD 5.0 Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter The 4 - Developing Database sectionApplications of each particular filter controls filter activation. In this example, the Web container is in Part filterTwo init - Working method where with J2EE: the filter The Distributed initializationApplication is done. Each Framework filter implements
Chapter 5
the javax.servlet.Filterinterface th
- J2EE Development
Listing65-9. The javax.servlet.Filter Filter Interface Chapter - J2EE EJB Development Chapter 7 - J2EE Web Development void setFilterConfig(FilterConfig config); Chapter FilterConfig 8 - J2EE XML getFilterConfig(); Development Part Public Three -void Working doFilter with Enterprise (ServletRequest Messaging
request,
response, Chapter ServletResponse 9 - J2EE Enterprise Messaging chain) Chapter FilterChain 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
The container calls the initandsetFilterConfigmethods only once to initialize the filter environment. The FilterC filter is being taken out of service. Next, the container invokes the doFiltermethod, which is similar to the servlet's ser
Index
List of Figures
Public void doFilter (ServletRequest request, List of Tables ServletResponse response, List of Code Examples FilterChain chain) Throws IOException, ServletException
List of Sidebars
{ }
TheFilterChainparameter passed to the doFiltermethod allows the servlet to instruct the container to invoke the n Chain.doFilter(request, response); How does the container know the next filter in the chain? It gets the information from the Deployment Descriptor. Listing Listing 5-10. Fragment of the Deployment Descriptor with the Filter Chain Definition MyFilter1 MyFilter1 /book/catalog MyFilter2 MyFilter2 /book/catalog
For every request starting from /book/catalog,a chain that consists of two filters (MyFilter1andMyFilter2) is de
processing flow executes all filters in the chain and then passes control to the original resource that has been requested WebSphere Studio Application Developer 5.0: Practical executed before the resource, it typically works with the request data. On the way back after the resource finished proces J2EE Development
ISBN:1590591208 byused Igor Livshin Filters are typically to validate HTTP requests, modify Request andResponseobjects before or after servlet and JS
Apress © 2003 (630 pages)
Listing 5-11. Logging Filter Code aExample This book provides practical, step-by-step approach in teaching how to use the WebSphere Studio Application
import javax.servlet.Filter; Developer (WSAD) tool for developing J2EE distributed import javax.servlet.FilterConfig; applications. import javax.servlet.FilterChain; Table of Contents public class LogFilter implements Filter WebSphere Studio Application Developer 5.0: Practical J2EE Development { Introduction FilterConfig config;
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 public void setFilterConfig(FilterConfig config)
Chapter { 1
- Introducing WSAD 5.0
Chapter 2
-this.config Setting Up the Development = config;Environment
Chapter}3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
public FilterConfig getFilterConfig() Part Two - Working with J2EE: The Distributed Application Framework { 5 Chapter
- J2EE Development
Chapter 6
-return J2EE EJBconfig; Development
Chapter}7
- J2EE Web Development
Chapter 8
- J2EE XML Development
public void doFilter(ServletRequest req, ServletResponse res, Chapter 9 - J2EE Enterprise Messaging FilterChain chain) { Chapter 10 - Using the WSAD-Embedded JMS Provider ServletContext context = getFilterConfig().getServletContext(); Chapter 11 - Using WebSphere MQ as the JMS Provider long bef = System.currentTimeMillis(); Appendix A - Deploying This Book's J2EE Examples chain.doFilter(req, res); // no chain parameter needed here Index long aft = System.currentTimeMillis(); List of Figures context.log("Request to " + req.getRequestURI() List of Tables + ": " + (aft-bef)); List of Code Examples } List of Sidebars } Part Three - Working with Enterprise Messaging
This filter shows how long it takes to process a request. Let's see how to control filter processing flow in WSAD 5.0. Swit MyFilterin the Filter Name field (see Figure 5-8).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter Figure 7 - 5-8: J2EECreating Web Development a new filter in a chain Chapter 8
- J2EE XML Development
Chapter 9
- J2EE Enterprise Messaging
Click Next. On the next youMessaging can add the Part Three - Working withscreen, Enterprise
initparameters and set the servlet mapping. Click the Addbutton atta
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 5-9: Servlet mapping
Select the servlet. This creates the entry in the Deployment Descriptor, controlling when this filter c click the Addbutton and add the next filter to the chain.
Understanding HTTP Session Event Listeners
Another new feature that has been introduced by the servlet 2.3 specification is session event listening. A listener is an ob The following sections discuss the interfaces provided for processing session events.
Using the HTTPSessionListener Interface WebSphere Studio Application Developer 5.0: Practical J2EE Development
This interface tracks when a new session is created or an existing session is destroyed. It provides the following methods by Igor Livshin
ISBN:1590591208
public void sessionCreated (HttpSeeionEvent event); public void sessionDestroyed (HttpS Apress © 2003 (630 pages)
This book provides a practical, step-by-step approach in TheHttpSessionEvent class passed as a parameter to those methods has only one getSessionmethod that return
teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed A class that implements this interface should include the previous respective methods that will be called by the container applications.
MySessionListenerClass
Table of Contents
WebSphere Application that Developer Practical J2EE Development You can doStudio any processing needs5.0: to be done before the session is created or destroyed within the sessionCreate Introduction
Using the HTTPSessionActivationListener Interface
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
This interface tracksUp session passivationEnvironment and activation. It provides the following methods: Chapter 2 - Setting the Development
public sessionDidActivate (HttpSeeionEvent event); public void sessionWillPassivat Chapter 3 void - Working with the WSAD 5.0 Workbench Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
A class that implements this interface should include the previous respective methods that will be called by the container - J2EE Development from one server to another. The methods of this interface give an application the chance to persist non-serializable data
Chapter 5 Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development Using the HTTPSessionBindingListener Interface
Chapter 8
- J2EE XML Development
Part - Working with Messaging ThisThree interface notifies an Enterprise object when it is being placed
into a session or removed from the session. It provides the follow
Chapter 9 void - J2EEvalueBound(HttpSessionBindingEvent Enterprise Messaging public event); public void valueUnbound(HttpSes Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter When an 11 attribute - Using implements WebSphere MQ thisasinterface, the JMS Provider it will be notified when it is added to the session object or removed from the Appendix A - Deploying This Book's J2EE Examples
Using Index
the HTTPSessionAttributeListener Interface
List of Figures
This interface is similar to the HTTPSessionBindingListenerinterface except that it is intended for any object that ca
List of Tables
public attributeAdded(HttpSessionBindingEvent event); public void attributeRemoved List of Codevoid Examples List of Sidebars
The last method is called when one attribute replaces another attribute in a session. The HttpSessionBindingEvent
Listing 5-12 shows an example of a session listener that puts a database connection in the servlet context, making it ava Listing 5-12. Fragment of the Listener Code public class MyConnection implements ServletContextListener { public void contextInitialized(ServletContextEvent e) { Connection con = // create connection e.getServletContext().setAttribute("con", con); } public void contextDestroyed(ServletContextEvent e) { Connection con = (Connection) e.getServletContext().getAttribute("con"); Try { con.close(); } catch (SQLException ignored) { } // close connection } }
WebSphere Studio Application Developer 5.0: Practical
J2EE Development TheMyConnection listener class must be registered in the Deployment Descriptor as a listener. The container creates a by Igor Livshin
ISBN:1590591208
Apress © 2003 (630 pages) This book provides a practical, step-by-step approach in MyListener teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Understanding ServletContext Event Listeners
Table of Contents
WebSphere The listeners Studio concept Application is alsoDeveloper applicable 5.0: to the Practical ServletContext J2EE Development events. The idea is similar to the session events. A cla Introduction events. The interface has two methods:
Part OnecontextInitialized(ServletContextEvent - Getting Started with WebSphere Studio Application Developer void event);(WSAD) void 5.0 contextDestroyed(ServletContex
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment The first is called when a Web Chapter 3 method - Working with the WSAD 5.0 application Workbench is first ready to process a request. The second method is called when
or destroyed. Chapter 4 - Developing Database Applications Part Two - Working with J2EE: The Distributed Application Framework
Understanding Character Chapter 5 - J2EE Development
Encoding
Chapter 6
- J2EE EJB Development This improvement is important for processing foreign languages that are different from Western European languages. C
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Req.setCharacterEncoding ("Shift_JIS"); // Now, read parameters in Japanese String book
Part Three - Working with Enterprise Messaging
Understanding JAR Dependence - J2EE Enterprise Messaging
Chapter 9
Chapter 10 - classes Using the JMS Application areWSAD-Embedded loaded at runtime byProvider the JVM classloaders. Classloaders impact the visibility of classes. Each se Chapter 11 Using WebSphere MQ as the JMS Provider not fully standardize how application components could share common code. That left a lot of flexibility to J2EE vendors Appendix A - Deploying This Book's J2EE Examples
After the EJB 2.0 specification, class visibility (and the associated issue of classloaders) has finally been standardized. A Index classloader. List of Figures List of Tables
Each Web module gets its own classloader, and all Web classloaders are children of the EJB classloader. This makes a directory are locally visible to all classes of this Web application.
List of Code Examples List of Sidebars
To place a JAR file in the WEB-INF/libdirectory, right-click the Web project in the J2EE Perspective and select Prope INF/libfolder (see Figure 5-10).
Figure 5-10: Including a JAR file in the WEB-INF/libfolder
Click OK. On the same dialog, Studio you canApplication specify other projects in5.0: the Practical Workbench that this Web application needs to access WebSphere Developer J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Figure other projects on the Workbench from the Web project Chapter 8 - 5-11: J2EE Accessing XML Development Part Three - Working with Enterprise Messaging
Chapter 9
J2EE Enterprise Messaging To specify -other projects referenced by the EJB project, right-click the EJB project and click the Project References
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 5-12: Accessing other projects on the Workbench from the EJB project
Still, the biggest issue before the EJB 2.0 specification was how to share JAR files located on the application level betwe dependencies.
To do this in WSAD 5.0, right-click the EJB project and select Open With JAR Dependency Editor. The screen th
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Figure 5-13: Specifying dependent JAR files for the Web project Table Contents Use of similar steps to specify dependent JAR files for the EJB projects (see Figure 5-14). WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Figure 5-14: Specifying dependent JAR files for the EJB project
Chapter - J2EE XML Development Another8 way of setting JAR-dependent files is right-clicking the Web or EJB project and selecting Attributes. On the Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 5-15: Setting JAR dependencies
This allows all components inside an application to share this JAR file (instead of including it multiple times in the individu
Understanding Classloaders
This section discusses how classloaders work in the WSAD 5.0/WAS 5.0 environments. In the J2EE 1.3 specification, cla in the CLASSPATH environment variable. On the next level is the WebSphere-specific classloader. It is responsible for lo
The application classloader is located on the next level and is a child of the WebSphere-specific classloader. The EJB c below the EJB class loader and are children of the EJB classloader. The Web classloader searches for classes to be lo
The classloader hierarchy is set in a parent-child relationship. Children classloaders can delegate a search for classes to haveDelegation Mode turnedONor OFF.
Java system classloader and WebSphere-specific classloaders have Delegation Mode turnedON. The rest of the cla Developer 5.0: Practical any new classes WebSphere that this triesStudio to loadApplication will reuse the same classloader. J2EE Development
ISBN:1590591208 by Igor Livshin For each application server, you can set the application classloader policy:
Apress © 2003 (630 pages)
SINGLEor MULTIPLE. Thisprovides setting controls thestep-by-step application isolation When the SINGLEpolicy is selected, a single a This book a practical, approachlevel. in teaching to use WebSphere Studio Application its own classloader, whichhow is used forthe loading that application's EJB modules, dependency JAR files, and shared librarie Developer (WSAD) tool for developing J2EE distributed
To set this policy applications. in WSAD 5.0, double-click the server configuration to open it in the Editor View. Then, click the Config Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework Figure 5-16: Setting policies
Chapter 5
- J2EE Development When the module policy is set to APPLICATION, the application classloader will be loading the Web module class Chapter 6 Web - J2EE EJB Development
settings: andPARENT_LAST. Chapter 7 PARENT_FIRST - J2EE Web Development Chapter 8
- J2EE XML Development
PARENT_FIRSTcauses the classloader to delegate the loading of classes to its parent classloaders before attempting to
Part Three - Working with Enterprise Messaging
Chapter 9 - J2EE Enterprise Messaging to attempt loading classes from its local CLASSPATH before delegating the class PARENT_LAST causes the classloader Chapter 10 Using the WSAD-Embedded JMSThen, Provider it in the Editor View (if it is not opened yet). click the Applicationtab. You should see the section that allows you Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 5-17: Setting the classloader policy and WAR classloader mode
In addition, the servlet 2.3 specification requires that the application classloaders and classloaders used by the server co classes of the same packages but of different versions caused conflict at runtime.
Understanding the WSAD Development and Runtime Environments
WSAD has two environments: development and runtime. During development, you need to make sure that the WSAD to
On the screen that appears, select Java Build Path. There are four tabs at the top of the screen. The Sourcetab d The Libraries tab displays a page that allows you to include additional libraries in the Build Path. You can includ displays the page that allows you to control the order of library in the Build Path (see Figure 5-18).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two Figure - Working 5-18: Setting with J2EE: the The development Distributed environment Application Framework
Chapter 5
- J2EE Development
TheBuild- Path constructed here is used by the WSAD development environment only and is completely meaningles J2EE EJB Development
Chapter 6
Chapter 7 -a J2EE Web Development Therefore, separate setting is required for the runtime environment. You set this on the server configuration. Switch to Chapter 8 - J2EE XML Development Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 5-19: Setting the runtime environment
This screen allows you to add JAR libraries to the Java standard CLASSPATH and/or the WebSphere CLASSPATH. Yo Web module requires in the WEB-INF/libdirectory or include them in the EJB JAR file for the EJB module. If the JAR
Processing Errors Servlets 2.2 introduced three request attributes that facilitate the creation of error pages:
javax.servlet.error.status_code (an integer telling the error status code) javax.servle
Still, you are missing two valuable parts of information: the exception stack trace and the Uniform Resource Identifier (UR
javax.servlet.error.exception (a throwable object thrown by exception) javax.servlet.er
Now the error page servlet can display all necessary data on the error page. Listing 5-13 shows the fragment of the erro Listing 5-13. Error Page Servlet Source Code
import java.io.*; WebSphere Studio Application Developer 5.0: Practical import javax.servlet.*; J2EE Development import javax.servlet.http.*; by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
public class ErrorPageServlet extends HttpServlet This book provides a practical, step-by-step approach in { teaching how to use the WebSphere Studio Application public void doGet(HttpServletRequest req, HttpServletResponse res) Developer (WSAD) tool for developing J2EE distributed throws ServletException, IOException applications. { res.setContentType("text/html"); Table of Contents PrintWriter out = res.getWriter(); WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction String errorCode = null, errorMessage = null, exceptionType = null, Part OnerequestURI - Getting Started WebSphere Studio Application Developer (WSAD) 5.0 = with null;
Chapter 1 Chapter 2
-Object Introducing WSAD 5.0 statusCodeObj, errorMessageObj, exceptionTypeObj; -Throwable Setting Up the errorException; Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
Retrieve the three possible error attributes, some may be null -// Developing Database Applications
statusCode = The req.getAttribute("javax.servlet.error.status_code"); Part Two - Working with J2EE: Distributed Application Framework Chapter 5
= req.getAttribute("javax.servlet.error.message"); -errorMessage J2EE Development
Chapter 6
= req.getAttribute("javax.servlet.error.exception_type"); -exceptionType J2EE EJB Development
= (Throwable) -errorException J2EE Web Development req.getAttribute("javax.servlet.error.exception"); Chapter 8 - J2EE XML Development requestURI = (String) req.getAttribute("javax.servlet.error.request_uri"); Part Three - Working with Enterprise Messaging Chapter 7
Chapter 9
- J2EE Enterprise Messaging
if (uri == null) { uri = req.getRequestURI(); // in case there's no URI given Chapter 11 - Using WebSphere MQ as the JMS Provider } Appendix A - Deploying This Book's J2EE Examples // Convert the attributes to string values Index if (statusCodeObj != null) statusCode = statusCodeObj.toString(); List of Figures if (errorMessageObj != null) errorMessage = errorMessageObj.toString(); List of Tablesif (exceptionTypeObj != null) exceptionType = exceptionTypeObj.toString(); Chapter 10 - Using the WSAD-Embedded JMS Provider
List of Code Examples List of Sidebars // The error reason is either the status code or exception type
String errorReason = (statusCode != null ? statusCode : exceptionType); out.println(""); out.println("" + reason + ": " + errorMessage + ""); out.println(""); out.println("" + erroReason + ""); out.println("" + errorMessage + ""); out.println(""); if (erroException != null) { errorException.printStackTrace(out); } out.println(""); out.println(""); out.println("Error accessing " + requestURI + ""); out.println(""); } }
Of course, the servlet must be registered as the application error page in the Deployment Descriptor:
WebSphere Studio Application Developer 5.0: Practical J2EE Development ISBN:1590591208 by Igor Livshin Apress © 2003 (630 pages) javax.servlet.ServletException This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed /servlet/ErrorPageServlet applications. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development
Of course, the servlet must be registered as the application error page in the Deployment Descriptor:
Introduction
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1 - Introducing WSAD 5.0 javax.servlet.ServletException Chapter 2 - Setting Up the Development Environment - Working with the WSAD 5.0 Workbench /servlet/ErrorPageServlet
Chapter 3 Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter - J2EE Follow 5these stepsDevelopment to set up this servlet as an exception processing servlet in WSAD 5.0: In the J2EE Perspective, right-c Chapter 6 J2EE EJB Development javax.servlet.ServletException in the Exception Type field. Enter your ErrorPageServletservlet in the Chapter 7
- J2EE Web Development
The remaining sections discuss several EJB and Web development topics that are not new in the J2EE 1.3 specification Chapter 8 - J2EE XML Development Part Three - Working with Enterprise Messaging
Understanding XForms Chapter 9 - J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
Starting from release 5.0, WSAD supports Extensible Hypertext Markup Language (XHTML). Currently, this new technol for XForms-the next-generation HTML-like language for developing Web pages. XForms uses an Extensible Markup Lan
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
Index It has been announced that the XHTML 2.0 specification will introduce XForms. For more information about XForms, ple List of Figures
Creating List of Tables
a Frameset
List of Code Examples
Framesets allow you to present complex multiple screens in a form convenient to the user. In this section, you will build a FrameProjectWEBthat is part of the new application project FrameProjectApp(see Figure 5-20).
List of Sidebars
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7 - 5-20: J2EE Setting Web Development Figure up a new Web project Chapter 8 - J2EE XML Development
Click Next. On the next enterMessaging the new application Part Three - Working withpage, Enterprise Chapter 9
project name as FrameProjectApp(see Figure 5-21).
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 5-21: Setting up a new application project
Click Finish. WSAD will create two new projects (FrameProjectWEBandFrameProjectApp). Next, you will create a
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Figure 5-22: Building a new HTML page
Chapter 8 - J2EE XML will Development Click Finish. WSAD create a new HTML page called index.htmland open it in the Page Editor View. Next, you c Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 5-23: Building a new folder
Click Finish. The index.htmlfile opens in the Page Editor View. Make sure you are on the Designpage. Remove the index.htmlwill be the file that contains the frameset instead of becoming a file called into a frameset (see Figure 5-24
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Figure 5-24: Building a new folder
Chapter 1
- Introducing WSAD 5.0
Chapter 2 You - Setting Development Environment Click OK. will seeUpa the vertical bar splitting your frameset in two vertical frames. Save the results. WSAD created two pla Chapter 3 appear. - Working with the WSAD 5.0 Workbenchname with main.html.Click OK. dialog will Replace the newpage2.html Chapter 4
- Developing Database Applications
Move the- Working vertical bar toJ2EE: the left soDistributed that your screen will look like the Part Two with The Application Framework Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
screen depicted in Figure 5-25.
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures
Figure 5-25: The frameset
List of Tables
List Click of Code the Links Examples tab. You should see the structure of the frame (see Figure 5-26). List of Sidebars
Figure 5-26: The structure of the frameset
You can find a ready-made HTML file to be displayed in the frameset in the Downloads section of the Apress Web site (h and click Next. On the next screen, click Browseand navigate to the c:\Tempdirectory. Click the Select All button
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8 - 5-27: J2EE The XML copied Development Figure files displayed in the frameset Part Three - Working with Enterprise Messaging
Next, click Then, click the Previewtab. You should see the screen in Figure 5-28. Chapter 9 -Finish. J2EE Enterprise Messaging Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 5-28: The already-made frameset page Click the QQQlink in the left frame. The QQQ portfolio screen will display (see Figure 5-29).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4 - 5-29: Developing Database Applications Figure The QQQ portfolio screen Part Two - Working with J2EE: The Distributed Application Framework
Try displaying other portfolios to see how the frame layout works. This is the end of the frame-building example. Chapter 5 - J2EE Development Chapter 6
- J2EE EJB Development
Developing Thread-Safe Servlets Chapter 7 - J2EE Web Development Chapter 8
- J2EE XML Development If the servlet implements the SingleThreadModelinterface, the container operates such a servlet in one of two ways:
Part Three - Working with Enterprise Messaging
Chapter 9 - J2EE Enterprise Instance pooling: The Messaging container maintains a pool of servlet instances, and for each request, the container invokes Chapter 10 - Using the WSAD-Embedded JMS Provider
Request synchronization: a single instance of the servlet is maintained by the container, and the container sy Chapter 11 - Using WebSphere MQOnly as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
Both types of processing consume substantial server resources and should be avoided for applications with many concu multiple service requests will be executed by multiple servlet threads. The immediate concern is the class-level variables
Index
List of Figures
The List of same Tablesconsideration is applicable to the servicemethod. If there is processing inside the servicemethod that is n List of Code Examples
Another point of concern is the session object, which is also not synchronized. If there is a possibility that the same user if the user screen is built in frames. Finally, some collection objects such as VectorandSETare thread-safe and do not r
List of Sidebars
WebSphere Studio Application Developer 5.0: Practical Managing EJB Transactions J2EE Development
Igor Livshin Atransaction is anbyundivided set of tasks (called a unit of work) ISBN:1590591208 that must be successfully completed. If at least Apress © 2003 (630 pages) one task is unsuccessful, all tasks of the unit of work must be rolled back. Local transactions run under a local resource manager onbook the same machine. Global Java Transaction This provides a practical, step-by-step approachAPI in (JTA) or two-phase commit transactions teaching howcoordinated to use the WebSphere Studio Application involve tasks executed under efforts of different transaction managers, and these tasks typically span Developer (WSAD) fortransaction developingisJ2EE distributed multiple machines. An example of atool JTA accessing multiple databases or a combination of a applications. database and a messaging system.
EJB components can manage the transaction context themselves (beanmanaged transactions) or delegate this responsibility to the container (container-managed transactions):
Table of Contents
WebSphere Studio Application Developer 5.0: Practical J2EE Development
Introduction Session beans can use either container-managed transactions or beanmanaged transactions. Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Entity use container-managed transactions. Chapter 1 beans - Introducing WSAD 5.0 Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Web components (servlets) use bean-managed transactions.
Chapter 4 - Developing Database Applications Container-managed transactions are controlled by the container and are the easiest way to execute applications Part Two Working with J2EE: The DistributeditApplication within a -transactional context. Furthermore, is suitable Framework in most cases.
CMP and BMP entity beans must use
Chapter 5 - J2EE Development container-managed transactions. WSAD and WAS support the following six types of EJB transactions: Chapter 6 - J2EE EJB Development
Required: transaction is required to run the application. If a client invokes a bean method in a transaction Chapter 7 -The J2EE Web Development context,8 that context is Development passed to the bean. If a nontransactional client invokes a bean method, a new transaction Chapter - J2EE XML context is -created bywith the Enterprise EJB container and committed Part Three Working Messaging Chapter 9
before the method returns.
- J2EE Enterprise Messaging
Mandatory: If a nontransactional client invokes the bean method, the container throws the
Chapter 10 - Using the WSAD-Embeddedexception. JMS Provider java.jtx.TransactionRequired
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix Supports: A -The Deploying client runs This within Book'saJ2EE transactional Examples context, it is passed to the bean. It is okay if the client is not part of
the transaction. Index List of Figures
RequiresNew: A new transaction will always be created by the container. If a client runs within a transaction, it is suspended and later renewed.
List of Tables
List of Code Examples
List of Sidebars NotSupported: If a client that invokes a method bean has a transaction context, the transaction will be suspended
and resumed after the method execution. Never: If the client calls a bean method from within a transaction context, the container throws the java.rmi.RemoteExceptionexception. If the client calls a bean method from outside a transaction context, the container behaves in the same way as if the Not Supported transaction attribute was set. The client must call the method without a transaction context. To set the transaction type, right-click your EJB project and select Open With Deployment Descriptor Editor. Click the Assembly Descriptor tab. In the “Container Transaction” section, click the Addbutton. On the screen that appears, select one or more EJB bean to set its transaction properties (see Figure 5-30).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 - 5-30: J2EE Setting Development Figure transaction properties for EJB beans Chapter 6 - J2EE EJB Development
Click Next. theWeb nextDevelopment screen, select the type of transaction in the Container transaction type field and Chapter 7 - On J2EE the corresponding methods of the selected EJB beans that should be assigned this transaction type (see Figure 5Chapter 8 - J2EE XML Development 31).Three - Working with Enterprise Messaging Part Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 5-31: Setting transaction properties for EJB bean methods Click Finish. Repeat the same steps until you have assigned all methods their transaction types. Note You can assign a selected transaction type to all bean methods by selecting the asterisk (*) from the list of bean methods. Session beans can manage themselves in their transaction context. The stateless session bean can control the transaction for one method only, where the stateful session beans can reuse the transaction context across the methods. In addition, the bean-managed transaction type can be set for the entire class and not for individual methods. To enable a session bean (or servlets) to use the beanmanaged transaction, you complete the following 1.
two steps:
WebSphere Studio Application Developer 5.0: Practical
1. You use the Application Assembly tool and set the Transaction Type attribute to Bean(instead of J2EE Development Container). ISBN:1590591208 by Igor Livshin Apress © 2003 (630 pages)
2. You write code that uses the javax.transaction.UserTransactionobject to explicitly control the This book provides a practical, step-by-step approach in transactionteaching demarcation boundaries. Listing 5-14 shows the code snippet. how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed
Listing 5-14. Code of the Bean-Managed Session Bean applications.
... import javax.transaction.*; Table of Contents ... WebSphere Studio Application Developer 5.0: Practical J2EE Development public class BeanManagedSessionBean implements SessionBean Introduction { Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 private SessionContext sessionContext = null; Chapter 1 - Introducing WSAD 5.0 ... Chapter 2 - void SettingsetSessionContext Up the Development Environment public (SessionContext ctx)throws EJBException Chapter { 3 - Working with the WSAD 5.0 Workbench Chapter 4 sessionContext - Developing Database Applications = ctx; Part Two } - Working with J2EE: The Distributed Application Framework Chapter... 5 - J2EE Development Chapterpublic 6 - J2EE EJB Development void processTransaction(int arg1) Chapter 7 -throws J2EE Web FinderException,EJBException Development { Chapter 8 - J2EE XML Development UserTransaction userTran = (UserTransaction)initCtx.lookup( Part Three - Working with Enterprise Messaging "java:comp/UserTransaction"); Chapter 9 - J2EE Enterprise Messaging bounderies Chapter // 10 -Manage Using thetransaction WSAD-Embedded JMS Provider userTran.begin (); Chapter 11 - Using WebSphere MQ as the JMS Provider AppendixcreditCardObject.ProcessPayment(payment1); A - Deploying This Book's J2EE Examples creditCardObject.ProcessPayment(payment2); Index userTran.commit (); List of Figures ... List of Tables } List of Code Examples ... List of Sidebars }
Notice that you get the UserTransactionobject by using the JNDI lookupmethod.
Using the Entity Bean Commit Option The entity bean’s Commit Option determines how the state data is loaded to the database or stored in state variables. This option also controls how entity beans are loaded and removed from the cache. Commit Option has a substantial entity bean performance implication and should be carefully considered. The following sections describe the types of Commit Option that entity beans can have.
Understanding the Cached Bean Option This option requires that an entity bean instance have exclusive access to its data. When the transaction commits, data is written to the database (in other words, ejbStoreis called). Because the instance has exclusive access to data, the instance data does not need to be reloaded (in other words, there is no ejbLoadcall) at the beginning of the next transaction. Concurrent client requests for the same data are queued by the container. No other applications can access the data. Concurrency is reduced, but the overall performance improves. This option could be quite dangerous, however. Imagine that at the beginning, there was only one application accessing the data, and this option was set. Several years later, another application is developed that accesses the same data. If at that time no one pays attention that this option was set originally, data integrity will be compromised.
Understanding the Stale Bean Option Developer 5.0: Practical WebSphere Studio Application J2EE Development
It is assumed thatbynoIgor single application has exclusive access toISBN:1590591208 data. When the transaction commits, the Livshin ejbStoremethod is called. Because there is no exclusive access to data, the ejbLoadmethod is called at the Apress © 2003 (630 pages) beginning of the next transaction. In the case of concurrent requests, the container assigns a different instance of This book provides a practical, step-by-step approach in the entity bean forteaching the second transaction. Concurrency is better in this situation than with the previous option, but how to use the WebSphere Studio Application more resources are consumed (thetool extra call anddistributed extra instance of the entity bean in memory). Developer (WSAD) forejbLoad developing J2EE applications.
Understanding the Polled Bean Option Table of Contents No exclusive access to data is assumed here (which is the same as in the previous option). When a transaction WebSphere Studio Application Developer 5.0:and Practical J2EEisDevelopment commits, the ejbStore method is called the data written to the database. The entity bean instance does Introduction not stay active in memory but is returned to the pool of instances. The ejbLoadmethod is called at the beginning Part of each One -transaction, Getting Started so both withthe WebSphere ejbLoadStudio andejbStore Application methods Developer are called (WSAD) during 5.0
the life cycle of a
Chapter transaction. 1 - Introducing WSAD 5.0 Chapter 2
- Setting Up the Development Environment
In addition, the ejbActivateis called at the beginning of each transaction, and the ejbPassivatemethod is - Working with the WSAD 5.0 Workbench called at the end of each transaction. Both ejbActivateandejbPassivateare expensive calls depending Chapter 4 - Developing Database Applications on the location where they are stored. This option has a potential for less memory usage (in the previous option, Part Two - Working with J2EE: The Distributed Application Framework entity bean instances remain active in memory after the end of the transaction but are still associated with the Chapter 5 - J2EE Development same client). Chapter 3
Chapter 6
- J2EE EJB Development
Chapter 7 - client J2EE Web Development If the same makes another call, it will reuse the same entity instance. However, a call for the same entity Chapter 8 another - J2EE XML Development data from client will be performed by a new instance of the entity bean. After a transaction is committed, Part - Working with Enterprise Messaging the Three instance of the entity bean is removed from
memory as a result of a timeout. Therefore, with a high level of
Chapter concurrency, 9 - J2EE the stale Enterprise bean Messaging option could easily consume all available memory. Chapter 10 - Using the WSAD-Embedded JMS Provider
In contrast with the stale bean option, the polled bean option reduces the memory usage because an instance of entity bean is immediately removed from memory at the end of each transaction. For the stale bean and polled Appendix A - Deploying This Book's J2EE Examples bean options, WSAD performs no database locking and no transaction serialization. Instead, each transaction Index creates its own copy of entity bean instance. The underlying database handles all locking. Chapter 11 - Using WebSphere MQ as the JMS Provider
List of Figures
List Tables To of summarize, the cached bean option provides the best performance and resource utilization, but it can be used List of when Code Examples only exclusive access to data from one application is guaranteed. The stale bean option is better than the List polled of Sidebars bean option when there is a relatively low level of concurrent processing. The polled bean option is better
than the stale bean option when there is a high level of concurrency. In addition, it is desirable for the entity bean to be loaded from the fast storage. To specify the Commit Option, right-click your EJB project and select Open With Deployment Descriptor Editor. Click the Beanstab. Select the EJB bean and find the “Bean Cache” section. The Activate at field specifies the point at which the bean is activated and placed in the cache. Oncemeans that the bean is activated when it is first accessed and is passivated at the container discretion. Transactionmeans that the bean is activated at the start of a transaction and passivated (removed from the cache) at the end of the transaction. ACTIVITY_SESSIONis bound to the session activity. TheLoad At field specifies when the state is loaded from the database. Activatemeans that the state is loaded at the beginning of transaction and implies exclusive access to data. Transactionmeans that the state is loaded at the start of the transaction, and it implies shared access to data. In addition, the Enable optimistic locking box controls the selection of pessimistic or optimistic locking. Table 5-1 shows how to set the entity bean Commit Option. Table 5-1: Transaction Isolation Level
OPTION
WebSphere Studio ACTIVATE Application ATDeveloper FIELD 5.0: Practical LOAD AT FIELD J2EE Development
Cached bean by Igor Livshin Stale bean
Once
ISBN:1590591208Activation
Apress © 2003 (630 pages) Once
Transaction
This book provides a practical, step-by-step approach in Polled bean Transaction teaching how to useTransaction the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications. Figure 5-32 shows an example of setting Commit Option to the polled bean option for the Book_catalog
entity bean. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - 5-32: UsingSetting WebSphere MQ as the JMS Provider Figure Commit Option Appendix A - Deploying This Book's J2EE Examples
On the Beanspage of the Deployment Descriptor, the “Local Transaction 2.0” section provides an IBM extension Index to the standard J2EE Deployment Descriptor that allows you to control certain local transaction properties (see List of Figures Figure 5-33). List of Tables List of Code Examples List of Sidebars
Figure 5-33: The “Local Transaction 2.0” section The following are additional properties that you can set to control the transaction context: TheBoundaryfield determines the duration of a local transaction context. When this field is set to ActivitySession, then the local transaction must be resolved within the scope of any ActivitySession in which it was started. If no ActivitySessioncontext is present, then it must be resolved within the same bean method in which it was started. When the field is set to BeanMethod, then the local transaction begins when the method begins and ends when the method ends. This is the default. TheResolverfield specifies how the local transaction is to be resolved before the local transaction context ends: by the application through user code or by the EJB container. The ContainerAtBoundaryoption means that the container takes responsibility for resolving each local transaction. The user code does not have to handle local transactions. The Applicationoption means that the user code must either commit or roll back the local transaction. If this does not occur, the runtime environment logs a warning and automatically commits or rolls back the connection as specified by the Unresolver action setting.
TheUnresolver action field specifies the action that the EJB container must take if resources are Studio Developer Practical uncommittedWebSphere by an application inApplication a local transaction. This5.0: setting is applicable only when Resolution J2EE Development controlis set to Application.
ISBN:1590591208 by Igor Livshin Apress © 2003 (630 pages) Rollbackis the default action. The alternative is the Commitaction. This book provides a practical, step-by-step approach in All JDBC connections, teaching how when to use firstthe obtained WebSphere through Studio a getConnection Application call, have AutoCommit = TRUE by (WSAD) tool for developing Context J2EE distributed default. If youDeveloper operate within a Local Transaction (LTC) and have its resolution-control set to applications.
Application, then AutoCommitremainsTRUEunless changed by the application.
If you operate within an LTC and have its resolution-control set to ContainerAtBoundary, then the application should not touch the AutoCommitsetting. The WAS runtime sets the AutoCommitvalue to WebSphere Studio Application Developer 5.0: Practical J2EE Development FALSEbefore work begins and then commits or rolls back the work as appropriate at the end of the LTC Introduction scope.
Table of Contents
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 using - Introducing WSAD within 5.0 a global transaction, upon first use of the connection, the database ignores When a connection Chapter the2AutoCommit - Setting Up setting the Development so that the transaction Environment service that controls the commit and rollback processing can
manage the transaction— regardless of the user changing the AutoCommitsetting. After the transaction Chapter 3 - Working with the WSAD 5.0 Workbench completes, the AutoCommit value returns to the value it had before the first use of the connection. Chapter 4 - Developing Database Applications Therefore, even if the AutoCommit valueApplication is set to TRUE before the Part Two - Working with J2EE: The Distributed Framework
connection is used in a global
transaction, need not set the value to FALSEbecause the database ignores the value. In this example, Chapter 5 - J2EEyou Development after transaction completes, the AutoCommitvalue of the connection returns to TRUE. Chapter 6 the - J2EE EJB Development Chapter 7
- J2EE Web Development
Chapter 9
- J2EE Enterprise Messaging
If you use multiple distinct connections within a global transaction, all work is guaranteed to commit or roll back Chapter 8 - J2EE XML Development together. This is not the case with the LTC scope. Within LTC, work done on one connection commits or rolls back Part Three - Working with Enterprise Messaging independently from work done on any other connection within the LTC (see Listing 5-15). Chapter - Using the the WSAD-Embedded Provider Listing10 5-15. Setting AutoCommitJMS Option for LTC Transactions Chapter 11 - Using WebSphere MQ as the JMS Provider
public void addAmount(int fromAcct, int toAcct, double amt, DataSource ds) throws CreateException, RemoteException Index { List of Figures Connection con = ds.getConnection(user, password); Appendix A - Deploying This Book's J2EE Examples
List of Tables List of Code //Examples Set autocommit to false List of Sidebars con.setAutoCommit(false);
try { --- Some database processing ---con.commit(); cin.close(); } catch(Exception e) { con.rollback(); } }
Listing 5-16 shows a code fragment for the JTA transaction. Listing 5-16. Setting the AutoCommitOption for JTA Transactions public void addAmount(int fromAcct, int toAcct, double amt) throws CreateException, RemoteException { ----- Some code here ----UserTransaction userTran = (UserTransaction) ejbContext.getUserTransaction();
try WebSphere Studio Application Developer 5.0: Practical { J2EE Development userTran.begin(); ISBN:1590591208 by Igor Livshin ------ processing ---Apress © 2003 (630 pages) userTran.commit(); This book provides a practical, step-by-step approach in } teaching how to use the WebSphere Studio Application catch(Exception e) (WSAD) tool for developing J2EE distributed Developer { applications. userTran.rollback(); } Table } of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One Another - Getting IBM Started extension with to WebSphere the standardStudio J2EEApplication Deployment Developer Descriptor (WSAD) is the 5.0 Lifetime
in cache option.
Chapter This 1 value - Introducing is set in seconds WSAD 5.0 and indicates how long the cached data is to exist beyond the end of the
transaction in which theDevelopment data was retrieved. This might avoid another retrieval from persistent storage if the Chapter 2 - Setting Up the Environment same instance to be 5.0 used in later transactions. If your application uses CMP beans in which the Chapter 3 bean - Working withwere the WSAD Workbench underlying data changes infrequently, you might gain significantly better performance by using this setting with Chapter 4 - Developing Database Applications Lifetime in cache. Part Two - Working with J2EE: The Distributed Application Framework Chapter 5
- J2EE Development
Typically, data read from persistent storage is held temporarily in an internal cache until the state of the - J2EE EJB Development instance is restored. Cached data normally does not persist beyond state restoration or the end of the Chapter 7 - J2EE Development transaction in Web which the findermethod was called. By setting Lifetime in cache usage to a value Chapter 8 than - J2EE XML Development other Off, you indicate that the cached data is to be held for a longer time, potentially hours or days, Part Three Working with Enterprise Messaging before invalidating the version of the data in the cache and fetching a new version. Avoiding a trip to persistent Chapter 9 - greatly J2EE Enterprise Messaging storage speeds up access to such beans by applications. The default value is zero. Chapter 6
Chapter 10 - Using the WSAD-Embedded JMS Provider
In addition, theWebSphere use of a value other Offrequires that findermethods on the bean have an access Chapter 11 - Using MQ as the than JMS Provider typeAof-Read, because EJB applications are not permitted to update such CMP beans. When this value is Appendix Deploying This Book's J2EE Examples Indexused, the value of Lifetime in cache is ignored. Beans of this type are cached only in a transactionList ofscoped Figurescache. The cached data for this instance expires after the transaction in which it was retrieved is
completed. When the Elapsed Time is selected, the value of Lifetime in cache is added to the time of the completed transaction (the transaction in which the bean instance was retrieved). The resulting value List of Code Examples becomes the time at which the cached data expires. The value of Lifetime in cache can add up to List of Sidebars minutes, hours, days, and so on. List of Tables
When the value Clock Time is selected, the value of Lifetime in cache represents a particular time of day. The value is added to the immediately preceding or following midnight to calculate a future time, which is then treated as Elapsed Time. Using Clock Time enables you to specify that all instances of this bean type are to have their cached data invalidated at, for example, 3 A.M., no matter when they were retrieved. This is important if, for example, the data underlying this bean type is batch updated at 3 A.M. daily. The selection of midnight (preceding or following) depends on the value of Lifetime in cache. If Lifetime in cache plus the value that represents the preceding midnight is earlier than the current time, the following midnight is used. When you use Clock Time, the value of Lifetime in cache should not represent more than 24 hours. If it does, the cache manager subtracts 24-hour increments from it until it gets a value less than or equal to 24 hours. To invalidate data at midnight, set Lifetime in cache tozero. When the value Week Time is selected, the usage of this value is the same as for Clock Time, except that the value of Lifetime in cache is added to the preceding or following Sunday midnight (11:59 P.M. Saturday plus 1 minute). When Week Time is used, the value of Lifetime in cache can represent more than 24 hours but not more than seven days.
Understanding Concurrency Control and Optimistic/Pessimistic Locking TheAccess Intent section of the Deployment Descriptor (click the Accesstab) is different for EJB 1.1 and EJB 2.0 entity beans. For EJB 1.1 entity beans, you can set it to For Read Only to eliminate unnecessary load/store operations and improve the performance.
For EJB 2.0 beans, concurrency control is managed by the Pessimistic/Optimistic Access Intent. The WebSphere Studio Practicaland does not release it until the Pessimisticscheme locks the dataApplication at the earlyDeveloper stage of the5.0: transaction J2EE Development transaction is closed. The Optimisticscheme locks the data immediately before a read operation and ISBN:1590591208 by Igor Livshin releases it immediately afterward. Update locks are obtained immediately before an update operation and held Apress © 2003 (630 pages) until the end of the transaction. This book provides a practical, step-by-step approach in
teaching how to use the WebSphere Application To support optimistic concurrency, WebSphere usesStudio overqualified updates to test whether the underlying Developer (WSAD) tool for developing J2EE distributed Datasourcehasapplications. been updated by another transaction since the beginning of the current transaction. With this scheme, the columns marked for update and their original values are added explicitly through a WHEREclause in theUPDATEstatement so that the statement fails if the underlying column values have been changed. As a result, Table this scheme of Contents can provide column-level concurrency control. The Pessimisticscheme controls concurrency at the row level only. Pessimistic andOptimistic concurrency schemes require different transaction isolation WebSphere Studio Application Developer 5.0: Practical J2EE Development levels. Enterprise beans that participate in the same transaction and require different concurrency control schemes Introduction cannot the same connection. Part One operate - Gettingon Started withunderlying WebSpheredata Studio Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0
Chapter 6
- J2EE EJB Development
Whether to use Optimisticconcurrency depends on the type of transaction. Transactions with a high penalty Chapter 2 - Setting Up the Development Environment for failure might be better managed with a Pessimisticscheme. (A high-penalty transaction is one for which Chapter 3 - Working with the WSAD 5.0 Workbench recovery would be risky or resource intensive.) For low-penalty transactions, it is often worth the risk of failure to Chapter 4 - Developing Database Applications gain efficiency with an Optimisticscheme. In general, Optimisticconcurrency is more efficient when Part Two - Working with J2EE: The Distributed Application Framework update collisions are expected to be infrequent. The Pessimisticconcurrency is more efficient when update Chapter 5 - J2EE Development collisions are expected to occur often. Chapter The following 7 - J2EE values Webare Development available for selection: Chapter 8
- J2EE XML Development
wsPessimisticUpdate-WeakestLockAtLoad
Part Three - Working with Enterprise Messaging
Chapter 9 - J2EE Enterprise Messaging wsPessimisticUpdate Chapter 10 - Using the WSAD-Embedded JMS Provider
wsPessimisticRead Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index
wsOptimisticUpdate
List ofwsOptimisticRead Figures List of Tables List ofwsPessimisticUpdateNo-Collisions Code Examples List of Sidebars
wsPessimisticUpdate-Exclusive
The default access intent policy is wsPessimisticUpdate-WeakestLockAtLoad;however, you cannot use this policy with Oracle. In addition, if the Lifetime in cachepolicy is set to the Beanvalue, the default value is wsOptimisticRead. You can assign the Access Intent policies to individual methods of the entity beans and their associated Home Interfaces. A policy is acted upon by the combination of the EJB container and a specific persistence manager. IBM advises the following when using this setting: Start with defaults: The default access intent policy (wsPessimisticUpdate-WeakestLockAtLoad) loads persistent data with the weakest lock that is supported by the persistent store (typically a read lock). Updates are allowed, and the database is permitted to undertake lock escalation when necessary. This option generally works best for most EJB application patterns. After your application is built and running, you can more finely tune certain access paths in your application. Don’t mix access types: Avoid using both pessimistic and optimistic policies in the same transaction. For most databases, pessimistic and optimistic policies use different isolation levels. This results in multiple database connections, which prevents you from taking advantage of the performance benefits possible through connection sharing. Access intent for the ejbSelectmethod must be applied indirectly: Because ejbSelectmethods are not exposed through a Home, Remote, or Local Interface, you cannot apply a policy to them directly. An ejbSelectmethod is called by a home or business method, so apply the appropriate policy to the home or business method that governs the behavior of the ejbSelectmethod.
Take care when applying wsPessimisticUpdate-NoCollision:This policy does not ensure data WebSphere Studio Application Developer 5.0: Practical integrity. No database locks are held, so concurrent transactions can overwrite each other’s updates. Use this J2EE Development policy only if you can be sure that only one transaction will attempt to update a persistent store at any given ISBN:1590591208 by Igor Livshin time. Apress © 2003 (630 pages)
This book a practical, step-by-step approach in For entity beans that provides are backed by tables with nullable columns, use an optimistic policy with teaching how to use WebSphereexcluded Studio Application caution:Nullable columns are the automatically from overqualified updates at deployment time; Developer (WSAD) tool for developing J2EE distributed concurrent changes to a nullablefield might result in lost updates. WSAD supports selecting a subset of applications. thenonnullablecolumns that will be reflected in the overqualified update statement that is generated in the deployment code to support optimistic policies. Table of Contents
A method that is configured with5.0: a read-only policy that causes a bean to be activated can cause WebSphere Studio Application Developer Practical J2EE Development problems if updates are attempted within the same transaction: Those changes will not be committed, Introduction and-an exception willwith be thrown because data integrity might be compromised. Part One Getting Started WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0 Note Refer to the following two topics in the WSAD Help system for more information: “Frequently Asked Chapter 2 Questions: - Setting Up the Development Access Intent” and Environment “Access Intent: Isolation Levels and Update Locks.” Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Understanding Data Integrity
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development J2EE applications are typically driven by remote users. Consider the following scenario: A librarian performs
Chapter J2EEactivity EJB Development updates6 of -book to reflect book rentals by some company. A screen with the book-related data is displayed. Chapter 7 J2EE The librarian fills inWeb theDevelopment screen fields and clicks OK. The book-related data is sent to the system and the bookChapter - J2EE record XML Development related8database is updated. Part Three - Working with Enterprise Messaging
To display original book activity screen, the data should be retrieved by the application from the database. Chapter 9 -the J2EE Enterprise Messaging Typically, donethe by WSAD-Embedded the CMP bean, but this is not important here. What is important is that the book-related data Chapter 10 it- isUsing JMS Provider is retrieved and when the data is sent to the user, this transaction is closed. All possible Chapter 11 -under Usingtransaction WebSphere context, MQ as the JMS Provider data locks released, and the same information could be modified by another user. The data that Appendix A -are Deploying This Book's J2EE book-related Examples the first user sees on the screen is already staled, but the user does not know it.
Index
List of Figures When the first user sends the updates, the book-related data is updated in the database, replacing the updates List of madeTables by the second user. The second user’s transaction results are mysteriously lost. How do you prevent this List of integrity Code Examples data problem? It would be possible to design the system in such a way that the data originally retrieved to List of Sidebars be displayed on the user screen remains locked. This is impractical, though, because the time required by the user
to complete the screen is highly unpredictable. The user may receive a phone call or take a coffee break. This type of solution is suitable for an application with a low concurrency. For a typical application, this is not a solution. There are three architectural designs you can use for solving this data integrity problem for high concurrency applications:Timestamp,Version Count, and State Comparison. The main idea of all of them is to retrieve the data again (just before the update) and make sure that the data remains unchanged since it was originally retrieved.
Using the Timestamp This is an additional field that is added to the state variable to store the time when the data was committed. When the first user receives its data, it has a Timestampfield. When the data is ready for update, the application receives the same data again and compares the timestamps of both records. If they are different, another user managed to update the data and the current update should be terminated (because it is based on staled data). To eliminate the performance impact from reading the data a second time, the SQL query can include the expected value of the Timestampfield in the WHEREclause. In this case, if modifications are already made to the data, the updated record will not be found.
Using the Version Count A similar idea is implemented here, but the extra field is used not as a timestamp but as a counter. The counter is incremented at each data commit operation. If the counter doesn’t match at the update time, the transaction is roll backed.
Using the State WebSphere Comparison Studio Application Developer 5.0: Practical J2EE Development
Before each databy update operation, all fields involved in the update ISBN:1590591208 are compared against their values saved Igor Livshin somewhere whenApress they were © 2003originally (630 pages)retrieved. This alternative requires more effort to implement, but it is more flexible by working onbook the field level.a Ifpractical, the fieldsstep-by-step to be updated are the This provides approach in same, you are not concerned about the rest of the fields (that teaching could behow updated), to use the andWebSphere you can complete Studio Application the update. Developer (WSAD) tool for developing J2EE distributed
It also should be applications. mentioned that the TimestampandVersion Count alternatives work only if all different applications working with the same data consistently modify the Timestampor the Version Count field. The best way to ensure this is to include this logic in the CMP bean that every application will use for working with the Table of Contents same data. WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction
Setting the EJB Transaction Isolation Level
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 4
- Developing Database Applications
The isolation level controls data availability for concurrent data processing from multiple clients. The isolation level Chapter 2 - Setting Up the Development Environment controls the following types of database processing: dirty reads, repeatable reads, and phantom reads. These Chapter 3 - Working with the WSAD 5.0 Workbench types are as follows: Part Two - Working with J2EE: Thecurrent Distributed Application Adirty read means that the transaction readsFramework uncommitted
results of other transactions. If some of
Chapter 5 transactions - J2EE Development these issue rollback, the current transaction will be processing incorrect data. Chapter 6 - J2EE EJB Development
Aphantom read means that subsequent reads can produce different results (because of some update made Chapter 7 - J2EE Web Development during -this transaction). J2EE XML Development
Chapter 8
Part Three - Working with Enterprise Messaging
Arepeatable read always produces the same results for subsequent reads within the same transaction.
Chapter 9
- J2EE Enterprise Messaging The isolation level the values available for selection are Read uncommitted,Read committed,Repeatable Chapter 10 - Using WSAD-Embedded JMS Provider
read, and Chapter 11 -Serializable: Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index
TheRead uncommitted option allows dirty reads, nonrepeatable reads, and phantom reads.
List ofThe Figures Read committed option prohibits dirty reads but allows nonrepeatable reads and phantom reads. List of Tables
Repeatable read option prohibits dirty reads and nonrepeatable reads but allows phantom reads. List ofThe Code Examples List of Sidebars
TheSerializableoption prohibits all three: dirty reads, nonrepeatable reads, and phantom reads. TheSerializablelevel is the most restricted (providing sequential access to the same data). This isolation level leads to the worst performance but the best data integrity. To specify the isolation level in WSAD 5.0, open the Deployment Descriptor and click the Accesstab. At the bottom, you should see the “Isolation Level” section. Click the Addbutton. On the next screen, select the isolation level (see Figure 5-34).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
5-34:with Selecting the isolation level Chapter 3 Figure - Working the WSAD 5.0 Workbench Chapter 4
- Developing Database Applications
Click Next. On the next screen, select the EJB beans (notice that CMP entity beans are not available for selection) and click Next. On the last screen, expand the selected EJB beans and select the methods to use Chapter 5 - J2EE Development this isolation level (see Figure 5-35). Click Finish. Save the results and close the Editor View. Part Two - Working with J2EE: The Distributed Application Framework
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 5-35: Setting the methods for the isolation level
WebSphere Studio Application Developer 5.0: Practical Setting J2EE Application Security J2EE Development
Igor Livshin WSAD and WASby support two types of security: declarative andISBN:1590591208 programmatic. You set declarative security within the diff © 2003 pages) application code Apress maintains the(630 programmatic security. This book provides a practical, step-by-step approach in
Declarative security is based security.Studio A security role is a logical grouping of principles with security author teaching howon to role-based use the WebSphere Application Developer (WSAD) tool and for developing J2EE distributed mapped to the operating system users groups at assembly or deployment time. Global security roles of the J2EE ap applications. of the EAR application file. Security roles for components are stored in their corresponding Deployment Descriptors insid applications to be portable among different J2EE-compliant application servers. At runtime, WebSphere checks if the us authorized to access the method. Table of Contents
WebSphere Studio Application 5.0: aPractical J2EE Development For the J2EE resources, youDeveloper typically use method-level security (protecting methods of EJB components). As mention Introduction Deployment Descriptor. In this section, you will set security on the application level. Switch to the J2EE Perspective, expa Part One - Getting Started with WebSphere Application Developer (WSAD) 5.0 TechLibApp project, right-click the EJB Studio Deployment Descriptor, and select
Chapter 1
Open With Deployment Descri
- Introducing WSAD 5.0
The application levelUp ofthe theDevelopment Deployment Environment Descriptor will be displayed. Click the Securitytab. On the screen that appear Chapter 2 - Setting set two3security roles with (Librarian and 5.0 Director). Click the Addbutton. On the screen that appears, enter Librarianin the Chapter - Working the WSAD Workbench security4 role in the Description field (see Figure 5-36). Chapter - Developing Database Applications Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 5-36: Setting the Librarian security role
Click OK. Repeat the same steps to add the second security role, Director. When you are done, you screen should look li
Figure 5-37: Setting the Director security role
Next, you will indicate the method each security role is authorized to access. Highlight the Librarian security role and clic 'WebSphere Bindings' section. Click the Addbutton in the 'Groups' section. On the next screen, enter Library-clerks Director security role and repeat the same steps to enter the Library-administrationgroup. When you are done, t Figure 5-38.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Figure 5-38: Setting security groups
Part Two Distributed Application Framework Save the- Working changes with and J2EE: close The the editor.
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Protecting Web Resources - J2EE Web Development
Chapter 7
Chapter 8 modules, - J2EE XML For Web youDevelopment protect HTTP commands that access specific methods (typically GETandPOSTmethods of servle Part Threelevel. - Working with Enterprise Messaging module Expand Web Modules, right-click
the Web Deployment Descriptor of some Web project, and select Open
Chapter J2EE Enterprise On the 9next- screen, click theMessaging Securitytab. Highlight the Security Roles tab at the top of the screen. Click the Add Chapter 10Add - Using the WSAD-Embedded JMS Provider Click the button again and create the Director security role. Scroll to the 'Authorized Roles' section. Chapter 11 - Using WebSphere MQ as the JMS Provider
Click theASecurity tabExamples and click the Addbutton. A new security constrain will appear. Click the Addbutt Appendix - DeployingConstrains This Book's J2EE
EnterWeb_methodsin the Namefield and give the description for this name. Check the method that the security role is au Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 5-39: Setting security constrains
WebSphere Studio Application Developer 5.0: Practical
J2EE Click OK. Next, click theDevelopment Editbutton in the 'Authorized Roles' section. On the next screen, select the Librarian security ro ISBN:1590591208 by Igorthe Livshin POSTmethods. Repeat same steps to select the Web methods that the Director security role is authorized to access. Apress © 2003 (630 pages)
Click the Servlets andprovides select the BookRegisterController Thistab book a practical, step-by-step approach inservlet. Locate the 'Authorized Roles' section. Click teaching how BookRegisterController to use the WebSphere Studio Application that are authorized to access (see Figure 5-40). Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
J2EE Enterprise Messaging Figure- 5-40: Servlet access authorization
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter Click OK. 11Save - Using the results WebSphere and MQ close as the the editor. JMS Provider Appendix A - Deploying This Book's J2EE Examples Index
Protecting EJB Resources
List of Figures
List ForofEJB Tables modules, you control the access to EJB components methods. In this section, you will work on the EJB module
Deployment Descriptor of some EJB project, and select Open With Deployment Descriptor Editor. On the next scre List of Code Examples
Descriptor List of Sidebars tab. Click the Addbutton in the 'Security Roles' section and create the Librarian security role. Repeat the sa
Click the Addbutton in the 'Method Permission' section. On the next screen, select Librarian as the security role (see Fig
Figure 5-41: Selecting the Librarian security role
Click Next. On the next screen, select the enterprise beans that the Librarian security role is allowed to access (see Figu WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development Figure modules permitted to be accessed by the Librarian security role Chapter 6 - 5-42: J2EE EJB EJB Development Chapter 7
- J2EE Web Development
Chapter 8 - On J2EE Click Next. theXML nextDevelopment screen, expand the selected components and mark the methods this security role is authorized t Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 5-43: EJB method permitted to be accessed by the Librarian security role Click Finish. Save the results and close the editor.
Understanding Programmatic Security In addition to the declarative type of security, WSAD and WAS support programmatic security where the security logic is code fragment for checking the role and the identity of the caller of the Web tier. Listing 5-17. Programmatic Security Public void doGet(HTTPServletRequest request, HTTPServletResponse response) { // Get remote user by using getRemoteUser()
String remoteUser = request.getRemoteUser(); Studio Developer 5.0: Practical // Get WebSphere remote user byApplication using the getUserPrincipal() J2EE Development java.security.Principal proncipal = request.getRemoteProncipal(); ISBN:1590591208 by Igor Livshin String remoteUser = principal.getName(); Apress © 2003 (630 pages)
provides a practical, step-by-step // Check This if book remoteUser is granted "Mgr"approach role in teaching how to use the WebSphere Studio Application boolean isMgr = (WSAD) request.isUserInRole("Mgr"); Developer tool for developing J2EE distributed --applications.
} Table of Contents
WebSphere Studio Application 5.0: two Practical J2EEto Development The EJB tier developer usesDeveloper the following methods check the role and the identity of the caller: Introduction public javax.security.Principal EJBContext.getCallerPrincipal(); public Boolean EJBCont Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical Setting Security Delegation J2EE Development
by Igor Livshin The delegation policy allows an intermediary to perform a taskISBN:1590591208 initiated by the client under an identity Apress © 2003 (630 pages) determined by the delegation policy. By default, if no delegation is specified, the intermediary will use the identity of the client. is specified by setting the Run-as mode for each EJB ThisThe bookdelegation provides apolicy practical, step-by-step approach in teaching how to useThe the field WebSphere Studio Applicationvalues: component or component method. can have the following Developer (WSAD) tool for developing J2EE distributed
applications. Client identity: Say the session bean calls the method XXXof the entity bean. If the method XXX has the client identity, then the client should be authorized to invoke the XXX method (rather than the identity of the session bean itself). Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development EJB Server identity: This is the identity of the intermediate module. If the delegation policy for the Introduction methodXXXis set to the EJB Server identity, then the EJB server must be authorized to call the Part One - Getting method XXX. Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Specific Security identity: The session bean invokes the XXXmethod under this identity, so Chapter 2 - Setting Up Role the Development Environment this security role must have authorization to call the method XXX. Chapter 3 - Working with the WSAD 5.0 Workbench Chapter 4
- Developing Database Applications
Right-click the EJB Deployment Descriptor of an EJB project and select Open With Deployment Descriptor Editor.Click the Accessmethod. Two sections control the user identity: one on the Chapter 5 - J2EE Development bean level and the second on the method level. Clicking the Addbutton in the user identity (Bean Chapter - J2EE Development Level)6 opens theEJB screen shown in Figure 5-44. Part Two - Working with J2EE: The Distributed Application Framework
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 5-44: Bean-level user identity Here, you can specify to use the identity of a caller or the identity assigned to a specific role. In the latter case, select the security role and click Next. On the next screen, you select the EJB beans that should use this type of security identity (see Figure 5-45).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Figure 5-45: Selecting beans to use this security identity
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development Click Finish. Now, click the Addbutton in the “Security Identity (Method Level)” section. The next screen Chapter 7 - J2EE Web Development
presents choices for selection: Use identity of caller, Use identity of EJB server, and Use Chapter 8 three - J2EE XML Development identity assigned to specific role(see Figure 5-46). Part Three - Working with Enterprise Messaging Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 5-46: User identity of the specific security role Click Next. The next screens are identical to the previous Security Identity screen, but they allow you to set on the method level. Save the changes and close the editor.
WebSphere Application Developer 5.0: Practical Understanding UserStudio Authentication J2EE Development
by Igor Livshin WAS supports three authentication mechanisms:
ISBN:1590591208
Apress © 2003 (630 pages)
HTTP Basic This Authentication book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application
Form-BasedDeveloper Authentication (WSAD) tool for developing J2EE distributed applications.
HTTPS Client Certificate Authentication The of following sections describe the first two authentication mechanisms. Table Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development
Using HTTP Basic Authentication
Introduction
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
In HTTP Authentication, Chapter 1 Basic - Introducing WSAD the 5.0 Web browser presents a dialog window prompting the user (attempting to access to enterEnvironment his/her user ID and password. The security service validates the Chapter 2 a- protected Setting Upresource) the Development user response against thethe user registry. The password is encoded in simple base64 and should not be Chapter 3 - Working with WSAD 5.0 Workbench considered secure. The target Applications server used for authentication is not authenticated itself. If a security Chapter 4 - as Developing Database constrain has beenwith set,J2EE: but no authentication method forFramework a Web module Part Two - Working The Distributed Application
has been configured, the default
is to use Authentication. Chapter 5 Basic - J2EE Development Chapter 6
- J2EE EJB Development A more sophisticated variation of Basic Authentication is Digest Authentication, which encrypts the user ID
Chapter 7 - J2EE Web Development and password when they are transmitted over the network. Chapter 8 - J2EE XML Development Part Three - Working with Enterprise Messaging
Using Form-Based Authentication - J2EE Enterprise Messaging
Chapter 9
Chapter 10 - Using the WSAD-Embedded JMS Provider
Form-Based Authentication permits a proprietary site-specific HTTP or JSP login form. The password is
Chapter 11 - Using MQasasathe JMS text). Provider not encrypted at allWebSphere (transmitted simple The target server used for authentication is not Appendix A Deploying This Book's J2EE Examples authenticated itself. Because the container supports single sign on, the user does not need to Index reauthenticate to other protected resources. List of Figures List of Tables
Using HTTPS Client Certificate Authentication
List of Code Examples
List of authentication Sidebars This mechanism requires the client to possess a public key certificate. This is more involved
but also the most secured form of authentication. Coverage of HTTPS Client Certificate Authentication is beyond the scope of this book. Open the Deployment Descriptor for the Web project. Click the Pagestab. You should see the 'Login' section on the top of the screen. In this section, you can select the type of user identification, the login page, and the error page (see Figure 5-47).
Figure 5-47: Login settings Use groups rather than individual users when assigning security roles. This will improve the performance of checking the authorization. There are several reasons for that. First, the number of groups is substantially smaller than the number of users. Second, it reduces the administration work. Finally, adding or deleting users from groups outside the WebSphere environment is much more preferable to adding and removing WebSphere security roles because the application must be stopped and reloaded for such changes to take effect.
Summary
WebSphere Studio Application Developer 5.0: Practical J2EE Development
by explored Igor Livshin In this chapter, you the latest J2EE 1.3 specifications,ISBN:1590591208 discussed the major features of the EJB 2003 (630 and pages) 2.0 standard (theApress Local © Interface the new CMP entity beans model), and learned how to implement them in WSAD 5.0. The third major afeature, MDBs, will be covered This book provides practical, step-by-step approachininChapters 9, 10, and 11. You also teachingand howimprovements to use the WebSphere Studio Application explored many additions of the J2EE 1.3 specification and how you can use them with Developer (WSAD) tool for developing J2EE distributed WSAD 5.0. applications.
In addition, the chapter covered some advanced topics of EJB and Web development and linked them to the corresponding WSAD 5.0 facilities. In the next two chapters, you will develop a fully functional J2EE Table of Contents 1.3 application and many short examples that demonstrate additional development topics. Refer to the WebSphere Studio Application Developer 5.0: Practical J2EE Development appendix to see how to deploy this application. Introduction
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Studio Application Developer 5.0: Practical Chapter WebSphere 6: J2EE EJB Development J2EE Development by Igor Livshin
ISBN:1590591208
In this chapter, you will start developing a complete Java 2 Enterprise Edition (J2EE) 1.3 application that Apress © 2003 (630 pages) consists of the Enterprise JavaBean (EJB) and Web modules. This chapter covers EJB development, and book provides a practical, step-by-step approach in Chapter 7 coversThis Web development. The EJB module will include entity beans-the Container Managed teaching how to use the WebSphere Studio Application Persistence (CMP) and Bean Managed Persistence types-and session beans (stateless and Developer (WSAD) tool for developing(BMP) J2EE distributed stateful beans). Inapplications. Chapter 7, you will build the Web module by following the industry best-practice ModelView-Controller (MVC) pattern, and it will consist of Hypertext Markup Language (HTML), servlets, JavaServer Pages (JSP), and JavaBean files. In this chapter's example, you will use J2EE technology for Table of Contents developing the application used by a hypothetical library that rents technical books to its clients-data WebSphere Application Developer 5.0: Practical J2EE Development processingStudio companies. Introduction
TheOne EJB- Getting development process typically includes building theDeveloper entity beans (CMP and Part Started with WebSphere Studio Application (WSAD) 5.0
BMP) that represent
the database records and building Chapter 1 - Introducing WSAD 5.0 the session beans (stateless and stateful) that represent the business processing It also frequently includes building the helper classes. Chapter 2 -logic. Setting Up the Development Environment Chapter 3
- Working with the WSAD 5.0 Workbench
- Developing Database Applications Understanding the EJB Project Organization
Chapter 4
Part Two - Working with J2EE: The Distributed Application Framework
The J2EE EJBDevelopment projects are organized in the following directory structure: Chapter 5 1.3 - J2EE Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
ejbModule: All EJB module folders reside inside the ejbModuledirectory.
Chapter 8 Source: - J2EE XML Java JavaDevelopment source directories reside inside the ejbModule folder according to their package Part Three - Working with Enterprise Messaging structure.
Chapter 9
- J2EE Enterprise Messaging websphere-deploy: This directory is Provider a child of the corresponding Java Source folder. It Chapter 10 - Using the WSAD-Embedded JMS
contains compiled and WebSphere Application Developer (WSAD)-generated classes. Chapter 11 - Using WebSphere MQ as the Studio JMS Provider Appendix A - Deploying This Book's J2EE Examples Index
WSAD Classes: Container classes and other project support classes reside in this folder.
List ofMETA-INF: Figures This folder also resides inside the ejbModule folder. It contains the EJB Deployment
file (ejb-jar.xml), two proprietary IBM-extended configuration files (ibm-ejb-jar-bnd.xml and List ofDescriptor Tables and the MANIFEST file. List ofibm-ejb-jar-ext.xml), Code Examples List of Sidebars
backends: This is a subdirectory of the META-INF folder. It contains databases attached to the project. Thenext section discusses entity bean development.
Studio Application Developer 5.0: Practical DevelopingWebSphere Entity Beans J2EE Development
by Igor You will first develop twoLivshin CMP entity bean components called ISBN:1590591208 Book_catalog and Book_activity. The book’s examples us 2003 (630 pages) consists of three Apress tables:©BOOK_CATALOG, BOOK_ACTIVITY, and BOOK_NOTIFY. The BOOK_CATALOG table repre Finally, the BOOK_NOTIFY table is aused for communication with theinlibrary customers. This book provides practical, step-by-step approach teaching how to use the WebSphere Studio Application
Developer (WSAD) for to developing distributed You will use the Book_catalog entitytool bean maintain J2EE the BOOK_CATALOG database table. It should have two busines applications. activity in the BOOK_ACTIVITY database table. It also should have two business methods: findByBook and findByComp example, you will build a stateless session bean with both Local and Remote Interfaces and a stateful session bean with Table of Contents
Developing CMP Entity Beans
WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction
First, you- Getting need toStarted build a with new WebSphere project. So,Studio switchApplication to the J2EEDeveloper Perspective. By default, Part One (WSAD) 5.0
you will also be in the J2EE View. N Project and click Next. On the next screen, enter TechLibEJB in the Project name field, check Newin the Enterprise Chapter 1 - Introducing WSAD 5.0 should be attached to an EAR application project. If no such project exists yet (such as TechLibApp), the system will auto Chapter 2 - Setting Up the Development Environment Server (WAS). Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4 - Developing Database Applications and TechLibApp) will be generated and become visible in the J2EE View. Click Finish. Two new projects (TechLibEJB Part Two - Working with J2EE: The Distributed Application Framework
You probably remember that any project that requires database access needs this database to be imported in the projec Chapter 5 - J2EE Development Chapter 6
- J2EE EJB Development
Chapter 8
- J2EE XML Development
Importing the Web TECHBOOK Chapter 7 - J2EE Development Database
into the TechLibEJB Project
To import the TECHBOOK database, switch to the Data Perspective. Right-click the Con1connection in the DB Servers V its tables.
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 Servers - Using View, the WSAD-Embedded JMS Provider In the DB highlight two tables: LIB.BOOK_ACTIVITY and LIB.BOOK_CATALOG (keep the Control key pre Chapter 11to-the Using WebSphere MQ as Click the JMS navigate TechLibEJB project. OK.Provider Now you are back to the original screen. Click Finish. You will be prompte Appendix along with A the - Deploying schemaThis (LIB)Book's and the J2EE selected Examples tables. Index
Note You have several ways to do this importing operation. You can import the entire database and then delete the need from the DB Servers View to the Data Definition View and drop them in the Tablesentry.
List of Figures List of Tables
List of should Code Examples You now see the TECHBOOK database and two tables in your project. WSAD provides three methods of develop List of Sidebars
You use the Bottom Up method when the database and database tables are available; thus, you build the entity beans b happens in large organizations where the database design is the responsibility of the database administration. The Top D on the corresponding entity beans. You use the Meet in the Middle approach when both parts are available, and you map Bottom Up method. The Bottom Up approach provides for a much faster development process. Later, you will see how t will use the Bottom Up method.
Using the Bottom Up Method
To use the Bottom Up method, switch to the J2EE Perspective (J2EE View). Rightclick the TechLibEJBproject and sele Use an existing backend folder (that points to the imported database). Click Next. The next screen prompts you to select 2.0 enterprise beans. Enter apress.wsad.techlib in the Package for generated EJB classes field and TechLib in the Prefi
WSAD will generate two entity beans, the TechLib_activityBean.java and TechLib_catalogBean.javaimplementatio TechLib_activityLocalHome.java,TechLib_catalogLocal.java, and TechLib_catalogLocalHome.java). In additio that the Local Interfaces are generated for both entity beans. WSAD also generates the mapping of the entity bean fields
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4 - 6-1: Developing Database Figure Generated entity Applications bean and field mapping Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
The Content Pane shows the Map.mapxmi file opened in the Map Editor View. The upper part of the screen shows the b - J2EE EJB Development lower part shows that all bean attributes for both modules have been automatically mapped to the corresponding table f
Chapter 6 Chapter 7
- J2EE Web Development
Chapter 8 the - J2EE XML Development Building Entity Bean’s Business Methods Part Three - Working with Enterprise Messaging
Double-click the TechLib_activityBean.java implementation class to open it in the Java Editor View. Notice that the CMP Chapter 9 - J2EE Enterprise Messaging inheriting abstract class. Figure 6-2 JMS shows the Outline View. Chapter 10 this - Using the WSAD-Embedded Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List ofFigure Tables 6-2: The Outline View List of Code Examples
List of Sidebars Notice also that EJB 2.0 entity beans no longer have attributes defined as fields. Only getter/setter methods are generate
that the getter/setter attribute methods are marked with the decorated icon A, which stands for Attribute. In addition, all g (these methods are promoted to the Local Interface). To verify this, double-click the Local Interface class TechLib_act getter/setter methods for the key attribute to the Local Interface. Open TechLibBook_catalogBean.java.In the Ou Interface. Do the same for the setCatalog_number method. WSAD generates only the skeleton of the entity bean Java f use a new feature of the WSAD 5.0 new release. In the previous releases, WSAD generated only a single create method manually build a second create method with a full list of attribute fields as arguments for each entity bean so that when t with all the proper fields.
In addition, whenever you build an additional create method in the Home Interface, you have to build the corresponding e developers’ suggestions, and in release 5.0, you can see that WSAD has automatically generated the second create me
Next, you want to build two additional finder methods. These finder methods are called findByBook and findByCompany. BookCatalogNumber or CompanyName. The following are the signatures of these two finder methods:
publicCollection findByBook(java.lang.String workBookCatNum) throwsjavax.ejb.FinderExce publicjava.util.Collection findByCompany(java.lang.String workCompanyName) throws javax
Perform the following steps to add these finder methods: In the Hierarchical pane, double-click the TechLibBook_activity Interface class TechLibBook_activityLocalHome. Next, define each finder method’s processing logic by executing the fol Deployment Descriptor Editor. In the screen that appears, click the Beans tab, select the Book_activity bean, and then sc finder methods that you just entered (findByBook and findByCompany) as the existing methods. The method type of thes
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Figure- 6-3: Add Finder Descriptor dialog J2EE Development
Chapter 5 Chapter 6
- J2EE EJB Development After selecting the findByBook method, click Next. On the next screen, expand the Select a sample query list and select
Chapter 7 -JavaBean J2EE WebQuery Development Enterprise Language (EJB QL) language, which is the standard for EJB 2.0. For example, you can sele Chapter Figure 86-4).- J2EE XML Development Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 6-4: EJB QL query statement for the findByBookmethod The EJB QL statement entered for the findByBook() method looks like this: select object(o) from Book_activity o where o.book_cat_num = ?1
The meaning of the statement in a plain English is this: “Select all Book_activity records with the book_cat_num field equ familiar with EJB QL (and who is?), you can refer to the excellent book Enterprise JavaBeans (O’Reilly, 2001). Click Fini button again and select the findByCompany method. Click Next. Enter the following EJB QL statement: select object(o) from Book_activity o where o.company_name = ?1
In this EJB QL statement, you are selecting all Book_activity bean instances with the company_name field equal to the v
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Figure QL query statement for the findByCompanymethod Chapter 5 - 6-5: J2EEEJB Development Chapter 6
- J2EE EJB Development
Chapter 7 -You J2EE Web Development Click Next. are returned to the original screen where you should see both EJB QL queries in the list (see Figure 6-6) Chapter 8 - J2EE XML Development Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 6-6: Section of the EJB Deployment Descriptor with entered EJB QL statements
Save the results and make sure there are no errors in the Tasks View. Double-click the TechLibBook_catalogLocalHom
publicjava.util.Collection findByPlatform(java.lang.String workPlatform) throws javax.e
Next, define each findermethod’s processing logic by executing the following steps: With the Deployment Descriptor s theFindByPlatformmethod and click Next. Enter the following EJB QL query on the next screen: select object(o) from Book_catalog o where o.platform = ?1
Click Finish. Click the Add button again. Select the findAll method and click Next. Enter the following EJB QL query on th select object(o) from Book_catalog o Click Finish. Your Book_catalog Deployment Descriptor should look like Figure 6-7.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Figure 6-7: Section of the Deployment Descriptor with entered EJB QL statements
Part Two with J2EE:sure The there Distributed Framework Save the- Working results and make are noApplication errors. Close the Deployment
Descriptor. You will use the getter/setter met
Chapter 5 Editor - J2EE Development the Java View, right-click the getCatalog_numbermethod and select Enterprise Bean > Promote to the Lo Chapter 6 J2EE EJB Development methods for the key attributes (txnDate and txnTime) for TechLibBook_activityBean. Chapter 7
- J2EE Web Development
Listing 86-1 -shows the source code for the TechLibBook_catalog entity bean. Chapter J2EE XML Development Part Three - Working with Enterprise Messaging
Listing 6-1. TechLibBook_catalogBean.java:Implementation Class
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
package Chapter 11 - apress.wsad.techlib; Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
/** Index * Figures Bean implementation class for Enterprise Bean: Book_catalog List of */ public abstract class TechLibBook_catalogBeanimplements List of Code Examples { List of Sidebars private javax.ejb.EntityContext myEntityCtx; List of Tables
public void
javax.ejb.EntityBean
setEntityContext(javax.ejb.EntityContext ctx)
{ myEntityCtx = ctx; } public javax.ejb.EntityContext getEntityContext() { return myEntityCtx; } public void unsetEntityContext() { myEntityCtx = null; } public
apress.wsad.techlib.TechLibBook_catalogKey ejbCreate( java.lang.String catalog_number) throws javax.ejb.CreateException
{ setCatalog_number(catalog_number); return null;
} public throws { }
WebSphere Studio Application Developer 5.0: Practical J2EE Development
voidejbPostCreate(java.lang.String catalog_number) ISBN:1590591208 by Igor Livshin javax.ejb.CreateException Apress © 2003 (630 pages)
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed public void applications. ejbActivate()
{ } Table of Contents public void ejbLoad() WebSphere Studio Application Developer 5.0: Practical J2EE Development { Introduction } Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 void - Introducing WSAD 5.0 public ejbPassivate() Chapter { 2 - Setting Up the Development Environment
} Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
public void ejbRemove() throws javax.ejb.RemoveException Part Two - Working with J2EE: The Distributed Application Framework { Chapter 5
- J2EE Development
} Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
public void ejbStore() Chapter 8 - J2EE XML Development { Part Three - Working with Enterprise Messaging } Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
public apress.wsad.techlib.TechLibBook_catalogKey ejbCreate( String catalog_number, Appendix A - Deploying This Book's J2EE Examples String author, Index String book_title, List of Figures String location, List of Tables String platform, List of Codelanguage) Examples String List of Sidebars throws javax.ejb.CreateException { setCatalog_number(catalog_number); setAuthor(author); setBook_title(book_title); setLocation(location); setPlatform(platform); setLanguage(language); return null; } Chapter 11 - Using WebSphere MQ as the JMS Provider
public String String String String String String throws { } public public
void ejbPostCreate( catalog_number, author, book_title, location, platform, language) javax.ejb.CreateException
abstract java.lang.String getCatalog_number(); abstract void setCatalog_number(java.lang.String newCatalog_number);
public abstract java.lang.String getAuthor(); WebSphere Application Developer 5.0: Practical public abstract void Studio setAuthor(java.lang.String newAuthor); J2EE Development public abstract java.lang.String getBook_title(); ISBN:1590591208 by Igor Livshin public abstract void setBook_title(java.lang.String newBook_title); Apress © 2003 (630 pages) public abstract java.lang.String getLocation(); This book a practical, step-by-step approach in public abstract voidprovidessetLocation(java.lang.String newLocation); teaching how to use the WebSphere Studio Application public abstract java.lang.String getPlatform(); Developer (WSAD) tool for developing J2EE distributed public abstract void setPlatform(java.lang.String newPlatform); applications. public abstract java.lang.String getLanguage(); public abstract void setLanguage(java.lang.String newLanguage); Table } of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One6-2 - Getting with code WebSphere Application Developer (WSAD) 5.0 Listing showsStarted the source for the Studio TechLibBook_activity entity bean.
Chapter 1
- Introducing WSAD 5.0
Listing26-2. Chapter - TechLibBook_catalogLocal.java: Setting Up the Development Environment Local Interface Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter package 4 - apress.wsad.techlib; Developing Database Applications Part public Two - Working interface with J2EE: TechLibBook_catalogLocal The Distributed Application Framework extends
{ Chapter 5
javax.ejb.EJBLocalObject
- J2EE Development
public Chapter 6
-java.lang.String J2EE EJB Development getCatalog_number(); public setCatalog_number(String newCatalog_number); Chapter 7 void - J2EE Web Development
public Chapter 8
-java.lang.String J2EE XML DevelopmentgetAuthor(); public void setAuthor(java.lang.String newAuthor); Part Three - Working with Enterprise Messaging public java.lang.String getBook_title(); Chapter 9 - J2EE Enterprise Messaging public void setBook_title(java.lang.String newBook_title); Chapter 10 - Using the WSAD-Embedded JMS Provider public java.lang.String getLocation(); Chapter 11 - Using WebSphere MQ as the JMS Provider public void setLocation(java.lang.String newLocation); Appendix A - Deploying This Book's J2EE Examples public java.lang.String getPlatform(); Index public void setPlatform(java.lang.String newPlatform); List of Figures public java.lang.String getLanguage(); List of Tables public void setLanguage(java.lang.String newLanguage); List } of Code Examples List of Sidebars
Listing 6-3 shows the source code for the TechLibBook_catalogKey Primary Key class. Listing 6-3. Primary Key Class TechLibBook_catalogKey.java package apress.wsad.techlib; public class TechLibBook_catalogKeyimplements java.io.Serializable { static final long serialVersionUID = 3206093459760846163L; public java.lang.String catalog_number; public { }
TechLibBook_catalogKey()
public TechLibBook_catalogKey(java.lang.String catalog_number) { this.catalog_number = catalog_number; } public boolean equals(java.lang.Object otherKey) { if (otherKeyinstanceof
apress.wsad.techlib.TechLibBook_catalogKey) WebSphere Studio Application Developer 5.0: Practical { J2EE Development apress.wsad.techlib.TechLibBook_catalogKey o = ISBN:1590591208 by Igor Livshin (apress.wsad.techlib.TechLibBook_catalogKey) otherKey; Apress © 2003 (630 pages) return ((this.catalog_number.equals(o.catalog_number))); This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application return false;Developer (WSAD) tool for developing J2EE distributed } applications.
public int
hashCode()
Table { of Contents WebSphere Application Developer 5.0: Practical J2EE Development return Studio (catalog_number.hashCode()); Introduction } Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter public 1 - Introducing WSAD 5.0 java.lang.String getCatalog_number() Chapter { 2 - Setting Up the Development Environment
return Chapter 3
-catalog_number; Working with the WSAD 5.0 Workbench
} Chapter 4
- Developing Database Applications
public void setCatalog_number(java.lang.String Part Two - Working with J2EE: The Distributed Application FrameworknewCatalog_number) { Chapter 5
- J2EE Development
catalog_number newCatalog_number; Chapter 6 - J2EE EJB=Development } Chapter 7
- J2EE Web Development
} Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Listing 6-4 shows the source code for the TechLibBook_activityBean entity bean.
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter - Using WebSphere MQ as the JMS Provider Implementation Class Listing11 6-4. TechLibBook_activityBean.java: Appendix A - Deploying This Book's J2EE Examples Index
package
List of Figures
apress.wsad.techlib;
List of Tables public abstract class List { of Code Examples
TechLibBook_activityBeanimplements
javax.ejb.EntityBean
List of Sidebarsjavax.ejb.EntityContext myEntityCtx; private
public void setEntityContext(javax.ejb.EntityContext ctx) { myEntityCtx = ctx; } public { return }
javax.ejb.EntityContext getEntityContext() myEntityCtx;
public void unsetEntityContext() { myEntityCtx = null ; } public apress.wsad.techlib.TechLibBook_activityKey ejbCreate( java.lang.String txn_date, java.lang.String txn_time) throws javax.ejb.CreateException { setTxn_date(txn_date); setTxn_time(txn_time);
return null; WebSphere Studio Application Developer 5.0: Practical } J2EE Development by Igor Livshin
ISBN:1590591208
public void ejbPostCreate( Apress © 2003 (630 pages) java.lang.String txn_date, This book provides a practical, step-by-step approach in java.lang.String txn_time) teaching how to use the WebSphere Studio Application throws javax.ejb.CreateException Developer (WSAD) tool for developing J2EE distributed { applications. } public void ejbActivate() Table { of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development } Introduction public void ejbLoad() Part { One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1 - Introducing WSAD 5.0 } Chapter 2
- Setting Up the Development Environment public ejbPassivate() Chapter 3 void - Working with the WSAD 5.0 Workbench
{ Chapter 4
- Developing Database Applications
} Two - Working with J2EE: The Distributed Application Framework Part public ejbRemove()throws Chapter 5 void - J2EE Development { Chapter 6
- J2EE EJB Development
} Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
javax.ejb.RemoveException
public void ejbStore() { Chapter 9 - J2EE Enterprise Messaging }
Part Three - Working with Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider
public apress.wsad.techlib.TechLibBook_activityKey ejbCreate( java.lang.String txn_date, Index java.lang.String txn_time, List of Figures java.lang.String txn_type, List of Tables java.lang.String book_cat_num, List of Code Examples java.lang.String company_name) List of Sidebars javax.ejb.CreateException throws { setTxn_date(txn_date); setTxn_time(txn_time); setTxn_type(txn_type); setBook_cat_num(book_cat_num); setCompany_name(company_name); return null; } public void ejbPostCreate( java.lang.String txn_date, java.lang.String txn_time, java.lang.String txn_type, java.lang.String book_cat_num, java.lang.String company_name) throws javax.ejb.CreateException { } public abstract java.lang.String getTxn_date(); public abstract void setTxn_date(java.lang.String newTxn_date); public abstract java.lang.String getTxn_time(); public abstract void setTxn_time(java.lang.String newTxn_time); public abstract java.lang.String getTxn_type(); Appendix A - Deploying This Book's J2EE Examples
public public public public public }
abstract void setTxn_type(java.lang.String newTxn_type); WebSphere Studio Application Developer 5.0: Practical abstract java.lang.String getBook_cat_num(); J2EE Development abstract void setBook_cat_num(java.lang.String newBook_cat_num); ISBN:1590591208 by Igor Livshin abstract java.lang.String getCompany_name(); Apress © 2003 (630 pages) abstract void setCompany_name(java.lang.String newCompany_name); This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Listing 6-5 shows the source code for the TechLibBook_activityLocalHomeinterface. Listing 6-5. TechLibBook_activityLocalHome.java:Local Home Interface Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction package
apress.wsad.techlib;
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 import java.util.*;
Chapter 1 interface - Introducing WSAD 5.0 public TechLibBook_activityLocalHome extends Chapter 2 - Setting Up the Development Environment { Chapter 3 public
javax.ejb.EJBLocalHome
-apress.wsad.techlib.TechLibBook_activityLocal Working with the WSAD 5.0 Workbench
Chapter create(java.lang.String 4 - Developing Database Applications txn_date, Part Twojava.lang.String - Working with J2EE: The txn_time) Distributed Application Framework
Chapterthrows 5 - J2EEjavax.ejb.CreateException; Development
public Chapter 6
findByPrimaryKey( -apress.wsad.techlib.TechLibBook_activityLocal J2EE EJB Development Chapter apress.wsad.techlib.TechLibBook_activityKey 7 - J2EE Web Development Chapter primaryKey) 8 - J2EE XML Development
throws javax.ejb.FinderException; Part Three - Working with Enterprise Messaging public Chapter 9
create( -apress.wsad.techlib.TechLibBook_activityLocal J2EE Enterprise Messaging java.lang.String txn_date, Chapter 10 - Using the WSAD-Embedded JMS Provider java.lang.String txn_time, Chapter 11 - Using WebSphere MQ as the JMS Provider java.lang.String txn_type, Appendix A - Deploying This Book's J2EE Examples java.lang.String book_cat_num, Index java.lang.String company_name) List of Figures throws javax.ejb.CreateException; List of Tables List of Code Examples List of Sidebars public Collection findByBook(java.lang.String workBookCatNum)
throws public throws }
javax.ejb.FinderException;
java.util.Collection findByCompany(java.lang.String workCompanyName) javax.ejb.FinderException;
Listing 6-6 shows the source code for the TechLibBook_activityLocal interface. Listing 6-6. TechLibBook_activityLocal.java:Local Interface package
apress.wsad.techlib;
public interface TechLibBook_activityLocalextends javax.ejb.EJBLocalObject { public java.lang.String getTxn_date(); public void setTxn_date(java.lang.String newTxn_date); public java.lang.String getTxn_time(); public void setTxn_time(java.lang.String newTxn_time); public java.lang.String getTxn_type(); public void setTxn_type(java.lang.String newTxn_type);
public java.lang.String getBook_cat_num(); Studio Application Developer 5.0: Practical public void WebSphere setBook_cat_num(java.lang.String newBook_cat_num); J2EE Development public java.lang.String getCompany_name(); ISBN:1590591208 by Igor Livshin public void setCompany_name(java.lang.String newCompany_name); Apress © 2003 (630 pages) } This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed Listing 6-7 showsapplications. the source code for the TechLibBook_activityKey Primary Key lass.
Listing 6-7.Primary Key Class TechLibBook_activityKey.java Table of Contents WebSphere Application Developer 5.0: Practical J2EE Development package Studio apress.wsad.techlib; Introduction Part One - Getting with WebSphere Studio Application Developer (WSAD) 5.0 public class Started TechLibBook_activityKey implements java.io.Serializable
Chapter 1 {
- Introducing WSAD 5.0
Chapter 2 final - Setting Up the serialVersionUID Development Environment static long = 3206093459760846163L; Chapter 3 - Working with the WSAD 5.0txn_date; Workbench public java.lang.String Chapter public 4
- Developing java.lang.String Database Applications txn_time;
Part Two - Working with J2EE: The Distributed Application Framework
public Chapter 5
-TechLibBook_activityKey() J2EE Development
{ Chapter 6
- J2EE EJB Development
} Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
public Chapter 9
-TechLibBook_activityKey( J2EE Enterprise Messaging java.lang.String txn_date, Chapter 10 - Using the WSAD-Embedded JMS Provider java.lang.String txn_time) Chapter 11 - Using WebSphere MQ as the JMS Provider { Appendix A - Deploying This Book's J2EE Examples this.txn_date = txn_date; Index this.txn_time = txn_time; List of Figures } List of Tables List of Codeboolean Examples public
equals(java.lang.Object otherKey)
List { of Sidebars
if
(otherKeyinstanceof apress.wsad.techlib.TechLibBook_activityKey) { apress.wsad.techlib.TechLibBook_activityKey o = (apress.wsad.techlib.TechLibBook_activityKey) otherKey; return ( (this .txn_date.equals(o.txn_date)) && (this.txn_time.equals(o.txn_time))); } return false; } public int hashCode() { return (txn_date.hashCode() + txn_time.hashCode()); } public java.lang.String getTxn_date() { return txn_date; } public void
setTxn_date(java.lang.String newTxn_date)
{ Studio Application Developer 5.0: Practical txn_date WebSphere = newTxn_date; J2EE Development
}
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
public java.lang.String getTxn_time() This book provides a practical, step-by-step approach in { teaching how to use the WebSphere Studio Application return Developer txn_time; (WSAD) tool for developing J2EE distributed } applications. public void setTxn_time(java.lang.String newTxn_time) { Table of Contents txn_time = newTxn_time; WebSphere Studio Application Developer 5.0: Practical J2EE Development } Introduction } Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Binding Datasource Chapter 2 the - Setting Up the Development Environment Chapter 3
- Working with the WSAD 5.0 Workbench
You can bind the Datasourceon the project level. Alternatively, each CMP entity bean can be bound to a Datasource - Developing Database Applications Naming and Directory Interface (JNDI) name must be assigned and set in the JNDI data space, so each module can be Part Two - Working with J2EE: The Distributed Application Framework With.Deployment Descriptor Editor. Chapter 4 Chapter 5
- J2EE Development
Chapter 6 - to J2EE Development Scroll down theEJB “WebSphere Bindings” section of the Deployment Descriptor. Select the backend ID (which determine Chapter 7 J2EE Web DB2UDBNT_V72_1.In Development the “JNDI–CMP Factory Connection Binding” section, enter jdbc/TECHBOOKin the JNDIname fi Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index
Figure 6-8: Binding the CMP entity bean to the Datasource
List of Figures
List of need Tablesto specify JNDI names for your entity beans so the EJB clients can locate them. With the Deployment Descrip You List of Code section. Examples Bindings” Enter ejb/Book_activity in the JNDI name field (see Figure 6-9). List of Sidebars
Figure 6-9: Setting the JNDI name for the Book_activityCMP entity bean
Next, highlight the Book_catalog bean, and in the same “WebSphere Bindings” section, enter ejb/Book_catalog in the JN
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Figure- 6-10: Setting the JNDI name for the Book_catalogCMP entity bean Introducing WSAD 5.0
Chapter 1 Chapter 2
- Setting Up the Development Environment The next step is to generate the deployment code for the entity beans. Rightclick TechLibEJBand select Generate> De
Chapter 3 - Working with the WSAD 5.0 Workbench Book_catalog. Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: Distributed Framework Click Finish. You can see theThe generated codeApplication by switching to the J2EE
Chapter 5
Navigator View and expanding the apress.wsad.t
- J2EE Development
Configuring the Test Server Chapter 6 - J2EE EJB Development Chapter 7
J2EE Web Development To test the -entity beans you have just built, you need to create a test server and add a Datasource to its configuration. Sw Chapter - J2EE XML Developmentand click Finish. The TechLibTestServerProject will appear in the Navigator View. Nex project 8TechLibTestServerProject Part Three name - Working with Enterprise Messaging Also, select WebSphere version 5.0 Test Environment as the server insta appears, the server TechLibTestServer. Chapter 9
- J2EE Enterprise Messaging Click Finish. Next, the you WSAD-Embedded need to add the TechLibApp Chapter 10 - Using JMS Provider enterprise project to the server configuration. In the Server Configura
the server Double-click TechLibTestServer to open its configuration in the Editor View. Click the Data sour Chapter 11 configuration. - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 6-11: Adding a Datasourceto the server configuration In the “JDBC provider list” section, select Default JDBC DB2 Provider. Click the Add button attached to the “Datasource selecting the version 5.0 Datasource. Set the Datasource parameters on the next screen (see Figure 6-12).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging Figure 6-12: Datasource configuration
Chapter 9
- J2EE Enterprise Messaging EnterTECHBOOK in the the WSAD-Embedded Namefield. It is just a display Chapter 10 - Using JMS Providername. Enter jdbc/TECHBOOKin the JNDI name field. This is the sa
theUse11this data sourceMQinas container managed persistence (CMP) box is checked (this creates several internal Chapter - Using WebSphere the JMS Provider followingA screen, highlight databaseName field and enter TECHBOOK as the value (see Figure 6-13). Appendix - Deploying Thisthe Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 6-13: Setting the database name
Click Finish. You should see the following section of the server configuration (see Figure 6-14). Click the Applications tab
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Figure Fragment the server configuration Chapter 3 - 6-14: Working with theofWSAD 5.0 Workbench Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List ofFigure Figures6-15: Classloader setting List of Tables
The setting controls the isolation level of applications and its different parts. If you set the Web Archive (WAR List of classloader Code Examples
also EJB module classes. Selecting the MODULE policy will assign a separate classloader for all classes of the W List of loads Sidebars
The classloader mode PARENT_FIRST causes the classloader to first delegate the loading of classes to its parent class on the other hand, causes the classloader to attempt to load classes from its local CLASSPATH before delegating it to t classes that exist in the parent classloader. Accept the default here and click the Configuration tab.
Make sure the Enable universal test client box is checked. This allows testing of EJB modules without developing an EJB applications. MULTIPLE means that each application will be assigned its own classloader and will be isolated from the re isolated from each other). Accept the default here (MULTIPLE). Save and close the Configuration Editor. You are ready
Using the IBM EJB Test Client
To test EJB modules, you need an EJB client that calls the EJB components you have just developed. Because you do n designed for such situations. To be able to use the Universal Test Client, you must activate it in the server configuration.
Switch to the Servers View, right-click TechLibTestServerand select Start. Wait until the server starts (you should s project and select Runon Server. The Universal Test Client will appear (see Figure 6-16).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Figure 6-16: The Universal Test Client
Table of Contents Note The Universal Test Client normally starts automatically in the Browser View of the Server Perspective. If this no WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Click JNDI Explorer. The JNDI Explorer screen will appear (see Figure 6-17). Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8 - 6-17: J2EE JNDI XML Development Figure Explorer Part Three - Working with Enterprise Messaging
Chapter 9 Local - J2EE Enterprise Messaging Click the EJB Beans link, and then click the ejb link. You should see two Local Home interfaces of the Book_activi Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 6-18: Local Home Interfaces of the entity beans
Click the Book_catalog link. The EJB References screen will appear. Expand TecLibBook_catalog all the way down unt
At that point, you should see two create methods and three finder methods. Click the findByPrimaryKey method (you will TechLibBook_catalogKey(String). Click the Expand link and enter 00002 as a BookCatalogNumber key (see Figure 6-1
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Figure 6-19: Request to find a Book_catalogwith a key of 00002
Chapter 3
- Working with the WSAD 5.0 Workbench Click the Invoke button. Click the Work with Object button. Now you should see all the object’s methods promoted to the
Chapter 4 - Developing Applications see “Developer Journal”Database displayed (see Figure 6-20).
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
Figure 6-20: Displaying the author of the book
Index
List of Figures Click the GetBook_titlemethod. Click Invoketo execute it. Click Work with Object. Now you should see “Window List of Tables List of Code Examples List of Sidebars
Figure 6-21: Displaying the book title
Let’s test another method. Click TechLibBook_catalogLocalHome to get back to the list of available methods. This time, Now, because multiple objects (records) are expected to be returned, a new button is displayed: Work with Contained O the getBookTitle method. Next, click Invoke. The “Windows NT Programming in Practice” title is displayed (see Figure 6-
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Figure 6-22: Displaying the first book title Table of Contents
WebSphere Now, repeat Studio the same Application for the Developer second returned 5.0: Practical object. J2EE The Development result is “MCSE Windows 2000 Professional” (see Figure 6-2 Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three Figure - Working 6-23: Displaying with Enterprise the second Messaging book title
Chapter 9
- J2EE Enterprise Messaging
Let’s create a new record in the BOOK_CATALOGtable. Click TechLibBook_catalogLocalHome to get back to the list of prompts you to enter the value for the six method’s arguments. Enter the following values: Chapter 11 - Using WebSphere MQ as the JMS Provider Chapter 10 - Using the WSAD-Embedded JMS Provider Appendix A 00008 - Deploying This Book's J2EE Examples Enter for Catalog Number. Index
Vanderburg and a team for Author. List ofEnter Figures List of Tables
Enter Maximum Java 1.1 for Book Title.
List of Code Examples
List ofEnter Sidebars Library for Location.
Enter 00 for Platform. Enter 01 for Language. Your screen should now look like Figure 6-24.
Figure 6-24: Creating a new database record
Click Invoke and then click Work with Object. A new object appears in the References section. You should see a list of a title is displayed: “Maximum Java 1.1.” This is the title of the new book that you have just added to the database. Now, le link. Click Book_activityLocalHome. A list of available methods will be displayed. Click the findByCompany method. You
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Figure 6-25: Finding records with the AAA_Companyfield value Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development
Click Invoke. Again, multiple return objects are expected. Click Work with Contained Objects. Three objects appear “00002.” Click getBook_txn_type. The result is “RENT” (see Figure 6-26).
Introduction
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterpriseresults Messaging Figure 6-26: The processing
Chapter 9
- J2EE Enterprise Messaging Close the Test Client and stopJMS theProvider server. Chapter 10 Universal - Using the WSAD-Embedded Chapter 11 - Using WebSphere MQ as the JMS Provider
Note If the nature of your database processing is of type Read Only, create only getter methods. The container wil of each transaction, which improves performance.
Appendix A - Deploying This Book's J2EE Examples Index
List of concludes Figures This the CMP entity bean Bottom Up development example. List of Tables List Using of Code the Examples Top Down
Method
List of Sidebars
The next example demonstrates the Top Down method—an alternative way of developing CMP entity beans. In this exam of developing entity beans. After the skeleton is built, the remainder of the development process is identical to the Bottom your main development work. You will call this new EJB project AltCMPDevEJB (which stands for alternative method of
Switch to the J2EE Perspective and create a new EJB project. From the main menu, select File > New > EJB Project. C name. Select New and enter AltCMPDevApp as the new J2EE application project name. Click Finish.
WSAD will generate two new projects: AltCMPDevEJB and AltCMPDevApp. Import the TECHBOOK database into the A Reconnect. Expand the Con1 connection until you will see all the database tables. Right-click TECHBOOK and select Im Finish. Finally, confirm the creation of the new folder.
The Top Down method assumes that the CMP entity bean is present. Because you do not have it, you need to build it firs next screen, select AltCMPDevEJB as the project name and click Next. On the subsequent screen, select CMP 2.0 as th and select CMP 2.0 Bean. Enter Book_details as the bean name and apress.wsad.sample as the default package. Ensu
Click Next. On the EJB Details screen, accept the default names of all classes that WSAD generates. Select Local clien database table BOOK_DETAILS that will be generated later based on this bean). Of course, I simulated a citation that th catalogNumber in the Name field. Select java.lang.String as the Type field. Mark the field as the Key field (see Figure 6-
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Figure 6-27: Creating CMP attributes Table of Contents
WebSphere Studio Practical J2EE Development Click Apply. EnterApplication the rest ofDeveloper the fields:5.0: publishingCompany and bookPrice. For each field, select String as the field type. Introduction selected. When you have finished entering attributes, click Close. You should see the screen shown in Figure 6-28. Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 6-28: Enterprise Bean Details screen
What is strange here is that you are forced to generate both the getter and the setter methods, even if you are developin from an existing bean in the same EJB project. You do not need this; click Finish. The Book_detailsBean class will be ge
At this point, you could edit the classes generated for the Book_details entity bean. You could even add several finder m previous example (the Bottom Up approach). Instead, you will concentrate on what is unique for the Top Down method o
Considering that your bean is done, you will define a new database table based on the existing Book_detailsCMP ent new database table. Switch to the J2EE Hierarchy View of the J2EE Perspective. Expand the Databasesfolder and the entry and select New> TableDefinition. On the New dialog, enter BOOK_DETAILS in the Table name field (see Figure 6
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Figure 6-29: Table Definition screen
Part Three - Working with Enterprise Messaging Click Next. On the Table Columns page, click
Add Another to add a new column to the table. Enter CATALOG_NU
Chapter 9 the - J2EE Enterprise uncheck Nullable and Messaging the Forbit data fields, and check the Key column box (see Figure 6-30). Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 6-30: TheTable Columns screen Click Add Another again. Use the same procedure to enter the rest of the table columns:
PUBLISHING_COMPANY: Select VARCHAR, uncheck Nullable, set the Stringlength field to 100, and uncheck F
BOOK_PRICE: Select VARCHAR, uncheck Nullable, set the String length to 10, and uncheck For bit da
When you are done entering all the columns, click Next. On the next screen, enter CATALOG_NUMBER in the Primary WebSphere Studio Application Developer 5.0: Practical
J2EE this Development field blank, the name will be autogenerated. Select the CATALOG_NUMBERcolumn in the left p Note If you leave by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
Figure 6-31: Primary Chapter 11 - Using WebSphere MQ asKey the screen JMS Provider Appendix A - Deploying This Book's J2EE Examples
Index Click Finish. You should see a new BOOK_DETAILS table appear under the TECHBOOK database. Now, you will gene List of Figures Generate DDL. On the next screen, check the following boxes: Generate SQL DDL with fully qualified names, Generate List of Tables BOOK_DETAILS.sql DDL file will be displayed for editing (see Figure 6-32). List of Code Examples List of Sidebars
Figure 6-32: Generated DDL file
You do not need to modify it, so close the Editor View. Export the generated DDL to the file system. Click the J2EE Nav click Next. On the next screen, specify the destination c:\temp as the destination directory. Expand the AltCMPDevEJB p 33).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Figure 6-33: Exporting a DDL file
Part Three - Working with Enterprise Messaging Click Finish. The BOOK_DETAILS.sql file will
be exported. To build a new table, open the DB2 Command Window (S
Chapter 9 - J2EE Enterprise Messaging -tf c:\temp\book_details.sql. Chapter 10 - Using the WSAD-Embedded JMS Provider
This will11build the BOOK_DETAILS Listing 6-8 shows the processing results. Chapter - Using WebSphere MQ astable. the JMS Provider Appendix A - Deploying This Book's J2EE Examples
Listing 6-8. BOOK_DETAILS Processing Results
Index
E:\PROGRA~1\SQLLIB\BIN>db2 connect to TECHBOOK List of Figures List of TablesDatabase Connection Information
Database server List of Code Examples SQL autorization ID List of Sidebars Local database alias
= DB2/NT 7.2.0 = ADMINIST... = TECHBOOK
E:\PROGRA~1\SQLLIB\BIN>db2 -tf c:\temp\book_details.sql DB21034E The command was processed as an SQL statement because it was a valid Command Line Processor command. During SQL processing it returned: SQL0204N "LIB.BOOK_DETAILS" is an undefined name. SQLSTATE=42704 DB20000I The SQL command completed successfully. DB20000I The SQL command completed successfully.
Mapping Entity Bean Attributes to the Database Tables
Next, you will map the Book_details entity bean to the BOOK_DETAILS database table. In the J2EE Perspective, right-cl to create a new backend folder or to use the existing one. The backend folder keeps the database imported in the projec
The next screen should prompt you to choose the type of the EJB/RDB mapping (Bottom Up, Top Down, or Meet In The you already built the BOOK_DETAILS database table, so WSAD sees both the Book_details entity bean and the BOOK_ corresponding fields. Click Next.
The next screen prompts you to match the corresponding database and entity bean fields. Three choices are available: fields. The Match by Name option will simply match fields by name. If identically named fields are present, you choose M file in the Editor View. The Book_details bean is in the upper-left pane and BOOK_DETAILS table is in the right pane. Ex
Because the mapping field names are constructed differently (catalogNumber vs. CATALOG_NUMBER), you will do ma WebSphere Studio Application Developer 5.0: Practical CATALOG_NUMBER in the right pane. Right-click CATALOG_NUMBER and select Create Mapping. You should see th J2EE Development see all fields that are mapped in the lower section of the screen (see Figure 6-34). by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development Figure attributes to database fields Chapter 6 - 6-34: J2EE Mapping EJB Development Chapter 7
- J2EE Web Development
Save the results and close the Editor View. Starting from this point, the remainder part of the development is similar to th Chapter 8 - J2EE XML Development Part Three - Working with Enterprise Messaging
Using the Meet in the Middle Method - J2EE Enterprise Messaging
Chapter 9
Chapter 10the - Meet Using in the WSAD-Embedded Provider You use the Middle method JMS of entity bean development when both the entity bean and the database table ar Chapter 11 - Using WebSphere MQ as the JMS Provider
The firstAstep is to mapThis the entity Appendix - Deploying Book'sbean J2EE attributes Examples to the corresponding fields of the database table. To do this, right-click t
dialog, check the Meet In The Middle mode. You will be presented with a similar mapping screen that maps bean attribu Index List of Figures
Developing BMP Entity Beans
List of Tables
List of Code Examples
In this section, you will develop a BMP entity bean with a Remote Interface. That means that all communication with the List of Sidebars
development of BMP entity beans requires more effort because the persistence database-related logic and synchronizat (instead of simply relying on the EJB container to automatically manage this process as is the case for the CMP entity be
On the other hand, BMP entity beans give developers more flexibility in controlling the bean interaction with databases. T frequently includes processing of legacy databases. Your BMP entity bean will have one business method called bookAc query you will use in this section is not more complex than the one you used in the CMP examples. However, you will de let’s start the development.
You will develop the BookInquiryBMP bean under the same TechLibEJBproject. Right-click the TechLibEJB project TechLibEJB, so click Next. On the next screen, select the BMP entity bean and enter BookInquiry as the bean name. Ma navigate to this package (see Figure 6-35).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Figure 6-35: Building a BMP entity bean Part Three - Working with Enterprise Messaging Chapter 9
- J2EE Enterprise Messaging
Click Next. On the next screen, select Remote Client View and unselect LocalClient View. In addition, enter ejb/B
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 6-36: BMP details screen
Click Finish. WSAD will generate the skeleton of the BMP entity bean. You should see the BookInquiry files generated by Home Interface), and BookInquiryKey (the Primary Key class).
Building the Transport Object WebSphere Studio Application Developer 5.0: Practical J2EE Development
You will now temporarily stop developing the BMP entity bean and build a helper JavaBean class that will serve as a tran ISBN:1590591208 by Igor Livshin The transport object allows you to deliver all SQL processing results as one network data transfer object (eliminating a n Apress © 2003 (630 pages)
This book provides a practical, approach in You will name this transport JavaBean class asstep-by-step TransportBean.java. To create this JavaBean class, right-click the teaching to use the WebSphere Studio Application Make sure that the correcthow project is selected in the Folder field. If not, click Browse and select the TechLibEJB project. E Developer (WSAD) tool for developing J2EE distributed Finally, check Constructors applications.from superclass (see Figure 6-37).
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List ofFigure Figures6-37: Creating a Java class List of Tables
Click Finish. WSAD will generate the skeleton of the Java class. The generated skeleton of the TransportBean class will List of Code Examples
BOOK_CATALOG and BOOK_ACTIVITY. Modify the code skeleton as shown in Listing 6-9. Save the results and close t List of Sidebars Listing 6-9. TransportBean.java package apress.wsad.techlib; import java.io.Serializable; import java.lang.*; import java.util.*; public class TransportObjectBean implements Serializable { protected String catalogNumber; protected String author; protected String bookTitle; protected String location; protected String platform; protected protected protected protected protected
String String String String String
txnDate; txnTime; txnType; bookCatNum; companyName;
public TransportObjectBean() WebSphere Studio Application Developer 5.0: Practical { J2EE Development super(); ISBN:1590591208 by Igor Livshin // Init all fields Apress © 2003 (630 pages) catalogNumber = ""; author = This "";book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application bookTitleDeveloper = ""; (WSAD) tool for developing J2EE distributed location applications. = ""; platform = ""; txnDate = ""; Table oftxnTime Contents = ""; WebSphere Studio = Application Developer 5.0: Practical J2EE Development txnType ""; Introduction bookCatNum = ""; Part One - Getting Started companyName = with ""; WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0
Chapter } 2
- Setting Up the Development Environment
} Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Next, you to Development create the getter/setter methods for this JavaBean attribute. Right-click elsewhere in the Outline View Chapter 5 need - J2EE 38). WSAD generate all getter/setter methods. Chapter 6 - will J2EE EJB Development Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 6-38: Building getter/setter methods
Save the results and close the Editor View. There are several important differences between coding CMP and BMP entit
Within the ejbCreate method of BMP entity bean, you need to code the SQL insert statement because the ejbCreate me pseudoconstructor. The BMP entity bean can have multiple ejbCreate methods. In this case, the corresponding ejbPostC included in the bean’s Home or Local Home Interface. Because you coded an additional ejbCreate and corresponding e bean’s Home Interface (BookInquiryHome). All ejbCreate, ejbPostCreate, and FindByPrimeryKey methods must return t
Two other methods require SQL coding: ejbStore and ejbLoad. Both of these methods are callback methods that are ca corresponding database record(s) needs to be performed. When an EJB client calls some of the setter methods, the sta ejbStore method, which has to execute the SQL update statement.
The EJB container calls the ejbLoad method in the opposite situation—to reflect a database change in the value of the b new business method. This ensures that the bean’s state variables always represent the current data in the database (w
Therefore, the ejbLoad method needs to execute the SQL Select statement and update the values of the bean’s state va EntityContext and not directly from the state variable or variables that represent the Primary Key. The reason is that the c passivated). In this case, the value of the state variable(s) that holds the key is undefined. It is also undefined when the e
execute the following SQL statement:
WebSphere Studio Application Developer 5.0: Practical
select BOOK_TITLE, TXN_DATE, TXN_TYPE, COMPANY_NAME form LIB.BOOK_CATALOG, LIB.BOOK_ACT J2EE Development by Igor Livshin
ISBN:1590591208
The SQL statement simply performs a search for all activity records related to the selected book’s catalog number. The Apress © 2003 (630 pages) any other resource), the bean needs to use the JNDI to locate the resource factory and then use the lookup method to g This book provides a practical, step-by-step approach in the database connection. Notice that the lookup JNDI name originally assigned to your Datasourceas jdbc/TECHBOO teaching how to use the WebSphere Studio Application java:comp/env. Developer (WSAD) tool for developing J2EE distributed applications.
You also modified the Primary Key class (BookInquiryKey). You added the second constructor with one String paramete added a new method getPrimaryKey that returns the catalogNumber string. Table of Contents
Listing 6-10 shows the source code of 5.0: all BookInquiry modules. You need to reflect all code changes in the BookInquiry WebSphere Studio Application Developer Practical J2EE Development Introduction
Listing 6-10. BookInquiryBean.java:Implementation Class
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
package apress.wsad.techlib; Chapter 2 - Setting Up the Development Environment import javax.ejb.*; Chapter 3 - Working with the WSAD 5.0 Workbench import java.rmi.*; Chapter 4 - Developing Database Applications import java.sql.*; Part Two - Working with J2EE: The Distributed Application Framework import java.lang.*; Chapter 5 - J2EE Development import java.util.*; Chapter 6 - J2EE EJB Development import javax.naming.*; Chapter 7 - J2EE Web Development import java.sql.Connection; Chapter 8 - J2EE XML Development import javax.sql.DataSource; Part Three - Working with Enterprise Messaging
Chapter 9
/**
- J2EE Enterprise Messaging
Chapter 10 - implementation Using the WSAD-Embedded Provider * Bean classJMS for Enterprise Bean: BookInquiry Chapter 11 Using WebSphere MQ as the JMS Provider */ Appendix - Deploying This Book's J2EE Examples publicA class BookInquiryBean implements
javax.ejb.EntityBean
Index { List of Figures private
javax.ejb.EntityContext myEntityCtx; String catalogNumber; String author; List public of Code Examples public String bookTitle; List of Sidebars public String location; public String platform; public String language; private ResultSet result = null ; List of public Tables
public
BookInquiryKey ejbCreate() throws javax.ejb.CreateException
{ return null; } public BookInquiryKey ejbCreate(String catalogNumber, String author, String bookTitle, String location, String platform, String language ) throws javax.ejb.CreateException { Connection dbCon = null ; PreparedStatement prepStm = null ;
if
(catalogNumber == null) WebSphere Studio Application Developer 5.0: Practical J2EE Development
{
throw new
javax.ejb.CreateException ("Invalid catalogNumber parameter");
by Igor Livshin Apress © 2003 (630 pages)
}
ISBN:1590591208
This book provides a=practical, step-by-step approach in this .catalogNumber catalogNumber; teaching how to use the WebSphere Studio Application this .author author; Developer=(WSAD) tool for developing J2EE distributed this.bookTitle = bookTitle; applications. this .location = location; this .platform = platform; Tablethis of Contents .language = language; WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction try Part One -{Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter dbCon 1 - Introducing 5.0 = this WSAD .getDBConnection(); Chapter 2 - Setting Up the Development Environment
= dbCon.prepareStatement("insert into LIB.BOOK_CATALOG " + Chapter prepStm 3 - Working with the WSAD 5.0 Workbench BOOK_TITLE, LOCATION, PLATFORM, LANGUAGE) " Chapter "(CATALOG_NUMBER, 4 - Developing DatabaseAUTHOR, Applications Part Two"values - Working (?,?,?,?,?,?)"); with J2EE: The Distributed Application Framework
catalogNumber); ChapterprepStm.setString(1, 5 - J2EE Development ChapterprepStm.setString(2, 6 - J2EE EJB Development author); ChapterprepStm.setString(3, 7 - J2EE Web DevelopmentbookTitle);
prepStm.setString(4, location); - J2EE XML Development prepStm.setString(5, platform); Part Three - Working with Enterprise Messaging prepStm.setString(6, language); Chapter 8 Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
if
(prepStm.executeUpdate() != 1) { Appendix A - Deploying This Book's J2EE Examples throw new EJBException ("Faild to add Catalog record to database Index Create method"); List of Figures } Chapter 11 - Using WebSphere MQ as the JMS Provider
List of Tables List of } Code Examples
// End of the try statement
List of Sidebars catch(SQLException sq)
{ System.out.println("SQL Error. " + sq); throw new EJBException("SQL call failed " + sq); } finally { try { if (result != null) result.close(); if (prepStm != null) prepStm.close(); if (dbCon != null) dbCon.close(); } catch (SQLException se) { se.printStackTrace();
} WebSphere Studio Application Developer 5.0: Practical J2EE Development
} // End of the finally statement ISBN:1590591208 by Igor Livshin return new BookInquiryKey(catalogNumber); Apress © 2003 (630 pages) } This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application public voidDeveloper ejbPostCreate() (WSAD) tool forthrows developingjavax.ejb.CreateException J2EE distributed { applications.
} Table of Contents public void ejbPostCreate(String catalogNumber, WebSphere Studio author, Application Developer 5.0: Practical J2EE Development String Introduction String bookTitle, Part OneString - Getting location, Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter String 1 - Introducing WSAD 5.0 platform, Chapter String 2 - Setting language Up the Development Environment Chapter ) 3
- Working with the WSAD 5.0 Workbench
javax.ejb.CreateException Chapterthrows 4 - Developing Database Applications Part{Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
} 6 Chapter
- J2EE EJB Development
Chapter 7
- J2EE Web Development
public BookInquiryKey ejbFindByPrimaryKey(BookInquiryKey primaryKey) Chapter 8 - J2EE XML Development throws javax.ejb.FinderException Part Three - Working with Enterprise Messaging { Chapter 9 - J2EE Enterprise Messaging Connection dbCon = null; Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 - Using WebSphere MQ as the JMS Provider
PreparedStatement prepStm = null
Appendix A - Deploying This Book's J2EE Examples Index
;
catalogNumber = primaryKey.getPrimeKey();
List of Figures List of Tables try List of Code Examples { List of Sidebars dbCon = this
.getDBConnection();
prepStm = dbCon.prepareStatement("select CATALOG_NUMBER,AUTHOR,BOOK_TITLE,LOCATION,PLATFORM,LANGUAGE " + "from LIB.BOOK_CATALOG " + "where CATALOG_NUMBER=?"); prepStm.setString(1, catalogNumber); result = prepStm.executeQuery(); // Does the book exists if (result.next()) { author = result.getString("AUTHOR"); bookTitle = result.getString("BOOK_TITLE"); location = result.getString("LOCATION"); platform = result.getString("PLATFORM"); language = result.getString("LANGUAGE"); } } catch(SQLException sql) {
System.out.println("SQL Error. " + sql); WebSphere Studio Application Developer 5.0: Practical J2EE Development
try ISBN:1590591208 by Igor Livshin { Apress © 2003 (630 pages) if (prepStm != null ) This book provides a practical, step-by-step approach in prepStm.close(); teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed (dbCon != null) applications.
if dbCon.close(); } Table of Contents catch (SQLException se) WebSphere { Studio Application Developer 5.0: Practical J2EE Development Introduction // Ignore this exceptin Part One } - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0
Chapter 2
-throw Settingnew Up the EJBException("SQL Development Environmentcall failed " + sql);
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter}4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
finally Chapter 5 - J2EE Development Chapter{6
- J2EE EJB Development
Chapter 7
-try J2EE Web Development
{ - J2EE XML Development if (result != null ) Part Three - Working with Enterprise Messaging result.close(); Chapter 8 Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
if (prepStm != null) prepStm.close();
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index
if
(dbCon != null)
List of Figures dbCon.close(); List of Tables } List of Code Examples catch List of Sidebars {
(SQLException se)
se.printStackTrace(); } } // End of the finally statement return
primaryKey;
} public {
Vector bookActivityByCompany(String companyName) Connection dbCon = null; PreparedStatement prepStm = null; Vector vector = new Vector(); try { dbCon = this.getDBConnection();
prepStm = dbCon.prepareStatement("select BOOK_TITLE, TXN_DATE, TXN_TYPE, COMPANY_NAME " + "from LIB.BOOK_CATALOG, LIB.BOOK_ACTIVITY " + "where CATALOG_NUMBER=? and
CATALOG_NUMBER=BOOK_CAT_NUM"); WebSphere Studio Application Developer 5.0: Practical J2EE Development
prepStm.setString(1, companyName); by Igor Livshin result = prepStm.executeQuery(); Apress © 2003 (630 pages) while (result.next())
ISBN:1590591208
This book provides a practical, step-by-step approach in { teaching how to use the WebSphere Studio Application TransportBean = new TransportBean(); DevelopertransObject (WSAD) tool for developing J2EE distributed transObject.bookTitle = result.getString("BOOK_TITLE"); applications. transObject.txnDate = result.getString("TXN_DATE"); transObject.txnType = result.getString("TXN_TYPE"); Table of transObject.companyName Contents = result.getString("COMPANY_NAME"); WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction vector.addElement(transObject); Part One}- Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
-return Setting Upvector; the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4 } - Developing Database Applications
// End of the try statement
catch(SQLException Part Two - Working with J2EE: Thesql) Distributed Application Framework Chapter 5 { - J2EE Development
Error. " + sql); Chapter System.out.println("SQL 6 - J2EE EJB Development new call failed " + sql); Chapter throw 7 - J2EE Web EJBException("SQL Development Chapter 8
}
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
finally { Chapter 11 - Using WebSphere MQ as the JMS Provider try Appendix A - Deploying This Book's J2EE Examples { Index if (result != null) List of Figures result.close(); Chapter 10 - Using the WSAD-Embedded JMS Provider
List of Tables List of Code if Examples (prepStm != null List of Sidebars prepStm.close();
)
if (dbCon != null) dbCon.close(); } catch (SQLException se) { se.printStackTrace(); } } // End of the finally statement } // End of the method
public void {
ejbStore()
Connection dbCon = null ; PreparedStatement prepStm = null;
try
{ WebSphere Studio Application Developer 5.0: Practical J2EE Development
dbCon = this.getDBConnection(); by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
prepStm = dbCon.prepareStatement("update LIB.BOOK_CATALOG set AUTHOR = ?, This book a practical, in BOOK_TITLE = ?,provides LOCATION = ?,step-by-step PLATFORMapproach = ?, LANGUAGE = ?" + teaching how to use the WebSphere Studio Application "where CATALOG_NUMBER = for ?"); Developer (WSAD) tool developing J2EE distributed prepStm.setString(1, author); applications. prepStm.setString(2, bookTitle); prepStm.setString(3, location); Table of Contents prepStm.setString(4, platform); WebSphere Studio Application Developer 5.0: Practical J2EE Development prepStm.setString(5, language); Introduction prepStm.setString(6, catalogNumber); Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 Chapter { 2
-if Introducing WSAD 5.0 (prepStm.executeUpdate() != 1) - Setting Up the Development Environment
new with EJBException ("Faild ejbStore processing"); Chapter throw 3 - Working the WSAD 5.0 Workbench Chapter } 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 } - J2EE Development
// End of the try statement
sq) Chaptercatch(SQLException 6 - J2EE EJB Development Chapter 7 { - J2EE Web Development
System.out.println("SQL Error. " + sq); - J2EE XML Development throw new EJBException("SQL call failed " + sq); Part Three - Working with Enterprise Messaging } Chapter 8 Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
finally { Appendix A - Deploying This Book's J2EE Examples try Index { List of Figures if (result != null) List of Tables result.close();
Chapter 11 - Using WebSphere MQ as the JMS Provider
List of Code Examples List of Sidebars if (prepStm != null)
prepStm.close(); if (dbCon != null) dbCon.close(); } catch (SQLException se) { se.printStackTrace(); } } // End of the finally statement } // End of the method public void ejbLoad() { Connection dbCon = null ; PreparedStatement prepStm = null; String catalogNumber = (String)myEntityCtx.getPrimaryKey(); try { dbCon = this.getDBConnection();
prepStm = dbCon.prepareStatement("select AUTHOR, BOOK_TITLE, LOCATION, WebSphere Studio PLATFORM, LANGUAGE " +Application Developer 5.0: Practical J2EE Development "from LIB.BOOK_CATALOG " + ISBN:1590591208 by Igor Livshin "where CATALOG_NUMBER = ?"); Apress © 2003 (630 pages)
This book providescatalogNumber); a practical, step-by-step approach in prepStm.setString(1, teaching how to use the WebSphere Studio Application result = Developer prepStm.executeQuery(); (WSAD) tool for developing J2EE distributed applications.
if
(result.next()) {
Table of author Contents = result.getString("AUTHOR"); WebSphere Studio Application Developer 5.0: Practical J2EE Development bookTitle = result.getString("BOOK_TITLE"); Introduction location
= result.getString("LOCATION");
Part Oneplatform - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 = result.getString("PLATFORM");
Chapter language 1 - Introducing WSAD 5.0 = result.getString("LANGUAGE"); Chapter 2 } - Setting Up the Development Environment Chapterelse 3 - Working with the WSAD 5.0 Workbench Chapter 4 { - Developing Database Applications
throw with newJ2EE: The EJBException ("Faild ejbLoad Part Two - Working Distributed Application Framework
processing");
Chapter 5 } - J2EE Development Chapter 6
- J2EE EJB Development
} 7 Chapter
// End of the try statement - J2EE Web Development catch (SQLException sq) Chapter 8 - J2EE XML Development { Part Three - Working with Enterprise Messaging System.out.println("SQL Error. " + sq); Chapter 9 - J2EE Enterprise Messaging throw new EJBException("SQL call failed " + sq); Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 - Using WebSphere MQ as the JMS Provider
}
Appendix A - Deploying This Book's J2EE Examples Index finally List { of Figures List of Tables try List of Code { Examples List of Sidebars if (result != null)
result.close(); if (prepStm != null prepStm.close();
)
if (dbCon != null) dbCon.close(); } catch (SQLException se) { se.printStackTrace(); } // End of the finally statement } public javax.ejb.EntityContext getEntityContext() { return myEntityCtx; } public void
setEntityContext(javax.ejb.EntityContext ctx)
{ WebSphere myEntityCtx = ctx;Studio Application Developer 5.0: Practical J2EE Development
}
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
public void unsetEntityContext() This book provides a practical, step-by-step approach in { teaching how to use the WebSphere Studio Application myEntityCtx = null ; for developing J2EE distributed Developer (WSAD) tool } applications. public void
ejbActivate()
Table{ of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development } Introduction Part One - Getting with WebSphere Studio Application Developer (WSAD) 5.0 public void Started ejbPassivate()
Chapter { 1
- Introducing WSAD 5.0
Chapter } 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench public ejbRemove() Chapter 4 void - Developing Database throws Applicationsjavax.ejb.RemoveException Part{Two - Working with J2EE: The Distributed Application Framework
Chapter 5
dbCon = null; -Connection J2EE Development
Chapter 6
-PreparedStatement J2EE EJB Development prepStm = null;
Chapter 7
catalogNumber = (String)myEntityCtx.getPrimaryKey(); -String J2EE Web Development
Chapter 8
- J2EE XML Development
try {
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
dbCon = this.getDBConnection();
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index
prepStm = dbCon.prepareStatement("delete from LIB.BOOK_CATALOG where CATALOG_NUMBER = ?");
List of Figures List of TablesprepStm.setString(1, catalogNumber); List of Code Examples List of Sidebars if
(prepStm.executeUpdate() != 1)
{ throw new }
EJBException ("Faild ejbRemove processing");
} // End of the try statement catch(SQLException sq) { System.out.println("SQL Error. " + sq); throw new EJBException("SQL call failed " + sq); } finally { try { if (result != null) result.close(); if (prepStm != null) prepStm.close();
if (dbCon != null) WebSphere Studio Application Developer 5.0: Practical dbCon.close(); J2EE Development } ISBN:1590591208 by Igor Livshin catch (SQLException se) Apress © 2003 (630 pages) { This book provides a practical, step-by-step approach in se.printStackTrace(); teaching how to use the WebSphere Studio Application } Developer (WSAD) tool for developing J2EE distributed applications.
} // End of the finally statement Table } of Contents WebSphere Application getDBConnection() Developer 5.0: Practical J2EE Development private Studio Connection throws SQLException Introduction { Part One -try Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
-{ Introducing WSAD 5.0
Chapter InitialContext 2 - Setting Up the Development jndiContext Environment = new InitialContext();
dataSource = Workbench Chapter DataSource 3 - Working with the WSAD 5.0 Chapter (DataSource)jndiContext.lookup("java:comp/env/jdbc/TECHBOOK"); 4 - Developing Database Applications
dataSource = (DataSource)jndiContext.lookup("jdbc/TECHBOOK"); Part Two//DataSource - Working with J2EE: The Distributed Application Framework Chapter 5
- J2EE Development dataSource.getConnection(); Chapter return 6 - J2EE EJB Development -} J2EE Web Development catch(NamingException ne) Chapter 8 - J2EE XML Development { Part Three - Working with Enterprise Messaging System.out.println("Error locating jdbc/TECHBOOK: " + Chapter 7
Chapter 9
- J2EE Enterprise Messaging
ne.getMessage());
Chapter 10 - Using the WSAD-Embedded JMS Provider
throw new }
EJBException(ne);
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index } List of Figures List of } Tables List of Code Examples List of Sidebars
Listing 6-11 shows the source code for the BookInquiryHome interface. Listing 6-11. BookInquiryHome.java:Home Interface Class package
apress.wsad.techlib;
public interface {
BookInquiryHomeextends
javax.ejb.EJBHome
public BookInquiry create() throws javax.ejb.CreateException, java.rmi.RemoteException;
public BookInquiry create(String catalogNumber, String author, String bookTitle, String location, String platform, String language ) throws javax.ejb.CreateException, java.rmi.RemoteException;
public BookInquiry findByPrimaryKey(BookInquiryKey primaryKey) WebSphere Studio Application Developer 5.0: Practical throws javax.ejb.FinderException, java.rmi.RemoteException; J2EE Development } by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This provides practical, step-by-step approach Listing 6-12 shows thebook source code afor the BookInquiry Remote inInterface. teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
isting 6-12. BookInquiry.java:Remote Interface Class Table of Contents
package
apress.wsad.techlib;
WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction import
java.util.Vector;
Part One - Getting Started with WebSphereextends Studio Application Developer (WSAD) 5.0 public interface BookInquiry javax.ejb.EJBObject
Chapter 1 {
- Introducing WSAD 5.0
Chapter 2 - Setting Up the Development Environment public Vector bookActivityByCompany(String companyName) Chapterthrows 3 - Working with the WSAD 5.0 Workbench java.rmi.RemoteException; Chapter } 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development Listing 66-13- shows theDevelopment source code for the BookInquiryKey Primary Key class. Chapter J2EE EJB Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Listing 6-13. BookInquiryKey.java:Primary Key Class
Part Three - Working with Enterprise Messaging
package Chapter 9 - J2EEapress.wsad.techlib; Enterprise Messaging public BookInquiryKey Chapter 10 class - Using the WSAD-Embeddedimplements JMS Provider
java.io.Serializable { Chapter 11 - Using WebSphere MQ as the JMS Provider static final long serialVersionUID = 3206093459760846163L; Appendix A - Deploying This Book's J2EE Examples Index
// Primary key public String catalogNumber; List of Tables public BookInquiryKey() List of Code Examples { List of Sidebars } List of Figures
public BookInquiryKey(String catalogNumber) { this.catalogNumber = catalogNumber; } public { return }
String getPrimeKey() catalogNumber;
public boolean equals(java.lang.Object otherKey) { if (otherKeyinstanceof apress.wsad.techlib.BookInquiryKey) { apress.wsad.techlib.BookInquiryKey o = (apress.wsad.techlib.BookInquiryKey) otherKey; return (super.equals(otherKey)); } return false; }
public int hashCode() WebSphere Studio Application Developer 5.0: Practical { J2EE Development return (super.hashCode()); ISBN:1590591208 by Igor Livshin } Apress © 2003 (630 pages)
}
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed Notice that withinapplications. a BMP entity bean you do not save the database connection for subsequent reuse; instead, you close i
connection is simply returned to the pool. Another reason for this is that you never know when the next call to the entity b
Nowof you need to promote the getBookActivity method to the Remote Interface. With BookInquiryBean.java open in the J Table Contents
Promoteto Remote Interface. Validate5.0: thePractical bean. Right-click the TechLibEJB project and select Run Validation. There s WebSphere Studio Application Developer J2EE Development
Generate > Deploy and RMIC code. On the dialog that appears, select the BookInquiry module. Click Finish. There shou Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Next, check that the JNDI name for your bean is assigned correctly (ejb/BookInquiry)and that the BMP bean is corr - Introducing WSAD 5.0 OpenWith > Deployment Descriptor Editor. Select the Overview tab, click the BookInquiry bean and make sure that the J Chapter 2 - Setting Up the Development Environment in the JNDI name field (see Figure 6-39). Chapter 1 Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 6-39: The Deployment Descriptor “WebSphere Bindings” section
Next, click the Referencestab. Select BookInquiryand click the Addbutton. On the next screen, select EJB resour Namefield, select javax.sql.DataSourcefor the Type field, select Application for the Authentication field, and select
Figure 6-40: Setting the Datasourcereference
WebSphere Studio Application Developer 5.0: Practical
J2EE Development Expand BookInquiry and click ResourceRef TechbookDS. You should see that a new ResourceReferenceentry by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2 - 6-41: Setting Up the Development Figure Setting the JNDI nameEnvironment for the Datasourceresource Chapter 3
- Working with the WSAD 5.0 Workbench
Finally,4save the results Database and closeApplications the Editor View. Chapter - Developing Part Two - Working with J2EE: The Distributed Application Framework
Testing Beans Chapter 5 -BMP J2EE Entity Development Chapter 6
- J2EE EJB Development
To test the BMP entity beans, switch to the Server Perspective. In the Servers View, right-click TectLibTestServer and se - J2EE Web Development You should see a set of messages informing you that the server is starting. Wait until you see a message that the server Chapter 8 - J2EE XML Development select Run on Server. The IBM Universal Test Client will appear. Chapter 7
Part Three - Working with Enterprise Messaging
Chapter 9 -Explorer. J2EE Enterprise Messaging Click JNDI The JNDI Explorer screen will appear. Expand the ejb entry (which is the naming subcontext for EJB Chapter 10 - and Using the expand WSAD-Embedded JMS Provider BookInquiry then BookInquiryHome. At that point, you should see the create and FindByPrimaryKeyHome In
Chapter parameters. 11 - Using Enter WebSphere 00031 as the MQbookCatalogNumber, as the JMS Provider Bob Quinn as the author, Windows Sockets Network Programmin Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 6-42: Executing the createmethod
Figure 6-43 shows the processing result of the DB2 command that displays all records in the Book_CATALOG table. Yo
Figure 6-43: The result of the DB2 command execution
WebSphere Studio Application Developer 5.0: Practical
J2EE Development Next, click the findByPrimaryKey method. You are prompted to enter the catalog number parameter. Enter 00001 (see F by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Figure TestingWSAD a BMP Chapter 1 - 6-44: Introducing 5.0entity bean Chapter 2
- Setting Up the Development Environment
Click Invoke. Click Work with Object. A second object will appear under References. Expand it all the way down. You sh - Working with the WSAD 5.0 Workbench argument—the book’s Catalog_Number. Enter 00001. Click Invoke. Click Work with Objects. Two TransferBean objects Chapter 4 - Developing Database getCompanyName method. ClickApplications Invoke. Click Work with Object. The “AAA_Company” company will be displayed (see Chapter 3
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples IndexFigure 6-45: The result of executing the getCompanyNamemethod List of Figures
Close the Browser View and stop the server. This concludes the BMP entity bean development example. List of Tables List of Code Examples List of Sidebars
Application Developer 5.0: Practical DevelopingWebSphere SessionStudio Beans J2EE Development
ISBN:1590591208 bywill Igor Livshin both types of session beans: stateless In this section, you develop and stateful session beans. The Apress © 2003 (630 pages)beans is similar in regards to the tools used and steps that need to be development of both types of session performed. Even This the generated code looks similar. However, their lifein cycle is different, and the way they book provides a practical, step-by-step approach teaching how to use the WebSphere Studio Application perform at runtime is substantially different. Stateless beans are selected from a pool to serve a client for the Developer (WSAD) After tool for developing distributed duration of one method execution. that, they are J2EE returned to the pool that is waiting to serve another client applications. request (again to execute one method only). They do not remember any state between method invocations. In comparison with other beans, stateless beans consume the smallest amount of system resources and are the bestof performers. Table Contents
WebSphere Studio Application Developer 5.0: Practical J2EE Development
On the other hand, stateful session beans are attached to a specific client for the duration of the client session (conversation), which typically involves multiple screens and multiple invocations of the stateful bean's methods. Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 Stateful beans can be temporarily swapped out of memory (passivation) and subsequently brought back in Chapter 1 - Introducing WSAD 5.0 (activation) by the container, but they always maintain the state between multiple method invocations. You will Chapter 2 - Setting Up the Development Environment start with the session bean development example from the stateless session bean section. Introduction
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Developing Stateless Session Beans
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development The stateless session bean you will develop is called TechLibFacade.TheTechLibFacadesession bean - J2EE EJB Development will implement one business method called getBookForPlatform that should be accessible via Remote and Chapter 7 - J2EE This Web method Development Local Interfaces. will return all books written for the platform requested by the user. To perform Chapter 8 - J2EEit XML Development this processing, will call local methods of the previously developed entity beans. This technique of wrapping Part Three - Working with Enterprise Messaging entity beans by a session bean substantially improves the application performance. Chapter 6
Chapter 9
- J2EE Enterprise Messaging Note thisthe technique is especially Chapter 10 Using - Using WSAD-Embedded JMS important Provider for working with entity beans that expose a Remote
for the EJBMQ clients; therefore, each call is a network call. For entity beans that expose the Chapter 11 Interface - Using WebSphere as the JMS Provider Interface forBook's the EJB client, this method is less useful for improving application performance, Appendix A Local - Deploying This J2EE Examples but it is still a good development pattern because it provides a more structural organization of the developed application. List of Figures Index
List of this Tables With quick introduction, let's start developing this project. You will do the TechLibFacade session bean List of Code Examples development under the same TechLibEJB project. Switch to the J2EE View of the J2EE Perspective. Right-click List Sidebars theofTechLibEJB project and select New > Enterprise Bean. On the next screen, confirm the project selection
and click Next. On the following screen, select the Session bean type. Enter TechLibFacade as the bean name. Leave the Source folder field as ejbModule, and set the default package name to apress.wsad.techlib (see Figure 6-46).
Figure 6-46: TheCreate an Enterprise Bean screen Click Next. On the subsequent screen, make sure the stateless bean type and the Remote Client Views are selected. Click Finish. WSAD will generate the TechLibFacade stateless session bean classes. In the J2EE
View, you should see the generated classes for the TechLibFacade session bean: WebSphere Studio Application Developer 5.0: Practical
J2EE Development TechLibFacadeBean: The session bean implementation class by Igor Livshin
ISBN:1590591208
TechLibFacadeHome: Apress © 2003 The (630 session pages) bean Remote Home Interfaces This book provides a practical, step-by-step approach in
TechLibFacade: The how session bean Interfaces teaching to use theRemote WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed
Make sure you are in the J2EE Hierarchy View of the J2EE Perspective. Right-click the TechLibEJBproject applications. and select Open With > Deployment Descriptor Editor. On the next screen, find the 'WebSphere Bindings' section. Make sure that TechLibFacade is highlighted and enter ejb/TechLibFacade in the JNDI name Table Contents field of (see Figure 6-47). WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
Figure 6-47: Setting the JNDI name for TechLibFacade
Index
List of Figures List of Tables Next, click the References tab. On the screen that appears, click the Add button. On the next dialog, select the List EJB of local Code reference Examples option because this session bean will be calling the Book_catalog entity bean (see Figure
6-48). List of Sidebars
Figure 6-48: TheEnterprise Bean Details screen Click Next. On the next screen, click the Browsebutton located next to the Linkfield and select the Book_catalog entity bean. Based on the selected Link field, all other field will be filled in already. Change the Name field's prefilled value ejb/Book_catalog to Book_catalog (see Figure 6-49).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench Figure TheAdd EJB Local Reference screen Chapter 4 - 6-49: Developing Database Applications Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 You - J2EE canDevelopment always use the Linkfield for the EJB reference to the beans located within the same Note Chapter 6 project. - J2EE EJB Development Chapter 7
- J2EE Web Development
Click Finish. Expand TechLibFacadeand click EJB local ref EJB Book_catalog. You should see Chapter 8 - J2EE XML Development all corresponding fields with values. Change the Name field by replacing the ejb/Book_catalog value with Part Three - Working withfilled Enterprise Messaging Book_catalog (see Figure 6-50). Chapter 9 - J2EE Enterprise Messaging Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 6-50: Setting EJB references Save the results and close the EJB Deployment Descriptor Editor. WSAD has generated only the skeletons of the TechLibFacade classes. Now, you need to add the necessary business methods. The session bean is the EJB module where the business logic should be implemented. Open the TechLibFacadeBean implementation class in the Java Editor. You will add one helper method called getCatalogLocalHome, which returns the local reference to the TechLibBook_catalog entity bean object, and a business method called getBookByPlatform (in addition to several variables and import statements to support these methods). Listing 6-14 shows the source code for the TechLibFacadeBean session bean. Listing 6-14. TechLibFacadeBean.java:Implementation Class package apress.wsad.techlib; import javax.ejb.*; import javax.naming.*; import javax.rmi.*; import java.rmi.*; import java.lang.*; import java.util.*;
public class TechLibFacadeBeanimplements javax.ejb.SessionBean WebSphere Studio Application Developer 5.0: Practical { J2EE Development private javax.ejb.SessionContext mySessionCtx; by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
// Variable to keep the Home Local refernce to TechLibBook_catalog object This book provides a practical, step-by-step approach in private TechLibBook_catalogLocalHome catalogLocalHome = null ; teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed // Method to get the Home Interface of the Book_catalog entity bean. applications.
private TechLibBook_catalogLocalHome getCatalogLocalHome() throws RemoteException Table of { Contents WebSphere tryStudio Application Developer 5.0: Practical J2EE Development Introduction { Part Oneif - Getting Started with WebSphere (catalogLocalHome == Studio null)Application Developer (WSAD) 5.0 Chapter { 1 - Introducing WSAD 5.0 Chapter 2
- Setting Up the Development Environment initContext = new Chapter InitialContext 3 - Working with the WSAD 5.0 Workbench Chapter 4
InitialContext();
- Developing Database Applications
objRef = The Distributed Application Framework Part TwoObject - Working with J2EE: Chapter initContext.lookup("java:comp/env/Book_catalog"); 5 - J2EE Development
= (TechLibBook_catalogLocalHome) objRef; Chapter catalogLocalHome 6 - J2EE EJB Development (TechLibBook_catalogLocalHome) objRef; Chapter return 7 - J2EE Web Development } - J2EE XML Development else Part Three - Working with Enterprise Messaging { Chapter 9 - J2EE Enterprise Messaging return catalogLocalHome; Chapter 10 - Using the WSAD-Embedded JMS Provider } Chapter 11 - Using WebSphere MQ as the JMS Provider } Appendix A - Deploying This Book's J2EE Examples catch (NamingException ne) Index { List of Figures System.out.println("Error locating TechLibBook_catalogLocalHome: " + List of Tables ne.getMessage()); List of Code Examples throw List of Sidebars new RemoteException("Error locating TechLibBook_catalogLocalHome: " + ne.getMessage()); } } Chapter 8
// This business method must be promoted to the remote interface public Vector getBookForPlatform(String workPlatform) throws FinderException { Vector bookVector = new Vector(); TransportBean transObject; TechLibBook_catalogLocal bookCatalogLocal = null; Collection collBookRecords; try { collBookRecords = getCatalogLocalHome().findByPlatform(workPlatform); Iterator iterator = collBookRecords.iterator(); while (iterator.hasNext()) { bookCatalogLocal =
(TechLibBook_catalogLocal) iterator.next(); WebSphere Studio Application Developer 5.0: Practical J2EE Development
transObject = new
TransportBean();
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
transObject.catalogNumber = bookCatalogLocal.getCatalog_number(); This book provides a practical,=step-by-step approach in transObject.author bookCatalogLocal.getAuthor(); teaching how to use the WebSphere Studio Application transObject.bookTitle bookCatalogLocal.getBook_title(); Developer (WSAD) tool for developing=J2EE distributed transObject.location = bookCatalogLocal.getLocation(); applications. transObject.platform = bookCatalogLocal.getPlatform(); transObject.txnDate = bookCatalogLocal.getLanguage(); Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development bookVector.addElement(transObject); Introduction } // End of while Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 } -// Introducing End of WSAD try 5.0 Chaptercatch(FinderException 2 - Setting Up the Development fe)Environment Chapter 3 { - Working with the WSAD 5.0 Workbench
executing findByPlatform method: " + Chapter System.out.println("Error 4 - Developing Database Applications Part Twofe.getMessage()); - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development Chapter throw 6 - J2EE EJB Development
EJBException("Error executing findByPlatform method: " + Chapter new 7 - J2EE Web Development fe.getMessage()); - J2EE XML Development } Part Three - Working with Enterprise Messaging Chapter 8 Chapter 9
- J2EE Enterprise Messaging
catch(Exception e) { Chapter 11 - Using WebSphere MQ as the JMS Provider System.out.println("Error getting TechLibBook_catalogLocalHome from Appendix A - Deploying This Book's J2EE Examples findByPlatform method:" + e.getMessage()); Index throw List of Figures new EJBException("Error getting TechLibBook_catalogLocalHome from List of Tables findByPlatform method:" + e.getMessage()); List of Code } Examples List of Sidebars return bookVector; } Chapter 10 - Using the WSAD-Embedded JMS Provider
public
javax.ejb.SessionContext getSessionContext()
{ return
mySessionCtx;
} public void setSessionContext(javax.ejb.SessionContext ctx) { mySessionCtx = ctx; } /** * ejbCreate */ public void ejbCreate()throws javax.ejb.CreateException { } public void ejbActivate() { }
public void
ejbPassivate()
WebSphere Studio Application Developer 5.0: Practical J2EE Development
{ }
by Igor Livshin ejbRemove() Apress © 2003 (630 pages)
public void { } }
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Listing 6-15 shows the source code for the TechLibFacade Home interface. Table of Contents
Listing 6-15. TechLibFacadeHome.java: HomeJ2EE Interface Class WebSphere Studio Application Developer 5.0: Practical Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 package apress.wsad.techlib;
Chapter 1 interface - Introducing WSAD 5.0 public TechLibFacadeHome extends Chapter 2 - Setting Up the Development Environment {
javax.ejb.EJBHome
Chapterpublic 3 - Working with the WSAD 5.0 Workbench apress.wsad.techlib.TechLibFacade create() Chapter throws 4 -javax.ejb.CreateException, Developing Database Applications java.rmi.RemoteException; Part } Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development Listing 76-16- shows the Development source code for the TechLibFacade Remote Interface. Chapter J2EE Web Chapter 8
- J2EE XML Development
Listing 6-16. TechLibFacade.java:Remote Interface Class
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging package Chapter 10 - apress.wsad.techlib; Using the WSAD-Embedded JMS Provider
import Chapter 11 -javax.ejb.FinderException; Using WebSphere MQ as the JMS Provider import java.util.Vector; /** Index * Remote interface for Enterprise Bean: TechLibFacade List of Figures */ List of Tables public interface TechLibFacadeextends javax.ejb.EJBObject List of Code Examples { List Sidebars //ofThis business method must be promoted to the remote interface public Vector getBookForPlatform(String workPlatform) throws FinderException, java.rmi.RemoteException; } Appendix A - Deploying This Book's J2EE Examples
Listing 6-17 shows the source code for the TechLibFacadeLocalHome Local Home Interface. Listing 6-17. TechLibFacadeLocalHome.java:Local Home Interface package apress.wsad.techlib; /** * Local Home interface for Enterprise Bean: TechLibFacade */ public interface TechLibFacadeLocalHomeextends javax.ejb.EJBLocalHome { /** * Creates a default instance of Session Bean: TechLibFacade */ public apress.wsad.techlib.TechLibFacadeLocal create() throws javax.ejb.CreateException; }
WebSphere Application Developer 5.0:Local Practical Listing 6-18 shows the sourceStudio code for the TechLibFacadeLocal Interface. J2EE Development
Listing 6-18. TechLibFacadeLocal.java: Local InterfaceISBN:1590591208 by Igor Livshin Apress © 2003 (630 pages) This book provides a practical, step-by-step approach in package apress.wsad.techlib; teaching how to use the WebSphere Studio Application import javax.ejb.FinderException; Developer (WSAD) tool for developing J2EE distributed import java.util.Vector; applications.
/** Table* of Contents Local interface for Enterprise Bean: TechLibFacade WebSphere Studio Application Developer 5.0: Practical J2EE Development Chapter 6 */ Introduction public interface
TechLibFacadeLocalextends
javax.ejb.EJBLocalObject
Part { One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter// 1 This - Introducing WSAD 5.0 business method must be promoted to the remote interface Chapterpublic 2 - Setting Vector Up the getBookForPlatform(String Development Environment workPlatform)
FinderException; Chapter throws 3 - Working with the WSAD 5.0 Workbench } Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
After making all the necessary source code modifications, you need to promote the getBookForPlatform - J2EE EJB Development method to the Remote and Local Interfaces. This will allow EJB clients to call the method locally and remotely. Chapter 7 - J2EE Web Development With the TechLibFacadeBeanimplementation class still open in the Java Editor, right-click the Chapter 8 - J2EE XML Development getBookForPlatform method and select Enterprise Bean > Promote to Remote Interface. Repeat the same step Part Three - Working with Enterprise Messaging and promote the same method to the Local Interface. Chapter 6
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 an - Using the WSAD-Embedded JMS Provider If you get error message after promotion, all you need to is to include the following import statement in the Chapter 11 Using WebSphere MQ as the TechLibFacade Remote Interface class:JMS Provider Appendix - Deploying This Book's J2EE Examples importA java.util.*; Index List Save of Figures the change and the error message will disappear. Next, validate the project. Right-click the TechLibEJB
project and select Run Validation. There should be no errors. Next, generate the deployment code. Right-click List of Tables theofTechLibEJB project, and select Generate > Deploy and RMIC code. On the dialog that appears, select the List Code Examples TechLibFacade module (see Figure 6-51). List of Sidebars
Figure 6-51: Generating deployment code Click Finish. There should be no errors after the end of the generation process.
Testing the Stateless Session Bean
You are ready to test the TechLibFacadesession bean. Switch to the Server Perspective and start WebSphere Developer 5.0:Perspective. Practical Right-click the TechLibEJB TechLibTestServer. Wait Studio until it isApplication ready. Switch to the J2EE J2EE Development project and select Run on server. The IBM Universal Test Client's main screen will appear. Click JNDI ISBN:1590591208 by Igor Livshin Explorer. Expand Local EJB beans all the way down. You should see the TechLibFacademodule in Apress © 2003 (630 pages) the list. Now, expand another ejbentry located below Local EJB beans. This entry keeps components with This book provides a practical, approach in module here also. That's because the Remote Client View. Expand ejb. You will step-by-step see the TechLibFacade teaching how to use the WebSphere Studio Application theTechLibFacade module exposes the Remote anddistributed the Local Client View. Therefore, in real-life Developer (WSAD) toolboth for developing J2EE development, youapplications. should remember to test both interfaces. In this section, you will test the Remote Client View. Click the TechLibFacadeentry under Local EJB beans. The screen shown in Figure 6-52 will appear. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Figure Test Client Chapter 8 - 6-52: J2EE The XML Universal Development Part Three - Working with Enterprise Messaging
Expand the Local EJB beans naming context all the way down. You should see Book_activityand - J2EE Enterprise Messaging Book_catalog entity beans because they are developed with the Local Client Views. Expand the ejb Chapter 10 - Using WSAD-Embedded JMS Provider naming context forthe modules with the Remote Client Interface. Here you will see the TechLibFacadesession Chapter 11 Using WebSphere MQ as the JMSinProvider bean. Click it. TechLibFacadewill appear the Referencessection. Expand TechLibFacadein the Appendix A - section Deploying Book's J2EE Examples References all This the way down until you see available the Home Interface methods. Notice that you have Index only one default (with no parameters) create method. Click the create method to create an instance of the List of Figures session bean object. On the next screen, click the Invoke button. Then click the Work with Object button. The List of Tables TechLibFacade reference object (named TechLibFacade 1) will appear (see Figure 6-53). Chapter 9
List of Code Examples List of Sidebars
Figure 6-53: Home Interface of the session bean Expand the TechLibFacade 1 object to see all the Interface methods and click getBookByPlatform. You are prompted to enter the value for the Platform parameter. Enter 04, which means the Windows NT/2000 platform. Click Invoke. Because getBookByPlatform returns a vector of TransferBean objects, a new button appears on the screen called Work with Ojects. Click this button to get all returned object references in the References area of the screen. You will see five object references appear under References (see Figure 6-54).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Figure 6-54: A collection of object references is returned Table of Contents
Expand theStudio first one. You willDeveloper see all available getter/setter methods of the TransferBeanobject. Click the WebSphere Application 5.0: Practical J2EE Development getAuthormethod. Click Invoke. Click Work with Object. You will see the author 'Developer Journal' Introduction appear the Parameters section (see Figure 6-55). Part One in - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Figure 6-55: The result of executing the getAuthormethod
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11getBookTitle - Using WebSphere as the JMS Provider Click the method.MQ Click Invoke. Click Work with Object. You will see the 'Windows NT Appendix A Deploying This Book's J2EE Examples Programming' title appear next (see Figure 6-56). Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 6-56: The result of executing the getTitlemethod Expand the last object and click the getAuthormethod. Click Invoke. Click Workwith Object. The name 'Kevin Miller' is displayed. You can check the rest of the return objects. Close the Browser View and stop the server. This concludes development of the TechLibFacade session bean EJB module.
Developing Stateful Session Beans In this section, you will develop a stateful session bean called TechLibFacade1. The TechLibFacade1 stateful session bean will have two business methods: getBookByPlatform and getBookActivity. Both methods will be promoted to the Local Interface to expose the methods to EJB clients. The main idea is to show that the state of the stateful session bean is maintained between different method invocations. With this quick introduction, let's start development. You will do the TechLibFacade1 session bean development under the same TechLibEJB project. Switch to the J2EE View of the J2EE Perspective. Right-click the TechLibEJB project and select New > Enterprise Bean. Alternatively, you can click the Create an Enterprise Bean icon on the toolbar. Confirm the TechLibEJB project,
and on the next screen, select the session bean as the bean type. Enter TechLibFacade1 as the bean name. Studio Application Developer 5.0: Practical Leave the SourceWebSphere folder as ejbModule, and set the default package name to apress.wsad.testlib. Click Next. J2EE Development
ISBN:1590591208 by Igor Livshin On the next screen, select Statefulas a session bean type, check Local client view and uncheck Apress © 2003 (630 pages) Remote client view. Click Finish. WSAD will generate the necessary classes for the TechLibFacade1 stateful This book provides a practical, step-by-stepclass), approach in session bean: TechLibFacade1Bean (the implementation TechLibFacade1LocalHome (the Local Home teaching how to use the WebSphere Studio Application Interface class), and TechLibFacade1Local (the Local Interface class).
Developer (WSAD) tool for developing J2EE distributed applications.
Because the TechLibFacade1 stateful session bean calls both entity beans (Book_catalog and Book_activity), you need to reflect this in the Deployment Descriptor. In the J2EE Navigator View, right-click the TechLibEJB project and select Open With > Deployment Descriptor Editor. Highlight the TechLibFacade1 Table of Contents module, 'WebSphere Bindings' enter ejb/TechLibFacade1in the JNDIname field WebSpherelocate Studiothe Application Developer 5.0: section Practicaland J2EE Development (see Figure 6-57). Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Figure theMessaging JNDI name for TechLibFacade1 Chapter 9 - 6-57: J2EE Setting Enterprise Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11References - Using WebSphere MQ asTechLibFacade1 the JMS Provider and click the Add button. On the dialog that appears, Click the tab. Highlight Appendix A Deploying This Book's J2EE select the EJB local reference and clickExamples Next. On the next screen, click the Browse button that is attached to the Index Link field and select Book_Catalog. Click OK, which sends you back to the original screen. The rest of the fields List willofbeFigures prefilled. Change ejb/Book_catalog to Book_catalog in the Name field. List of Tables
Repeat theExamples same steps for the Book_activity entity bean. When you are done, your Deployment Descriptor List of Code screen should look like Figure 6-58.
List of Sidebars
Figure 6-58: Setting the second EJB references for TechLibFacade1 Save the results and close the editor. Double-click the TechLibFacade1Bean implementation class to open it in the Java Editor View. You will now borrow some code from the previously developed stateless session bean TechLibFacade. Open the TechLibFacadeBean implementation class in the Java Editor. Switching between them (by clicking their titles on the editor bar), copy the existing code from TechLibFacadeBean and paste it into the new TechLibFacade1Bean class. Copy and paste the following code fragments: all import statements and code located between the class statement and the first getter method called getSessionContext. Paste this code right after the class statement. Create a new activityLocalHome variable (similar to the catalogLocalHome variable) to keep the Home Local reference to the TechLibBook_activity object. Next, create a new getActivityLocalHome method (similar to the getCatalogLocalHome method) to get the value for the
activityLocalHome variable. Create a new method called initStateVariables. This method calls the WebSphere Studio Application Developer 5.0: Practical getCatalogLocalHome and getActivityLocalHome methods to obtain the Local Home Interfaces for both the J2EE Development Book_catalog and Book_activity entity beans. Create a new getBookActivity method (similar to the ISBN:1590591208 by Igor Livshin getBookByPlatform method but for processing the findByBook method). Apress © 2003 (630 pages)
This provides a practical, step-by-step approach Listing 6-19 depicts a book fragment of the TechLibFacade1Bean file that in shows the two variables and four methods teaching how to use the WebSphere Studio Application discussed previously. Developer (WSAD) tool for developing J2EE distributed applications.
Listing 6-19. Fragments of New Methods
// Variable to keep the Home Local refernce to TechLibBook_catalog object Table of Contents TechLibBook_catalogLocalHome catalogLocalHome = null; private WebSphere Application 5.0:Home Practical J2EE Development //Studio Variable to Developer keep the Local refernce to TechLibBook_activity object Introduction private TechLibBook_activityLocalHome activityLocalHome = null; Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 //- Helper Introducing WSAD 5.0 method to get the LocalInterface of the Book_catalog entity bean. Chapter private 2 - TechLibBook_catalogLocalHome Setting Up the Development Environment getCatalogLocalHome()
throws RemoteException Chapter 3 - Working with the WSAD 5.0 Workbench { 4 Chapter
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter try 5 - J2EE Development Chapter { 6
- J2EE EJB Development Chapter if 7 - (catalogLocalHome J2EE Web Development == null)
{
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
InitialContext initContext = new
Chapter 9
- J2EE Enterprise Messaging
InitialContext();
Chapter 10 - Using the WSAD-Embedded JMS Provider
Object objRef = initContext.lookup("java:comp/env/Book_catalog");
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index
catalogLocalHome = (TechLibBook_catalogLocalHome) objRef;
List of Figures List of Tables return
(TechLibBook_catalogLocalHome) objRef;
List of Code Examples List of Sidebars }
else { return }
catalogLocalHome;
} catch (NamingException ne) { System.out.println("Error locating TechLibBook_catalogLocalHome: " + throw new RemoteException("Error locating TechLibBook_catalogLocalHome: " + } } // Helper method to get the LocalInterface of the Book_activity entity bean. private TechLibBook_activityLocalHome getActivityLocalHome() throws RemoteException { try
{ WebSphere Studio Application if (activityLocalHome == null)Developer 5.0: Practical J2EE Development { ISBN:1590591208 by Igor Livshin InitialContext initContext = new InitialContext(); Apress © 2003 (630 pages)
This book =provides a practical, step-by-step approach in Object objRef teaching how to use the WebSphere Studio Application initContext.lookup("java:comp/env/Book_activity"); Developer (WSAD) tool for developing J2EE distributed applications.
activityLocalHome = (TechLibBook_activityLocalHome) objRef; Table of return Contents (TechLibBook_activityLocalHome) objRef; WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction } Part Oneelse - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter { 1
- Introducing WSAD 5.0
Chapter return 2 - Setting activityLocalHome; Up the Development Environment Chapter } 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two}- Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development ne) Chapter catch 6 - J2EE(NamingException EJB Development Chapter { 7
- J2EE Web Development
System.out.println("Error locating TechLibBook_activityLocalHome: " + Chapter 8 - J2EE XML Development ne.getMessage()); Part Three - Working with Enterprise Messaging throw new Chapter 9 - J2EE Enterprise Messaging RemoteException("Error locating TechLibBook_activityLocalHome: " + Chapter 10 - Using the WSAD-Embedded JMS Provider ne.getMessage()); Chapter 11 - Using WebSphere MQ as the JMS Provider } Appendix A - Deploying This Book's J2EE Examples } Index List Figures //ofBusiness helper method. Must be promoted to the local interface List of Tables public void initStateVariables() List of Code Examples throws
FinderException
List of { Sidebars
try { // Calculate catalogLocalHome and activityLocalHome variables getCatalogLocalHome(); getActivityLocalHome();
} // End of try catch(Exception e) { System.out.println("Error executing findByPlatform WITHIN getBookByPlatform:" + e.getMessage()); throw new EJBException("Error executing findByPlatform WITHIN getBookByPlatform:" + e.getMessage()); } }
// Business method WebSphere Studio Application Developer 5.0: Practical public Vector getBookForPlatform(String workPlatform) J2EE Development throws FinderException ISBN:1590591208 by Igor Livshin { Apress © 2003 (630 pages) Vector bookVector = new Vector(); This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application TransportBean transObject; Developer (WSAD) tool for developing J2EE distributed TechLibBook_catalogLocal bookCatalogLocal = null; applications.
Collection collBookRecords; try Table of Contents { WebSphere Studio Application Developer 5.0: Practical J2EE Development collBookRecords = Introduction catalogLocalHome.findByPlatform(workPlatform); Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 Chapter 2
-Iterator Introducingiterator WSAD 5.0 = collBookRecords.iterator(); - Setting Up the Development Environment
Chapter 3
-while Working (iterator.hasNext()) with the WSAD 5.0 Workbench
Chapter { 4
- Developing Database Applications
= Distributed Application Framework Part TwobookCatalogLocal - Working with J2EE: The iterator.next(); Chapter (TechLibBook_catalogLocal) 5 - J2EE Development Chapter 6
- J2EE EJB Development = new TransportBean(); Chapter transObject 7 - J2EE Web Development Chapter 8
- J2EE XML Development
transObject.catalogNumber = bookCatalogLocal.getCatalog_number(); transObject.author = bookCatalogLocal.getAuthor(); Chapter 9 - J2EE Enterprise Messaging transObject.bookTitle = bookCatalogLocal.getBook_title(); Chapter 10 - Using the WSAD-Embedded JMS Provider transObject.location = bookCatalogLocal.getLocation(); Chapter 11 - Using WebSphere MQ as the JMS Provider transObject.platform = bookCatalogLocal.getPlatform(); Appendix A - Deploying This Book's J2EE Examples transObject.txnDate = bookCatalogLocal.getLanguage(); Part Three - Working with Enterprise Messaging
Index List of Figures bookVector.addElement(transObject); List of Tables } // End of while List of Code Examples List of Sidebars } // End of try
catch (Exception e) { System.out.println("Error executing findByPlatform WITHIN getBookByPlatform:" + e.getMessage()); throw new EJBException("Error executing findByPlatform WITHIN getBookByPlatform:" + e.getMessage()); } return
bookVector;
}
// Business method public Vector getBookActivity(String workCatalogNumber) throws FinderException { Vector activityVector = new Vector();
TransportBean transObject; // Receiving object from Book_activity method WebSphere Studio Application Developer 5.0: Practical TechLibBook_activityLocal bookActivityLocal = null ; J2EE Development Collection collActivityRecords; ISBN:1590591208 by Igor Livshin try Apress © 2003 (630 pages) { This book provides=a practical, step-by-step approach in collActivityRecords teaching how to use the WebSphere Studio Application activityLocalHome.findByBook(workCatalogNumber); Developer (WSAD) tool for developing J2EE distributed applications.
Iterator iterator = collActivityRecords.iterator(); Table of while Contents (iterator.hasNext()) WebSphere { Studio Application Developer 5.0: Practical J2EE Development Introduction bookActivityLocal = Part One(TechLibBook_activityLocal) - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 iterator.next();
Chapter 1
- Introducing WSAD 5.0
Chapter transObject 2 - Setting Up the = new Development TransportBean(); Environment Chapter 3
- Working with the WSAD 5.0 Workbench = bookActivityLocal.getTxn_date(); Chapter transObject.txnDate 4 - Developing Database Applications
= bookActivityLocal.getTxn_type(); Part TwotransObject.txnType - Working with J2EE: The Distributed Application Framework Chapter transObject.companyName 5 - J2EE Development
= bookActivityLocal.getCompany_name();
Chapter activityVector.addElement(transObject); 6 - J2EE EJB Development
EndWeb of Development while Chapter } 7 // - J2EE Chapter 8
- J2EE XML Development
} // End of try
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
catch(Exception e) { Chapter 11 - Using WebSphere MQ as the JMS Provider System.out.println("Error executing findByPlatform WITHIN Appendix A - Deploying This Book's J2EE Examples getBookByPlatform:" + e.getMessage()); Index throw List of Figures new EJBException("Error executing findByPlatform WITHIN List of Tables getBookByPlatform:" + e.getMessage()); List of Code } Examples List of Sidebars return activityVector; } Chapter 10 - Using the WSAD-Embedded JMS Provider
Notice the following twist. Instead of the methods calling their corresponding getCatalogHome or getActivityHome methods, you added a new initStateVariables method that calls both of them. In addition, you promote this method to the Local Interface so it can be called by the EJB clients. Because this is the stateful session bean and the state of the variables is persistent, your business methods (getBookByPlatform and getBookActivity) no longer need to call the getCatalogHome and getActivityHome methods respectively but instead simply use the catalogLocalHome and activityLocalHome variables calculated during the initStateVariables method call. That demonstrates how the stateful session bean works. With the TechLibFacade1Bean class open in the Java Editor, right-click the Promote to Local Interface. Do the same for the second business method getBookActivity. Save the results and close the Java Editor. Listing 6-20 shows the source code for the TechLibFacade1Bean implementation class. Listing 6-20. TechLibFacade1Bean.java:Implementation Class package apress.wsad.techlib; import javax.ejb.*; import javax.naming.*; import javax.rmi.*; import java.rmi.*;
import import import
java.lang.*; WebSphere Studio Application Developer 5.0: Practical java.util.*; J2EE Development apress.wsad.techlib.TransportBean; by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
public class TechLibFacade1Beanimplements javax.ejb.SessionBean This book provides a practical, step-by-step approach in { teaching how to use the WebSphere Studio Application private Developer javax.ejb.SessionContext (WSAD) tool for developingmySessionCtx; J2EE distributed applications.
// Variable to keep the Home Local refernce to TechLibBook_catalog object private TechLibBook_catalogLocalHome catalogLocalHome = null ; Table of Contents WebSphere Studio Application Developer Practical J2EE Development // Variable to keep the 5.0: Home Local refernce to TechLibBook_activity object Introduction private TechLibBook_activityLocalHome activityLocalHome = null ; Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter// 1 Helper - Introducing WSAD method to5.0get the LocalInterface of the Book_catalog entity bean. Chapterprivate 2 - Setting TechLibBook_catalogLocalHome Up the Development Environment getCatalogLocalHome()
RemoteException Chapter 3 throws - Working with the WSAD 5.0 Workbench Chapter 4
-{ Developing Database Applications
Part Twotry - Working with J2EE: The Distributed Application Framework
Chapter { 5
- J2EE Development == null) Chapter if 6 - (catalogLocalHome J2EE EJB Development Chapter { 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
InitialContext initContext = new
Part Three - Working with Enterprise Messaging
Chapter 9
InitialContext();
- J2EE Enterprise Messaging
Object objRef = initContext.lookup("java:comp/env/Book_catalog");
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
catalogLocalHome = (TechLibBook_catalogLocalHome) objRef;
Index List of Figures return
(TechLibBook_catalogLocalHome) objRef;
List of Tables } List of Code Examples else List of Sidebars {
return }
catalogLocalHome;
} catch (NamingException ne) { System.out.println("Error locating TechLibBook_catalogLocalHome: " +
throw new RemoteException("Error locating TechLibBook_catalogLocalHome: " + } } // Helper method to get the LocalInterface of the Book_activity entity bean. private TechLibBook_activityLocalHome getActivityLocalHome() throws RemoteException { try
{ if {
WebSphere Studio Application (activityLocalHome == null)Developer 5.0: Practical J2EE Development
by Igor Livshin Apress © 2003 (630 pages)
InitialContext initContext = new
ISBN:1590591208
InitialContext();
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Object objRef Developer=(WSAD) tool for developing J2EE distributed initContext.lookup("java:comp/env/Book_activity"); applications.
activityLocalHome = (TechLibBook_activityLocalHome) objRef; Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development return (TechLibBook_activityLocalHome) objRef; Introduction Part One}- Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter else 1 - Introducing WSAD 5.0 Chapter { 2
- Setting Up the Development Environment activityLocalHome; Chapter return 3 - Working with the WSAD 5.0 Workbench Chapter } 4
- Developing Database Applications
Part Two}- Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development ne) Chapter catch 6 - J2EE EJB(NamingException Development Chapter { 7
- J2EE Web Development
System.out.println("Error locating TechLibBook_activityLocalHome: " + Chapter 8 - J2EE XML Development Part Three - Working with Enterprise Messaging
throw new - J2EE Enterprise Messaging RemoteException("Error locating TechLibBook_activityLocalHome: " Chapter 10 - Using the WSAD-Embedded JMS Provider + ne.getMessage()); Chapter 11 - Using WebSphere MQ as the JMS Provider } Appendix A - Deploying This Book's J2EE Examples } Chapter 9
Index List of Figures List Tables //ofBusiness helper method. Must be promoted to the local interface List public of Code Examples void initStateVariables() List of Sidebars throws
FinderException
{ try { // Calculate catalogLocalHome and activityLocalHome variables getCatalogLocalHome(); getActivityLocalHome(); } // End of try catch(Exception e) { System.out.println("Error executing findByPlatform WITHIN getBookByPlatform:" + e.getMessage()); throw new EJBException("Error executing findByPlatform WITHIN getBookByPlatform:" + e.getMessage()); } } // Business method public Vector getBookForPlatform(String workPlatform)
throws
FinderException
WebSphere Studio Application Developer 5.0: Practical J2EE Development
{
Vector bookVector = new by Igor Livshin Apress © 2003 (630 pages)
Vector();
ISBN:1590591208
TransportBean transObject; This book provides a practical, step-by-step approach in TechLibBook_catalogLocal bookCatalogLocal = null; teaching how to use the WebSphere Studio Application Collection collBookRecords; Developer (WSAD) tool for developing J2EE distributed try applications. { // Calculate catalogLocalHome and activityLocalHome variables Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development collBookRecords = Introduction catalogLocalHome.findByPlatform(workPlatform); Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 Chapter 2
-Iterator Introducingiterator WSAD 5.0 = collBookRecords.iterator(); - Setting Up the Development Environment
Chapter 3
-while Working (iterator.hasNext()) with the WSAD 5.0 Workbench
Chapter { 4
- Developing Database Applications
= Distributed Application Framework Part TwobookCatalogLocal - Working with J2EE: The iterator.next(); Chapter (TechLibBook_catalogLocal) 5 - J2EE Development Chapter 6
- J2EE EJB Development = new TransportBean(); Chapter transObject 7 - J2EE Web Development Chapter 8
- J2EE XML Development
transObject.catalogNumber = bookCatalogLocal.getCatalog_number(); transObject.author = bookCatalogLocal.getAuthor(); Chapter 9 - J2EE Enterprise Messaging transObject.bookTitle = bookCatalogLocal.getBook_title(); Chapter 10 - Using the WSAD-Embedded JMS Provider transObject.location = bookCatalogLocal.getLocation(); Chapter 11 - Using WebSphere MQ as the JMS Provider transObject.platform = bookCatalogLocal.getPlatform(); Appendix A - Deploying This Book's J2EE Examples transObject.txnDate = bookCatalogLocal.getLanguage(); Part Three - Working with Enterprise Messaging
Index List of Figures bookVector.addElement(transObject); List of Tables } // End of while List of Code Examples List of Sidebars } // End of try
catch(Exception e) { System.out.println("Error executing findByPlatform WITHIN getBookByPlatform:" + e.getMessage()); throw new EJBException("Error executing findByPlatform WITHIN getBookByPlatform:" + e.getMessage()); } return
bookVector;
} // Business method public Vector getBookActivity(String workCatalogNumber) throws FinderException { Vector activityVector = new Vector(); TransportBean transObject; // Receiving object from Book_activity method TechLibBook_activityLocal bookActivityLocal = null; Collection collActivityRecords;
try WebSphere Studio Application Developer 5.0: Practical { J2EE Development collActivityRecords = ISBN:1590591208 by Igor Livshin activityLocalHome.findByBook(workCatalogNumber); Apress © 2003 (630 pages)
book provides a practical, step-by-step approach in IteratorThis iterator = collActivityRecords.iterator(); teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed (iterator.hasNext()) applications.
while { bookActivityLocal = Table of (TechLibBook_activityLocal) Contents iterator.next();
WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction transObject = new
TransportBean();
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter transObject.txnDate 1 - Introducing WSAD 5.0
= bookActivityLocal.getTxn_date();
Chapter transObject.txnType 2 - Setting Up the Development Environment = bookActivityLocal.getTxn_type();
= bookActivityLocal.getCompany_name(); Chapter transObject.companyName 3 - Working with the WSAD 5.0 Workbench Chapter activityVector.addElement(transObject); 4 - Developing Database Applications
// End with of J2EE: while Part Two}- Working The Distributed Application Framework Chapter 5
- J2EE Development EndEJB ofDevelopment try Chapter } 6 // - J2EE Chapter 7
- J2EE Web Development
catch(Exception e) Chapter 8 - J2EE XML Development { Part Three - Working with Enterprise Messaging System.out.println("Error executing findByPlatform WITHIN Chapter 9 - J2EE Enterprise Messaging getBookByPlatform:" + e.getMessage()); Chapter 10 - Using the WSAD-Embedded JMS Provider throw Chapter 11 - Using WebSphere MQ as the JMS Provider new EJBException("Error executing findByPlatform WITHIN Appendix A - Deploying This Book's J2EE Examples getBookByPlatform:" + e.getMessage()); Index } List of Figures return activityVector; List of } Tables List of Code Examples List of Sidebars javax.ejb.SessionContext getSessionContext() public
{ return mySessionCtx; } public void setSessionContext(javax.ejb.SessionContext ctx) { mySessionCtx = ctx; } public void
ejbCreate()throws
public void
ejbActivate()
public void
ejbPassivate()
public void
ejbRemove()
{ } { } { } { } }
javax.ejb.CreateException
Listing 6-21 shows the sourceStudio code for TechLibFacade1LocalHome Local Home Interface class. WebSphere Application Developer 5.0: Practical J2EE Development
Listing 6-21. TechLibFacade1LocalHome: Local Home Interface Class ISBN:1590591208 by Igor Livshin Apress © 2003 (630 pages)
package
apress.wsad.techlib; This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application
Developer (WSAD) tool for developing J2EE distributed /** applications. * Local Home interface for Enterprise Bean: TechLibFacade1 */ public interface TechLibFacade1LocalHomeextends javax.ejb.EJBLocalHome Table of Contents { WebSphere Studio Application Developer 5.0: Practical J2EE Development /** Introduction Creates a with default instance of Session Bean:(WSAD) TechLibFacade1 Part One -*Getting Started WebSphere Studio Application Developer 5.0 */ Chapter 1 - Introducing WSAD 5.0 public apress.wsad.techlib.TechLibFacade1Local create() Chapter 2 - Setting Up the Development Environment throws javax.ejb.CreateException; Chapter 3 - Working with the WSAD 5.0 Workbench } Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter J2EE Development Listing 56-22- shows the source code for the TechLibFacade1Local Local Interface class. Chapter 6 - J2EE EJB Development
Listing76-22. TechLibFacade1Local: Local Interface Class Chapter - J2EE Web Development Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging package apress.wsad.techlib;
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 -javax.ejb.FinderException; Using the WSAD-Embedded JMS Provider import Chapter 11 - Using WebSphere MQ as the JMS Provider import java.util.Vector; Appendix A - Deploying This Book's J2EE Examples Index /**
* Figures Local interface for Enterprise Bean: TechLibFacade1 List of */Tables List of public List of Codeinterface Examples
TechLibFacade1Localextends
javax.ejb.EJBLocalObject
{ of Sidebars List // Business method public Vector getBookForPlatform(String workPlatform) throws FinderException; // Business method public Vector getBookActivity(String workCatalogNumber) throws FinderException; // Business helper method. Must be promoted to the local interface public void initStateVariables()throws FinderException; }
Next, validate the project. Right-click the TechLibEJBproject and select RunDeploy and RMIC code. On the dialog that appears, select only the TechLibFacade1 method. Finally, click Finish. There should be no errors after the end of the generation process. You are now ready to test the TechLibFacade1 session bean.
Testing the Stateful Session Bean Switch to the Server Perspective and start TechLibTestServer. Wait until it is ready, and then right-click the TechLibEJB project and select Run on Server. The Universal Test Client main screen will appear. Click JNDI
Explorer (see Figure 6-59).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Figure Testing stateful session bean in the Universal Test Client Chapter 2 - 6-59: Setting Up thethe Development Environment Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4 If- you Developing Database Applications Note are testing a component that is developed with both Local and Remote Client Views, you need Part Two - Working with J2EE: The(by Distributed Application to test both interfaces opening both LocalFramework EJB beans
andejbnaming contexts and selecting
Chapter 5 the - J2EE Development same module for testing). Chapter 6 - J2EE EJB Development
Click the link (from the Local EJB beans name context. Its Local Interface will appear in the Chapter 7 TechLibFacade1 - J2EE Web Development References it all the way down. You should see the create method without parameters. Click it Chapter 8 - section. J2EE XMLExpand Development andThree then click Invoke. Next, click Work with Object. Part - Working with Enterprise Messaging
Now, the TechLibFacade1Local 1 entry (the Local Home Interface of this stateful session bean) will appear in the References section; it displays three methods: Chapter 9 - J2EE Enterprise Messaging initStateParameters, getBookActivity, and getBookForPlatform. Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere the JMS Providerthat the method completed successfully. Now, when the Click initStateParameters. YouMQ willasget the message Appendix A Deploying This Book's J2EE Examples state variables are set, you can call your business methods. Click getBookForPlatform. You will be prompted to Index enter the value of the platform attribute. Enter 04 (which means the Windows NT/2000 platform). Click Invoke. List of Figures Again, because multiple objects are expected to be returned in a vector, you have the two buttons in the List Parameters of Tables pane: Work with Object andWork with Contained Objects. Click Work with Contained List Objects of Code (see Examples Figure 6-60). List of Sidebars
Figure 6-60: Returning multiple objects Five objects appear in the References section. Expand the last object. Click the getBookTitle method. Click Invoke. The following book title is displayed: 'Programming NT Services' (see Figure 6-61).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Figure 6-61: Getting the title of the last object Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development
Now, let's test the second method. Click the getBookActivity method. You will be prompted for the value of one parameter-the book CATALOG_NUMBER. Enter 00001 and click Invoke. Because the expected result could Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 include multiple objects, the Work with Object button is displayed. Click it. Several objects are displayed in the Chapter 1 - Introducing WSAD 5.0 References section. Click the last one. You will see all available local methods of the TransferBean object. If Chapter 2 - Setting Up the Development Environment you look at the getBookActivity method, you will see that you are returning only three fields within the Chapter 3 - Working with the WSAD 5.0 Workbench TransferObject: TxnDate, TxnType, and CompanyName. Click the getTxnDate method. Next, click Invoke. Click Chapter 4 - Developing Database Applications Work with Object. The displayed result is '02/11/2002.' Click the getTxnType method. Click Invoke. The Part Two - Working with J2EE: The Distributed Application Framework displayed result is 'RENT.' Click the getCompanyName method. Click Invoke. The displayed result is Chapter 5 - J2EE(see Development 'BBB_Company' Figure 6-62). Introduction
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List ofFigure Tables 6-62: Getting the company name of the object List of Code Examples List Close of Sidebars the Universal Test Client and stop the server. This concludes this example and the EJB development
examples. Tip The stateless bean is bound to a client only for a period of one method execution. The second time this method is invoked by the same client, it will most likely be served by another instance of the stateless session bean available from the pool. So, the Local Home Interface to entity beans will be recalculated with every method invocation. Multiscreen Considerations For the sake of simplicity, you did not develop a multiscreen client conversation in this chapter, but the processing logic is the same. Notice that although the code for the stateless and stateful beans are similar, they behave differently during execution. For instance, look at the initStateVariablesmethod. It calls thegetCatalogHomeandgetActivityHomemethods to get the Local Home Interfaces for both the entity beans (TechLibBook_activityandTechLibBook_catalog)and saves it in the state variables:activityLocalHomeandcatalogLocalHome. The Local Home Interface is created only if the value of the corresponding variable is equal to null. For the stateful beans, these variables are part of the state and are saved and restored during the bean swapping out and in of memory (passivation/activation). So, once calculated as the result of the initStateVariablesmethod call, these variables can simply be reused when both business methods (getBookForPlatformand getBookActivity) are subsequently called by the client. For the same reason, you developed the TransferBean class that includes all fields from both database tables (regardless of how many fields are actually used in transmission). This is not an efficient way to
communicate (especially across the network) where the amount of transmitted data must be reduced to a WebSphere Studio Application Developer 5.0: Practical minimum. Therefore, in real programming, it is recommended you develop several TransferBean-like J2EE Development classes, each specifically designed to carry only the necessary fields. by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Summary
WebSphere Studio Application Developer 5.0: Practical J2EE Development
by developed Igor Livshina working EJB tier of a J2EE 1.3ISBN:1590591208 In this chapter, you application. This example included the Apress © 2003 (630 pages) development of CMP and BMP entity beans and stateless and stateful session beans. You also learned how to use IBM Universal Client tool for testing EJB components. This bookTest provides a practical, step-by-step approach in In addition, the chapter discussed teaching and how using to useEJB the WebSphere Studio Application the EJB project structure QL for developing finder methods. Developer (WSAD) tool for developing J2EE distributed applications. In the next chapter, you will develop the Web part of the J2EE 1.3 application. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Studio Application Developer 5.0: Practical Chapter WebSphere 7: J2EE Web Development J2EE Development
Overview
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in
This chapter continues teaching thehow development to use the WebSphere of the J2EEStudio 1.3 technical Application library application you started in Developer (WSAD) for Enterprise developing JavaBean J2EE distributed Chapter 6. You have developed thetool entire (EJB) tier of the application. Now, you will applications. concentrate on developing the Web tier of this application. You will build the Web tier of the technical library application by following the industry best-practice Model-View-Controller (MVC) pattern. This will consist of Hypertext Markup Language (HTML), servlets, JavaServer Pages (JSP), and JavaBean files. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development
This chapter also discusses how the Web projects are organized and developed with WebSphere Studio Application Developer (WSAD) 5.0 by following the industrystandard MVC pattern for the presentation part Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 of the J2EE application. You will also learn how to use the WSAD Web Page Designer tool and how to Chapter - Introducing WSAD 5.0 develop1 sophisticated dynamic Web pages. You will also learn how to develop stateless and stateful Chapter 2 - Setting Upfor theWeb Development Environment conversation sessions application debugging. Finally, you will learn how the Web application Chapter 3 - Working with the WSAD 5.0 Workbench components can function as EJB clients to communicate with the EJB part of the technical library Chapter 4 -developed DevelopinginDatabase application Chapter Applications 6. The chapter also discusses the Local and Remote Client Views. Introduction
Part Two - Working with J2EE: The Distributed Application Framework
The chapter startsDevelopment by discussing how WSAD 5.0 organizes Web projects. Chapter 5 - J2EE Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Developer 5.0: Practical Understanding the Studio Web Application Project Organization J2EE Development
ISBN:1590591208 by Igor Livshin The J2EE 1.3 specification requires that any Web application must be built as a Web Archive (WAR) file, Apress 2003 (630 pages)file specially structured for Web applications (also called Web which is actually a Java ©Archive (JAR) modules). The structure of provides a Web module consists of several directories: This book a practical, step-by-step approach in
teaching how to use the WebSphere Studio Application
Java Source: Developer This is (WSAD) the folder tool where for developing WSAD stores J2EE distributed Java source code for JavaBeans and servlets. applications. When exporting Web applications, the context of this directory is not packaged in the WAR file (unless you check a special option that instructs WSAD to include source files in the WAR file). When files in this directory are saved, they are automatically compiled and added to the Web Content/WEBTable of Contents INF/classesdirectory. WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment Web Content: This folder contains the content of the WAR file that will be deployed on the server. - Working with the WSAD 5.0 Workbench Files that are not placed in this directory or its subdirectories are considered development resources Chapter Developing Database Applications and4 will- not be found during execution. Links to these files will be marked as broken. Files in this Part Two Working with J2EE: The Distributed Framework directory are deployed to the application Application server at the time of application deployment. Chapter 3
Chapter 5
- J2EE Development Web This folder contains Cascading Style Sheet (CSS) files and other styleChapter 6 Content/theme: - J2EE EJB Development
related Chapter 7 - objects. J2EE Web Development Chapter 8
- J2EE XML Development
Web Content/WEB-INF: This directory contains supporting Web resources, including web.xml (the standard Deployment Descriptor) and two IBMextended Deployment Descriptors (ibm-webChapter 9 - J2EE Enterprise Messaging bnd.xmlandibm-web-ext.xmi).It also includes the classesandlibdirectories. All Web Chapter 10 - Using the WSAD-Embedded JMS Provider resource files (HTML, servlets, JSP, graphics, JavaScript, and so on) reside in this directory. Part Three - Working with Enterprise Messaging
Chapter 11 - Using WebSphere MQ as the JMS Provider
Appendix WebA Content/WEB-INF/classes: - Deploying This Book's J2EE Examples Java source modules added to the source directory are Indexautomatically compiled, and the generated code is placed in this directory. This directory is for storing List ofservlets Figures and utility classes. In addition, any loose classes (classes outside the JAR files) can be stored
this folder. The classes in this directory are used by the application classloader. Folders in this List ofinTables map Java class package statements with the corresponding Java classes. Classes are List ofdirectory Code Examples in this directory by WSAD only as a result of the compilation of Java source files. List ofplaced Sidebars Web Content/WEB-INF/lib: This folder stores supporting JAR libraries files that the Web module references. Any JAR file placed in this directory is included in the project's Build Path and is available for the Web module. Web Content/WEB-INF/Library: This folder helps to reference and locate JAR files that exist elsewhere in a Java project. If they are in the Web project's Build Path, this allows you to avoid the need to explicitly copy these JAR files into the project's libfolder.
WebSphere Application Developer 5.0: Practical Understanding WebStudio Application Development J2EE Development
ISBN:1590591208 by Igor Livshin WSAD 5.0 contains a new Page Designer (implemented in Java). The Page Designer used in WSAD 4.0x is also availab Apress © 2003 (630 pages) dynamic table extensions, event controls, rollover effects, or many other features It does not support dynamic elements, Classic in its examples. This book provides a practical, step-by-step approach in
teaching how to use the WebSphere Studio Application
If you installed WSAD Developer 5.0 with (WSAD) the new tool Page for developing Designer, J2EE youdistributed need to install the additional Page Designer Classic. Fortuna applications. Updatesdialog will display. Click Yes. The Configuration Changes dialog will appear next. Check the box within t
Now, the new Page Designer is still marked as the default designer on your Workbench. You can go to Windows> Pref
Table JSP of fileContents and select Open With > Page Designer Classic. Whichever method you prefer to use, make sure you us WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction
Creating the Web Project
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0 The first step in developing a Web module is to create the Web project. Switch to the Web Perspective and select New> Chapter 2 content). - SettingThe Up alternative the Development dynamic is the Environment Static Web Project option, which means it can be deployed on any standa Chapter 3
- Working with the WSAD 5.0 Workbench You can select twoDatabase files (a .css file and a .cvsignorefile) and a variety of libraries to be included in the project. T Chapter 4 also - Developing Applications Part appropriate Two - Working for thewith black-and-white J2EE: The Distributed illustrations Application used for Framework book publishing).
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Also, select to include the JSP standard tag lib
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 7-1: Creating a Web project
Click Next. The J2EE Settings Page will appear. Indicate that you will use the existing enterprise application projec project, you need to be able to call EJB components located in the TechLibEJBproject. Check this project, so it will be
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7 - 7-2: J2EEModule Web Development Figure Dependences screen Chapter 8 - J2EE XML Development Part Three - Working with Enterprise Messaging
Click Finish. WSAD will notify you that adding this Web project to the enterprise application project TechLibAppwill af - J2EE Enterprise Messaging
Chapter 9
Chapter 10 - Using the WSAD-Embedded JMS Provider
Understanding Stateless Web Session Development
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
Because the user interaction with the system consists of a single request and reply screen, you can use stateless proces calledBookRegisterHelperthat will pass information between modules.
Index
List of Figures
List of Tables Let’s build the BookRegisterHelperJavaBean class first. Right-click the TechLibWEBproject and select File> New> List CodeSerializable. Examples andoftype Select the Constructors from superclass field and deselect Inherited abstrac List of Sidebars
Figure 7-3: Building the BookRegisterHelperclass
WebSphere Studio Application Developer 5.0: Practical
Click Finish. WSAD generate the BookRegisterHelperclass and open it in the Java Editor View. To add a new J2EE will Development
Igor Livshin Enter these fieldsby(that will be used on the input/output screens) as attributes of the BookRegisterHelper.javaclass Apress © 2003 (630 pages) generated (see Figure 7-4). ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Figure 7-4: Generating the getter/setter methods
Part Three - Working with Enterprise Messaging
Chapter 9 You - J2EE Enterprise Click OK. should see theMessaging generated getter/setter methods. Right-click any empty space within the Java Editor View a Chapter 10 - Using the WSAD-Embedded JMS Provider
Listing11 7-1. Chapter - BookRegisterHelper.java Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index packageapress.wsad.techlib; List of Figures import java.io.Serializable; List of Tables List public of Codeclass ExamplesBookRegisterHelperimplements
{ of Sidebars List // Attributes private String catalogNumber; private String author; private String bookTitle; private String location; private String platform; private String language; public {
BookHelper()
super(); } public String getAuthor() { return author; } public String getBookTitle() { return bookTitle; } public String getCatalogNumber() {
Serializable
return catalogNumber; WebSphere Studio Application Developer 5.0: Practical } J2EE Development public String getLanguage() ISBN:1590591208 by Igor Livshin { Apress © 2003 (630 pages) return language; This book provides a practical, step-by-step approach in } teaching how to use the WebSphere Studio Application public String (WSAD) getLocation() Developer tool for developing J2EE distributed { applications. return location; } Tablepublic of Contents String getPlatform() WebSphere Studio Application Developer 5.0: Practical J2EE Development { Introduction return platform; Part}One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1 - void Introducing WSAD 5.0 public setAuthor(String author) Chapter { 2 - Setting Up the Development Environment = author; Chapter 3 this - Working .author with the WSAD 5.0 Workbench } 4 - Developing Database Applications Chapter void with setBookTitle(String bookTitle) Partpublic Two - Working J2EE: The Distributed Application Framework { 5 - J2EE Development Chapter = bookTitle; Chapterthis.bookTitle 6 - J2EE EJB Development } 7 - J2EE Web Development Chapter public void setCatalogNumber(String catalogNumber) Chapter 8 - J2EE XML Development { Part Three - Working with Enterprise Messaging this.catalogNumber = catalogNumber Chapter 9 - J2EE Enterprise Messaging } Chapter 10 - Using the WSAD-Embedded JMS Provider public void setLanguage(String language) Chapter 11 - Using WebSphere MQ as the JMS Provider { Appendix A - Deploying This Book's J2EE Examples this .language = language; Index } List of Figures void public setLocation(String location) List of Tables { List of Code thisExamples .location = location; List of Sidebars } public void setPlatform(String platform) { this .platform = platform; } }
You will use the BookRegisterHelperJavaBean class to automatically generate your Web pages. Right-click the Tec
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Figure- 7-5: Generating JavaBean Web pages J2EE Development
Chapter 5 Chapter 6
- J2EE EJB Development
Chapter Click Next. 7 - You J2EEshould Web Development see the screen shown in Figure 7-6. Next, click the Browsebutton attached to the Java packag Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 7-6: Creating Web pages that access JavaBeans
Click Nextto continue the building process. On the subsequent screen, click the Browsebutton attached to the Beanfield
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index
Figure 7-7: Selecting the JavaBean
List of Figures
List of Tables When you click OK, you see the screen shown in Figure 7-8. Here, you can select the fields for building input and output List of Code Examples List of Sidebars
Figure 7-8: Selecting attributes for building Web pages
Click Next. On the next screen, select Request(you do not need Sessionhere because this is one-screen processing) WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Figure design screen Chapter 8 - 7-9: J2EEInput XML page Development Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Improving the Form Design
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider
You should probably make some changes to improve how the form looks. First, change the page title. Click the Pagetab
Appendix A - Deploying This Book's J2EE Examples
Index Click the Fieldstab. Now, rearrange the screen fields by putting them in the following order: catalogNumber,bookTi List of Figures position. List of Tables
Use steps to adjust the position of other fields. Select the catalogNumberfield in the Properties and meth List of similar Code Examples andofclick elsewhere for the changes to take effect. List Sidebars
Select the bookTitlefield in the Properties and method parameters window and click the Labelvalue field. C changes for the rest of the fields. When you have finished updating the input page, it should look like the screen shown i
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Figure 7-10: Modifying the input page
Click Next. form will display. Change the form’s title to Registration Status. Select only one field— ca Chapter 8 - The J2EEresults XML Development look like the one in Figure 7-11. Part Three - Working with Enterprise Messaging Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 7-11: Modifying the results form The final screen prompts you for the prefix that will be used to form the names of the generated files. Change the prefix
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Figure 7-12: Specifying the prefix
Chapter 7 - J2EE Webwill Development Click Finish. WSAD generate a set of files that maintain the MVC pattern for developing the presentation part of the Chapter 8 - J2EE XML Development Part Three - Working with Enterprise Messaging
Working with WSAD-Generated Files - J2EE Enterprise Messaging
Chapter 9
Chapter 10 - Using WSAD-Embedded Provider Files generated bythe WSAD display in theJMS Navigator View. Two Java-based files (BookRegisterController.javaand Chapter 11 - Using WebSphere MQ as the JMS Provider
As you already know, Java files placed in the Java Source directory (and its subdirectories) are automatically compile Appendix A - Deploying This Book's J2EE Examples Contentdirectory, according to the package structure. You can see them in Figure 7-13. Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 7-13: The Web project structure
These five classes implement the MVC pattern with the main goal of separating the presentation from the data and proc code from BookRegisterInputForm.htmlthat handles this Submitclick logic. Listing 7-2. Fragment of the BookRegisterInputForm.htmlfile
WebSphere Studio Application Developer 5.0: Practical J2EE Development ISBN:1590591208 by Igor Livshin Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Register New Book Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter - Introducing WSAD 5.0 Chapter
Submit Chapter 3 - Working with the WSAD 5.0 Workbench Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
You should JavaScript function called submitFormat the top of the code fragment. The last line of the code fra Chapter 5 - see J2EEthe Development Submit Chapter 6 - J2EE EJB Development Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
This code reacts to the user clicking the Submitlink and triggers the execution of the JavaScript function called submit
action="BookRegisterController" Part Three - Working with Enterprise Messaging Chapter 9
- J2EE Enterprise Messaging
Right-click the web.xmi file and select Open With > Deployment Descriptor Editor. On the Overviewpage, click the B
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 7-14: The Web project Deployment Descriptor BookRegisterControlleris coded under the actionkeyword (therefore, the BookRegisterControllerservlet
Now let’s look at the code snippet of BookRegisterController. Both the doPostanddoGetmethods delegate contr variable:
//Perform any specialized sevices performServices(request, response); //Get the Web pag
On the BookRegisterInputForm, there is a hidden field called commandwith a value equal to BookRegisterResul Deployment Descriptor Editor. On the Overviewpage, click BookRegisterController. In the “Initialization BookRegisterResultsJSP module (see Figure 7-15).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2 - 7-15: Setting UpWeb the Development Environment Figure The project Deployment Descriptor Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
You can see that the request.getParameter("BookRegisterResults")statement will return the value /BookR
Part Two - Working with J2EE: The Distributed Application Framework
RequestDispatcher dispatch = request.getRequestDispatcher(nextPage); dispatch.forward(r Chapter 5 - J2EE Development Chapter 6
- J2EE EJB Development
This effectively forwards control to the BookRegisterResults.jspmodule, which will display the results on the user - J2EE Web Development JavaBean class.
Chapter 7 Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Adding- the Logic J2EE Business Enterprise Messaging
Chapter 9
Chapter 10 - Using the WSAD-Embedded JMS Provider
Now that the functionality of the MVC pattern is clear to you, let’s add some business code. There is a performServic
Chapter 11 - Using WebSphere MQ as the JMS Provider
Appendix - Deploying Book's Examples NoteA Typically, theThis Web clientJ2EE should call an EJB session bean that wraps multiple calls to entity beans, but here yo Index
You List of probably Figures remember that the TechLibBook_catalogentity bean provides a Local Client View. Listing 7-3 shows th List of Tables
Listing 7-3. The performServicesMethod
List of Code Examples List of Sidebars
public void performServices(HttpServletRequest request, HttpServletResponse response) { // Variable to keep the Book_catalog Home Interface TechLibBook_catalogLocalHome catalogLocalHome; TechLibBook_catalogLocal catalogLocal;
String catalogNumber = request.getParameter("catalogNumber"); String author = request.getParameter("author"); String bookTitle = request.getParameter String author = request.getParameter("author"); String bookTitle = request.getParameter("bookTitle"); String location = request.getParameter("location"); String platform = request.getParameter("platform"); String language = request.getParameter("language"); try { InitialContext initContext = new
InitialContext();
catalogLocalHome = (TechLibBook_catalogLocalHome) initContext.lookup("java:comp/env/Book_catalog");
catalogLocal = WebSphere Studio Application Developer 5.0: Practical catalogLocalHome.create(catalogNumber, J2EE Development author, ISBN:1590591208 by Igor Livshin bookTitle, Apress © 2003 (630 pages) location, This book provides a practical, step-by-step approach in platform, teaching how to use the WebSphere Studio Application language); Developer (WSAD) tool for developing J2EE distributed applications.
// If we are here, successful result Table of Contents
}
WebSphere Studio Application Developer 5.0: Practical J2EE Development catch(Exception e) Introduction { Part OneSystem.out.println("Error - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 locating ejb/Book_catalog Home
Chapter interface" 1 - Introducing 5.0 + WSAD e.getMessage()); Chapter 2
- Setting Up the Development Environment
Chapter throw 3 - Working the WSAD 5.0 Workbenchregistering a new book"); new with EJBException("Error Chapter } 4 - Developing Database Applications Part Two - Working } with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development The method retrieves parameters passed from the user form. Next, it creates an InitialContextandlookupfor th Chapter 7 - J2EE Web all Development
database table. If any exception happens, the method handles it and throws it as EJBException. - J2EE XML Development
Chapter 8
Part Three - Working with Enterprise Messaging
TheperformTaskmethod calls the performServicemethod. If no exception is thrown, it will form the nextPagefield
Chapter - J2EE Enterprise Messaging display9its page only in the case of successful registration; otherwise, the generic error_pagewill display. See Listing 7 Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter Listing11 7-4. - BookRegisterController.java Using WebSphere MQ as the JMS Provider Servlet Appendix A - Deploying This Book's J2EE Examples Index package
apress.wsad.techlib; java.rmi.*; List of Tables import javax.ejb.*; List of Code Examples import javax.naming.*; List of Sidebars javax.rmi.*; import import java.rmi.*; import java.util.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; List of Figures import
public class BookRegisterControllerextends HttpServletimplements { /************************************************************** * Initializes the servlet *@param config The servlet's configuration information */ public void init(ServletConfig config) throws ServletException { super.init(config); //Place code here to be done when the servlet is initialized } /*************************************************************** * Destroy the Servlet */ public void destroy()
Serializable
{ WebSphere Developer 5.0: Practical //Place code here Studio to beApplication done when the servlet is shut down J2EE Development
}
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
/*************************************************************** practical, * This methodThis isbook runprovides once afor eachstep-by-step request.approach in teaching how to use the WebSphere Studio Application *@param request The(WSAD) incoming Developer tool forrequest developinginformation J2EE distributed *@param response The outgoing response information applications. */ public void performServices(HttpServletRequest request, Table of HttpServletResponse Contents response) WebSphere Studio Application Developer 5.0: Practical J2EE Development { Introduction //Place any code here that you would like to run on every request Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 //Logging, Authentication, Debugging... Chapter 1
- Introducing WSAD 5.0
Chapter // Variable 2 - Settingto Up the keep Development the Book_catalog Environment Home Interface
catalogLocalHome; ChapterTechLibBook_catalogLocalHome 3 - Working with the WSAD 5.0 Workbench catalogLocal; ChapterTechLibBook_catalogLocal 4 - Developing Database Applications Part Two - Working with J2EE: The Distributed Application Framework
catalogNumber = ChapterString 5 - J2EE Development
request.getParameter("catalogNumber"); request.getParameter("author"); bookTitle ChapterString 7 - J2EE Web Development= request.getParameter("bookTitle"); String location = request.getParameter("location"); Chapter 8 - J2EE XML Development String platform = request.getParameter("platform"); Part Three - Working with Enterprise Messaging String language = request.getParameter("language"); author ChapterString 6 - J2EE EJB Development =
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
try
Chapter 11 - Using WebSphere MQ as the JMS Provider
{ InitialContext initContext = new
Appendix A - Deploying This Book's J2EE Examples
InitialContext();
Index List of Figures catalogLocalHome = List of Tables (TechLibBook_catalogLocalHome) List of Code Examples initContext.lookup("java:comp/env/Book_catalog"); List of Sidebars
catalogLocal = catalogLocalHome.create(catalogNumber, author, bookTitle, location, platform, language); // If we are here, successful result } catch(Exception e) { System.out.println("Error locating ejb/Book_catalog Home interface" + e.getMessage()); throw new
EJBException("Error registering a new book");
}
} Chapter 7 /*************************************************************** * Process both HTTP GET and HTTP POST methods *@param request The incoming request information *@param response The outgoing response information
*/ Studio Application Developer 5.0: Practical public void WebSphere performTask( J2EE Development HttpServletRequest request, ISBN:1590591208 by Igor Livshin HttpServletResponse response) Apress © 2003 (630 pages) throws ServletException, IOException This book provides a practical, step-by-step approach in { teaching how to use the WebSphere Studio Application String nextPage; Developer (WSAD) tool for developing J2EE distributed try applications. { //Perform any specialized sevices Table of Contents performServices(request, response); WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction //Get the web page associated with the command in the request Part One -nextPage Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 = getInitParameter(request.getParameter("command"));
Chapter 1 }
- Introducing WSAD 5.0
Chapter catch2 (Exception - Setting Up the ex) Development Environment
{ Chapter 3
- Working with the WSAD 5.0 Workbench exception isApplications thrown serve the error page Chapter//If 4 - an Developing Database
nextPage getInitParameter("error_page"); Part Two - Working = with J2EE: The Distributed Application Framework } Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development //Forward theWeb request to the next page Chapter 7 - J2EE Development
dispatch(request, response, nextPage); - J2EE XML Development } Part Three - Working with Enterprise Messaging Chapter 8 Chapter 9
- J2EE Enterprise Messaging
/*************************************************************** * Process incoming requests for a HTTP GET method Chapter 11 - Using WebSphere MQ as the JMS Provider *@param request The incoming request information Appendix A - Deploying This Book's J2EE Examples *@param response The outgoing response information Index */ List of Figures public void doGet(HttpServletRequest request, HttpServletResponse response) List of TablesServletException, IOException throws List { of Code Examples List of Sidebars performTask(request, response); } Chapter 10 - Using the WSAD-Embedded JMS Provider
/*************************************************************** * Process incoming requests for a HTTP POST method *@param request The incoming request information *@param response The outgoing response information */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { performTask(request, response); } /**************************************************************** * Dispatches to the next page *@param request The incoming request information *@param response The outgoing response information *@param nextPage The page to dispatch to */ public void dispatch( HttpServletRequest request,
HttpServletResponse response, WebSphere Studio Application Developer 5.0: Practical String nextPage) J2EE Development throws ServletException, IOException ISBN:1590591208 by Igor Livshin { Apress © 2003 (630 pages) RequestDispatcher dispatch = request.getRequestDispatcher(nextPage); This book provides a practical, step-by-step approach in dispatch.forward(request, response); teaching how to use the WebSphere Studio Application } Developer (WSAD) tool for developing J2EE distributed } applications. Table of Contents
Designing the Output User Interface
WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction
In this section, you will work on the output user screen. Again, WSAD has already built a skeleton that you can use as a s textSuccessful Registration. Save the changes. Click the Previewtab to see the page (see Figure 7-16).
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Figure 7-16: Output screen design
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using WSAD-Embedded JMSisProvider Save changes andthe close the editor. There one last step before you can test the module. You need to set the EJB refer Chapter 11References - Using WebSphere the that JMS appears, Provider click the EJB Local tab located near the top of the page. Highlig click the tab. OnMQ the as page Appendix field. OnAthe - Deploying dialog thatThis appears, Book'sselect J2EE Examples the Book_catalogentry (see Figure 7-17). Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples IndexFigure 7-17: Setting a local reference to the Book_catalogentity bean List of Figures List of Tables
Click The rest of the fields will be filled in already (see Figure 7-18). List of OK. Code Examples List of Sidebars
Figure 7-18: Checking the local reference to the Book_catalogentity bean Save the results and close the editor. You are now ready to test the application.
Testing the Application
Switch to the Server Perspective and start the server TechLibTestServer. Wait for the message indicating that the se the translation of JSP modules. After that, it works much faster. Enter the following data: Enter00016for Catalog number. EnterJava 1.2 Developer's Handbook for Book title.
EnterPhilip Heller and team for Author.
WebSphere Studio Application Developer 5.0: Practical
J2EE Development EnterLibrary for Location. by Igor Livshin
ISBN:1590591208
Enter00for Platform. Apress © 2003 (630 pages) This book provides a practical, step-by-step approach in
Enter01for Language. teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed
Your input screenapplications. should look like the one shown in Figure 7-19. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Figure 7-19: Filling the input screen
Chapter 7 Submit - J2EE link. Web The Development Click the results screen will display confirming the successful book registration (see Figure 7-20). Chapter 8 - J2EE XML Development Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List ofFigure Code Examples 7-20: A successful registration status List of Sidebars
Using the WSAD Page Designer
Let’s improve the user input screen by replacing the Submitlink with a Submitbutton. You also want the Submitbutton show you how to use the WSAD Page Designer. (Remember to use the Page Designer Classic for these examples.)
Open the BookRegisterInputForm.htmlfile in the Editor View and click the Designtab. From the main menu, sele Font, and Styles. There is also a toolbar button that allows you to invoke the Netscape or Microsoft browser from WS
Now, let’s get back to the screen design. Click inside the screen where you want to insert a button. Ensure that it is below toolbar button, a message displays the description of the button. Locate the button that says Insert Submit Button Figure 7-21).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Figure Inserting button controls Chapter 2 - 7-21: Setting Up the the Development Environment Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4 the - Developing Let’s run application.Database Switch toApplications the Server Perspective and start TechLibTestServer. Right-click the BookRegis Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List ofFigure Tables 7-22: Running the application List of Code Examples
Click the Submitbutton.Figure 7-23 shows the result. List of Sidebars
Figure 7-23: The processing results
Clicking the Resetbutton clears all the fields. Close the Web Browser View and stop the server. Now, you want to devel BookRegisterInputForm.htmlunder the Page Designer Classic and click the Sourcetab. You will manually code a function submitForm() { document.myForm.submit() }
Add the code shown in Listing 7-5. It consists of several functions (one function per each input field to be validated). For WebSphere Studio Application Developer 5.0: Practical
J2EE Development Listing 7-5. JavaScript Validating Functions by Igor Livshin
ISBN:1590591208
function checkCatalogNumber() Apress © 2003 (630 pages) { This book provides a practical, step-by-step approach in if(document.myForm.catalogNumber.value.length teaching how to use the WebSphere Studio Application < 5) { Developer (WSAD) tool for developing J2EE distributed applications. alert("Catalog number is a 5-character field") return(false) } Table of Contents else WebSphere Studio Application Developer 5.0: Practical J2EE Development { Introduction return(true) Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 } Chapter } 1 - Introducing WSAD 5.0 Chapter 2
- Setting Up the Development Environment
Chapter 3 - checkBookTitle() Working with the WSAD 5.0 Workbench function Chapter { 4 - Developing Database Applications Part Two - Working with J2EE: The Distributed Application Framework if(document.myForm.bookTitle.value.length < 1)
Chapter 5 { - J2EE Development Chapter 6
-alert("Enter J2EE EJB Development Book title data")
-return(false) J2EE Web Development } Chapter 8 - J2EE XML Development else Part Three - Working with Enterprise Messaging Chapter 9 { - J2EE Enterprise Messaging Chapter 10 -return(true) Using the WSAD-Embedded JMS Provider } - Using WebSphere MQ as the JMS Provider Chapter 11 } Appendix A - Deploying This Book's J2EE Examples Chapter 7
Index
function checkAuthor() { List of Tables if(document.myForm.author.value.length < 1) List of Code Examples { List of Sidebars alert("Enter Book author data") return(false) } else { return(true) } } List of Figures
function checkLocation() { if(document.myForm.location.value.length < 1) { alert("Enter Book location data") return(false) } else { return(true) } }
function checkPlatform() WebSphere Studio Application Developer 5.0: Practical { J2EE Development if(document.myForm.platform.value.length < 2) ISBN:1590591208 by Igor Livshin { Apress © 2003 (630 pages) alert("Enter Development platform data (two-character field)") This book provides a practical, step-by-step approach in return(false) teaching how to use the WebSphere Studio Application } Developer (WSAD) tool for developing J2EE distributed else applications. { return(true) Table of Contents } WebSphere Studio Application Developer 5.0: Practical J2EE Development } Introduction function checkLanguage() Part{One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 Chapterif(document.myForm.language.value.length 1 - Introducing WSAD 5.0 < 2) Chapter 2 { - Setting Up the Development Environment language data (two-character field)") Chapter 3 -alert("Enter Working with the Programming WSAD 5.0 Workbench Chapter 4 -return(false) Developing Database Applications Part Two -}Working with J2EE: The Distributed Application Framework Chapterelse 5 - J2EE Development Chapter 6 { - J2EE EJB Development Chapter 7 -return(true) J2EE Web Development } Chapter 8 - J2EE XML Development } Part Three - Working with Enterprise Messaging Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
Now, click the Designtab. Right-click the Book title input field and select Edit Events. On the next dialog, selec
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 7-24: Event processing Click OK. The line of the selected event and the corresponding script to be executed appear in the Event/Actionbox (s
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Figure Event/action assignment Chapter 2 - 7-25: Setting Up the Development Environment Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Click OK. Here is how the code works: When the next field in sequence gets the focus (the user moves the cursor to this f
Part Two - Working with J2EE: Thefor Distributed Enter checkBookTitle() Author. Application Framework
Chapter 5
- J2EE Development
checkAuthor() for Location. Chapter 6 - J2EE EJB Development Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
checkLocation()for Platform.
Part Three - Working with Enterprise Messaging checkPlatform() for Language.
Chapter 9
- J2EE Enterprise Messaging To check last field (Language), youJMS canProvider react on the OnMouseOutevent (when the user moves the cursor out of the Chapter 10 the - Using the WSAD-Embedded
(see Figure Chapter 11 -7-26). Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 7-26: Event/action assignment for the last field
As you can see, the last input field (Language) is assigned two events. Click OK. You need to do one last step before tes Catalog number —and select Attributes. Click the Othertab and enter 1in the Tab display order field (se
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 - 7-27: J2EE Processing Developmentattributes for the input field Figure Chapter 6 - J2EE EJB Development Chapter 7
- J2EE Web Development
Repeat the same steps for the rest of the input fields and assign them sequential orders: 2, 3, and so on. Save the updat Chapter 8 - J2EE XML Development Server. On the input screen, enter 000in the Catalog number field (this is wrong because catalog number is a Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 7-28: Testing data validation
Click OKand enter the correct catalog number. Enter the rest of the fields but leave the Languagefield empty. When you
Figure 7-29: Testing data validation of the last field Click OK.Listings 7-6, 7-7, 7-8, and 7-9 show the final source code for the modified application. Listing 7-6. The BookHelperClass
package import
apress.wsad.techlib; WebSphere Studio Application Developer 5.0: Practical J2EE Development java.io.Serializable; by Igor Livshin
ISBN:1590591208
© 2003 (630implements pages) public class Apress BookHelper Serializable { This book provides a practical, step-by-step approach in // Attributesteaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed private String catalogNumber; applications. private String author; private String bookTitle; private Table of Contents String location; private platform; WebSphere Studio String Application Developer 5.0: Practical J2EE Development private String language; Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
/** 1 Chapter
- Introducing WSAD 5.0
* Constructor for BookHelper. Chapter 2 - Setting Up the Development Environment */ Chapter 3 - Working with the WSAD 5.0 Workbench public BookHelper() Chapter 4 - Developing Database Applications { Part Two - Working with J2EE: The Distributed Application Framework super(); Chapter 5 - J2EE Development } Chapter 6
- J2EE EJB Development
Chapter /** 7
- J2EE Web Development
Chapter 8 - J2EEthe XML author. Development * Returns Part*Three - Working with Enterprise Messaging @return String
Chapter */ 9
- J2EE Enterprise Messaging
Chapter 10 -String Using thegetAuthor() WSAD-Embedded JMS Provider public Chapter 11 - Using WebSphere MQ as the JMS Provider { Appendix returnA -author; Deploying This Book's J2EE Examples
} Index List of Figures
/** List of Tables * Code Returns the bookTitle. List of Examples * Sidebars @return List of */ public { return }
String String getBookTitle() bookTitle;
/** * Returns the catalogNumber. * @return String */ public String getCatalogNumber() { return catalogNumber; } /** * Returns the language. * @return String */ public String getLanguage() { return language;
} WebSphere Studio Application Developer 5.0: Practical J2EE Development
/** ISBN:1590591208 by Igor Livshin * Returns the location. Apress © 2003 (630 pages) * @return String This book provides a practical, step-by-step approach in */ teaching how to use the WebSphere Studio Application public String getLocation() Developer (WSAD) tool for developing J2EE distributed { applications. return location; } Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development /** Introduction * Returns the platform. Part*One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 @return String
Chapter */ 1
- Introducing WSAD 5.0
Chapter public 2
- Setting String Up the getPlatform() Development Environment
{ Chapter 3
- Working with the WSAD 5.0 Workbench
return Chapter 4
platform; - Developing Database Applications
} Two - Working with J2EE: The Distributed Application Framework Part Chapter 5
- J2EE Development
/** 6 Chapter
- J2EE EJB Development * Sets author. Chapter 7 - the J2EE Web Development
* @param author The author to set - J2EE XML Development */ Part Three - Working with Enterprise Messaging public void setAuthor(String author) Chapter 9 - J2EE Enterprise Messaging { Chapter 10 - Using the WSAD-Embedded JMS Provider this.author = author; Chapter 11 - Using WebSphere MQ as the JMS Provider } Chapter 8
Appendix A - Deploying This Book's J2EE Examples Index /**
List of * Figures Sets the bookTitle. List of * Tables @param bookTitle The bookTitle to set List */ of Code Examples List of Sidebars public void
setBookTitle(String bookTitle) { this.bookTitle = bookTitle; } /** * Sets the catalogNumber. * @param catalogNumber The catalogNumber to set */ public void setCatalogNumber(String catalogNumber) { this.catalogNumber = catalogNumber; } /** * Sets the language. * @param language The language to set */ public void setLanguage(String language) { this .language = language; }
/** * Sets the WebSphere location.Studio Application Developer 5.0: Practical J2EE Development * @param location The location to set ISBN:1590591208 by Igor Livshin */ Apress © 2003 (630 pages) public void setLocation(String location) This book provides a practical, step-by-step approach in { teaching how to use the WebSphere Studio Application this .location location; Developer=(WSAD) tool for developing J2EE distributed } applications. /** Table* ofSets Contents the platform. WebSphere Studio Application Developer Practical to J2EEset Development * @param platform The 5.0: platform Introduction */ Part One - Getting with WebSphere Studio Application Developer (WSAD) 5.0 public void Started setPlatform(String platform)
Chapter 1 {
- Introducing WSAD 5.0
Chapter this.platform 2 - Setting=Upplatform; the Development Environment
} Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
} Two - Working with J2EE: The Distributed Application Framework Part Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development Listing77-7. Class, BookRegisterController.java Chapter - The J2EE BookRegisterController Web Development Chapter 8
- J2EE XML Development
Part package Three - Working apress.wsad.techlib; with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
import java.rmi.*; Chapter 10 - Using the WSAD-Embedded JMS Provider import javax.ejb.*; Chapter 11 - Using WebSphere MQ as the JMS Provider importA -javax.naming.*; Appendix Deploying This Book's J2EE Examples import Index import List of Figures import List of Tables
javax.rmi.*; java.rmi.*; java.util.*;
List of Code Examples
import import import
java.io.*; javax.servlet.*; javax.servlet.http.*;
List of Sidebars
/** *Description - BookRegister Front Controller * * The Controller is the initial point of contact for handling a request. * Place in this class any services you would like to do on every request * (Logging, Debugging, Authentication...) */
public class BookRegisterControllerextends HttpServletimplements { /************************************************************** * Initializes the servlet *@param config The servlet's configuration information */ public void init(ServletConfig config) throws ServletException { super.init(config); //Place code here to be done when the servlet is initialized
Serializable
} WebSphere Studio Application Developer 5.0: Practical J2EE Development
/*************************************************************** ISBN:1590591208 by Igor Livshin * Destroy the Servlet Apress © 2003 (630 pages) */ book provides a practical, step-by-step approach in public void This destroy() teaching how to use the WebSphere Studio Application { Developer (WSAD) tool for developing J2EE distributed //Place code applications. here to be done when the servlet is shut down } Table of Contents /*************************************************************** WebSphere Studio Application 5.0:each Practical J2EE Development * This method is run Developer once for request. Introduction *@param
request The incoming request information
Part One - Getting Started with Application Developer (WSAD) 5.0 *@param response The WebSphere outgoingStudio response information
Chapter 1 */
- Introducing WSAD 5.0
Chapter public 2 void - Setting performServices(HttpServletRequest Up the Development Environment request, Chapter HttpServletResponse 3 - Working with the WSADresponse) 5.0 Workbench
{ Chapter 4
- Developing Database Applications
//Place any code hereThe that you would likeFramework to run Part Two - Working with J2EE: Distributed Application
on every request
//Logging, Authentication, Debugging... Chapter 5 - J2EE Development Chapter 6
- J2EE EJB Development // Variable to Development keep the Book_catalog Home Interface Chapter 7 - J2EE Web
TechLibBook_catalogLocalHome catalogLocalHome; - J2EE XML Development TechLibBook_catalogLocal catalogLocal; Part Three - Working with Enterprise Messaging Chapter 8 Chapter 9
- J2EE Enterprise Messaging
String catalogNumber = request.getParameter("catalogNumber"); String author = request.getParameter("author"); Chapter 11 - Using WebSphere MQ as the JMS Provider String bookTitle = request.getParameter("bookTitle"); Appendix A - Deploying This Book's J2EE Examples String location = request.getParameter("location"); Index String platform = request.getParameter("platform"); List of Figures String language = request.getParameter("language"); Chapter 10 - Using the WSAD-Embedded JMS Provider
List of Tables List of Code Examples List of Sidebars try
{ InitialContext initContext = new
InitialContext();
// calling the local reference of the Book_catalog entity bean catalogLocalHome = (TechLibBook_catalogLocalHome) initContext.lookup("java:comp/env/Book_catalog"); catalogLocal = catalogLocalHome.create(catalogNumber, author, bookTitle, location, platform, language); // If we are here, successful result } catch (Exception e) { System.out.println("Error locating ejb/Book_catalog Home interface" + e.getMessage());
throw new EJBException("Error a new book"); WebSphere Studio Application registering Developer 5.0: Practical } J2EE Development } ISBN:1590591208 by Igor Livshin Apress © 2003 (630 pages)
/*************************************************************** This book provides a practical, step-by-step approach in * Process both HTTPhow GET andthe HTTP POST Studio methods teaching to use WebSphere Application Developer tool forrequest developinginformation J2EE distributed *@param request The(WSAD) incoming applications. The outgoing response information *@param response */ public void performTask( Table of Contents HttpServletRequest request, WebSphere Studio Application Developer 5.0: Practical J2EE Development HttpServletResponse response) Introduction throws ServletException, IOException Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 { Chapter 1 - Introducing WSAD 5.0 String nextPage; Chapter 2 - Setting Up the Development Environment try Chapter 3 - Working with the WSAD 5.0 Workbench { Chapter 4 - Developing Database Applications //Perform any specialized sevices Part Two Working with J2EE: The Distributed Application Framework performServices(request, response); Chapter 5
- J2EE Development
Chapter - J2EE Development //Get6 the WebEJB page associated with the command in the request Chapter 7 J2EE Web Development nextPage = getInitParameter(request.getParameter("command")); Chapter 8
- J2EE XML Development
Part } Three - Working with Enterprise Messaging
Chapter catch9
- J2EE (Exception Enterprise Messaging ex)
{ Chapter 10 - Using the WSAD-Embedded JMS Provider //If an is thrown serve the error page Chapter 11 -exception Using WebSphere MQ as the JMS Provider nextPage getInitParameter("error_page"); Appendix A - = Deploying This Book's J2EE Examples } Index List of Figures
//Forward the request to the next page dispatch(request, response, nextPage); List of Code Examples } List of Tables
List of Sidebars
/*************************************************************** * Process incoming requests for a HTTP GET method *@param request The incoming request information *@param response The outgoing response information */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { performTask(request, response); } /*************************************************************** * Process incoming requests for a HTTP POST method *@param request The incoming request information *@param response The outgoing response information */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { performTask(request, response); }
WebSphere Studio Application Developer 5.0: Practical /**************************************************************** Development * Dispatches J2EE to the next page ISBN:1590591208 by Igor Livshin *@param request The incoming request information Apress © 2003 (630 pages) *@param response The outgoing response information This book provides step-by-step *@param nextPage The pagea practical, to dispatch to approach in teaching how to use the WebSphere Studio Application */ Developer (WSAD) tool for developing J2EE distributed public void applications. dispatch( HttpServletRequest request, HttpServletResponse response, Table of Contents String nextPage) WebSphere Application Developer 5.0: Practical J2EE Development throws Studio ServletException, IOException Introduction { Part One RequestDispatcher - Getting Started with WebSphere dispatchStudio = Application Developer (WSAD) 5.0 Chapter request.getRequestDispatcher(nextPage); 1 - Introducing WSAD 5.0 response); Chapterdispatch.forward(request, 2 - Setting Up the Development Environment } Chapter 3 - Working with the WSAD 5.0 Workbench } Chapter 4 - Developing Database Applications Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Listing 7-8. The BookRegisterInputForm Page, BookRegisterInputForm.html - J2EE EJB Development
Chapter 6
Chapter 7 - J2EE Web Development Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging Chapter - J2EE Enterprise Messaging Chapter - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider
Register New Book
Appendix A - Deploying This Book's J2EE Examples Index
List of Tables List of Code Examples
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications. Register New Book
WebSphere Studio Application Developer 5.0: Practical
J2EE Development ISBN:1590591208 by Igor Livshin Apress © 2003 (630 pages) Catalog number | This book provides a practical, step-by-step approach in | applications.
Book title | Table Contents | Chapter 1 - Introducing WSAD 5.0
Chapter 2 - Setting Up the Development Environment Chapter 3 - Working with the WSAD 5.0 Workbench Author | Chapter 4 - Developing Databasename='author' Applications | Chapter
6 - J2EE EJB Development Chapter 7 - J2EE Web Development Chapter 8 - J2EE XML Development Location | Part - Working with Enterprise Messaging the WSAD-Embedded JMS Provider
11 - Using WebSphere MQ as the JMS Provider Chapter A - Deploying This Book's J2EE Examples Appendix Platform | Index | List of Code Examples
List of Sidebars Language | |
Listing 7-9. The BookRegisterResultsForm Page, BookRegisterResultsForm.jsp J2EE Development ISBN:1590591208 by Igor Livshin Apress © 2003 (630 pages) This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Registration Status Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents ' /> WebSphere Studio Application Developer 5.0: Practical
Registration Status Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 - Introducing 5.0 Chapter
- Setting Up the Development Environment
Chapter 3 - Working with the WSAD 5.0 Workbench 4 Chapter
- Developing Database Applications
Catalog number | Part Two - Working with J2EE: The Distributed Application Framework | Chapter 5 - J2EE Development /TR> 6 Chapter
- J2EE EJB Development
7 Chapter
- J2EE Web Development
Successful Registration | Chapter 8 - J2EE XML Development | Part Three - Working with Enterprise Messaging
Chapter 9 - J2EE Enterprise Messaging Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List ofNote Tables WSAD generates the BookRegisterViewBean.javamodule; it has not been changed. List of Code Examples
As of mentioned, List Sidebars there are many ways to validate the data entered by the user. An alternative way of the data validation is t
Developing the Stateful Web Session
The next Web example will be developed under the same project, TechLibWEB. You will develop a Web function that a book for the specified platform. Although this is a onescreen interaction, the processing logic will call multiple methods fr
Following the MVC Pattern Technically, you will implement this functionality by using the MVC pattern. WSAD automatically builds the MVC pattern BookByPlatformInputForm.html:The input screen BookByPlatformController.java:Servlet controlling the flow of data BookByPlatformOutputForm.jsp:Output result form BookByPlatformHelper1.java:Helper JavaBean class
TheBookByPlatformController.javacontroller servlet coordinates the flow of information for the Web tier of the a
Coding for the Local Client View
You probably remember that you have already developed a stateful session bean called TechLibFacade1that provide (TechLibBook_catalogandTechLibBook_activity)and saves them in the state variables (catalogLocalHome
catalogLocalHomestate variable.
WebSphere Studio Application Developer 5.0: Practical
Development When calling theJ2EE stateful session bean, it is important to ensure that the same instance of the stateful bean is used for th ISBN:1590591208 by Igor initStateVariablesLivshin method following by the getBookForPlatform method): Apress © 2003 (630 pages)
TheBookByPlatformHelper1.java JavaBean class willapproach provide ainmethod called populateIndexedAttributeth This book provides a practical, step-by-step JavaBean’s populateIndexedAttribute teaching how to use the WebSphere methodStudio and use Application the accumulated data to display the dynamic table conten Developer (WSAD) tool for developing J2EE distributed
applications. First, you will build the input user screen (the HTML file called BookByPlatformInputForm.html).Right-click the W
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List ofFigure Tables 7-30: Creating the HTML input form List of Code Examples
Click Finish. WSAD generates the BookByPlatformInputForm.htmlfile and opens it in the Editor View (see Figur
List of Sidebars
Figure 7-31: Creating the HTML input form
Click the Designtab and delete this sentence: Place BookByPlatformInputForm.html's content here. To d button (if the controls you need are not present on the toolbar, click the Toolbarmenu and ensure that the Insert,Fo
You want to place the Logo,Form,Option menu,andSubmit button controls on the page. First, insert the LogoHTM Platform, scroll down, and select the style. You can also manually select the font size and other attributes (see Figure
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development Figure the page logo style Chapter 6 - 7-32: J2EE Setting EJB Development Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Click Finish. Below the logo, enter the plain text: Select the platform and click Submit. Right-click the text
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 7-33: Setting the page logo attributes
Click OKtwice. Next, enter the Form,Option, and Submit button HTML controls. From the main menu, select Inser Select the Postmethod (see Figure 7-34).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Figure 7-34: Creating the FormHTML tag
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development Click OK. outline ofDevelopment the Formcontrol will appear on the screen. Select Insert> Form and Input Fields > Opti Chapter 7 The - J2EE Web Chapter 8
- J2EE XML Development
Part Table Three 7-1:- Working Platforms with and Enterprise Their Codes Messaging
Chapter 9
- J2EE Enterprise Messaging
PLATFORM
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Cross-platform Appendix A - Deploying This Book's J2EE Examples
Unix (AIX)
Index
ListUnix of Figures (Solaris) List of Tables
Unix (HP-UX)
List of Code Examples
NT/2000 ListWindows of Sidebars Linux
Enter each platform-code pair in the ItemandValuefields. Click the Addbutton. The entered platform-code pair will app
Figure 7-35: Entering the item-value pairs in the Choicelist
When you are done, click OK. Place the cursor after the Optioncontrol and press the Enter key three times. Figure 7-36
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
7-36: Creating the form page Table Figure of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development
Insert the Submitbutton. On the Attributesdialog for the push button, enter Submitin both the NameandLabelfields
Introduction
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List ofFigure Code Examples 7-37: Inserting the Submitbutton List of Sidebars
Click OK. Next, click the Previewtab. Your page should look like the one shown in Figure 7-38.
Figure 7-38: The designed input screen
Save the file and close the editor. The action of the form indicates that when a user clicks the Submitbutton, the BookB
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in how to use the WebSphere Studio Application Figure 7-39:teaching The Links View Developer (WSAD) tool for developing J2EE distributed applications.
Just ignore the broken link in the Links View for now. Because the BookByPlatformControlletservlet uses the Java
Right-click the Java Class folder under the TechLibWEBproject and select New> Class. On the dialog that appears, button and select Serializable. You want this JavaBean class to implement the Serializableinterface so that it c
Table of Contents
WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 7-40: Building the JavaBean class
Click Finish. WSAD will generate the skeleton of the JavaBean class.
Adding the Processing Logic
Add the processing logic for the BookByPlatformHelper1class.Listing 7-10 shows the source code of the BookByPl Listing 7-10. BookByPlatformHelper1.java package apress.wsad.techlib; import java.io.Serializable; import java.lang.*; import java.util.*; import javax.ejb.*; import javax.naming.*; import java.rmi.*; import javax.ejb.Handle.*; import apress.wsad.techlib.TransportBean; public class {
BookByPlatformHelper1 implements Serializable
// Attributes WebSphere Studio Application Developer 5.0: Practical TransportBean[] transObjList; J2EE Development by Igor Livshin
ISBN:1590591208
// Instance variables Apress © 2003 (630 pages) String selectedPlatform; This book provides Vector bookVector = nulla practical, ; step-by-step approach in
teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed // Variables to keep LocalHome and Local interfaces for applications.
the TechLibFacade1 stateful session bean TechLibFacade1LocalHome facade1LocalHome = null; TableTechLibFacade1Local of Contents facade1Local = null; WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction /** Part One Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 * -Default Constructor
Chapter*/ 1
- Introducing WSAD 5.0
Chapter public 2 - Setting BookByPlatformHelper1() Up the Development Environment
{ 3 Chapter
- Working with the WSAD 5.0 Workbench
Chaptersuper(); 4 - Developing Database Applications Part Two - Working with J2EE: The Distributed Application Framework
} 5 Chapter
- J2EE Development
Chapter 6
- J2EE EJB Development // Method get the LocalHome Interface of the TechLibFacade1 session bean. Chapter 7 - J2EEto Web Development
private TechLibFacade1LocalHome getFacade1LocalHome() - J2EE XML Development { Part Three - Working with Enterprise Messaging Chapter 8 Chapter 9
- J2EE Enterprise Messaging
try { Chapter 11 - Using WebSphere MQ as the JMS Provider if (facade1LocalHome == null) Appendix A - Deploying This Book's J2EE Examples { Index InitialContext initContext = new InitialContext(); Chapter 10 - Using the WSAD-Embedded JMS Provider
List of Figures List of Tables Object objRef = List of Code Examples initContext.lookup("java:comp/env/TechLibFacade1"); List of Sidebars
facade1LocalHome = (TechLibFacade1LocalHome) objRef; return facade1LocalHome; } else { return facade1LocalHome; } } catch (NamingException e) { System.out.println("Error locating TechLibBook_catalogLocalHome: " + e.getMessage()); throw new EJBException("Error locating TechLibBook_catalogLocalHome: " + e.getMessage()); }
}
// Method to get the Local Interface of the TechLibFacade1 stateful session
// bean. WebSphere Studio Application Developer 5.0: Practical private TechLibFacade1Local getFacade1Local() J2EE Development throws RemoteException, CreateException ISBN:1590591208 by Igor Livshin { Apress © 2003 (630 pages) try This book provides a practical, step-by-step approach in { teaching how to use the WebSphere Studio Application // Create remote handle for the first time and Developer (WSAD) tool for developing J2EE distributed facade1Local = facade1LocalHome.create(); applications. return
facade1Local;
Table of Contents WebSphere Studio 5.0: Practical J2EE Development } // EndApplication of the Developer try block Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 catch(Exception e)
Chapter { 1
- Introducing WSAD 5.0
Chapter System.out.println("Exception 2 - Setting Up the Development Environment in getFacade1Local method: " + Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Twoe.getMessage()); - Working with J2EE: The Distributed Application Framework
-throw J2EE Development EJBException("Exception in getFacade1Local method: " + Chapter new 6 - J2EE EJB Development Chapter 5
Chapter e.getMessage()); 7 - J2EE Web Development
}
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
} // End of getFacade1Remote method
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider
// Common processing logic public void populateIndexedAttribute() Index { Appendix A - Deploying This Book's J2EE Examples List of Figures List of Tables try List of Code Examples { List of Sidebars facade1LocalHome = getFacade1LocalHome();
facade1Local = getFacade1Local(); // First call the initSataeVariables facade1Local.initStateVariables(); // Now, we can call the getBookForPlatform business method bookVector = facade1Local.getBookForPlatform(selectedPlatform); if
(bookVector == null) { transObjList = new TransportBean[1]; transObjList[0] = new
TransportBean();
transObjList[0].setCatalogNumber(""); transObjList[0].setBookTitle(""); transObjList[0].setAuthor(""); transObjList[0].setLocation(""); } else {
// Convert bookVector to an array of TransportBean objects WebSphere Studio Application Developer 5.0: Practical int workSize = bookVector.size(); J2EE Development transObjList = new TransportBean[bookVector.size()]; ISBN:1590591208 by Igor Livshin bookVector.copyInto(transObjList); Apress © 2003 (630 pages) } This book provides a practical, step-by-step approach in } teaching how to use the WebSphere Studio Application catch (Exception re) tool for developing J2EE distributed Developer (WSAD) { applications. System.out.println("RemoteException in the populateIndexedAttribute method: + re.getMessage()); Table of throw Contents WebSphere Application Developer 5.0: Practical J2EEin Development newStudio EJBException("RemoteException the populateIndexedAttribute Introduction method: " + re.getMessage()); Part One -}Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0
Chapter } // 2 End - Setting of the Up the populateIndexedAttribute Development Environment method Chapter 3
- Working with the WSAD 5.0 Workbench
public Chapter 4
-TransportBean[] Developing Database getTransObjList() Applications
{ - Working with J2EE: The Distributed Application Framework Part Two transObjList; Chapter 5 return - J2EE Development Chapter}6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
public void setTransObjList(TransportBean[] transObjList) Chapter 8 - J2EE XML Development { Part Three - Working with Enterprise Messaging this .transObjList = transObjList; Chapter 9 - J2EE Enterprise Messaging } Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 - Using WebSphere MQ as the JMS Provider
public {
String getSelectedPlatform()
Appendix A - Deploying This Book's J2EE Examples Index
return
selectedPlatform;
List of Figures } List of Tables List public of Code Examples void
setSelectedPlatform(String selectedPlatform)
List of { Sidebars
this.selectedPlatform = selectedPlatform; } }
Examining the BookByPlatformHelper1 Code
Let’s examine the BookByPlatformHelper1JavaBean’s processing logic. The main processing happens within the po session bean and saves the results in the facade1LocalHomeandFacade1Localstate variables. The populateInd this: bookVector = facade1Local. getBookForPlatform(selectedPlatform);
This call returns a vector of objects of type TransferBean. Finally, you convert the vector object to an array called tra BookByPlatformControllerservlet. Right-click the apress.wsad.techlibfolder and select New> Servlet.
Tip Right-clicking the apress.wsad.techlibfolder (instead of the TechLibWEBproject) fills in the apress.wsad On the dialog that appears, shown in Figure 7-41, enter BookByPlatformControllerin the Class Name field.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Figure a new servlet component Chapter 8 - 7-41: J2EE Creating XML Development Part Three - Working with Enterprise Messaging
Click Next. On the next screen, select the doPost(),doGet(),doDelete(),andinit()methods (see Figure 7-42).
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 7-42: Setting servlet attributes
Click Finish. WSAD will generate the skeleton of the BookByPlatformControllerservlet. Modify the servlet to add Listing 7-11. BookByPlatformController.java package
apress.wsad.techlib;
import java.io.IOException; WebSphere Studio Application Developer 5.0: Practical import javax.servlet.ServletException; J2EE Development import javax.servlet.*; ISBN:1590591208 by Igor Livshin import javax.servlet.http.*; Apress © 2003 (630 pages) import javax.servlet.http.HttpServlet; This book provides a practical, step-by-step approach in import javax.servlet.http.HttpServletRequest; teaching how to use the WebSphere Studio Application import javax.servlet.http.HttpServletResponse; Developer (WSAD) tool for developing J2EE distributed public class applications. BookByPlatformControllerextends HttpServlet { public void doDelete(HttpServletRequest req, HttpServletResponse resp) Table of Contents throws ServletException, IOException WebSphere Studio Application Developer 5.0: Practical J2EE Development { Introduction Part } One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter public 2 void - Setting doGet(HttpServletRequest Up the Development Environment req, HttpServletResponse resp)
throws Chapter 3
ServletException, IOException - Working with the WSAD 5.0 Workbench
{ Chapter 4
- Developing Database Applications
resp); Part TwoperformTask(req, - Working with J2EE: The Distributed Application Framework } Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development public doPost(HttpServletRequest req, HttpServletResponse resp) Chapter 7 void - J2EE Web Development
throws- J2EE ServletException, IOException XML Development { Part Three - Working with Enterprise Messaging performTask(req, resp); Chapter 9 - J2EE Enterprise Messaging } Chapter 8
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 - Using WebSphere MQ as the JMS Provider
public void init()throws { Index super.init(); List } of Figures
ServletException
Appendix A - Deploying This Book's J2EE Examples
List of Tables List of Code Examples List of Sidebars public void
performTask(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{ String nextPage; try { HttpSession session = request.getSession(true); // Prepare invocation of the jsp module BookByPlatformOutputForm.jsp nextPage = "/BookByPlatformOutputForm.jsp"; } catch (Exception ex) { //If an exception is thrown, serve the error page nextPage = getInitParameter("error_page");
} //Forward the request to the next page dispatch(request, response, nextPage);
}
WebSphere Studio Application Developer 5.0: Practical J2EE Development
public void dispatch(HttpServletRequest request, ISBN:1590591208 by Igor Livshin HttpServletResponse response, Apress © 2003 (630 pages) String nextPage) This book provides a practical, step-by-step approach in throws teaching ServletException, IOException how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed { applications. RequestDispatcher dispatch = request.getRequestDispatcher(nextPage); dispatch.forward(request, response); Table of } Contents } WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Notice that the warning message about the broken link has disappeared.
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Discussing the Servlet - Working withBookByPlatformController the WSAD 5.0 Workbench
Chapter 3 Chapter 4
- Developing Database Applications
Let’s examine the servlet code. You added two new methods called performTaskanddispatch. Both methods perfor JSP module.
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Developing theDevelopment BookByPlatformOutputForm Output Form - J2EE Web
Chapter 7 Chapter 8
- J2EE XML Development
Next, you need to develop the BookByPlatformOutputForm.jspmodule responsible for displaying the dynamic con in the File Name field (see Figure 7-43).
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 7-43: Building the JSP component
Click Finish. WSAD will generate the BookByPlatformOutputForm.jspfile. Switch to the Design View by clicking t Click the Previewtab to see the picture (see Figure 7-44).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
Figure 7-44:This Previewing the logo book provides a practical, step-by-step approach in
teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed Now, click the Design applications. tab. This JSP code should call the BookByPlatformHelper1JavaBean to get the data accumu
Insert Bean. On the dialog that appears, enter Helper1in the IDfield. Enter the fully qualified JavaBean class name Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - 7-45: UsingInserting the WSAD-Embedded Provider Figure the JavaBeanJMS class in the JSP module Chapter 11 - Using WebSphere MQ as the JMS Provider
Click OK.AWSAD will generate the following tag: Appendix - Deploying This Book's J2EE Examples
Index Using JavaScripts List of Figures Index
List of Tables
List of Code Examples List of Sidebars When elementFormDefault="unqualified"is coded in the XML Schema, only global elements within
the corresponding XML file must be namespace qualified (see Listing 8-10). Listing 8-10. XML Schema with elementFormDefault="unqualified"
Listing 8-11. XML File Built Based on the XML Schema with elementFormDefault="unqualified"
Studio Application Developer 5.0: Practical Apress © 2003 (630 pages)
This book provides a practical, step-by-step approach in Using JavaScripts teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Additional Considerations for XML Schemas
Table of Contents
WebSphere Application Practical J2EE Schemas: Development You shouldStudio also consider theDeveloper following5.0: when using XML Introduction
Declaration vs. definition: You declare elements and attributes. XML(WSAD) Schema5.0 components Part One - Getting Started with WebSphere Studio Application Developer
that are declared
are those are represented in an XML instance document. Defined schema components (type, attribute Chapter 1 that - Introducing WSAD 5.0 group definitions, and group definitions) are used just within the schema document. The implication is Chapter 2 - Setting Upmodel the Development Environment that you should not declare an element simply because you want to reference it from another element - Working with the WSAD 5.0 Workbench (instead, define the type). Declare elements that you need to be present in the XML instance document.
Chapter 3 Chapter 4
- Developing Database Applications
Part Two element - Workingdeclarations with J2EE: The Distributed Application Framework Global and global type definitions: They are immediate
children of the schema.
Chapter 5 - J2EE Development Local element declarations and local type definitions are always nested within other elements/types. Only Chapter 6 J2EE EJB Development global elements and types can be referenced (reused). Local elements/types are effectively invisible to the Chapter 7 schema - J2EE Web Development rest of the (and to other schemas). Chapter 8
- J2EE XML Development
Complex elements: Use the complexType element Part Three -type Working with Enterprise Messaging
when you need to define child elements and/or attributes. Use the simpleType element when you want to create a new type that is a refinement of a built-in Chapter 9 - J2EE Enterprise Messaging type (string, date, gYear, and so on). Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - UsingLocal WebSphere MQ are as the Provider Local elements: elements notJMS formally in the targetNamespace. They informally belong to this Appendix A Deploying This Book's J2EE Examples namespace only by association with the global element with which they are in line. Index
Attributes: List of FiguresAttributes are not namespace qualified, but they do not belong to the default namespace. Rather, they associated with the elements, which are in the namespace. List of are Tables List of Code Examples
Global element declarations and global type definitions: These must be namespace qualified when they are referenced within the XML Schema.
List of Sidebars
Elements: Elements must be namespace qualified on the instance document: When the schematag has elementFormDefault="qualified" When the element is declared globally When the element is declared with form="qualified" That concludes the XML introduction. The goal of this part of the chapter was to help you better understand the XML namespace and other XML Schema constructs. The rest of this chapter uses XML namespaces in the development examples. You are now ready to explore the many XML-related tools that WSAD 5.0 provides.
WebSphere Application Developer 5.0: Practical Using WSAD's XMLStudio Tools J2EE Development
ISBN:1590591208 by impressive Igor Livshinarray of XML-related tools. They WSAD provides an allow building, importing, editing, and validating Apress © 2003 pages) Editor), DTD files (the DTD Editor), and XML files (the XML Editor). of XML Schema files (the XML(630 Schema Additional functionality is provided many XML cross-file manipulations: This book providesfor a practical, step-by-step approach in
teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE Schema distributed Generating XML, JavaBean, and DTD files from XML applications.
Generating XML Schema, DTD, and Hypertext Markup Lanugage (HTML) files from XML files Table of ContentsXML, DTD, JavaBean, and HTML files from DTD files Generating WebSphere Studio Application Developer 5.0: Practical J2EE Development
Generating Extensible Stylesheet Language (XSL), XML, and XML Schema from JavaBean files Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Tools are also available for developing XSL Transformations (XSLT) and for XML integration with databases. - Introducing WSAD 5.0 You will build a series of examples that use some of these tools. You will develop all the XML examples under a Chapter 2 - called SettingXMLSamplesProject. Up the Development Environment new project Chapter 1 Chapter 3
- Working with the WSAD 5.0 Workbench To create project,Database select File > New> Project> Simple Project. On the screen that appears, Chapter 4 a- new Developing Applications
enter XMLSamplesProject theDistributed ProjectApplication Name field. Click Finish. Part Two - Working with J2EE: in The Framework
WSAD will create the project
XMLSamplesProject. Chapter 5 - J2EE Development Chapter 6
- J2EE EJB Development
- J2EE Development Building anWeb XML Schema
Chapter 7 Chapter 8
- J2EE XML Development
Part TheThree first example - Working shows with Enterprise how to create Messaging a new XML
Schema using the XML Schema Editor. You will build the XML
Schema Listing 8-12. Chapter 9 shown - J2EEinEnterprise Messaging Chapter 10 - Using the WSAD-Embedded JMS Provider
Listing 8-12. XML Schema
Chapter 11 - Using WebSphere MQ as the JMS Provider
Appendix - Deploying This Book's J2EE Examples List of Tables List of Code Examples
List of Sidebars
WebSphere Application Developer globally 5.0: Practical ISBN:1590591208 by Igor Livshin Apress © 2003 (630 pages) book provides a practical, step-by-step approach in (WSAD) tool for developing J2EE distributed applications. Table of Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0
Chapter Development Environment - Working with the WSAD 5.0 Workbench type="bk:bookTitle" Chapter Chapter 3
-- Cordinality is defined when the element Part Two - Chapter is 5 -referenced J2EE Development name="Author" type="bk:authorType" Chapter Chapter minOccurs="1" 7 - J2EE Web Development - J2EE XML Development Part Three - Working with Enterprise Messaging Chapter 8 Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples Chapter 11 - Using WebSphere MQ as the JMS Provider
List of Sidebars
>
Switch to the XML Perspective. From the main menu, select File> New> XML Schema. On the screen shown inFigure 8-1, select XMLon the left pane and XML Schemaon the right.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Figure- 8-1: Building the XML Schema J2EE Development
Chapter 5
Chapter 6 - On J2EE Development Click Next. theEJB next screen, the project XMLSamplesProjectwill be filled in already. Just enter Chapter 7 J2EE Web Development Library.xsdin the File name field and click Finish. The Library.xsdXML Schema appears under Chapter 8 - J2EE XML Development XMLSamplesProject and automatically opens in the XML Schema Editor (see Figure 8-2). Part Three - Working with Enterprise Messaging
By default, areEnterprise in the Design View, where you can also switch to the Source and Graph Views. The Chapter 9 -you J2EE Messaging Workbench the Outline View. the items you will be adding to the XML Schema will appear in the Chapter 10 - also Usingpresents the WSAD-Embedded JMS All Provider Outline11 View. You can also edit theasXML Schema in the Source View; however, any changes made in the Source Chapter - Using WebSphere MQ the JMS Provider View willAnot be reflected inBook's the Outline View. Appendix - Deploying This J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 8-2: The XML Schema Editor
Adding Global Elements To build your XML Schema, you need to add several global elements (four simple types, three complex types, and two global elements). In the Outline View, rightclick Library.xsdand select Add Simple Type. In the Design View, change the name to bookTitle. Repeat the previous steps three times to add three more simple
types (firstName,middleName, and lastName). Notice that four simple types appear in the Outline View. In Studio Application Developer 5.0: Practical the Outline View,WebSphere right-click Library.xsd and select Add Complex Type. In the Design View, change the J2EE Development name to authorType. Repeat the same steps to enter two more complex elements: bookTypeand ISBN:1590591208 by Igor Livshin LibraryType. Apress © 2003 (630 pages)
book providesright-click a practical, step-by-step in To add the globalThis Book elements, Library in theapproach Outline View and select Add Global Element. teaching how use the Studio Application In the Design View, change thetoname to WebSphere Book.Check the User-defined complex type box and select Developer (WSAD) tool for developing J2EE distributed bookTypeas a user-defined complex type. Repeat the same steps to add the second global element applications. Library; however, select libraryTypeas the user-defined complex type (see Figure 8-3). Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples IndexFigure 8-3: XML Schema general outline List of Figures List of Tables
Adding List of Code Details Examples
for Each Objects
List of Sidebars
You just built the general outline for the XML Schema, so now you will fill in the details for each object. You will start from the simple types. In the Outline View, right-click bookTitleand select Add Restriction. On the screen shown in Figure 8-4, check Built-in simple type and make sure that stringis selected. Enter 200in the maxLengthfield. Repeat the same steps for the rest of the simple types, but set a different maxLengthvalue (20for firstName,2for middleName, and 50for lastName). Next, you will enter details for the complex types. In the Outline View, right-click authorTypeand select Add Content Model. Check the Sequencebox. Rightclick the content model in Outline View and select Add Element. On the screen that appears, enter FirstNamein the Element name field. Check User-defined simple type and select firstName. Notice that the type is made namespace qualified by the Libraryprefix. Enter 1in the Minimumand Maximumfields (see Figure 8-5).
Figure 8-4: XML Schema simple type details
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Application Developer 5.0: Practical J2EE Development FigureStudio 8-5: Details for the XML Schema complex type FirstName Introduction Part Repeat One -the Getting sameStarted steps towith addWebSphere two more elements Studio Application (MiddleName Developer andLastName). (WSAD) 5.0
Next, right-click the second
complex bookTypeWSAD and select Chapter 1 type - Introducing 5.0 Add Content Model. Right-click the content model in Outline View and selectAdd screen thatEnvironment appears, enter BookTitlein the Element name field. Enter Chapter 2 -Element. Setting UpOn thethe Development bookTitle the User-defined simple type field. Enter 1in the MinimumandMaximumfields. Chapter 3 - in Working with the WSAD 5.0 Workbench Repeat4the- same steps Database to add theApplications second element called Author(see Figure 8-6). Chapter Developing Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List ofFigure Tables 8-6: Details for the XML Schema complex type Author List of Code Examples
You also need to add an attribute field here called PublishYear. In the Outline View, right-click bookType and select Add Attribute. On the next screen, shown in Figure 8-7, enter PublishYearas the Attribute name, select gYearas the simple type, and indicate that the attribute is required.
List of Sidebars
Figure 8-7: Adding a required attribute Repeat similar steps to enter the last complex type named libraryType. The only difference is that you need to add an element reference and not an element, and you select the element from the list of available elements—in this case, Book(see Figure 8-8). Make sure 0is specified as the value for the Minimumfield and unboundedis specified as the value for the Maximumfield.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching use Schema the WebSphere Studio Figure 8-8: Details forhow theto XML complex typeApplication bookType Developer (WSAD) tool for developing J2EE distributed applications.
You are almost done. You still need to correct the value of targetNamespaceand the prefix automatically generated by the XML Schema Editor. In the Outline View, click Library.xsdand switch to the Design View (if you are not already there). Enter http://www.techlib.comin the Target namespace field and enter bk Table of Contents in the Prefix field. Click Apply. WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction
Now, click the FirstNameelement inside the authorTypecomplex type. You should see that the userdefined type is namespace qualified by the bkprefix. The change is global for the entire document, and it is not Chapter 1 - Introducing WSAD 5.0 only related to the prefix but to any change. The XML Schema Editor maintains a referential integrity, meaning Chapter 2 - Setting Up the Development Environment that when you make a change, all affected fields are modified (see Figure 8-9). Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter Note 4 The - Developing referentialDatabase integrity Applications feature does not work if you make changes on the source page. Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 8-9: Changed namespace prefix Your XML Schema is ready. Click the Sourcetab to see the generated code (see Listing 8-13). Listing 8-13. Generated XML Schema
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications. Table of Contents name="lastName"> The Authorelement will be inserted. Next, you want to add the MiddleName Chapter 2 Author. - Setting Upsecond the Development Environment element. element and select Add Child > MiddleName. Enter Pavel A. Chapter 3 Right-click - Workingthe withAuthor the WSAD 5.0 Workbench Vorobiev the value Database for the second Authorelement. Save the XML file. No errors should be displayed on Chapter 4 -asDeveloping Applications the Two Tasks View. with J2EE: The Distributed Application Framework Part - Working Chapter 5
- J2EE Development
Next, you need to add a second book. Right-click the Libraryelement and select Add Child > Book. A new - J2EE EJB Development Bookelement will be inserted (see Figure 8-14). Enter 1999as the PublishYear,Java in a Nutshell Chapter 7 - J2EE Web Development as the BookTitle, and David Flanagan as the Author. Save the XML file. There should be no errors. The Chapter 8 - J2EE Development Library.xml fileXML is ready. Chapter 6
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 8-14: Library.xml You can also switch to the Source View to see the Library.xmlsource code (see Listing 8-15). Listing 8-15. Library.xml The Java 1.1 Programmer's Reference Daniel I Joshi Pavel A Vorobiev
WebSphere Studio Application Developer 5.0: Practical J2EE Development Java in a Nutshell ISBN:1590591208 by Igor Livshin Apress © 2003 (630 pages) David This book provides a practical, step-by-step approach in Flanagan teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications. Table of Contents WebSphere Application 5.0:the Practical J2EE Development While you Studio are here, you canDeveloper quickly build DTD file called BookLibrary.dtdthat resembles the structure Introduction of the TECHBOOK database table called BOOK_CATALOG. You will use this file in one of the examples you will Part One -later Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 develop in this section.
Chapter 1
- Introducing WSAD 5.0
Chapter 4
- Developing Database Applications
In the XML Perspective, right-click XMLSampleProjectand select New> DTD. On the next screen, select Chapter 2 - Setting Up the Development Environment Create DTD file from scratch and click Next. On the following screen, name the file Chapter 3 - Working with the WSAD 5.0 Workbench BookCatalog.dtdand make sure that XMLSamplesProjectis the destination folder. Click Finish. Part - Working with J2EE: The open Distributed Application TheTwo skeleton of the DTD file will in the DTD Editor.Framework Click the Sourcetab
(for the sake of demonstration,
Chapter - J2EE Development you will5quickly build the DTD file using the Source View). In the Outline View, right-click BookCatalog.dtd and Chapter 6 J2EE EJB select Add Element. Development Replace the NewElementname with CatalogNumber. Replace EMPTYwith Chapter 7 - J2EE Webthe Development (#PCDATA). Repeat same steps and enter the following elements: Author,BookTitle,Location, Chapter Platform, 8 - and J2EELanguage. XML Development Part Three - Working with Enterprise Messaging
Then, add new element called Bookand indicate that it consists of single CatalogNumberandBookTitle Chapter 9 -a J2EE Enterprise Messaging elements, one or more Authorelements, and single Location,Platform,Languageelements:
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 - Using MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
Finally, add one more element called BookCatalogand indicate that it consists of multiple Bookelements:
Index
List of Tables
You should see the screen shown in Figure 8-15.
List of Code Examples List of Sidebars
Figure 8-15: Building the DTD file
Parsing XML Documents Among the many different Application Programming Interfaces (APIs) for parsing XML documents, the Document Object Model (DOM) and Simple API for XML (SAX)—together with their corresponding parsers—are the most popular and widely used. When DOM parses an XML document, the returned result is a tree structure (located in memory) that contains all of the elements of the document. DOM provides various APIs for traversing the DOM tree, making modifications to its structure, and making other tree manipulations. The advantage of the DOM is that it allows direct access to any node in the memory-based node tree. DOM processing has some limitations because it keeps the entire document tree structure in memory. For large XML documents, the memory requirement could be a prohibitive factor. SAX is an event-driven methodology. When SAX parses an XML document, the parser generates events at various points in the document, passing control to the program’s callback methods that handle the events. SAX
also provides a class called DefaultBasethat implements all of these callback functions, providing default WebSphere Studio Application Developer 5.0: Practical empty implementations. The SAX developer extends this DefaultBase class and overrides those callback J2EE Development functions that require nondefault processing. SAX events that have no corresponding event handlers are ignored ISBN:1590591208 by Igor Livshin (default processing). Apress © 2003 (630 pages)
Thiswere bookdeveloped provides a by practical, step-by-step approach in of the XML-Dev mailing list. The World Note SAX APIs David Meggison and members teaching how to use the WebSphere Studio Application Wide Web Consortium (http://www.w3.org) has not yet standardized SAX. Developer (WSAD) tool for developing J2EE distributed applications.
The main SAX limitation is its inability to manipulate the XML file as an object in memory. It always requires sequential processing. The main SAX advantage is that it does not need to keep the entire node tree in memory. Another SAX advantage is that it can be instructed to stop the parsing process before reaching the end of the Table of Contents document withoutApplication losing theDeveloper data already To stop the parsing process, you throw a new WebSphere Studio 5.0:collected. Practical J2EE Development SAXException. Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Use DOM in the following circumstances:
Chapter 1
- Introducing WSAD 5.0
Chapter 2 -you Setting Development Environment When needUp to the perform processing that requires the entire document structure (sorting is one example). Chapter 3 - Working with the WSAD 5.0 Workbench
When can parse the document once and then process the document tree multiple times. Chapter 4 -you Developing Database Applications Part Two - Working with J2EE: The Distributed Application Framework
Use SAX in the following circumstances:
Chapter 5
- J2EE Development
Chapter 6 -you J2EE EJBtoDevelopment When need extract only limited number of elements Chapter 7 - J2EE Web Development
If the is Development large and you have a limited memory Chapter 8 document - J2EE XML Part Three - Working with Enterprise Messaging
If you need to process the document only once
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - and Using theparsers WSAD-Embedded JMSfrom Provider Many DOM SAX are available different vendors (each with its own proprietary features). Again, Chapter as with11 Java - Using Database WebSphere Connectivity MQ as(JDBC), the JMS Provider Java Naming and Directory Interface (JNDI), and Java Message
Service A (JMS), Sun Microsystems developed a set of vendor-independent APIs, classes, and interfaces called Appendix - Deploying This Book's J2EE Examples Java APIs for XML Processing (JAXP). Using JAXP, developers are able to work with any DOM or SAX JAXPIndex compatible List of Figuresparser. The latest release is JAXP 2, which supports the latest DOM 2.0 and SAX 2.0 standards. List of Tables
You will develop the following XML programming examples as Web applications; therefore, you need to create a Web project. Switch to the Web Perspective and select File> New> Web Project. Enter XMLProjectWEB List of Sidebars in the Project name field and click Next. On the next screen, indicate that this Web module will belong to a new enterprise application project; name it XMLProjectAppand click Finish. WSAD will generate two new projects. List of Code Examples
You now need to update the project’s Java Build Path to include three XML supporting tools that you will be using: the XERCER parser, the XALAN transformation engine, and the SQLTOXML tool. When you are in the XML Perspective, these variables are automatically initialized. You can check which variables are initialized by selecting Windows> Preferences> Java> Classpath Variables. You should see that three variables—XERCES, WAS_V5XALAN, and SQLTOXML—are initialized (see Figure 8-16).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 - 8-16: J2EE List Development Figure of WSAD environment variables Chapter 6 - J2EE EJB Development
Next, you to Web update the project’s Java Build Path to include these three variables. Right-click Chapter 7 need - J2EE Development XMLProjectWEB and Development select Properties> Java Build Path. Select the Librariestab and click the Chapter 8 - J2EE XML AddThree Variable button. Scroll down on the dialog Part - Working with Enterprise Messaging
that appears, and select the SQLTOXMLvariable. Then, click
OK(see9Figure 8-17). Chapter - J2EE Enterprise Messaging Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 8-17: Adding environment variables to the Java Build Path Repeat the same steps and include two more variables: WAS_V5_XALAN and XERCES. You should see all three variables being added to the Java Build Path. Click OKto save the results. As mentioned, you use the Java Build Path at development time. The runtime environment has no idea about the Java Build Path, projects, Perspectives, and so on. Therefore, you always have to think about the runtime environment. To make these three XML tools accessible by all Web module classes at runtime, you will add them to the Web-INF/libdirectory. If this does not look familiar, refer to the “Understanding Classloaders” section of Chapter 5. To do this, select File> Import> File system. Click Next. On the next screen, click Browseand navigate to the \wstools\eclipse\plugins\com.ibm.etools.sqltoxml_5\jars library (see Figure 818).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Figure the JAR library Chapter 8 - 8-18: J2EE Selecting XML Development Part Three - Working with Enterprise Messaging
Click OK. Next, check the sqltoxml.jarbox and click OK. Use the Browsebutton attached to the Folder - J2EE Enterprise Messaging field to set the destination folder to the XMLProjectWEB/Web Content/WEB-INF/lib folder (see Figure 8Chapter 10 - Using the WSAD-Embedded JMS Provider 19). Chapter 9
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 8-19: Adding the JAR library to the Web-INF/libfolder Click Finish. The sqltoxml.jarwill be added to the WEB-INF/libfolder. You do not need to do the same for XERCES.JARandXALAN.JARbecause they are already included in the WAS server runtime environment. Look again at the list of WSAD environment variables. Both are located in the \runtimes\base_V5\libfolder. Of course, you always need to consult the WAS Studio Application Developer 5.0: Practical administration to WebSphere make sure that this is the case with your specific WAS instance. J2EE Development
ISBN:1590591208 bythe Igorlib Livshin folder under WEB-INFand select Import > File system. The next screen will Tip Right-click Apress © 2003 (630 pages) be prefilled with the correct destination folder.
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Note If your application uses a database, you need to do the same with the JDBC drivers. The DB2 JDBC (WSAD) toolinfor J2EE distributedServer (WAS) runtime; however, other drivers Developer are already included thedeveloping WebSphere Application applications. databases’ JDBC drivers need to be placed in the WEB-INF/libfolder.
The project environment is now ready for XML development. Before you can go on, you need to update the Library.xmlfile to correctly reflect the location of the XML Schema file Library.xsd.The XML Schema WebSphere Studio Application Developer 5.0: Practical J2EE Development Library.xsdfile is located in the WSAD environment at \workspace\XMLSamplesProject\Library.xsd.You need to modify the Library.xml Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 file to correctly point to the XML Schema location (see Listing 8-16).
Table of Contents
Chapter 1
- Introducing WSAD 5.0
Chapter - Setting Up the Development Environment Listing28-16. Corrected XML Schema Location Chapter 3
- Working with the WSAD 5.0 Workbench
- Developing Database Applications Deploy and RMIC Code.Figure - J2EE Web Development 10-7 shows the next screen. On this screen, check Book_notifyand make sure that the ReceivingMDB Chapter 8 - J2EE XML Development is unchecked. Chapter 7
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 10-7: Generating the deployment and Remote Method Invocation Code (RMIC) Click Finish. The deployment code and RMIC will be generated. Make sure there are no errors in the Tasks View. Note Remember that unlike session and entity beans, MDBs do not provide client interfaces (neither Local nor Remote) because they are never directly called by EJB clients. Therefore, you never generate deployment and RMIC code for MDBs.
Creating the Test Server Project Now, you need to set the development and runtime environments. You will create a new server project that will be used for testing both of your applications. Select File> New> Project> Server> Server Project. On the screen that appears, enter JMSTestServerProjectin the Project name field. Click Finish. Next, right-click JMSTestServerProjectand select New> Server and Server Configuration. On the next screen, enter JMSServerin the Server name field. Select WebSphere
version 5.0 Test Environment and click Finish.
WebSphere Studio Application Developer 5.0: Practical
J2EE Development In the Server Configuration View, right-click JMSServer, select Add> ReceivingJMSProjectApp. This ISBN:1590591208 Igor Livshin makes this serverbythe default server for testing the ReceivingJMSProjectApp project. In the Server Apress © 2003 (630 pages) Configuration View, double-click JMSServerto open it in the Editor View. Click the Configurationtab. This providesconfiguration. a practical, step-by-step Figure 10-8 shows thebook JMSServer Check theapproach Enable inadministration console and teaching how to use the boxes. WebSphere Studio Application Enable universal test client Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4 - 10-8: Developing Database Applications Console and Universal Test Client Figure Enabling the Administrative Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Configuring Chapter 6 - J2EEthe EJB Datasource Development Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
To configure the Datasource, click the Data Source tab and select Default DB2 JDBC
Part Three - Working withclick Enterprise Messaging Provider DB2. Next, the Add button attached
to the 'Data source' section of the screen. Figure 10-9
Chapter 9 screen - J2EE Enterprise shows the you use toMessaging set the Datasource. Make sure that the Datasourceis called Chapter 10 - Using theits WSAD-Embedded JMS Provider DBDatasource and JNDI name is jdbc/DBDatasource. Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 10-9: SettingDBDatasource Click Next. On the next screen, shown in Figure 10-10, highlight the databaseNamefield and enter TECHBOOKin the Valuefield.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Figure- 10-10: Setting the database name J2EE Enterprise Messaging
Chapter 9
Chapter 10 - Using WSAD-Embedded Provider page shown in Figure 10-11. Click Finish. Youthe should see the DataJMS sources Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 10-11: The Data sources page In the next section, you will configure the JMS objects (also called administered objects) that are necessary for running this example.
Configuring JMS Administered Objects Any JMS program requires the presence of the corresponding JMS-administered objects (queue connection factories and queues for the P2P domain or topic connection factories and topics for the Pub/Sub domain). You are developing this example to initially run as a JMS P2P application. Later, with minor changes, you will make this example run as a JMS Pub/Sub application. To support both the P2P and Pub/Sub domains for this example, you will set all the necessary administered objects (queue-related and topic-related). Click the JMStab to configure the embedded JMS server and define the necessary administered objects (queue connection factory, queue,topic connection factory, and topic). You should see that you can do JMS
configuration on three different levels:
WebSphere Studio Application Developer 5.0: Practical
Development Server: The J2EE individual application server by Igor Livshin
ISBN:1590591208
Node: A set Apress of application © 2003 (630 servers pages) running on the same machine/node This book provides a practical, step-by-step approach in
Cell: A set ofteaching nodes that cell, which determines the scope of the availability of the howbelong to use to thea WebSphere Studio Application administeredDeveloper objects (WSAD) tool for developing J2EE distributed applications.
You will configure administered objects on the server level. For the server-level setting, get to the 'JMS Server Properties' section and click the Addbutton. Enter NotifyQin the Queue Names field and click Table of Contents OK. The server will maintain this queue. In addition, select STARTas the server instance's Initial State. WebSphere Studio Application Developer Selectlocalhost in the Host field. 5.0: Practical J2EE Development Introduction
Scroll to theStarted 'JMS Connection Factories' section. ClickDeveloper the Addbutton attached Part Onedown - Getting with WebSphere Studio Application (WSAD) 5.0
to the
'WASQueueConnectionFactory entries' section of the screen. Figure 10-12 shows the next screen. Enter Chapter 1 - Introducing WSAD 5.0 NotifyQCF the Name field and jms/NotifyQCF Chapter 2 - in Setting Up the Development Environmentin the JNDI Name field. Select localhostas the Node. Click Scrollwith to the Destination' section and click the Addbutton attached to the 'WASQueue Chapter 3 - OK. Working the 'JMS WSAD 5.0 Workbench entries' section of the screen. Enter NotifyQin the Namefield and jms/NotifyQin the JNDI Name - Developing Database Applications field. Select localhost in the Nodefield. Part Two - Working with J2EE: The Distributed Application Framework Chapter 4 Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 10-12: Configuring runtime connection factories The following fields are available on this screen: TheMin connections property determines the minimum number of physical connections to be maintained for the destination virtual channel (a queue in this case). TheMax connections property determines the maximum number of physical connections that can be created. TheConnection timeout property specifies the interval, in seconds, after which the connection request times out and an exception is thrown. TheReap time property specifies the interval, in seconds, between runs of the pool maintenance thread. TheUnused timeout property specifies the interval, in seconds, after which an unused or idle connection is returned to the pool. This value must be higher than the Reap timeout property for optimum performance.
TheAged timeout property specifies the interval, in seconds, after which the physical connection is WebSphere Studio Application Developer 5.0: Practical J2EE Development discarded. This value must be higher than the Reap timeout property for optimum performance. A Igor Livshin value of zeroby means active physical connections are neverISBN:1590591208 discarded from the pool. Apress © 2003 (630 pages)
ThePurge Policy what to do with the stale This book property provides determines a practical, step-by-step approach in connection. The available alternatives are discarding stale orApplication discarding the entire pool of connections. teaching how tothe use the connection WebSphere only Studio Developer (WSAD) tool for developing J2EE distributed
Click OK. As mentioned, applications. you also build the Pub/Sub-related administered objects here. (You will use them later when building the Pub/Sub application example.) Repeat the same steps and enter a TopicConnectionFactorywith the name NotifyTCFand corresponding JNDI name Table of Contents jms/NotifyTCF,with localhostas the selected node. Enter a topic with the name NotifyTand the WebSphere Studio Application Developer 5.0: Practical J2EE Development corresponding JNDI name jms/NotifyT. Figure 10-13 shows how your screen should look. Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
Figure 10-13: Setting queue and queue connection factory names
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index Configuring
the Listener Port
List of Figures
Next, you add a new listener port. Click the EJBtab. Locate the 'Listener Ports' section and click the Add List of Tables button. Figure 10-14 shows the Add Listener Port screen that will appear. Enter List of Code Examples TechLibListenerPort in the Namefield. Select jms/NotifyQCFas the Connection Factory List of Sidebars
JNDI name. Select jms/NotifyQas the Destination JNDI name. Make sure that the Initial Statefield is set to START, so when the server starts, the listener will also activate.
Figure 10-14: Mapping the listener port The most significant fields on this screen are as follows: TheMax messages property determines the maximum number of messages the listener can process in one JMS server session. TheMax retries property of the listener port determines the maximum number of times the listener attempts to read a message from a destination (queue or topic). When the Max retries limit is
reached, the listener for that destination stops. When the problem is resolved, the administrator must WebSphere Studio Application Developer 5.0: Practical restart the listener. The zero value means no retries happen. J2EE Development
ISBN:1590591208 by Igor Livshin TheMax sessions property determines the maximum number of concurrent JMS server sessions Apress © 2003 (630 pages) used by listener to serve the associated MDB.
This book provides a practical, step-by-step approach in
TheInitialteaching Statehow property to use determines the WebSphere the Studio state ofApplication the listener port the next time the JMS server Developer (WSAD) tool for developing J2EE distributed starts. applications.
Click OK.Figure 10-15 shows the next screen. Notice that you mapped the listener port (TechLibListenerPort) to the destination queue named jms/NotifyQ,making the MDB effectively Table of Contents request the container to listen on the destination queue NotifyQ. You can also set the Datasourceon the WebSphere Studio Application Developer 5.0: Practical J2EE Development server level. Select DBDatasourcein the Default data source field. Introduction
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Figure 10-15: Mapping the listener port to Part Three - Working with Enterprise Messaging Chapter 9
a queue
- J2EE Enterprise Messaging
Save the Server Configuration and close the Editor View.
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter - Using WebSphere MQJMS as the JMS Provider Tip11 When using an external provider (such as WebSphere MQ), you need to make this Appendix A Deploying This Book's J2EE Examples configuration by using the WebSphere Administrative Console. Index List of Figures Setting JMS
Resource References
List of Tables
Make sureExamples you are in the J2EE Perspective and J2EE Hierarchy View. Right-click the List of Code
ReceivingJMSProjectEJBand select Open With > Deployment Descriptor Editor. Click the Referencestab. This is the page for setting resource references. Because the ReceivingMDBMDB calls the createmethod of the Book_notifyentity bean, you need to set the EJB Reference to the Book_notifyentity bean. Highlight ReceivingMDBand click the Addbutton.Figure 10-16 shows the next screen. Check EJB local reference and click Next. On the next screen, click the Browsebutton attached to the Linkfield and select the Book_notifylink. The rest of the fields will be automatically set. Change the Namefield to Book_notify.
List of Sidebars
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench Figure Setting a reference to the entity bean component Chapter 4 - 10-16: Developing Database Applications Part Two - Working with J2EE: The Distributed Application Framework
Click Finish. Click EJBLocalRef.Figure 10-17 shows the next screen. Change the value of the JNDI - J2EE Development namefield to ejb/Book_notify.
Chapter 5 Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List ofFigure Sidebars 10-17: Setting the JNDI name for reference
Next, you need to add references to the administered objects. Highlight ReceivingMDBand click the Add button. Select EJB Resource Reference and click Next. On the next screen, enter NotifyQCFin the Namefield; select QueueConnectionFactoryin the Typefield and Applicationin the Authenticationfield. Click Finish. Highlight ReceivingMDBagain and click the Addbutton. Select EJB Resource Environment Reference and click Next. On the next screen, enter NotifyQin the Namefield; select Queuein the Typefield. Click Finish. For each entered reference, highlight it and enter the corresponding name with the jms/suffix in the JNDI Name field. Specifically, for NotifyQCF, enter jms/NotifyQCF,and for NotifyQ,enterjms/NotifyQ.You will also enter references for Pub/Sub-related administering objects, which you will use later in the Pub/Sub example. Repeat the same steps and enter NotifyTCFand the corresponding jms/ NotifyTCF (select TopicConnectionFactoryas the type). Enter NotifyTand the corresponding jms/ NotifyT (selectTopicas the type). For the Book_notify entity bean, you need to build the reference to the Datasource resource. Highlight the Book_notify entity bean and click the Add button. Select the EJB Resource Reference box and click Next. On the next screen, select javax.sql.DataSource as the resource type. Enter DBDatasource in the Name field, and select Application in the Authentication field. Click Finish. The ResourceRef Datasource reference will appear under Book_notify. Highlight this resource reference and enter jdbc/DBDatasource in the JNDI Name field. Your final screen should look like the one shown in Figure 10-18.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction
Figure 10-18:Started Settingwith the WebSphere JNDI nameStudio reference to the Book_notify entity bean Part One - Getting Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0
Chapter 2 Assembly - Setting UpDescriptor the Development Click the tab,Environment locate the 'Container Transaction' section, and click the Add Chapter Working WSAD 5.0 Workbench button. 3On -the screenwith thatthe appears, select both components (Book_notifyandReceivingMDB) and Chapter 4 -On Developing Database Applications click Next. the next screen, shown in Figure 10-19, expand the Book_notifyentity bean and check Part Two - Working The Distributed Application Frameworkand thecreate methodwith withJ2EE: two parameters. Expand ReceivingMDB
check the onMessagemethod.
Chapter Finally,5select - J2EE NotSupported Development in the Container transaction type field. Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 10-19: Setting a reference to the entity bean component Click Finish.Figure 10-20 shows the next screen. Here, you will configure the Book_notifyentity bean. Click the Beanstab. Highlight Book_notifyand enter Book_notifyin the Display name field. Enterejb/Book_notifyin the JNDI name field.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Figure 10-20: Configuring the entity bean component
Chapter 1
- Introducing WSAD 5.0
Chapter Notice 2that-Book_notify Setting Up the is Development the internalEnvironment reference name that ReceivingMDBuses to call this entity bean.
Click the to the 'WebSphere Bindings' section. Make sure that Chapter 3 Overview - Workingtab withand thescroll WSADdown 5.0 Workbench DB2UDBNT_V72_1 is selected in the Currentbackend ID field. Select Per_Connection_Factory in the Chapter 4 - Developing Database Applications Container authorization typeThe fieldDistributed and jdbc/DBDatasource in the Part Two - Working with J2EE: Application Framework
JNDI name field. Save the changes
and close Editor View. Chapter 5 the - J2EE Development Chapter 6
- J2EE EJB Development
Testing Receiving Side Chapter 7 -the J2EE Web Development
of the Application
Chapter 8
- J2EE XML Development You are ready to test this project. Switch to the Server Perspective and start JMSServer. Wait for the server to start, right-click ReceivingJMSProjectEJB, and select Run on Server. The IBM Universal Test Chapter 9 appear. - J2EE Enterprise Messaging Client will Click JNDI Explorerto get to the screen shown in Figure 10-21. Expand the Local Chapter 10 Using the WSAD-Embedded JMS Provider EJB beans andejbentries. Part Three - Working with Enterprise Messaging
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 10-21: The Universal Test Client Click Book_notify.To test the Book_notifyentity bean, expand SaveMsgBook_notifyLocaland SaveMsgBook_notifyLocalHome.On the next screen, shown in Figure 10-22, you should see the createmethod with two Stringtype parameters. Click it. You are prompted to add two parameters. The first parameter is messageKey, and the second parameter is messageBody. Enter Message 1 in the first field and The book you rented is due to be returned in the second field.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development
Figure 10-22: Testing the create method
Introduction
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter Click Invoke. 1 - Introducing The record WSAD will be 5.0written to the database. Click Work with Object. Now, the object's local
methods available. Click the getMessage_body method. Next, click Invoke.Figure 10-23 shows Chapter 2 become - Setting Up the Development Environment the subsequent screen. seeWorkbench the messageBodyyou just entered: 'The book you rented is due to Chapter 3 - Working withYou theshould WSAD 5.0 be returned.' Chapter 4 - Developing Database Applications Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures
Figure 10-23: Testing the getMessage method
List of Tables
List of Code Examples Close the Test Client Web Browser View and stop the server. List of Sidebars
Developing the Sending Part Now, you will create the second project called SendingJMSProjectWEBand the corresponding enterprise application project called SendingJMSProjectApp. You will build the servlet called SendingServlet, which functions as a JMS client that sends messages to the NotifyQqueue. Switch to the Web Perspective and select File> New> Web Project. On the screen that appears, enter SendingJMSProjectWEBin theProject Name field. Uncheck Create default CSS file and click Next. On the next screen, select a new enterprise application project and name it SendingJMSProjectApp. Click Finish. Right-click SendingJMSProjectWEBand select New> Other> Web> Servlet. On the next screen, enterapress.wsad.techlibin the Packagefield and SendingServletin the Class Name field. Click Finish. WSAD will generate the skeleton of the SendingServletservlet class and open it in the Editor View. You now need to add the necessary processing logic. Listing 10-2 shows the source code of the SendingServlet.javaclass. Listing 10-2. SendingServlet.java package apress.wsad.techlib; import javax.jms.*; import javax.naming.*; import java.util.*; import java.io.IOException;
import import import import
javax.servlet.ServletException; WebSphere Studio Application Developer 5.0: Practical J2EE Development
javax.servlet.http.HttpServlet; ISBN:1590591208 by Igor Livshin javax.servlet.http.HttpServletRequest; Apress © 2003 (630 pages) javax.servlet.http.HttpServletResponse;
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application public class Developer SendingServlet HttpServlet (WSAD) toolextends for developing J2EE distributed { applications.
String queueConnectionFactoryName = "java:comp/env/NotifyQCF"; String queueName = "java:comp/env/NotifyQ"; Table of Contents String[] messageList = {"Enterprise Java", WebSphere Studio HTML", Application Developer 5.0: Practical J2EE Development "Using Introduction "Java in a Nutshell", Part One"EJB - Getting StartedPatterns", with WebSphere Studio Application Developer (WSAD) 5.0 Design Chapter "Hacking 1 - Introducing WSAD 5.0 Java" Chapter }; 2 - Setting Up the Development Environment Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
queueConnectionFactory = null; -private Developing QueueConnectionFactory Database Applications
private Queue = null ; Part Two - Working with J2EE: TherequestQueue Distributed Application Framework Chapter 5
QueueConnection queueConnection = null; -private J2EE Development
Chapter 6
QueueSender queueSender = null; -private J2EE EJB Development
Chapter 7
QueueSession queueSession = null -private J2EE Web Development
Chapter 8
- J2EE XML Development
;
public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException Chapter 9 - J2EE Enterprise Messaging { Part Three - Working with Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 - Using WebSphere MQ as the JMS Provider
}
Appendix A - Deploying This Book's J2EE Examples Index
public void doGet(HttpServletRequest req, HttpServletResponse resp) ServletException, IOException List of Tables{ List of Code Examples processRequest(); List of Sidebars } List of Figures throws
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { processRequest(); } public void {
init()throws
ServletException
super.init(); // Get Administered object (only once per servlet) try { InitialContext initContext = new InitialContext(); queueConnectionFactory = (QueueConnectionFactory) initContext.lookup(queueConnectionFactoryName); requestQueue = (Queue) initContext.lookup(queueName);
queueConnection = queueConnectionFactory.createQueueConnection(); WebSphere Studio Application Developer 5.0: Practical queueConnection.start(); J2EE Development
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
} This book provides a practical, step-by-step approach in catch(NamingException ne) teaching how to use the WebSphere Studio Application { Developer (WSAD) tool for developing J2EE distributed System.out.println("Error locating Administrated Objects " + applications. ne.getMessage()); } Table of Contents WebSphere Studio Application Developer catch(JMSException je) 5.0: Practical J2EE Development Introduction { Part OneSystem.out.println("JMS - Getting Started with WebSphereException Studio Application Developer (WSAD) 5.0 " + je.getMessage());
Chapter Exception 1 - Introducing 5.0 le WSAD = je.getLinkedException(); Chapter if 2 - (le Setting !=Upnull) the Development Environment Chapter { 3
- Working with the WSAD 5.0 Workbench Chapter System.out.println("Linked 4 - Developing Database ApplicationsException " + le.getMessage()); Part Two}- Working with J2EE: The Distributed Application Framework
Chapter } 5
- J2EE Development
Chapter 6 } - J2EE EJB Development Chapter 7
- J2EE Web Development
public void processRequest() Chapter 8 - J2EE XML Development { Part Three - Working with Enterprise Messaging try Chapter 9 - J2EE Enterprise Messaging { Chapter 10 - Using the WSAD-Embedded JMS Provider queueSession = Chapter 11 - Using WebSphere MQ as the JMS Provider queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); Appendix A - Deploying This Book's J2EE Examples Index
QueueSender queueSender = queueSession.createSender(requestQueue);
List of Figures List of Tables // Send five message List of Code Examples for (int i = 0; i < 5; i++) List of Sidebars {
TextMessage message = queueSession.createTextMessage(messageList[i]); Thread.sleep(10000); queueSender.send(message);
} } // End of try catch(JMSException je) { System.out.println("Send message failed " + je.getMessage()); } catch(InterruptedException se) { System.out.println("Interrupted exception for sleep" + se.getMessage()); } // Clean up. Make sure that Administered objects are closed finally { if (queueSender != null)
try WebSphere Studio Application Developer 5.0: Practical { J2EE Development queueSender.close(); ISBN:1590591208 by Igor Livshin } Apress © 2003 (630 pages) catch (JMSException je) {} This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application if (queueSession !=tool null) Developer (WSAD) for developing J2EE distributed try applications.
{ queueSession.close(); Table of } Contents WebSphere Studio Application Developer 5.0: Practical catch (JMSException je) {} J2EE Development Introduction Part One - Getting Started with WebSphere!= Studio Application Developer (WSAD) 5.0 if (queueConnection null)
Chapter try 1 - Introducing WSAD 5.0 Chapter { 2
- Setting Up the Development Environment Chapter queueConnection.close(); 3 - Working with the WSAD 5.0 Workbench Chapter } 4
- Developing Database Applications
(JMSException je) Application {} Part Twocatch - Working with J2EE: The Distributed Framework Chapter 5
- J2EE Development
End finally Chapter 6 } -// J2EE EJBof Development Chapter 7
- J2EE Web Development
} // End processRequest method Chapter 8 - J2EE XML Development Part Three - Working with Enterprise Messaging
} // End of the class
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Let's examine the SendingServlet source code. This servlet acts as a JMS client, putting messages on Appendix A Deploying This Book's J2EE Examples theNotifyQqueue. First, you need to use JNDI and locate two administered objects: Index QueueConnectionFactoryandQueue. A QueueConnectionis started. This logic is performed in the List of Figures init method because it needs to execute only once. Next, the doGetmethod executes. From this List of Tables method, you call the processRequestmethod where JMS processing logic resides. Here, you run a loop List producing of Code five Examples messages and put them on the NotifyQqueue. Inside the loop, you use the sleep
statement to avoid duplication of the record keys that are built based on the current time. In the finally List of Sidebars method, you close all opened objects. Save the results and close the editor. Next, you need to include this project in the JMSServerconfiguration. Rightclick JMSServerand select Add> SendingJMSProjectApp. Then, you need to set the development and runtime environment. Switch to the J2EE Perspective, rightclick SendingJMSProjectWEBand select Open With > Deployment Descriptor Editor. Click the Referencestab.Figure 10-24 shows the next screen. Highlight the Resourcetab at the top of the screen. Click the Addbutton. Replace Resource Reference with NotifyQCF. Click Browse, navigate to QueueConnectionFactory, select it, and click OK. Select Applicationin the Authenticationfield and put jms/NotifyQCFin the JNDIName field. Set the Isolation level field to TRANSACTION_NONE.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Figure 10-24: ConfiguringQueueConnectionFactory Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter - Introducing WSAD 5.0 On the 1same page, highlight the Resource Environment tab at the top of the screen. Click the Add Chapter button.2Replace - Setting the Up Resource the Development Environment Environment Reference name with NotifyQ. Click Browse, navigate
to the Queue interface, select it, and 5.0 clickWorkbench OK. Enter jms/NotifyQin the JNDI Name field.Figure 10-25 Chapter 3 - Working with the WSAD shows how screen Database should look. Chapter 4 - your Developing Applications Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples IndexFigure 10-25: ConfiguringQueue List of Figures List of Tables
At of thisCode point, you should ask yourself why you are not setting a reference to the ReceivingMDBMDB and List Examples
not including ReceivingJMSProjectEJBas a project you need to reference. The answer is that you are not directly calling ReceivingMDB. Remember, MDBs are never directly called by the JMS client, and they do not provide (neither Local nor Remote) interfaces for that. For that reason, you never create deployment and RMIC code for MDBs. JMS clients communicate with MDB indirectly via the queues and topics, which means less work for you. Save the results and close the editor.
List of Sidebars
Setting the Runtime Environment Next, you would normally set the runtime environment for the sending project. However, because both projects (the receiving and the sending) use the same JMSServeras a runtime environment, the necessary option was set at the time you configured the receiving project. You can check that the necessary setting is there. In the server configuration, double-click JMSServerto open it in the Editor View. Click the JMSand EJBtabs to do that. Finally, close the editor. You are now ready to execute the example. Both enterprise projects, SendingJMSProjectAppand ReceivingJMSProjectApp, are included in JMSServer; therefore, starting this server automatically activates the ReceivingMDBMDB because you set the Initial State value to START. Right-click SendingServlet.javaand select Run on Server. The five messages should display in the Console View. 04:43:11 04:46:34 04:58:23 04:58:27
The The The The
book book book book
Enterprise Java is due to be returned. Using HTML is due to be returned. Java in a Nutshell is due to be returned. EJB Design Patterns is due to be returned.
04:58:28
The book Hacking Java is due to be returned. WebSphere Studio Application Developer 5.0: Practical J2EE Development
ISBN:1590591208 by Igor Livshinyou should see five messages added When the processing is done, to the BOOK_NOTIFY table. Activate a Apress © 2003 (630 pages) DB2 command window and issue the following commands:
This book provides a practical, step-by-step approach in teaching to use the WebSphere Studio Application The execution results are how as follows: Developer (WSAD) tool for developing J2EE distributed applications. Stop the server and close the DB2 command window. Congratulations on developing your first WSAD P2P JMS application! In the next section, you will develop a similar Pub/Sub application. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Studio Application Developer 5.0: Practical DevelopingWebSphere a Publish/Subscribe JMS Application J2EE Development
Igor Livshin Next, you will useby the same projects for developing a Pub/SubISBN:1590591208 application. On the sending side, you will develop a new servlet calledApress PublishingServlet © 2003 (630 pages) that publishes messages on a topic. On the receiving side, all you need to do is to make your ReceivingMDB MDB listen on a topicapproach instead of This book provides a practical, step-by-step in on a queue. You will start your teaching how to side. use the WebSphere Studio ApplicationMDB listens on the port development from the receiving The receiving ReceivingMDB Developer (WSAD) tool for example, developingyou J2EE distributed TechLibListenerPort. In the previous mapped this port to the NotifyQqueue. Now, you will applications. remap it to the topic called NotifyT. With this introduction, let's start developing the example.
Setting Administered Objects
Table of Contents
WebSphere Studio Application Developer 5.0: Practical J2EE Development
Switch to the Server Perspective. In the Server Configuration View, double-click JMSServerto open its Introduction configuration in the Editorwith View. Here, youStudio need Application to set the properties TopicConnectionFactory and Part One - Getting Started WebSphere Developerof(WSAD) 5.0 Topic.1However, you already Chapter - Introducing WSAD did 5.0 this during the development of the P2P example. Figure 10-26 displays this setting.2 Chapter
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List ofFigure Figures10-26: SettingTopicConnectionFactoryandTopic List of Tables
Next, you want your MDB to listen on the topic and not on the queue. Click the EJBtab. You will see the screen depicted in Figure 10-27. Highlight TechLibListenerPortand click the Editbutton. On the pop-up screen, List of Sidebars selectNotifyTCFin the Connection Factory JNDI name field and jms/NotifyTin the Destination JNDI name field. Make sure that the Initial State is set to START, so when the server starts, the MDB will be activated automatically. List of Code Examples
Figure 10-27: The EJB tab Click OK. Save and close the JMSServerconfiguration. In the J2EE Perspective, expand ReceivingJMSProjectEJBand double-click its EJB Deployment Descriptor. Click the Beanstab and highlight ReceivingMDB. For the P2P example, the Destination type field was Queue. Now, change it to Topic.Figure 10-28 shows how your screen should look.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2 - 10-28: SettingSetting Up the the Development Figure destinationEnvironment type for the ReceivingMDB component Chapter 3 - Working with the WSAD 5.0 Workbench Chapter 4
- Developing Database Applications
Click OK. Save the results and close the editor. After the necessary administered objects are in place, you are ready to develop the sending application. That is what you will do in the next section.
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Building theWeb Sending Part of the Application - J2EE Development
Chapter 7 Chapter 8
- J2EE XML Development
Right-click SendingJMSProjectWEBand select New> Other> Web> Servlet. On the next screen, enter apress.wsad.techlibin the Java Package field and PublishingServletin the Class Name field. Chapter 9 - J2EE Enterprise Messaging Figure 10-29 shows how your screen should look. Part Three - Working with Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 10-29: BuildingPublishingServlet Click Finish. WSAD will generate the skeleton of the PublishingServletservlet class and open it in the Editor View. You need to add the necessary processing logic. Listing 10-3 shows the source code of the PublishingServlet.javaclass. Listing 10-3. PublishingServlet
WebSphere Studio Application Developer 5.0: Practical
package apress.wsad.techlib; J2EE Development import javax.jms.*; by Igor Livshin import javax.naming.*; Apress © 2003 (630 pages) import java.util.*; import import
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application java.io.IOException; Developer (WSAD) tool for developing J2EE distributed applications. javax.servlet.ServletException;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; WebSphere Studio Application Developer 5.0: Practical J2EE Development import javax.servlet.http.HttpServletResponse;
Table of Contents Introduction
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
public class
PublishingServletextends
HttpServlet
Chapter 1 {
- Introducing WSAD 5.0
Chapter 2 Chapter 3
-String Setting Up the Development Environment topicConnectionFactoryName = "java:comp/env/NotifyTCF"; -String Working topicName with the WSAD= 5.0 Workbench "java:comp/env/NotifyT";
Chapter 4
-String[] Developing messageList Database Applications = {"WinSock 2.0",
Part Two"NT - Working with J2EE: The Distributed Application Framework Services",
Chapter "Visual 5 - J2EE Development C++", Chapter "Socket 6 - J2EE EJB Programming", Development Chapter "Mastering 7 - J2EE Web Delphi" Development Chapter }; 8 - J2EE XML Development Part Three - Working with Enterprise Messaging
TopicConnectionFactory topicConnectionFactory = null; -private J2EE Enterprise Messaging private Topic requestTopic = null; Chapter 10 - Using the WSAD-Embedded JMS Provider private TopicConnection topicConnection = null; Chapter 11 - Using WebSphere MQ as the JMS Provider private TopicPublisher topicPublisher = null; Appendix A - Deploying This Book's J2EE Examples private TopicSession topicSession = null ; Chapter 9
Index
List of Figures
public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException List of Code Examples { List of Sidebars processRequest(); } List of Tables
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { processRequest(); } public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { processRequest(); } public void {
init()throws
ServletException
super.init(); // Get administered object (only once per servlet) try { InitialContext initContext = new
InitialContext();
topicConnectionFactory = WebSphere Studio Application Developer 5.0: Practical (TopicConnectionFactory) initContext.lookup(topicConnectionFactoryName); J2EE Development
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
requestTopic = (Topic) initContext.lookup(topicName); This book provides practical, step-by-step approach in topicConnection = atopicConnectionFactory.createTopicConnection(); teaching how to use the WebSphere Studio Application topicConnection.start(); Developer (WSAD) tool for developing J2EE distributed applications.
} Table of Contents catch(NamingException ne) WebSphere { Studio Application Developer 5.0: Practical J2EE Development Introduction System.out.println("Error locating Administrated Objects " + Part Onene.getMessage()); - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
-} Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
je)5.0 Workbench Chaptercatch(JMSException 3 - Working with the WSAD Chapter 4 { - Developing Database Applications
Exception " Framework + je.getMessage()); Part TwoSystem.out.println("JMS - Working with J2EE: The Distributed Application le = je.getLinkedException(); Chapter Exception 5 - J2EE Development != Development null) Chapter if 6 - (le J2EE EJB -{ J2EE Web Development System.out.println("Linked Exception " + le.getMessage()); Chapter 8 - J2EE XML Development } Part Three - Working with Enterprise Messaging } Chapter 7
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
} public void processRequest() Appendix A - Deploying This Book's J2EE Examples { Index try List of Figures {
Chapter 11 - Using WebSphere MQ as the JMS Provider
List of Tables List of Code Examples List of Sidebars topicSession =
topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); TopicPublisher topicPublisher = topicSession.createPublisher(requestTopic); // Send five messages for (int i = 0; i < 5; i++) { TextMessage message = topicSession.createTextMessage(messageList[i]); Thread.sleep(10000); topicPublisher.publish(message); } } // End of try catch(JMSException je) { System.out.println("Publish message failed " + je.getMessage()); } catch(InterruptedException se) {
System.out.println("Interrupted exception for sleep" + se.getMessage()); WebSphere Studio Application Developer 5.0: Practical J2EE Development
}
by Igor Livshin
ISBN:1590591208
// Clean up. Make sure that Administered objects are closed Apress © 2003 (630 pages) finally This book provides a practical, step-by-step approach in { teaching how to use the WebSphere Studio Application if (topicPublisher null ) distributed Developer (WSAD) tool!= for developing J2EE try applications. { topicPublisher.close(); Table of } Contents WebSphere Studio Developer 5.0: Practical J2EE Development catchApplication (JMSException je) {} Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 if (topicSession != null)
Chapter try 1 - Introducing WSAD 5.0 Chapter { 2
- Setting Up the Development Environment Chapter topicSession.close(); 3 - Working with the WSAD 5.0 Workbench Chapter } 4
- Developing Database Applications
(JMSException je) {} Application Framework Part Twocatch - Working with J2EE: The Distributed Chapter 5
- J2EE Development
!= null -if J2EE(topicConnection EJB Development Chapter try 7 - J2EE Web Development Chapter 6
)
{ - J2EE XML Development topicConnection.close(); Part Three - Working with Enterprise Messaging } Chapter 9 - J2EE Enterprise Messaging catch (JMSException je) {} Chapter 8
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider
} // End of finally
Appendix A - Deploying This Book's J2EE Examples Index
} // End processRequest method
List } of Figures List of Tables List of Code Examples
Let's examine the PublishingServletsource code. Again, the servlet acts as a JMS client, publishing List of Sidebars messages on the NotifyTtopic. Before doing this, you need to use JNDI and locate two administered objects: TopicConnectionFactoryandTopic. This logic is performed in the initmethod because it needs to execute only once. Next, the doGetmethod executes. From this method, you call the processRequest method where the JMS processing logic resides. Here, you run a loop, produce five messages, and publish them on the NotifyTtopic (you set different book titles in this program to distinguish them from messages that came from the queue). Inside the loop, you use the sleep statement to avoid duplication of the record keys that are built based on the current time. In the finallymethod, you close all opened objects. Save the results and close the editor.
Setting References to the Administered Objects Next, you need to add the topic-related administered objects to the development environment. Switch to the J2EE Perspective and J2EE Hierarchy View, right-click SendingJMSProjectWEB, and select Open With > Deployment Descriptor Editor. Click the Referencestab. There are several reference-related tabs located at the top of the page. Two of these tabs are used for setting the JMS-related resources. The Resource tab is used for setting the connection factories (queue or topic related). The Resource Environment tab is used for setting the destination objects (queues and topics). Highlight the Resourcetab at the top of the screen. Click the Addbutton. Replace the resource reference name with NotifyTCF. Click Browse, navigate to TopicConnectionFactory, select it, and click OK. Select Applicationin the Authenticationfield, select TRANSACTION_NONEin the Isolation Level field, and enter jms/NotifyTCFin the JNDI Name field.Figure 10-30 shows the completed screen.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Figure 10-30: Configuring the topic connection factory Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
On the 1same page, highlight the Resource Environment tab at the top of the screen. Click the Addbutton. Chapter - Introducing WSAD 5.0 Replace resource reference name with NotifyT. Click Browse, navigate to Chapter 2 the - Setting Upenvironment the Development Environment javax.jms.Topic, select and click OK. Enter jms/NotifyTin the JNDI name field.Figure 10-31 shows Chapter 3 - Working with theit,WSAD 5.0 Workbench how the4 completed screen shouldApplications look. Chapter - Developing Database Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider
Figure Configuring theJ2EE topicExamples Appendix A - 10-31: Deploying This Book's Index List of Figuresthat you already set the runtime environment and mapped the listener port to the NotifyTtopic. Remember List of Tables Save the results and close the editor. List of Code Examples List of Sidebars
Testing the Pub/Sub Application You are ready to execute the example. Again, starting JMSServerautomatically activates the ReceivingMDB MDB because you set the Initial State value to START. This time, the ReceivingMDBMDB listens on the NotifyTtopic. Switch to the Server Perspective and start JMSServer. When the server is started, right-click PublishingServlet.javaand select Run on Server. When the processing is done, you should see five new messages added to the BOOK_NOTIFY table. Activate the DB2 Command Center, click Interactive, and connect to the TECHBOOK database. Next, issue the following statement: Figure 10-32 shows the execution results.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents
Figure 10-32: Execution results of the Pub/Sub example
WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction
Stop the server and close the DB2 command window. Something is wrong with these two examples. (Congratulations for those who have already noticed this! ) The processing logic of the application you developed Chapter - Introducing 5.0functions: consists1 primarily of two WSAD business Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 2
- Setting Up the Development Environment
Receiving a message from a queue or topic Chapter 3 - Working with the WSAD 5.0 Workbench Chapter 4
- Developing Database Applications
Writing this message in a database table
Part Two - Working with J2EE: The Distributed Application Framework
Chapter - J2EE Development Each of5 these business functions is performed by an independent subsystem-JMS and Java Database Chapter 6 J2EE EJB Development Connectivity (JDBC). Because the entire processing happens outside of the transaction context, these two Chapter 7 functions - J2EE Web business are Development uncoordinated and could potentially lead to the data integrity problem. The next section Chapter 8 how - J2EE Development discusses thisXML application should be developed to maintain data integrity. Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical Using Two-Phase Commit Transactions J2EE Development
ISBN:1590591208 by Igor These two examples areLivshin fine for the initial demonstration of JMS processing. However, they are hardly Apress © 2003 (630 pages) suitable for the real application-not just because they are simple but because their designs have a serious flaw. Let's come back to the processing these examples doapproach on the receiving side. This book provides a practical, step-by-step in
teaching how to use the WebSphere Studio Application
TheReceivingMDB Developer MDB receives (WSAD) messages tool for developing from theJ2EE NotifyQ distributed queue or NotifyTtopic and calls applications.CMP entity bean to save the messages in the database. For both examples, theSaveMsgBook_notify you selected the NotRequiredtransaction type, effectively running your receiving-side processing outside of the transaction context. Table of Contents WebSphere Studio 5.0:receiving Practical side J2EErequires Development To run under the Application transactionDeveloper context, the support of two-phase commit processing. Introduction Indeed, to maintain data integrity, you should receive a message and put it in a database inside a single Part - Getting Started withOutside WebSphere Studio Application Developer 5.0 unitOne of work (or transaction). of the transaction context, reading(WSAD) a message
and writing it in the
Chapter 1 can - Introducing WSAD 5.0Reading a message can be successful but writing it to a database cannot database go uncoordinated. Chapter - Setting Upequivalent the Development Environment be. This2 would be the of missing the message. Therefore, the two-phase commit is necessary Chapter 3 - Working with the WSAD 5.0 Workbench to coordinate two independent processing subsystems: JMS and the database. Chapter 4 - Developing Database Applications
To support two-phase processing, you need to use the XA-compliant Part Two - Working with commit J2EE: The Distributed Application Framework
database driver and XAcompliant administered objects (queue and topic connection factories, queues, and topics). In this Chapter 5 - J2EE Development example, the ReceivingMDBMDB does not directly manipulate administered objects (the container Chapter 6 - J2EE EJB Development does). Therefore, it is sufficient for this example to change only the database driver to the XA-compliant Chapter 7 - J2EE Web Development DB2 database driver. Switch to the Server Perspective. Double-click JMSServerin the server Chapter 8 - J2EE XML Development configuration and click the Data Sources tab. Then select DB2 JDBC Providerand click the Edit Part Three - Working with Enterprise Messaging button. On the Create a JDBC Provider dialog shown in Figure 10-33, change the Nameand Chapter 9 - J2EE Enterprise Messaging Descriptionfields to DB2 JDBC Provider (XA). Select Chapter 10 - Using the WSAD-Embedded JMS Provider COM.ibm.db2.jdbc.DB2XADataSource as the Implementation class name. Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 10-33: Selecting the XA-compliant DB2 driver Click Finish. Next, select this JDBC provider and click the Addbutton next to the Data sources list. Select the new DB2 JDBC Provider (XA) and click Next. Enter DBDatasourceXAin the Name field and jdbc/DBDatasourceXAin the JNDI name field. Make sure that the Use this data source in container managed persistence (CMP) box is checked. Figure 10-34 shows the completed screen.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging Figure 10-34: Setting the XA-compliant Datasource
Chapter 9
- J2EE Enterprise Messaging Click Finish. Finally, highlight the database name and enter TECHBOOKin the resource properties' Chapter 10 - Using the WSAD-Embedded JMS Provider
Namefield, shown in Figure MQ 10-35. Click Finish. Chapter 11 -asUsing WebSphere as the JMS ProviderSave and close the JMSServerconfiguration. Now, you to change transaction-related Appendix A need - Deploying Thisthe Book's J2EE Examples settings. Open the Deployment Descriptor for
ReceivingJMSProjectEJBand click the Assembly Descriptor tab. Locate the 'Container Transactions' section, highlight NotSupported, and click the Editbutton. On the screen shown in List of Figures Figure 10-36, replace NotSupportedwith Required. Index
List of Tables
List of Code Examples List of Sidebars
Figure 10-35: Setting the database name for the XA-compliant Datasource 528
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 - 10-36: J2EE Development Figure Changing the transaction setting to Required Chapter 6 - J2EE EJB Development
You also to change the Book_notifyentity bean Datasourcereference. Click the Chapter 7 need - J2EE Web Development References tab. XML You Development will see the screen shown in Figure 10-37. Expand Book_notify,highlight the Chapter 8 - J2EE ResourceRef DBDatasourceXA reference, Part Three - Working with Enterprise Messaging
and change the Namefield to DBDatasourceXA. Change the JNDI name field to jdbc/DBDatasourceXA and change the Isolation Level field to Chapter 9 - J2EE Enterprise Messaging TRANSACTION_READ_COMMITTED. Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 10-37: The processing results Save the results and close the editor. Now it's time to get back to the P2P JMS domain. Switch to the Server Perspective and double-click JMSServerin the Server Configuration View to open it for editing. Click the EJBtab, highlight TechLibListenerPort, and click the Editbutton. Replace jms/NotifyTCFwith jms/NotifyQCFandjms/NotifyTwith jms/NotifyQ.Click OK. Also, make sure that DBDatasourceXAis selected in the Default data source field, as shown in Figure 10-38.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Figure 10-38: Setting the listener port Table of Contents
In addition, open the Deployment Descriptor for the ReceivingJMSProjectEJB, click the Beanstab, and select ReceivingMDB. Locate the "Message Driven Destination" section and change the Introduction DestinationTypefromTopictoQueue. Save and close the editor. WebSphere Studio Application Developer 5.0: Practical J2EE Development
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 will - Introducing WSAD 5.0 Now, you test the two-phase commit application. Chapter 2 - Setting Up the Development Environment
With this setting, the receiving side will run under the two-phase commit transaction mode. Chapter 3 Datasource - Working with the WSAD 5.0 Workbench The execution results are as follows: Chapter 4 - Developing Database Applications Database Connection Part Two - Working with J2EE:Information The Distributed Application Framework Database Chapter 5 - server J2EE Development = DB2/NT 7.2.4 SQL authorization ID = c6023 Chapter 6 - J2EE EJB Development Local7 database alias = TECHBOOK Chapter - J2EE Web Development Chapter 8
- J2EE XML Development
08:56:28 TheEnterprise book Enterprise Part Three - Working with Messaging
Java is due to be returned. 08:56:33 The book Using HTML is due to be returned. Chapter 9 - J2EE Enterprise Messaging 04:56:38 The book Java in a Nutshell is due to be returned. Chapter 10 - Using the WSAD-Embedded JMS Provider 04:56:43 The book EJB Design Patterns is due to be returned. Chapter 11 - Using WebSphere MQ as the JMS Provider 04:56:48 The book Hacking Java is due to be returned. Appendix A - Deploying This Book's J2EE Examples 5 record(s) selected Index
List of need Figures You to make similar changes to the Pub/Sub application. This concludes the examples of developing List of applications Tables JMS for the WAS 5.0 embedded JMS provider. List of Code Examples List of Sidebars
Summary
WebSphere Studio Application Developer 5.0: Practical J2EE Development
by Igor This chapter covered theLivshin WSAD 5.0 embedded JMS provider.ISBN:1590591208 It walked you through the JMS provider Apress discussed © 2003 (630 pages) installation and testing, its limitations, and compared it to WebSphere MQ as a JMS provider. Next, you developed applications utilizing the JMSapproach P2P andinPub/Sub domains. This two bookJ2EE provides a practical, step-by-step teaching how to use the WebSphere Studio Application (WSAD) tool J2EE provider. distributed Thenext chapter Developer covers WebSphere MQforasdeveloping a WSAD JMS applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Studio Application Developer 5.0: Practical Chapter WebSphere 11: Using WebSphere MQ as the JMS J2EE Development ISBN:1590591208 Igor Livshin Providerby Apress © 2003 (630 pages) This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications. Theprevious chapter discussed the embedded WebSphere Java Message Service (JMS) provider, which
Overview
is now part of the WebSphere Studio Application Developer (WSAD) package. You also learned that although the embedded WebSphere JMS provider is a useful tool, it has some serious limitations and is Table of Contents mostly suitable for application development and simple runtime environments because it is merely a WebSphere Studio Application Developer 5.0: Practical J2EE Development subset of the full WebSphere MQ package. Java 2 Enterprise Edition (J2EE) JMS applications using the Introduction embedded WebSphere JMS provider can only communicate with other J2EE JMS applications that also Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 use the embedded WebSphere JMS provider and that run on a node that belongs to the same Chapter 1 - Introducing WSAD 5.0 WebSphere cell. Chapter 2
- Setting Up the Development Environment
Chapter 3 limitation - Workingofwith WSAD 5.0 WorkbenchJMS provider is its lack of support for MQ channels. The main the the embedded WebSphere Chapter JMS applications 4 - Developing that use Database the embedded Applications WebSphere JMS provider cannot communicate with remote MQ Part applications, Two - Working so they with areJ2EE: unable The to Distributed support legacy Application applications. Framework Furthermore,
the embedded WebSphere
JMS provider doesDevelopment not support encrypted communication. Chapter 5 - J2EE Chapter 6
- J2EE EJB Development
Fortunately, both WSAD 5.0 and WebSphere Application Server (WAS) 5.0 allow close integration with - J2EE Web Development MQ messaging middleware and can use MQ as a JMS provider. J2EE JMS applications that use the MQ Chapter 8 - J2EE XML Development JMS provider are able to communicate remotely over MQ communication channels with J2EE and nonPart Three - Working with Enterprise Messaging J2EE applications running on a variety of platforms. These applications are even able to communicate Chapter 9 - J2EE Enterprise Messaging with non-Java (legacy MQ) applications; however, it requires more programming efforts to reconcile JMS Chapter 10 - Using the WSAD-Embedded JMS Provider and native MQ message formats. Chapter 7
Chapter 11 - Using WebSphere MQ as the JMS Provider
Appendix This chapter A - Deploying introducesThis youBook's to MQJ2EE messaging Examples middleware, shows you how to install MQ, and explains how
to configure it as the WSAD JMS provider. You will also see that JMS applications that use the MQ JMS Index provider are capable of using JMS objects built by the embedded WebSphere JMS provider. You will also List of Figures learn how to use native MQ tools (such as MQ Explorer and JMSAdmin) for building JMS objects. Finally, List of Tables youofwill develop and test Point-to-Point (P2P) and Publish/Subscribe (Pub/Sub) JMS applications that use List Code Examples MQofas the JMS provider. List Sidebars The chapter begins by introducing MQ.
Studio Application Developer 5.0: Practical IntroducingWebSphere WebSphere MQ J2EE Development
ISBN:1590591208 by Igormiddleware Livshin Among the messaging software packages currently available, IBM’s WebSphere MQ controls more than 80 Apress 2003 (630 pages) importance for the J2EE©technology (the package became a member of the WebSphere family of enterprise products).
This book provides a practical, step-by-step approach in
MQ supports more than 36 platforms andWebSphere is capableStudio of providing assured onetime message delivery to the target destina teaching how to use the Application (WSAD) forbut developing J2EE distributed not communicateDeveloper directly with eachtool other via virtual channels called queues andtopics. In the simple scenario shown applications. messages from this queue. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Figure 11-1: Simplified processing Part Two - Working with J2EE:MQ Themessage Distributed Application Framework Chapter 5
- J2EE Development
Two fundamentally important features of MQ are asynchronous communication and assured message delivery based on - J2EE EJB Development receiving side of the communication session does not need to be up and running. Even if a network is down, the sending
Chapter 6 Chapter 7
- J2EE Web Development
Chapter 8 -targeting J2EE XML Development Messages a remote destination are held on a special queue called a transmission queue. They stay there until Part Three - Working Enterprise Messaging accumulated in the with transmission queue are sent
Chapter 9
to the target destination. For persistent messages, MQ assures (notice t
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider
Understanding MQ Messages
Chapter 11 - Using WebSphere MQ as the JMS Provider
Appendix A communicate - Deploying This J2EE Examples Programs viaBook's messages. When MQ operates in native mode, a message is a string of bytes organized in a Index used by the system itself for controlling message delivery and other functions (the message descriptor). The message b List interpret of Figures this data. The message descriptor keeps the message control information (such as message type, destination, List of Tables
Understanding Queue Managers, Queues, and Channels
List of Code Examples List of Sidebars
Aqueue manager maintains the messaging environment by providing queuing services to applications and by managing managers on the same machine (the mainframe platform is an exception). Queuesare data structures that store messag operating system crash (all messages located in the queue at that time are lost). Queues that reside on disk are called p Input/Output (I/O); they also need to maintain a logging mechanism for recovery (a tradeoff between performance and d
Each queue belongs to a single queue manager that is responsible for its maintenance. A queue has a set of attributes t messages from a queue (get enabled), put messages onto a queue (put enabled), and access a queue in an exclusive o the maximum size of the queue message, and so on. Queues can be local (when they belong to a local queue manager
Channels support communication between remote queues (queues that belong to different queue managers). There are message channels for transmitting messages between queue managers. Each message channel maintains communica MQI channels for connecting MQ clients to queue managers running on remote machines.
Each message channel is closely associated with a remote queue. The remote queue is the mechanism for delivering m queue manager that owns that remote queue resides. The remote queue is not a physical queue; it is a local definition o queue temporarily stores messages destined for the queue on the remote queue manager. The sender channel is respo queue manager.
The following is an example of WebSphere MQ installed on two network machines: On machine A, you have a queue m manager called QueueManagerBand a remote queue called QueueB, which is linked to the local transmission queue a
When a program on a local machine connects to a local queue manager and puts messages on a remote queue, the m remote queue (defined as a local queue on a remote queue manager). Messages are delivered over message channels
Understanding MQ Studio Clients WebSphere Application Developer 5.0: Practical J2EE Development
An MQ client is a by program that runs on a machine without a queue manager. It remotely connects to a queue manager th ISBN:1590591208 Igor Livshin mechanism. For Apress a queue with (630 the pages) triggering attribute turned on, a message that arrives on the queue triggers the executi © 2003 This book provides a practical, step-by-step approach in
When a programteaching “gets” a how message a queue, the message is removed from that queue. Alternatively, a program ca to usefrom the WebSphere Studio Application supports clustering —a set (WSAD) of queuetool managers combined a network group, or cluster. Inside the MQ cluster, queue m Developer for developing J2EE in distributed applications. allows for simplified maintenance of queue managers and their channels (adding them to a cluster and removing them f
As you can see, MQ’s main advantage over the embedded JMS provider is its ability to connect programs running on diff Table of Contents automatically translated to the native code of the receiving application. WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction
Downloading and Installing WebSphere MQ
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 will - Introducing WSAD 5.0 Next, you learn how to download and install the WebSphere MQ package. Chapter 2 - Setting Up the Development Environment
Caution WebSphere MQ WSAD does not machine names that include spaces. If your machine name contains a sp Chapter 3 - Working with the 5.0 support Workbench Chapter 4
- Developing Database Applications
Part of the MQ software runs as a Windows service responsible for user authentication. As part of the user authentication The MQ service itself runs under the local account MUSR_MQADMIN,which is created during the MQ installation. This loc Chapter 5 - J2EE Development this security check. Therefore, if your machines are on a network that uses Windows 2000 domain controllers, you must Chapter 6 - J2EE EJB Development account) that has a special authority. Part Two - Working with J2EE: The Distributed Application Framework
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Configuring Your Windows Account
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
On a network, you must be a domain administrator (or you need a domain administrator’s participation) to install MQ. Fo membership of any account.
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 - Using WebSphere MQ as the JMS Provider
Appendix First, logAon- to Deploying a domain This controller Book's J2EE as the Examples domain administrator (or ask your domain administrator to do so). Second, cre
Finally, check Securityas the group type. Give members of this global group the authority to query the group member Index List of Figures
To set up the required authority level, follow these steps:
List of Tables
1. Code Right-click the domain name and select Delegate Control. Click Next. List of Examples List of Sidebars
2. On the subsequent screen, select domain mqm, click Add, and then click OK. 3. Highlightdomain mqm on the following screen and click Next. 4. On the screen that appears, select Create a custom task to delegate and click Next.
5. On the next screen, select Only the following objects in the folder and then check User objec
6. On the next screen, select Property-specificand then check Read group membership andRead grou 7. Finally, click Finish. Quite a procedure!
Next, create one or more domain accounts and add them to the domain mqm group. You will be using the MQAdmindo on any network machine, the MQ installation detects the existence of the domain mqm group on the Local Area Networ was installed. However, you still need to provide this special account when prompted during the MQ installation in order t screen at the end of the installation.
Finally, you are just about ready to start installing MQ. Log on to the machine where you want to install MQ as the admin with special authorization, you will enter the MQAdminaccount you have prepared. Note Make sure you log in with an account different from MQAdmin. This is an MQ requirement.
Until now, this section has discussed a stand-alone MQ installation. However, this is not your goal. You need to install MQ
should be installed as the WAS 5.0 JMS provider. The next section discusses it in more detail. WebSphere Studio Application Developer 5.0: Practical J2EE Development
Installing MQ asLivshin the WSAD JMS ProviderISBN:1590591208 by Igor Apress © 2003 (630 pages)
You need to consider two situations for installing MQ as the WSAD JMS provider. If MQ was installed on the machine be This book provides a practical, step-by-step approach in server. In this case, you the embedded WSAD JMS server during the WSAD 5.0 installation, but install teachingshould how tonot useinstall the WebSphere Studio Application the embedded JMS provider (the server and the clientJ2EE parts). Later, you can install MQ on top of the embedded JMS pro Developer (WSAD) tool for developing distributed file supplied with applications. the MQ installation.
Insert the MQ installation disk or download the latest MQ release (5.3 or later) from the following IBM Web site: http:// Table unzipofit,Contents and double-click setup.exe(because autorun will not work). WebSphere Studio Application Developer 5.0: Practical J2EE Development
Follow the installation instructions and select Custom Installation (when prompted) to avoid a potential problem w Introduction directory, which requires administrative access. do not recommend installing Part One - Getting Started with WebSphere StudioIApplication Developer (WSAD) MQ 5.0
into the default directory (also, avoid P
path as1short as possible. Chapter - Introducing WSAD 5.0 Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Note On my machine, I install MQ in the G:\WSMQdirectory. If your installation is different, please make the appropri
Chapter 4 installation. - Developing Applications Start the OnDatabase the WebSphere MQ Installation Launchpad screen, click Software Prerequisite Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 11-2: Checking software prerequisites
If everything is marked as OK, your software environment is ready for installation. If not, follow the installation recommen your machine is on a network with Windows 2000 domain controllers, you should click Yes. The installation screen will d chapter.)
Before installing MQ, you need to stop MQ services (in case the embedded JMS provider was installed during the WSAD WebSphere Embedding Messaging. Stop it (if it is not already stopped) and make sure its status is Manual. In addit amqprefix are loaded in memory. You can see them by starting the Windows 2000 Task Manager. You can stop them m the Task Manager, you should not see any services with the amqprefix running.
To start installing MQ, click WebSphere MQ Installation > Launch WebSphere MQ Installer and follow the version) is installed on the machine, the installation recognizes it as another MQ version that is already installed locally. I Modify, which gives you the ability to modify/replace installed MQ features
Uninstall, which lets you uninstall the current MQ installation and then start a new installation Select Modifyand displays a summary of the requested installation (see Figure 11-3).
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 Chapter 2
- Introducing WSAD 5.0 Figure 11-3: Summary of installation options - Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench Notice 4that-this installation keeps Applications the WAS_localhost_server1queue manager created by the embedded JMS provid Chapter Developing Database
\Java\lib (inApplication this case, Framework G:\WSMQ\Java\lib)has Part Two - Working with J2EE: The Distributed
been added to the PATH system var amqmjpse.txt installation log file located in (in this example, g:\WSMQ).This indicates a Chapter 5 - J2EE Development Chapter 6
- J2EE EJB Development
Extending - J2EEthe Web WebSphere Development MQ Middleware
Chapter 7 Chapter 8
- J2EE XML Development
All MQ releases prior to 5.3 install aMessaging version of Part Three - Working with Enterprise
MQ in native mode. In other words, you can use the installed MQ software Application Programming Interfaces (APIs) to communicate. It supported neither Java programs nor JMS programs beca Chapter 9 - J2EE Enterprise Messaging Chapter 10 - Using the WSAD-Embedded JMS Provider
To support developing MQ applications in Java and the JMS P2P domain, IBM released the support pack MA88, which c
Chapter 11 to - download Using WebSphere MQ as JMS Provider you need MA88 from thethe following IBM Web site: http://www-3.ibm.com/software/integration/ Appendix A - Deploying This Book's J2EE Examples IndexNote This download may require you to register with IBM, which is free. List of Figures
Starting from MQ 5.3, MA88 became part of the base package and automatically installs during the MQ installation. If yo
List of Tables
List CodeMA88, Examples To of install download ma88_win.zipinto some directory on your machine, unzip it, and run setup.exefrom this List of Sidebars theCustominstall and indicate the installation folder as G:\WSMQ\java(whereG:\WSMQis the MQ installation directory).
service pack.
Installing MA0C
JMS introduces two modes of communication: the P2P and Pub/Sub domains. However, MQ originally was developed to requirements, IBM introduced a second service pack called MA0C that adds the Pub/Sub functionality to MQ. To install M http://www.ibm.com/software/integration/support/supportpacs/individual/ma0c.html.
Run this file from the download directory and follow the installation instructions. This pack also installs MQ Broker 2.1, w
Note MQ Broker 2.1 is also present in the embedded JMS provider. IBM now recommends a separate, more sophis
With the necessary support pack installed, MQ becomes capable of supporting Java and JMS (both P2P and Pub/Sub d should be used outside of the J2EE environment.) JMS-based Java applications can also send messages to native MQ a more complicated because IBM changed the structure of the native MQ message descriptor to accommodate the additio to the native mode should clearly understand the issue of mapping JMS messages to native MQ messages.
Note You can find out more about this in the IBM online book Using Java at http://www-3.ibm.com/software MQ 5.0 already has a PTF for fixing recently discovered problems. You will install this PTF in the next section.
Installing PTF CSD03
CSD03 is the current PTF that you install after installing MQ 5.3. This PTF brings MQ to the level 5.3.3. You can check th
this maintenance release by browsing the following file: \PTF\en_us\memo.ptf. WebSphere Studio Application Developer 5.0: Practical
J2EE You can download thisDevelopment CSD03 PTF from https://www6.software.ibm.com/dl/wsmqcsd/wsmqcsd-p. by Igor Livshin
ISBN:1590591208
Unzip the downloaded Apressfile © 2003 and(630 runpages) the U200187A.exe program. Follow the installation instructions. Before installing the C Programs > IBM This WebSphere MQ > MQ Services. On theinscreen that appears, rightclick any running queue book provides aWebSphere practical, step-by-step approach teaching how to use the WebSphere Studio Application
Next, open the Windows Services window. Locate the IBM MQSeries service and stop it. In addition, scroll to the bot Developer (WSAD) tool for developing J2EE distributed applications. entry, and stop it. Finally, right-click the Windows taskbar and select Windows Task Mana WAS_localhost_server1 starts with the amqprefix belongs to MQ and must be stopped. Right-click it and select End Process. Confirm that you
Table Note of Contents Sometimes, even after stopping all the MQ-related programs and services, CSD03 is still unable to install, com WebSphere need StudiotoApplication 5.0: Practical Development reboot theDeveloper machine to clear theseJ2EE DLLs from memory. However, before rebooting, change the status o Introduction
Next, open the Windows 2000WebSphere ServicesStudio window, locate theDeveloper MQ-related services Part One - Getting Started with Application (WSAD) 5.0 previously discussed,
double-click them
CSD031support pack, and change Chapter - Introducing WSAD 5.0 Manualback to Automatic. Then, start them by right-clicking and selecting Start Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Starting from CSD01, IBM moves the mqji*.propertiesfiles from their original location in the
Chapter 4 - Developing Database Applicationsfrom the CLASSPATH and deleting the following files from the ../java/li IBM recommends removing ../java/lib Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development mqji.properties, mqji_de.properties, mqji_en.properties, mqji_en_US.properties,
Chapter 6 - J2EE EJB Development mqji_es.properties, mqji_fr.properties, mqji_it.properties, mqji_ja.properties, mqji_ko Chapter 7 - J2EE Web Development Chapter 8
- J2EE XML Development
Part Now, Three with-the Working WebSphere with Enterprise MQ installation Messaging made
on top of the embedded JMS provider, MQ replaces the embedded JMS
is that the 5.0 MQ JMS provider recognizes JMS objects previously defined under the embedded JMS provider. Chapter 9 WSAD - J2EE Enterprise Messaging Chapter 10 - Using the WSAD-Embedded JMS Provider
In the next section, you will run ReceivingJMSProjectAppandSendingJMSProjectApp(the same applications you
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
Running the Example with the MQ JMS Provider
Index
List of Figures
StartJMSServerin the debug mode (to see messages printed by the running application—sometimes they are not visibl the Server Perspective, right-click SendingServlet, and select Run on Server.Figure 11-4 shows the Console View
List of Tables
List of Code Examples List of Sidebars
Figure 11-4: Messages produced by the running application
You can also use the DB2 command-line processor to browse the BOOK_NOTIFY table and see that the messages hav
Figure 11-5 shows the content of the BOOK_NOTIFY table after processing the following SQL: SELECT * FROM LIB.
Figure 11-5: Messages written in the BOOK_NOTIFY table As you can see, you get the same results as in the previous chapter without making any changes.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical Using the MQ JMS Provider J2EE Development
ISBN:1590591208 Next, you want toby run Igor thisLivshin example against the new JMS objects (queue connection factory, queue, topic connection fact Notify_MQ_TCF, Apress andNotify_MQ_T, © 2003 (630 pages) respectively. In addition, you will modify the source code of your applications to u
This book provides a practical, step-by-step approach in
You do not want to change thetotwo applications (SendingJMSProjectApp andReceivingJMSProjectApp) teaching how useexisting the WebSphere Studio Application original applications Developer but use(WSAD) the newtool MQ-based for developing JMS objects. J2EE distributed You can do this with minimum effort by exporting the origin applications.
Next, you will import them back to the Workbench; however, during import, you will assign them new project names. Afte
Table Contents Withof this explanation under your belt, let’s start developing. In the next section, you will build these two new applications. WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction
Building the New Application Examples
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter - Introducing WSAD 5.0 Switch 1to the J2EE Perspective, right-click SendingJMSProjectApp, and select Export. On the next screen, select E Chapter 2 - existing Setting Up the Development Environment Overwrite files without warning, and Include project build path and meta-data files). Click Finish. This exp Chapter 3
- Working with the WSAD 5.0 Workbench Now you do the opposite process. Select Importfrom the main menu. On the next screen, select EAR file as the Chapter 4 will - Developing Database Applications
ReceivingJMSMQProjectApp. Click Next. Accept the defaults on Part Two - Working with J2EE: The Distributed Application Framework
the next screen and click Next. On the subsequen
Chapter 5
J2EE Development Repeat the- same steps to import the SendingJMSProjectApp.earfile. Again, assign a new name to the application:
Chapter 6
- J2EE EJB Development
Chapter Now you 7 have - J2EE twoWeb newDevelopment enterprise applications: SendingJMSMQProjectAppandReceivingJMSMQProjectApp. The
Descriptor. theDevelopment Display Name. Save the results and close the editor. Repeat the same steps for the Receivi Chapter 8 -Correct J2EE XML Part Three - Working with Enterprise Messaging
Next, you will make some minor source code changes so that your new applications use the MQ-based objects: Notify - J2EE Enterprise Messaging
Chapter 9
Chapter 10 -code Using the WSAD-Embedded Provider No source changes are necessaryJMS for the receiving application because both the ReceivingMDBMessage Driven Chapter 11 - Using WebSphere MQ as the JMS Provider
For the sending application, you need make some limited source code changes. In the J2EE Perspective (Navigator V Appendix A - Deploying This Book's J2EEtoExamples Index
They are located near the top of the file:
List of Figures List of Tables
String = "java:comp/env/NotifyQCF"; List of CodeQueueConnectionFactoryName Examples String QueueName = "java:comp/env/NotifyQ"; List of Sidebars
ChangeNotifyQCFtoNotify_MQ_QCFand change Notify_QtoNotify_MQ_Q.Now, the SendingServletwill perfo String QueueConnectionFactoryName = "java:comp/env/Notify_MQ_QCF"; String QueueName = "java:comp/env/Notify_MQ_Q";
That is all you need to do for the SendingServletservlet. Save the changes and close the editor. Open the Publishi String topicConnectionFactoryName = "java:comp/env/Notify_MQ_TCF"; String topicName = "java:comp/env/Notify_MQ_T";
Save the changes and close the editor. In the next section, you will build a new server project called JMSMQServerProj
Building the Unit Test Server Project
Switch to the Server Perspective and create a new UTS project called JMSMQServerProject. Right-click JMSMQServ In the Server Configuration View, right-click JMSMQServerand click Add> ReceivingJMSMQProjectApp. Repeat the application projects. Double-click JMSMQServerto open it in the Editor View. Click the Configurationtab and check
In the next two sections, you will configure the UTS environment for running your applications. WebSphere Studio Application Developer 5.0: Practical J2EE Development
Configuring the Datasource
ISBN:1590591208 by Igor Livshin Apress © 2003 (630 pages) Double-click JMSMQServerin the server configuration, click the Data Sources tab, select DB2 JDBC Provider, an This book a practical, name step-by-step approach in EnterDBDatasourceXA in provides the Datasource andjdbc/DBDatasourceXA in the JNDI name field. Make sure t teaching how to use the WebSphere Studio Application editor. Developer (WSAD) tool for developing J2EE distributed applications.
Building MQ-Based JMS Objects
In contrast with the embedded JMS provider, filling the corresponding WSAD screens for the MQ JMS provider builds on Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development
MQ provides several different tools for building MQ objects. This section uses the Graphical User Interface (GUI) tool MQ
Introduction
Part One11-6 - Getting Started with WebSphere Application 5.0 Figure depicts the MQ Explorer mainStudio window. The tool Developer allows you(WSAD) to create and
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
view MQ objects.
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
J2EE XML Development Figure- 11-6: MQ Explorer’s main window
Part Three - Working with Enterprise Messaging
Chapter - J2EE Enterprise Messaging Expand9WebSphere MQ and click Queue Managers. You will see the WAS_localhost_server1queue manager. T Chapter domain. 10You - Using can also the WSAD-Embedded manually start theJMS queue Provider manager by right-clicking a nonrunning queue manager and selecting S
Persistence field. PersistentMQ queues on disk and are recoverable during the system crash. Leave the rest o Chapter 11 - Using WebSphere as theare JMSwritten Provider Appendix A - Deploying This Book's J2EE Examples
Now you are back to the MQ Explorer main window, as shown in Figure 11-7. Click the Queuesfolder. You should see a
Index
List of Figures List of Tables List of Code Examples List of Sidebars
Figure 11-7: The default queue manager that is running Notice that the Current Depth field is 0. This field shows the number of messages in the corresponding queue. The JMSAdmin utility works, which is the subject of the next section.
Using the JMSAdmin Utility
The J2EE 1.3 specification requires that all JMS vendors provide a tool for creating the administered objects and placing
The JMSAdmin utility builds the administered objects and places them in the JNDI namespace. The JMSAdmin configur It is possible to use a different file as the JMSAdmin utility’s configuration file by specifying the file as a command-line pa JMSAdmin -cfg MyJMSAdmin.config
Table 11-1 shows the JMSAdmin commands you can use for building administered objects and placing them in the JND Table 11-1: JMSAdmin Commands
COMMAND
WebSphere Studio Application Developer 5.0: Practical J2EE Development
DEFINE ctx(ctxName) by Igor Livshin
ISBN:1590591208
DISPLAY ctx Apress © 2003 (630 pages) This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed DELETE ctx(ctxName) applications. CHANGE ctx(ctxName) Table of Contents
ALTER TYPE [property] WebSphere Studio (name) Application Developer 5.0: Practical J2EE Development Introduction DEFINE TYPE (name)[property] Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
DISPLAY (name) Chapter 1 - TYPE Introducing WSAD 5.0 Chapter 2 -TYPE Setting Up the Development Environment DELETE (name) Chapter 3
- Working with the WSAD 5.0 Workbench
COPY TYPE (name A) TYPE (name B) - Developing Database Applications
Chapter 4
Part Two -TYPE Working with J2EE: The Distributed Application Framework MOVE (name A) TYPE (name B)
Chapter 5
END
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Note Any attempt to execute a JNDI command will fail if the subcontext indicated by ctxNamecannot be found (bec Chapter 8 - J2EE XML Development Part Three Working with Enterprise Messaging To set up -the JMSAdmin environment, you will
Chapter 9
update both the JSMAdmin.batand JMSAdmin.config files located in the
- J2EE Enterprise Messaging
the JMSAdmin.config Chapter Note 10 Before - Usingupdating the WSAD-Embedded JMS Providerfile, save the original version of the file in a different directory or just re Chapter 11 - Using WebSphere MQ as the JMS Provider
Open the JSMAdmin.configfile by using any text editor and find the section shown in Listing 11-1, which is located nea
Appendix A - Deploying This Book's J2EE Examples
Index Listing 11-1. Fragment of the JMSAdmin.configFile List of Figures List of Tables
#INITIAL_CONTEXT_FACTORY=com.sun.jndi.ldap.LdapCtxFactory #INITIAL_CONTEXT_FACTORY=com. #PROVIDER_URL=ldap://polaris/o=ibm,c=us #PROVIDER_URL=file:/%MQ_JAVA_INSTALL_PATH%/JNDI
List of Code Examples List of Sidebars
The file comes preconfigured for using Sun Microsystem’s Lightweight Directory Access Protocol (LDAP) naming service file-based naming context that does not depend on the WSAD UTS. To do this, comment out (using the character #) the context will reside (see Listing 11-2). Listing 11-2. Fragment of the Changed JMSAdmin.configFile #INITIAL_CONTEXT_FACTORY=com.sun.jndi.ldap.LdapCtxFactory INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory #INITIAL_CONTEXT_FACTORY=com.ibm.ejs.ns.jndi.CNInitialContextFactory #INITIAL_CONTEXT_FACTORY=com.ibm.websphere.naming.WsnInitialContextFactory # #PROVIDER_URL=ldap://polaris/o=ibm,c= usPROVIDER_URL=file:/%MQ_JAVA_INSTALL_PATH%/JNDI#ROVIDER_URL=iiop://localhost/
Save and close the file. Next, update the JMSAdmin.batprocedure located in the -Djava.ext.dirs="%MQ_JAVA_DATA_PATH%"\lib
Listing 11-3 shows the modified JMSAdmin.batfile.
Listing 11-3. The Modified JMSAdmin.batFile
WebSphere Studio Application Developer 5.0: Practical
@echo off remJ2EE --rem IBM Websphere MQ JMS Admin Tool Execution Script rem for Development Windows NT rem remLivshin Licensed Materials - Property of IBM rem rem 5648-C60 5724-B4 ISBN:1590591208 by Igor 5655-F10 rem Apress rem ©© 2003 Copyright (630 pages) IBM Corp. 2002. All Rights Reserved. rem rem US Government Users Restricted Rightsstep-by-step - Use, duplication or rem disclosure This book provides a practical, approach in restricted byteaching GSA ADP Schedule Contract with IBM Corp. rem rem Note that the how to use the WebSphere Studio Application Developer tool forprogram developingare J2EEdefaults, distributed properties passed to(WSAD) the java rem and should be edited to applications. suit your installation if necessary rem --cls java Djava.ext.dirs="%MQ_JAVA_DATA_PATH%"\lib-DMQJMS_LOG_DIR="%MQ_JAVA_DATA_PATH%"\log -Table of Contents DMQJMS_TRACE_DIR="%MQ_JAVA_DATA_PATH%"\errors -WebSphere Studio Application Developer 5.0: Practical J2EE Development DMQJMS_INSTALL_PATH="%MQ_JAVA_INSTALL_PATH%" com.ibm.mq.jms.admin.JMSAdmin Introduction %1 %2 %3 %4 %5 Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2 close - Setting Up the Development Environment Save and the file. Finally, create the JNDI directory where the file-based naming context will reside. In this environm Chapter 3 - Working with the WSAD 5.0 Workbench
In the next you will use the JMSAdmin utility to build the following JMS objects for your projects: the queue conn Chapter 4 -section, Developing Database Applications Part Two - Working with J2EE: The Distributed Application Framework
Using5 JMSAdmin for Building Chapter - J2EE Development Chapter 6
Administered Objects
- J2EE EJB Development
Because JMSAdmin runs outside WSAD, it needs an environment that supports JMS. Adding multiple sets of directories - J2EE Web Development are limited in their length, which is another reason to keep them reasonably short.
Chapter 7 Chapter 8
- J2EE XML Development
Part Threebetter - Working with Enterprise A much approach is to createMessaging a batch procedure,
Chapter 9
which (when executed from the command prompt) builds the ne
- J2EE Enterprise Messaging
Listing 10 11-4- shows theWSAD-Embedded procedure for building the combined WSAD/MQ JMS environment necessary for running JMSAdm Chapter Using the JMS Provider \Java\lib directory Chapter 11 - Using WebSphere MQ as the JMS Providerbefore using them. Appendix A - Deploying This Book's J2EE Examples
Listing 11-4. SetJMSAdminEnv.cmd
Index
List of Figures
@echo off set WAS_HOME=g:\WSAD\runtimes\base_v5 List of Tables @rem ==== Java runtime ===== set List of Code Examples
JAVA_INSTALL_PATH=g:\WSMQ\java set JAVA_HOME=g:\WSAD\runtimes\base_v5\java\bin @rem ==== MQ JMS =========== set MQ=%MQ_JAVA_INSTALL_PATH%\lib set MQ=%MQ%;%MQ_JAVA_INSTALL_PATH%\lib\com.ibm.mq.jar MQ=%MQ%;%MQ_JAVA_INSTALL_PATH%\lib\com.ibm.mqjms.jar set MQ=%MQ%;%MQ_JAVA_INSTALL_PATH%\lib\jms.jar set MQ=%MQ%;%MQ_JAVA_INSTALL_PATH%\lib\connector.jar set MQ=%MQ%;%MQ_JAVA_INSTALL_PATH%\lib\com.ibm.mq.amt.jar set MQ=%MQ%;%MQ_JAVA_INSTALL_PATH%\lib\com.ibm.mqbind.jar set MQ=%MQ%;%MQ_JAVA_INSTALL_PATH%\lib\jta.jar @rem ==== LDAP JNDI =========== set MQ=%MQ%;%MQ_JAVA_INSTALL_PATH%\lib\ldap.jar @rem ==== File System JNDI =========== set MQ=%MQ%;%MQ_JAVA_INSTALL_PATH%\lib\providerutil.jar set MQ=%MQ%;%MQ_JAVA_INSTALL_PATH%\lib\fscontext.jar @rem ==== WebSphere JNDI =========== set MQ=%MQ%;%MQ_JAVA_INSTALL_PATH%\lib\jndi.jar set WebSphereCP=%WAS_HOME%\lib\naming.jar set WebSphereCP=%WebSphereCP%;%WAS_HOME%\lib\namingclient.jar set CLASSPATH=%WebSphereCP%;%MQ%;%CLASSPATH% set PATH=%JAVA_HOME%;%JAVA_INSTALL_PATH%\bin;%JAVA_INSTALL_PATH%\lib;%PATH%
List of Sidebars
Tip To check if the environment for the JMSAdmin utility is set correctly, open a command line, switch to Application Servers > server1 Namefield. Enter jms/Notify_MQ_QCFin the Connection factory JNDI name field; enter jms/Notify_MQ_Qin
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 - 11-15: Introducing WSAD 5.0 Figure Configuring the listener port for the P2P domain Chapter 2 - Setting Up the Development Environment
Click OK. the configuration and 5.0 log Workbench out of the Administrative Console. Close the Web browser. Let’s stop here for a Chapter 3 Save - Working with the WSAD Chapter 4
- Developing Database Applications
For the embedded JMS provider, you expanded Resources, clicked WebSphere JMS Provider, and went through
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 - J2EE Descriptor Development The Deployment configuration is the last part; you will do this in the next section. Chapter 6 - J2EE EJB Development Chapter 7
- J2EE Web Development Configuring Deployment Descriptors Chapter 8 - J2EE XML Development Part - Working with Enterprise MessagingDescriptors TheThree final step is to configure the Deployment
Chapter 9
for both applications. In the J2EE Perspective (J2EE Hierarchy
- J2EE Enterprise Messaging
First, you to define the listener portJMS for the ReceivingMDBMDB. This is the port that the MDB delegates the contai Chapter 10 want - Using the WSAD-Embedded Provider namefield. Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 11-16: Setting the listener port
TheBook_notifyentity bean indirectly manipulates the TECHBOOK database, so you need to set a reference to the DB
Figure 11-17: Setting a Datasourceresource
TheReceivingMDBMDB calls the createmethod of the Book_notifyentity bean. In addition, this module indirectly u
Expand ReceivingMDBand click ResourceRef. Set the Namefield to Notify_MQ_QCFand the JNDI Name field to jm WebSphere Studio Application Developer 5.0: Practical Namefield to jms/Notify_MQ_TCF. Click ResourceEnvRef again. Set the Namefield to Notify_MQ_Tand the JNDI N J2EE Development
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Figure- 11-18: Setting the queue object reference Working with the WSAD 5.0 Workbench
Chapter 3
Chapter 4 changes - Developing Database Applications Save the and close the editor. Now you need to configure the sending side. On the sending side, you have two Part Two - Working with J2EE: The Distributed Application Framework
topic connection factory and topic MQ objects. You need to set the references to the MQ resources accordingly.
Chapter 5
- J2EE Development Double-click to open its Deployment Descriptor. Select the Referencestab, highlight Res Chapter 6 - SendingJMSMQProjectWEB J2EE EJB Development
Notify_MQ_TCF and enter jms/Notify_MQ_TCFin the JNDI Name field.Figure 11-19 shows how your final screen s Chapter 7 - J2EE Web Development Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure 11-19: Setting the new queue connection factory reference
HighlightResource Environment and click the Addbutton. Set the New ResourceEnvRef name to Notify_MQ_Q how your final screen should look.
Figure 11-20: Setting the new queue reference
Save the changes and close the editor. You are ready to test your projects. In the next section, you will test how your two
Testing the Projects for the Point-to-Point Domain
Stop the UTS (if it is still running). Start the server again but in debug mode (so you can see the messages printed by the WebSphere Studio Application Developer 5.0: Practical Perspective. Right-click SendingServletand select Run on Server.Figure 11-21 shows the messages printed duri J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Figure 11-21: P2P execution results displayed in the Console View
Table of Contents
WebSphere Studio Developer 5.0:toPractical Development Next, you use theApplication DB2 Command Center browseJ2EE the BOOK_NOTIFY table. Figure 11-22 shows the content of the BO Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9 - 11-22: J2EE Enterprise Messaging Figure P2P messages in the BOOK_NOTIFY table Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider
In the next section, you will test how your two projects work in the Pub/Sub domain.
Appendix A - Deploying This Book's J2EE Examples Index Testing
the Projects for the Publish/Subscribe Domain
List of Figures
The change you need to do before testing the Pub/Sub domain is to change the TechLibMQListenerPort. You List of only Tables
Run administrative console. Enter your user ID to log in. Click Servers> Application Servers > server1. Scroll d List of Code Examples
You now mapped this listener port to the topic connection factory and topic JMS objects. Figure 11-23 shows how y List of have Sidebars
Figure 11-23: Listener port changed to topic Save the server configuration and log out from the Administrative Console. Close the Web browser.
You also need to open the deployment descripter for the receiving project. Click the Beans tab and change the type of th
Start the JMSMQServer. Switch to the Server Perspective, right-click PublishingServlet, and select Run on Serv
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how printed to use the WebSphere Application Figure 11-24: Messages during programStudio execution
Developer (WSAD) tool for developing J2EE distributed Next, you use theapplications. DB2 Command Center to browse the BOOK_NOTIFY table. Figure 11-25 shows the content of the BO Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Figure 11-25: Pub/Sub messages in the BOOK_NOTIFY table
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 Administered - Using WebSphere MQ as thefor JMS the Provider Setting Objects JMS
MQ Provider Simply
Appendix A - Deploying This Book's J2EE Examples
Now that you have learned the hard way of this type of development (and sometimes the only way), there is good news: Index
Administrative List of Figures Console and run the project. If at runtime WSAD 5.0 (WAS 5.0) determines that a necessary JMS object i List of Tables
You can download the two exported project files (ReceivingJMSMQProject1App.earandSendingJMSMQProject1
List of Code Examples
List Sidebars Of of course, there are situations when the default configuration being set in the Administrative Console is not appropriate f
Summary
WebSphere Studio Application Developer 5.0: Practical J2EE Development
ISBN:1590591208 by Igorhow Livshin This chapter discussed to integrate the WSAD and MQ environments to use MQ as the WSAD JMS Apress ©how 2003 to (630 pages)MQ on top of the WSAD embedded JMS provider and showed how provider. It also covered install to use the MQ Explorer andprovides JMSAdmin utilities step-by-step for building and registering MQ objects. Next, it discussed This book a practical, approach in teaching how to use Studio Application how to set the UTS environment and the theWebSphere Deployment Descriptor configuration. Finally, you developed the Developer tool for J2EE distributed sending and receiving sides(WSAD) of the J2EE 1.3developing JMS application and tested it for both JMS domains (P2P and applications. Pub/Sub).
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Studio Application Developer 5.0: Practical AppendixWebSphere A: Deploying This Book's J2EE Examples J2EE Development
Overview
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in
In this appendix, you teaching will learn how to how usetothe deploy WebSphere the Java Studio 2 Enterprise Application Edition (J2EE) 1.3 applications on Developer (WSAD) tool 5.0. for developing J2EE distributed WebSphere Application Server (WAS) You will deploy some of the application examples that you developed in this applications. book. The runtime environment discussed in this appendix resides on a network server machine called JULIA. On this machine, the following software packages have been installed: WAS 5.0, DB2 Universal Database WebSphere Studio Application Developer 5.0: Practical J2EE Development (UDB) 7.2 with Fixpack 6,and WebSphere MQ 5.3.1 with all the necessary service packs. Installation of Introduction the DB2 and MQ packages for the runtime and development environments is very similar.
Table of Contents
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 - Introducing WSAD 5.0 for the development environment.) (See Chapter 3 where it is covered Chapter 2 - Setting Up the Development Environment
Note installation WAS 5.0 package is beyond the scope of this book. Please consult the Chapter 3 The - Working with of thethe WSAD 5.0 Workbench Chapter 4
vendor documentation. - Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
The installation documentation for the Windows NT/2000 platform comes in the WAS 5.0 downloadable
Chapter 5 - the J2EE Development files. Unzip Readme.zip file and read two documents: Chapter 6 - J2EE EJB Development
Installation.html andInstallGuide_en.PDF.Similar documentation is available for other Chapter 7 - J2EE Web Development platforms. addition, can refer to several books written for WAS, such as IBM WebSphere Chapter 8 In - J2EE XML you Development Application Server V5.0 Management Part Three - Working with System Enterprise Messaging
and Configuration , which is available from IBM Redbooks at
http://www.redbooks.ibm.com. Chapter 9 - J2EE Enterprise Messaging Chapter 10 - Using the WSAD-Embedded JMS Provider
These packages are installed on the runtime machine in the following directories:
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying Book's 7.2 J2EE Examples C:\SQLLIB: DB2This database Index
WebSphere MQ 5.3.1 List ofC:\WSMQ: Figures List of Tables
C:\WAS: WAS 5.0
List of Code Examples
List of appendix Sidebars frequently mentions these directories (or their subdirectories). Make the appropriate This
adjustments if your installation is different. Avoiding Port Conflicts If you install both the WSAD 5.0 and WAS 5.0 packages on the same machine, you will not be able to run them concurrently because of a conflict in the ports. One solution is to always stop WAS and the IBM HTTP Server before activating WSAD (and vice versa). Another solution is to modify the ports WAS uses. A typical WAS 5.0 installation uses the following ports: 80, 443, 900, 2809, 5557, 5558, 5559, 7873, 8008, 8880, 9000, 9043, 9080, 9090, and 9443. Issue the network command netstat ñanto display the ports currently used on your machine. To change the ports that WAS 5.0 uses and avoid the port conflicts, go to the WAS configdirectory and change the default ports that have been set within several configuration files. Be careful when directly modifying the WAS configuration files (back up them first). You can make the same modifications using the WAS Administrative Console: Expand Nodesall the way until you see Application Servers > Web Containers andEJB Containers.Check and change (if necessary) all the default ports. Also, expand Virtual Hosts > Aliasesto examine (and change if necessary) the port assignments.
WebSphere Application Developer 5.0: Practical Preparing the WAS Studio Environment for Deployment J2EE Development
ISBN:1590591208 bywill Igor Livshin In this section, you deploy the database application developed in Chapter 4. The first task is to install the Apressand © 2003 pages) TECHBOOK database its(630 tables in the runtime environment (in the same way you installed it in the development environment). You willa use the same procedure (used in This book provides practical, step-by-step approach in the development environment in teaching to use the database WebSphere Applicationenvironment. The procedure is called Chapter 4) for building thehow TECHBOOK in Studio your production Developer (WSAD) tool J2EE distributed BuildTechbookDatabase.sql, andfor youdeveloping can download it from the Downloads section of the Apress applications. Web site (http://www.apress.com).
Listing A-1 shows the procedure. Make the appropriate adjustments if your runtime environment is different. Finally, remember to copy this procedure to the Programs > IBM HTTP Server 1.3.26 > Stop HTTP Server. To start the Chapter 8 -Server, J2EE XML Development IBM HTTP select Start > Programs > IBM HTTP Server 1.3.26 > Start HTTP Server. Part Three - Working with Enterprise Messaging
Start the Console again. Log in, expand Applications and click Enterprise Applications. Chapter 9 Administrative - J2EE Enterprise Messaging Figure 10 A-17- shows theWSAD-Embedded next screen. YouJMS should see that the DBDatasourceProjectApp application is not Chapter Using the Provider
only included in the list of installed applications but it has also successfully started (indicated by the green arrow on the Status column).
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure A-17: The started DBDatasourceProjectAppapplication You are ready to run the application. To invoke the application under the Web browser, you need to know how to construct the invocation Uniform Resource Locator (URL) for your application. The URL includes the node name where the server is running (which is localhost in this case). You also need to know the Context-root of the Web module. In the Administrative Console, click the DBDatasourceProjectApp application. In the 'Additional Properties' section, click View Deployment Descriptor.Figure A-18 shows the application-level Deployment Descriptor. Expand Web Modules all the way down. You should seeContext-root:DBDatasourceProject.
Figure A-18: The application Deployment Descriptor
To construct the URL, you concatenate the node (which is localhostin this case) with the Context-root WebSphere Studio Application Developer 5.0: Practical and with the module name to be invoked (BookSearchInputForm.html). The final URL is J2EE Development http://localhost/DBDatasourceProject/BookSearchInputForm.html. ISBN:1590591208 by Igor Livshin Apress © 2003 (630 pages) You are ready to run your application. Start your Web browser and enter the following URL in the This book provides a practical, step-by-step approach in command line: http://localhost/DBDatasourceProject/BookSearchInputForm.html. teaching how to use the WebSphere Studio Application Developer (WSAD)input tool for developing distributed Figure A-19 shows the application screen. Type J2EE Library in the Booklocation field. applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Figure A-19: The user input screen
Chapter 4 - Developing Database Applications Click Submit. Figure A-20 shows the processing results. Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
Figure A-20: The main processing results
Index
List of Figures Select the first record and click Details. Figure A-21 shows the results. List of Tables List of Code Examples List of Sidebars
Figure A-21: TheDetails View page This is the end of the DBDatasourceApp application deployment example. In the next section, you will deploy the full J2EE application called TechLibApp. Chapters 6 and 7 cover the development of this application.
WebSphere Studio Application Developer 5.0: Practical Deploying the TechLibApp Application J2EE Development
by Igor Livshin To deploy the TechLibApp application, you need to export the ISBN:1590591208 application from your WSAD 5.0 Apress © 2003 pages) development environment and(630 then install it on WAS 5.0 in your runtime environment. This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Exporting the TechLibApp Application from WSAD On the development machine, you need to export the TechLibApp project from the WSAD Workbench. Again, in the J2EE Perspective, right-click TechLibApp and select Export. On the next screen, select EAR Table of the Contents file as type of export. Click Next. Figure A-22 shows the next screen. TechLibApp should already WebSphere Application Practical J2EE Development appear as Studio the resource to beDeveloper exported.5.0: Click the Browse button and navigate to the directory where you Introduction want to place the exported resource. You want to place the TechLibApp application in the WAS install Part subdirectory One - Getting called Started installableApps. with WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables
Figure A-22: Exporting the TechLibAppapplication
List of Code Examples
List of Finish. Sidebars The TechLibApp.earfile will be placed in the WAS installableAppsdirectory. In Click
thenext section, you will install the TechLibApp application.
Installing the TechLibApp Application Now, switch to the runtime machine JULIA (where WAS 5.0 is installed) and activate the WAS Administrative Console. Enter your user ID and click OK. Expand Applications and click Install New Application. On the next screen, shown in Figure A-23, click Browse, navigate to the WAS installableApps directory, and select the TechLibApp.ear file.
Figure A-23: Installing the TechLibAppapplication
WebSphere Studio Application Developer 5.0: Practical
Click Next. FigureJ2EE A-24Development shows the first screen of the installation wizard. by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter Figure 9 - A-24: J2EE Enterprise Preparing Messaging for the application installation screen Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider
Accept the defaults and click Next. You will see the screen depicted in Figure A-25.
Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure A-25: Installation options Again, accept the default and click Next. The next screen, shown in Figure A-26, allows you to change the mapping of the EJB modules to their JNDI names.
Figure A-26: Mapping EJB modules to JNDI names
All the names are already filled in correctly, so you do not need to change anything on this screen. Click WebSphere Studio Application Developer 5.0: Practical Next. The subsequent screen, shown in Figure A-27, allows you to change the mapping of the J2EE Development TECHBOOK Datasource to its external JNDI name. Enter jdbc/DBDatasource in the JNDI Name field. ISBN:1590591208 by Igor Livshin This is the EJB modulelevel Datasource mapping that applies to every EJB 2.0 Container Managed Apress © 2003 (630 pages) Persistence (CMP) component within the EJB module. This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Developer 5.0: Practical J2EE Development FigureStudio A-27:Application Mapping the Datasource to the JNDI name Introduction Part One - Getting with the WebSphere Studio Application 5.0 individual Click OK. Figure Started A-28 shows next screen, where you canDeveloper optionally(WSAD) map each
EJB 2.0 CMP
Chapter - specific Introducing WSAD 5.0 module1 to a Datasource. Chapter 2 - Setting Up the Development Environment Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Figure A-28: Mapping individualMessaging CMP modules
Chapter 9
to the DatasourceJNDI names
- J2EE Enterprise Messaging
You do10 not-need map individual CMPJMS components Chapter Usingtothe WSAD-Embedded Provider to different Datasources, so click Next. The next screen,11 shown in Figure A-29, MQ allows youJMS to change Chapter - Using WebSphere as the Providerthe mapping of the EJB module references. Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure A-29: Mapping EJB module references All names are already filled in correctly, so click Next. Figure A-30 shows the next screen, which allows you to change the mapping of the resource references to the actual resources. Make sure TechLibEJB is checked, expand the Select box, and select the Datasource called julia:jdbc/DBDatasource. Enter jdbc/DBDatasource in the JNDI Name field.
Figure A-30: Mapping EJB module references Click Next. The subsequent screen, shown in Figure A-31, allows you to change the mapping of the Web module to the virtual host.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Figure A-31:Developer Mapping the Webtool module to the virtual (WSAD) for developing J2EEhost distributed applications.
This screen does not require any changes, so click Next. Figure A-32 shows the next screen, where you can map modules to the application server. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Figure- A-32: Mapping modules to the application server J2EE Development
Chapter 5 Chapter 6
J2EE EJB Development Click Next.-The next screen, depicted in Figure A-33, allows you to define declarative security to protect
Chapter - J2EE Web Development the EJB7 methods. Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables
A-33: Setting EJB module protection List ofFigure Code Examples List of Sidebars
You do not want to define declarative security for this application example, so click Next. Figure A-34 displays the installation summary.
Figure A-34: The installation summary Click Finish. WAS starts installing the application. When it is done, the installation results look like Figure A-35.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter Figure 2 - A-35: Setting Installation Up the Development results Environment Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
The installation is done. Expand Applications on the left part of the screen and click Enterprise Applications. Figure A-36 shows a list of the installed applications.
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure A-36: List of installed applications You should see the TechLibApp application in the list of installed applications, but you can see that its status shows that it has not been started yet. Figure A-37 shows a message on the top of the screen reminding you that the server configuration has been changed.
Figure A-37: WAS message You need to save the server configuration and then stop and restart WAS. Click the Save button on the Administrative Console toolbar. Click Save on the confirmation screen. Click the Logout button to exit the Administrative Console. Activate the WAS First Steps utility. Figure A-38 shows the main utility screen.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working withWAS J2EE:Fist TheSteps Distributed Framework Figure A-38: The utility'sApplication main screen
Chapter 5
- J2EE Development Click Stop Wait for the server to completely stop. Click Start the Server and wait for Chapter 6 - the J2EE Server. EJB Development
the server start.Web Figure A-39 shows the started server. Chapter 7 to - J2EE Development Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Figure A-39: The WAS First Steps utility, after the server has started Start the Administrative Console again and enter your user ID. Expand Applications and click Enterprise Applications. Figure A-40 shows that the TechLibApp application has been started.
Figure A-40: The started TechLibAppapplication
Click the Logout button to exit the Administrative Console. You are ready to run your application. WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical Running the TechLibApp Application J2EE Development
ISBN:1590591208 by Igorapplication, Livshin To run the TechLibApp you will execute two business functions. First, you want to register a Apresscatalog. © 2003 (630 pages) new book in the library Start your Web browser and enter the following URL in the command line:
This book provides a practical, step-by-step approach in
http://localhost:9080/TechLibWEB/BookBookRegisterInputForm.html. teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed
Figure A-41 shows applications. the user input screen. Enter 00008 in the Catalog number field, enter Maximum Java 1.1 in the Book title field, enter Vanderburg and a team in the Author field, enter BBB_Company in the Location field, enter 00 in the Platform field, and enter 01 in the Language field.
Table of Contents
WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development Figure Registering a new book Chapter 7 - A-41: J2EE Web Development Chapter 8
- J2EE XML Development
Click Submit. Figure A-42 shows the book's registration results.
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables
A-42: The book's registration results List ofFigure Code Examples List of Sidebars
Next, you will execute the second business function that searches for all books written for a specific platform. Enter the following URL in the Web browser command line: http://localhost:9080/TechLibWEB/BookByPlatformInputForm.html. On the user input screen, shown in Figure A-43, select Cross platform as the platform in question.
Figure A-43: Searching for all books written for Cross platform Click Submit. Figure A-44 shows the processing results.
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Figure A-44: The cross-platform search results Table of Contents
This completes the TechLibApp installation example.
WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Summary
WebSphere Studio Application Developer 5.0: Practical J2EE Development
ISBN:1590591208 Igor Livshin This is the end ofby a long journey to J2EE development using WebSphere technology. The main goal for Apress 2003 (630 the book is to make the ©reader to pages) become familiar with J2EE development using WSAD 5.0 and with the subsequent process installing J2EE applications on WASapproach 5.0. Thisinbook has covered a lot of ground. This of book provides a practical, step-by-step
teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed By now, you should know how to install various development tools necessary for building your applications. development environment, and you should feel comfortable with various aspects of J2EE development with WSAD 5.0. I hope this book has achieved its goal to make you more knowledgeable and productive in the development of J2EE applications with WSAD 5.0. Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
A
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
book provides a practical, step-by-step approach in acknowledgmentThis mode, JMS, 459 teaching how to use the WebSphere Studio Application
Developer (WSAD) tool for developing J2EE distributed addBookActivity method, 123-124 applications.
Administrative Console Datasource, defining and, 577 WAS and, 36-37 Tableembedded of Contents enabling, 495 Application Developer 5.0: Practical J2EE Development WebSphere Studio mapping listener port and, 502 Introduction WAS configuration and, 580 Studio Application Developer (WSAD) 5.0 Part saving One - Getting Started with WebSphere starting Chapter 1 -TechLibApp Introducing application WSAD 5.0 and, 601-602` Chapter Aged timeout 2 - Setting property, Up the JMS, Development 500 Environment Chapter 3 - Working Agent Controller, 14 with the WSAD 5.0 Workbench Chapter 4
- Developing Database Applications
ALTER TYPE (name) [property] command, 548
Part Two - Working with J2EE: The Distributed Application Framework
Application project, 43,45 Chapter 5 - Client J2EE Development Chapter Application 6 - Name J2EE EJB WAS Development installation option, 585 Chapter 7 -servers J2EE Web Development application Chapter 8 - J2EE XML Development classloader and, 145 Part IBM Three - Working with Enterprise Messaging WebSphere Application Server. SeeWebSphere
Application Server (WAS),IBM WebSphere
Chapter 9 - J2EE Enterprise Messaging Application Server V5.0 System Management and Configuration,571 Chapter 10 - modules Using the to, WSAD-Embedded JMS Provider mapping 586,596 Chapter restarting, 11 - Using 581 WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples applications. See also database applications development;J2EE, deploying examples;Web application Index development List of Figuresnew application examples, WebSphere MQ, 544-545 building List of Tables P2P applications. SeeJava Message Service (JMS), developing P2P applications List of Pub/Sub Code Examples applications, developing, 515-525
administered objects, setting, 516-518 List of Sidebars administered objects, setting references to, 522-524 sending part, building, 518-522 testing,524-525 Apress Web site downloading BuildTextbookDatabase.sql file, 65 downloading exported project files from, 569 downloading SetJMSAdminEnv.cmd, 551 for information, 155,339 for source code, book examples, xx asterisk (*), and bean methods, 161 asynchronous communication asynchronous message receipt, 464 basics of, 447-448 MDBs and, 468 WebSphere MQ and, 532 attributes creating, Top Down method, 219 dynamic attributes, setting, 352-353 entity bean attributes, mapping to database tables, 225-226 Web pages and processing for input field, 315-316 selecting for, 291-292
XML adding,391WebSphere Studio Application Developer 5.0: Practical J2EE Development of XML namespaces, 380-381 ISBN:1590591208 by Igor Livshin XML Schemas and, 377,383 Apress © 2003 (630 pages)
authentication alias, 581 a practical, step-by-step approach in This579-580, book provides teaching how to use the WebSphere Studio Application AUTHOR table field, 64 Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
B
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in BMP entity beans, 227-251 teaching how to use the WebSphere Studio Application introduction to, 227-229 (WSAD) tool for developing J2EE distributed Developer testing,249-251 applications. transport object, building BookInquiryHome.java: Home Interface Class (code listing), 244-245 BookInquiry.java: Remote Interface Class (code listing), 245 Table of BookInquiryKey.java: Contents Primary Key Class (code listing), 245-246 WebSphere Studio Application Developer 5.0: Practical J2EE Development introduction to, 229-230 Introduction methods,231-233 Part Onesource - Getting Started withmodules, WebSphere Studio Application Developer (WSAD) 5.0 code for book 233-246 Chapter TransportBean.java 1 - Introducing WSAD 5.0 (code listing), 230-231 Chapter 2
- Setting Up the Development Environment BOOK_ACTIVITY table
Chapter 3 - Working Book_activity and,with 188the WSAD 5.0 Workbench Chapter 4 - Developing Database Applications structure, 65
Part Two - Working with J2EE: The Distributed Application Framework
BookByPlatformController servlet, 348
Chapter 5
- J2EE Development BookByPlatformController.java (code listing), 346-348 Chapter 6 - J2EE EJB Development Chapter BookByPlatformController.java 7 - J2EE Web Development controller, and MVC pattern, 331 Chapter 8 - J2EE XML Development BookByPlatformHelper1, examining code, 344-348 Part Three - Working with Enterprise Messaging
BookByPlatformHelper1.java (code listing), 340-343
Chapter 9
- J2EE Enterprise Messaging
BookByPlatformHelperX.java (code listing), 357-362 Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter BookByPlatformOutputForm.jsp 11 - Using WebSphere MQ(code as thelisting), JMS Provider 348-351,354-356 Appendix A - Deploying This Book's J2EE Examples BOOK_CATALOG table IndexBook_catalog and, 188 List of Figures constructing SQL statements and, 82-83 List of Tables 72-73 records, List of structure, Code Examples 64,72 List of Sidebars BOOK_CAT_NUM table field, 65
BOOK_DETAILS Processing Results (code listing), 225 The BookHelper Class (code listing), 317-320 BookInquiryBean.java: Implementation Class (code listing), 233-244 BookInquiryHome.java: Home Interface Class (code listing), 244-245 BookInquiry.java: Remote Interface Class (code listing), 245 BookInquiryKey.java: Primary Key Class (code listing), 245-246 Book.java CMP Entity Bean (code listing), 120 BOOK_NOTIFY table. See also XML Schemas importing into project, 486,488 messages written in, 542-543 P2P messages in, 566 Pub/Sub messages in, 568 structure of, 65 BookRegisterController setting references for, 306-307 source code, 302-305 The BookRegisterController Class, BookRegisterController.java (code listing), 320-324 The BookRegisterController Class, BookRegisterInputForm Page, BookRegisterInputForm.html (code listing), 324-328
The BookRegisterController Page, BookRegisterResultsForm.jsp (code WebSphereClass, StudioBookRegisterResultsForm Application Developer 5.0: Practical listing), 328-330 J2EE Development by Igor Livshin BookRegisterController.java Servlet (code listing), 302-305
ISBN:1590591208
Apress © 2003 (630 pages)
BookRegisterHelper class, building, 287-288
This book provides a practical, step-by-step approach in
BookRegisterHelper.java (code teaching how tolisting), use the288-290 WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed Bottom Up method, 190-212 applications. business methods, building. Seebusiness methods, building (entity beans) Datasource, binding, 206-207 server, configuring, 208-212 Tabletest of Contents WebSphere Application Developer Practical Boundary Studio field, and transaction context5.0: control, 166J2EE Development Introduction
breakpoints removing,365 Chapter 1 for - Introducing setting debugging,WSAD 365 5.0 Chapter 2 - at, Setting stopping 367 Up the Development Environment Chapter 3 during - Working with the367-370 WSAD 5.0 Workbench using debugging,
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 4
- Developing Database Applications
Breakpoints View, 55
Part Two - Working with J2EE: The Distributed Application Framework
brokers5 Chapter
- J2EE Development
Pub/Sub, defined, 450 - J2EE EJB Development WebSphere versions and, 473
Chapter 6 Chapter 7
- J2EE Web Development
BuildTechbookDatabase.sql (code listing), 572-576 Chapter 8 - J2EE XML Development Part Three - Working with Enterprise Messaging BuildTextbookDatabase.sql (code listing), 65-69
Chapter 9
- J2EE Enterprise Messaging business methods, building (entity beans), 191-205
Chapter 10 of, - Using the WSAD-Embedded JMS Provider basics 191-196 Chapter 11 - Key Using WebSphere MQ as the JMS Provider (code listing), 204-205 Primary Class TechLibBook_activityKey.java Appendix A Deploying This Book's J2EE Examples Primary Key Class TechLibBook_catalogKey.java (code listing), 200 IndexTechLibBook_activityBean.java: Implementation Class (code listing), 201-203 List of Figures TechLibBook_activityLocalHome.java : Local Home Interface (code listing), 203 List of TechLibBook_activityLocal.java: Tables Local Interface (code listing), 204
TechLibBook_catalogBean.java: Implementation Class (code listing), 197-199 List of Code Examples TechLibBook_catalogLocal.java: Local Interface (code listing), 199 List of Sidebars BytesMessage type, JMS, 452,453
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
C
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in cached bean option, 162 teaching how to use the WebSphere Studio Application
Developer CATALOG_NUMBER table(WSAD) field, 64tool for developing J2EE distributed applications.
CHANGE ctx(ctxName) command, 548 channels Tablelack of Contents of in embedded provider, 531 WebSphere Studio Application Developer 5.0: Practical J2EE Development message channels, 533–534 Introduction Message Queue Interface (MQI) channels, 533 Part WebSphere One - GettingMQ Started WebSphere Studio Application Developer (WSAD) 5.0 and, with 533–534
Chapter 1
- Introducing WSAD 5.0 character encoding, 140
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
classes4 Chapter
- Developing Database Applications
chg ctx(jms) command, 554
downloading, 339 Part BookByPlatformHelper1 Two - Working with J2EE: class, The Distributed Application Framework dependent value classes, EJB, 117–119 Chapter 5 - J2EE Development Java6 classes, new, 53–55 Chapter - J2EE creating EJB Development
JavaBean class building, 229–230,339 - J2EE Web Development inserting in JSP module, 350
Chapter 7 Chapter 8
- J2EE XML Development
classloaders Part Three - Working with Enterprise Messaging configuring testEnterprise servers and, 210–211 Chapter 9 - J2EE Messaging Web10tier, 144–146 Chapter - Using the WSAD-Embedded JMS Provider Chapter CLASSPATH 11 - Using environment WebSphere variables MQ as the JMS Provider
installation of WSAD and, 17 J2EE Examples Appendix A - Deploying This Book's IndexServer Perspective and, 34, 35 List of FiguresLT, 14 ClearCase List of Tables
client modules, J2EE, 108
List of Code Examples
clients Client Certificate Authentication, HTTPS, 184–185 IBM Universal Test Client, and CMP entity beans, 212–218 MQ clients, 534 multiscreen clients, 281
List of Sidebars
CMP Entity Bean with the Dependent Value Class (code listing), 118 CMP entity beans components.SeeBook_activity;Book_catalog developing,188–227.See also Bottom Up method IBM EJB test client and, 212–218 importing TECHBOOK into TechLibEJB project and, 189 mapping entity bean attributes to database tables, 225–226 Middle method and, 227 Top Down method and, 218–225 EJB 2.0 dependent value classes and, 117–119 find and select methods and, 127 persistence fields and, 116–117 relationship fields and, 119–126 CMP fields, 116–117 co-location, defined, 113 code.See also listings;source code Java.See also Debug Perspective Code Assist, 47 controlling appearance of, 46–47
Code Assist, Java, 47
WebSphere Studio Application Developer 5.0: Practical
Code of the Bean-Managed Session Bean (code listing), 161–162 J2EE Development
ISBN:1590591208 by Igor Livshin columns Apress © 2003 (630 pages) adding, Top Down method, 221–222 mapping to entity This bean book provides attributes, a 487–488 practical, step-by-step approach in teaching how to use the WebSphere selecting values, TECHBOOK database, 84–85 Studio Application
Developer (WSAD) tool for developing J2EE distributed
commands.Seespecific commands applications.
CommandsForJMSAdmin.txt (code listing), 553 Commit Option, 162–171 Table of Contents cachedStudio bean option, 162Developer 5.0: Practical J2EE Development WebSphere Application concurrency control, 169–171 Introduction bean option, 163–168 Part polled One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 stale1 bean option, 163 Chapter - Introducing WSAD 5.0 COMPANY_NAME field, 65 Chapter 2 - Setting table Up the Development Environment Chapter 3 - Working with the WSAD 5.0 Workbench components Chapter 4 entity - Developing Database Applications CMP beans. See Book_activity; Book_catalog Part EJB Two -components, Working withlocating J2EE: The Distributed Application Framework using JNDI, 109–112
Chapter 5 -P2P J2EE Development in JMS applications configuring, 505–506 Chapter development 6 - J2EE EJBof, Development 486–488
and development of, 489–494 Chapter MDBs 7 - J2EE Web Development a reference to, 502–503,505 Chapter setting 8 - J2EE XML Development Part Three - Working with Messaging Conceptual Fragment ofEnterprise the MDB Code (code
Chapter 9
listing), 470–471
- J2EE Enterprise Messaging
concurrency control, 169–171
Chapter 10 - Using the WSAD-Embedded JMS Provider
Concurrent Versions System (CVS), and WSAD installation, 14
Chapter 11 - Using WebSphere MQ as the JMS Provider
connection Appendix A -factories Deploying This Book's J2EE Examples Indexconfiguring for runtime, JMS, 499–500
WebSphere MQ and setting queue connection factory, 557–558,565 List of Figures setting topic connection factory, 559–560 List of Tables connection pool selection, TECHBOOK database, 87 List of Code Examples List of Sidebars Connection timeout property, JMS, 500
Container Managed Persistence. SeeCMP entity beans container relationship fields, defined, 119 Content Pane, Workbench, 22–23,26 Control Center, and TECHBOOK, 71–72 conversational sessions, 370–371 COPY TYPE (name A) TYPE (name B ) command, 548 Corrected XML Schema Location (code listing), 406 Create MBeans for Resources WAS installation option, 585 create method, testing, 507 CSD03 PTF, 541–542 ctx subcontext, 548 CVS (Concurrent Versions System), and WSAD installation, 14
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
D
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in DAD file generation, 428–429 teaching how to use the WebSphere Studio Application
Developer (WSAD) tool for developing J2EE distributed data access to, andapplications. bean options, 162–163,164 availability. Seetransaction isolation levels checking table data, TECHBOOK, 72–74 Table of Contents data integrity, EJB transactions, 171–173 WebSphere Studio Application Developer 5.0: Practical J2EE Development testing data validation, Web pages, 316 Introduction
Data Perspective, 31 Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1 applications - Introducing WSAD 5.0 database development, 63–103 Chapter J2EE 2 database - Settingapplication Up the Development development. Environment SeeJ2EE database application development
TECHBOOK database basics of,5.0 63–65 Chapter 3 - Working with the WSAD Workbench and, Database 188 Chapter entity 4 - beans Developing Applications database, building, 65–74 Application Framework Part TECHBOOK Two - Working with J2EE: The Distributed tables, checking in Control Center, 71–72 Chapter database 5 - J2EEand Development started, 65–71 Chapter getting 6 - J2EE EJB Development checking, 72–74 Chapter table 7 - data, J2EE Web Development Database Pages wizard, 81 Chapter 8 Web - J2EE XML Development Part Three - Working with Enterprise Messaging databases
Chapter 9 - J2EE Messaging checking, with Enterprise Control Center, 71–72 Chapter - Using theand, WSAD-Embedded JMS Provider Data10Perspective 31 Chapter 11 - Using WebSphere MQ as the JMS Provider importing for Web project, 79–80 Appendix importing A - Deploying into TechLibEJB, This Book's 189J2EE Examples Indexname, setting, 497
records, List of Figurescreating new, 216–217 List of Tables Datasource List of Code Examples adding to test servers, 208–209 List of binding Sidebars with Bottom Up method, 206–207
checking reference, and transport object building, 247–248 configuring for P2P JMS application project, 495–498 connections, configuring, 98–100 defining for WAS 5.0, examples, 577–581 setting a resource, 562–563 TECHBOOK database and configuring, 93–94 configuring connections, 98–100 setting,95–96 WebSphere MQ test server project and configuring, 545–546 setting a resource, 563 XA-compliant,526–527 DB2 DB2 provider attributes, 578–579 DB2 UDB, downloading and installing, 11–13 integrating with XML, 424–433 DAD file generation, 428–429 Extender, enabling for, 430–433 Extender, installing, 425–428 test harness generation, 429–430 setting runtime environments, and DB2 commands, 515 DB2 Extender enabling DB2 for, 430–433
installing,425–428
WebSphere Studio Application Developer 5.0: Practical
DBDatasourceProject J2EE Development configuring Datasource connection, 98–100 ISBN:1590591208 by Igor Livshin creating,77–78 Apress © 2003 (630 pages) creating and configuring server and, 96–98 step-by-step approach in This book provides a practical, importing database into, 79–80 teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed SQL statements and building, 80–82 applications. visually constructing, 82–88 testing,101–103 DBDatasourceProjectApp application, deploying, 582–591 Table of Contents exporting fromApplication WSAD, 582–583 WebSphere Studio Developer 5.0: Practical J2EE Development installing,583–591 Introduction Part - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 DDLOne files, generating, 223–224
Chapter 1
- Introducing WSAD 5.0 Debug Perspective, 32–33
Chapter 2
- Setting Up the Development Environment
debugging - Working with the WSAD 5.0 Workbench breakpoints, using during, 367–370 Chapter 4 - Developing Database Applications “Hello World” Java application, 55–57 Part Two - Working with J2EE: The Distributed Application Framework TechLibWEB project, 365–367 Chapter 5 - J2EE Development XSL,435–437 Chapter 6 - J2EE EJB Development XSL transformation, 441 Chapter 3
Chapter 7
- J2EE Web Development
declarations Chapter 8 - J2EE XML Development finder methods declarations, 195 Part Three - Working with Enterprise Messaging XML namespace declarations, 377–384 Chapter 9 - J2EE Enterprise Messaging default namespaces, using, 378–380 Chapter 10 - Using the WSAD-Embedded JMS Provider local elements qualification, 381–383 Chapter 11 - Using WebSphere MQ as the JMS Provider XML namespace attributes, 380–381 Appendix - Deploying XML ASchemas and This Book's J2EE Examples Index declarations vs. definitions, 383 List of Figures global element declarations, 383 List of Tables
declarative security, 175
List of Code Examples
def ctx(jms) command, 554
List of Sidebars
DEFINE ctx(ctxName) command, 548 DEFINE TYPE (name) [property] command, 548 definitions, and XML Schemas declarations vs. definitions, 383 global type definitions, 383 delegation policy, 181–183 DELETE ctx(ctxName) command, 548 DELETE TYPE (name) command, 548 Dependent Value Class (code listing), 118 Deploy EJBs WAS installation option, 585 Deployment Descriptor application-level, 589 EJB, 195–196 filters and, 132,133–134 J2EE Perspective and, 30–31 opening,30 relationship set in, 122 setting for database applications, J2EE, 93–103 basics of, 93–96 Datasource connection, configuring, 98–100
testing and, 101–103 WebSphere Studio Application Developer 5.0: Practical unit test server environment, setting, 96–98 J2EE Development using EJB QL and, 130-131 ISBN:1590591208 by Igor Livshin Web project and, 298,299 Apress © 2003 (630 pages) WebSphere MQ, configuring and, 562–569 This book provides a practical, step-by-step approach in
development environments, 11–20 teaching how to use the WebSphere Studio Application Developer (WSAD) tool forand, developing DB2 UDB, downloading and installing 11–13 J2EE distributed applications. setting JMS P2P application and, 494 WSAD basics of, 146–148 Table of Contents installation files, picking, 13–15 WebSphere Studio Application Developer 5.0: Practical J2EE Development installation files requirements, 15–18 Introduction installing,18–20
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Director1 security role, setting, Chapter - Introducing WSAD176 5.0 Chapter directories, 2 -481 Setting Up the Development Environment
DB2, and, 12the WSAD 5.0 Workbench Chapter 3 installing - Working with EJB4projects directory structure, 187–188 Chapter - Developing Database Applications directory Part Java Two -Source Working with J2EE: The Distributed Application Framework of, 283 Chapter basics 5 - J2EE Development files and, 296–297 Chapter WSAD-generated 6 - J2EE EJB Development for software packages (book examples), 571 Chapter 7 - J2EE Web Development
Web applications, 283–284 - J2EE XML Development Web Content directory basics of, 284 Part Three - Working with Enterprise Messaging WSAD-generated files and, 296–297 Chapter 9 - J2EE Enterprise Messaging WebSphere MQ, installing and, 537 Chapter 10 - Using the WSAD-Embedded JMS Provider WSAD Chapter 11 - Using WebSphere MQ as the JMS Provider installation of JMS client and, 482–483 Appendix A - Deploying This Book's J2EE Examples installing and, 15–17 Index workspace directory, 15–16, 19, 22 Chapter 8
List of Figures
Directory to Install Application WAS installation option, 584
List of Tables
dirty 173 List of reads, Code Examples List disk of space Sidebars
requirements for examples, xx requirements for WSAD, 9 DISPLAY ctx command, 548 DISPLAY TYPE (name) command, 548 Distribute Application WAS installation option, 584 Document Object Model (DOM) parser basics of, 401–402 vs. SAX, 401 using,407–415 Document Type Definition (DTD) building DTD files, 400 XML and, 374 documents, XML building,395–400 defined, 375 parsing,401–424 basics of, 401–407 DOM parser, 407–415 SAX parser, 415–424 valid documents, defined, 374
well-formed documents, defined, 374
WebSphere Studio Application Developer 5.0: Practical
doFilter method, J2EE 133 Development
Igor Livshin DOM (Documentby Object Model) parser. SeeDocument Object ISBN:1590591208 Model (DOM) parser Apress © 2003 (630 pages)
domains, defined, 481
This book provides a practical, step-by-step approach in
drivers, JDBC, and configuring 13 WebSphere Studio Application teaching how toDB2, use the Developer (WSAD) tool for developing J2EE distributed DTD (Document Type Definition) applications. building DTD files, 400 XML and, 374 Table of Contents dumpSpace utility, 112 WebSphere Studio Application Developer 5.0: Practical J2EE Development
dynamic pages, defined, 29
Introduction
dynamic defined,with 8 WebSphere Studio Application Developer (WSAD) 5.0 Part One - queries, Getting Started dynamic generating, 351–363 Chapter 1 tables, - Introducing WSAD 5.0 basics 351–354 Chapter 2 of, - Setting Up the Development Environment BookByPlatformOutputForm.jsp code, 354–357 Chapter 3 - Working with the WSAD source 5.0 Workbench processing logic, examining, Chapter 4 - Developing Database362–363 Applications Client with ViewJ2EE: code,The 357–362 Part Remote Two - Working Distributed Application Framework Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
E
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed EJB. See also entity beans development; J2EE EJB development applications. building new projects, 485
Eclipse, 3
EJB 2.0 entity beans, 116–132 dependent value classes, 117–119 Table of Contents EJB Query Language, 128–132 WebSphere Studio Application Developer 5.0: Practical J2EE Development find and select methods, 127 Introduction persistence fields, 116–117 Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 relationship fields, 119–126 Chapter 1 - Introducing WSAD 5.0 EJB 2.0 tier, 113–116 Chapter 2 - Setting Up the Development Environment EJB components, locating using JNDI, 109–112 Chapter - Working EJB3modules, 108with the WSAD 5.0 Workbench Chapter 4 Developing Database Applications EJB projects Part Twoaccessing - Workingother with projects J2EE: Thefrom, Distributed 142 Application Framework Chapter building, 5 - J2EE Development 485 Chapter described, 6 - J2EE43, EJB45Development Chapter organization, 7 - J2EE Web Development 187–188 Chapter specifying 8 - J2EEdependent XML Development JAR files for, 143 Part modules, Three - Working 594,595–596, with Enterprise 597 Messaging references, setting for Messaging Chapter 9 - J2EE Enterprise servlet, 306–307 Chapter BookRegisterController 10 - Using the WSAD-Embedded JMS Provider resources, protecting, 178–180 Chapter 11 - Using WebSphere MQ as the JMS Provider transactions, managing, 158–174. also Commit Option Appendix A - Deploying This Book's J2EESee Examples basics of, 158–162 Index data integrity, 171–173 List of Figures transaction isolation levels, setting, 173–174 List of Tables transactions, types of, 159 List of Code Examples Web tier development. SeeWeb application development List of Sidebars WSAD and support of EJB 2.0 specifications, 5–6 EJB Query Language (EJB QL), 128–132 ejbLoad method, 232–233 elements, XML adding global, 388–389,390 complex type elements, 383 defined, 374 local,383 namespace qualification and, 384 XML namespaces and, 380 Enable class reloading WAS installation option, 585 encoding.Seecharacter encoding END command, 548 Enterprise JavaBeans. SeeEJB Enterprise JavaBeans 2.1 (Apress, 2003), 107 Enterprise JavaBeans (O’Reilly, 2001), 193 Enterprise messaging. SeeWebSphere MQ as JMS provider;Java Message Service (JMS);JMS provider enterprise tier, J2EE, 107 entity beans
calling,300 WebSphere Studio Application Developer 5.0: Practical Commit Option, 162–171 J2EE Development cached bean option, 162 ISBN:1590591208 by Igor Livshin concurrency control, 169–171 Apress © 2003 (630 pages) polled bean option, 163–168 book provides a practical, step-by-step approach in stale beanThis option, 163 teaching how to use the WebSphere Studio Application components inDeveloper JMS P2P(WSAD) applications tool forconfiguring, developing 505–506 J2EE distributed development of, 486–488 applications. setting a reference to, 502–503,505 EJB 2.0 Table of dependent Contents value classes, 117–119 WebSphere EJBStudio QueryApplication Language,Developer 128–1325.0: Practical J2EE Development Introduction find and select methods, 127 Part Onepersistence - Getting Started WebSphere Studio Application Developer (WSAD) 5.0 fields, with 116–117 Chapter references 1 - Introducing WSAD 5.0 for BookRegisterController servlet, 306–307 Chapter relationship 2 - Settingfields, Up the Development Environment 119–126 Chapter 3 - Working with the WSAD 5.0 Workbench entity beans development, 188–251 Chapter 4 entity - Developing DatabaseSee Applications BMP beans, 227–251. also transport object, building Part Twointroduction - Working with J2EE: The Distributed Application Framework to, 227–229
Chapter testing, 5 - J2EE Development 249–251 Chapter 6 entity - J2EE EJB Development CMP beans, 188–227.See also Bottom Up method Chapter attributes, 7 - J2EEmapping Web Development to database tables, 225–226 Chapter IBM 8 -Universal J2EE XMLTest Development Client, 212–218 Part Three importing - Working TECHBOOK with Enterprise into TechLibEJB Messaging
project, 189
the Enterprise Middle method, 227 Chapter Meet 9 - in J2EE Messaging 218–225 Chapter Top 10 -Down Usingmethod, the WSAD-Embedded JMS Provider multiscreen considerations, 281 Chapter 11 - Using WebSphere MQ as the JMS Provider session 251–280 Appendix A -beans, Deploying This Book's J2EE Examples stateful session beans, 264–277 stateful session beans, testing, 277–280 List of Figures stateless session beans, 252–260 List of Tables stateless session beans, testing, 261–263 Index
List of Code Examples
environment List of Sidebarsvariables CLASSPATH environment variables installation of WSAD and, 17 Server Perspective and, 34,35 Web project, adding, 402–404 WSAD-provided, 50 environments.Seedevelopment environments;runtime environments Error Page Servlet Source Code (code listing), 149–150 error processing, and Web tier, 148–151 Event Broker, WebSphere MQ, 540 events,313–315 Example of the Listener Class (code listing), 465–467 examples.See also J2EE, deploying examples; projects disk space requirements for, xx RAM requirements for, xx software packages for, downloading, xx source code for, downloading, xxi WebSphere MQ building new application examples, 544–545 downloading and installing, 542–543 Windows 2000 platform and, xx execution results, Pub/Sub application, 524
Extender.SeeDB2 Extender
WebSphere Studio Application Developer 5.0: Practical
Extensible Markup Language (XML), 373–443.See also XML Schemas J2EE Development DB2 integration 424–433 ISBN:1590591208 by and, Igor Livshin DAD file generation, 428–429 Apress © 2003 (630 pages) DB2, enabling Extender, This for book provides 430–433 a practical, step-by-step approach in DB2 Extender, installing, teaching how to425–428 use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed test harness generation, 429–430 applications. introduction to, 373–374 parsing XML documents, 401–424 basics of, 401–407 Table of Contents DOM parser, 407–415 WebSphere Studio Application Developer 5.0: Practical J2EE Development SAX parser, 415–424 Introduction WSAD’s XML tools, 384 Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 XML documents, building, 395–400 Chapter 1 - Introducing WSAD 5.0 XML namespace declarations, 377–384 Chapter 2 - Setting Up the Development Environment additional considerations for XML schemas, 383–384 Chapter basics 3 - Working with the WSAD 5.0 Workbench of, 377–378 Chapter default 4 - Developing Database namespace, using, Applications 378–380 Part Twolocal - Working with J2EE: The Distributed element qualification, 381–383 Application Framework Chapter XML 5 - namespace J2EE Development attributes, using, 380–381 Chapter - J2EE EJB 32 Development XML6 Perspective, Chapter - J2EEbuilding, Web Development XML7 project, 434–443 Chapter stylesheet 8 - J2EE editing, XML Development 438–441 Part Three XSL- Working debugging, with435–437 Enterprise Messaging alternate creation, 441–443 Chapter XSL 9 -transformations, J2EE Enterprise Messaging stylesheet, creating, 434–435 Chapter XSLT 10 - Using the WSAD-Embedded JMS Provider XSL11 transformations, 434,441–443 Chapter - Using WebSphere MQ as the JMS Provider Appendix A -Stylesheet DeployingLanguage This Book's(XSL) J2EE debugging, Examples 435–437 Extensible Indexstylesheet editing, 438–441
XSL transformations, 434,441–443 List of Figures List of Tables List of Code Examples List of Sidebars
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
F
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in fields teaching how to use the WebSphere Studio Application CMP fields, 116–117 Developer (WSAD) tool for developing J2EE distributed JMS header fields, 451 applications. Multiplicity field, Book_catalog, 121–122 persistence fields, EJB, 116–117 Tablerelationship of Contents fields, EJB, 119–126 WebSphere Studio Application Developer table fields, TECHBOOK, 82–84 5.0: Practical J2EE Development Introduction transaction context control and Boundary field, 166 Part OneResolver - Gettingfield, Started 166with WebSphere Studio Application Developer (WSAD) 5.0 Chapter Unresolver 1 - Introducing 5.0 action WSAD field, 166 Chapter 2 fields, - Setting virtual 116Up the Development Environment Chapter files 3
- Working with the WSAD 5.0 Workbench
Chapter - Developing DAD4 files generation,Database 428–429Applications Part DDL Two -files Working with J2EE: The Distributed Application Framework generation, 223–224
Chapter 5 - J2EE dependent JARDevelopment files for EJB projects, 143 Chapter 6 J2EE EJB Development DTD files, building, 400 Chapter 7 - J2EE Web Development exported project files, downloading, 569 Chapter HTML 8 files, - J2EE downloading XML Development ready-made, 155 Part WSAD Three - and Working with Enterprise Messaging
files, picking, 13–15 Chapter installation 9 - J2EE Enterprise Messaging requirements, 15–18 Chapter installation 10 - Usingfiles the WSAD-Embedded JMS Provider 296–300 Chapter WSAD-generated, 11 - Using WebSphere MQ as the JMS Provider XSL A stylesheet files,This selecting, 435–436 Appendix - Deploying Book's J2EE Examples Index filters
creating List of Figuresnew, 129–130 defined, List of Tables 132 Web tier, J2EE 1.3 applications, 132–136 List of Code Examples List Sidebars 127 findofmethods,
finder methods building entity bean business methods and, 192–194 declarations,195 Fixpack 6 database, 11 Flanagan, David, 397 folders building new, 153–154 Web application directories, 283–284 Form-Based Authentication, 184 forms form design, improving for Web pages, 293–296 HTML input forms, Web project, 332–333 output forms, BookByPlatformOutputForm, 348–351 XForms,151 Fragment of an XML Schema File (code listing), 377 Fragment of the BookRegisterInputForm.html file (code listing), 297–298 Fragment of the Changed JMSAdmin.config File (code listing), 549 Fragment of the Deployment Descriptor (code listing), 132 Fragment of the Deployment Descriptor with the Filter Chain Definition (code listing), 134
Fragment of the JMSAdmin.config File (code listing), 549
WebSphere Studio Application Developer 5.0: Practical
Fragment of the Listener J2EE Development Code (code listing), 139 byMethods Igor Livshin Fragments of New (code listing), 266–270
ISBN:1590591208
Apress © 2003 (630 pages)
framesets, creating (Web tier), 151–157
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
G
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in Gallery View, Workbench, 25 teaching how to use the WebSphere Studio Application
Developer (WSAD) tool for developing J2EE distributed Generate DAD file wizard, 428 applications.
Generated BookCatalog.xml File (code listing), 431–433 The Generated Library.xml Skeleton File (code listing), 397 Table of Contents
Generated XML Schema (code listing), 393–395
WebSphere Studio Application Developer 5.0: Practical J2EE Development
The getAllCompanyNames Method (code listing), 124 Introduction Part One - Getting Started with 508 WebSphere Studio Application Developer (WSAD) 5.0 getMessage method, testing,
Chapter 1 - Introducing getter/setter methods WSAD 5.0 Chapter 2 - Setting Up the Development Environment BookRegisterHelper.java class and, 288 Chapter 3 beans - Working with methods the WSADand, 5.0 Workbench entity business 191–192,196 Chapter 4 - Developing Applications message object and,Database JMS, 452–453 Part Top Two Down - Working with and, J2EE:220 The Distributed Application Framework method
Chapter 5 - J2EE Development transport object and, 231–232 Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
H
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in Handle object, and Local Client View, 115–116 teaching how to use the WebSphere Studio Application
Developer header fields, JMS, 451 (WSAD) tool for developing J2EE distributed applications.
“Hello World” Java application, building, 48–61 debugging,55–57 classes, creating new, 53–55 TableJava of Contents Java projects, creating new, 48–525.0: Practical J2EE Development WebSphere Studio Application Developer packages, creating new, 52 Introduction testingStarted environment and, 57–61Studio Application Developer (WSAD) 5.0 Part WSAD One - Getting with WebSphere Chapter 1 - Introducing HelloWorld.java (listing),WSAD 54–555.0 Chapter 2 - Setting Up the Development Environment Help Perspective, 39–41 Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
high-penalty transactions, defined, 169
Home Part TwoInterface - Working with J2EE: The Distributed Application Framework BookInquiryHome.java: Home Interface Class (code listing), 244–245 Chapter 5 - J2EE Development source Chapter 6 code, - J2EE258 EJB Development
stateless session beans, 261–262 - J2EE Web Development
Chapter 7
HTML.See Language (HTML) Chapter 8 Hypertext - J2EE XMLMarkup Development Part Three - Working with Enterprise Messaging HTML Editor View, 29
Chapter 9
- J2EE Enterprise Messaging
HTTP.SeeHypertext Transfer Protocol (HTTP)
Chapter 10 - Using the WSAD-Embedded JMS Provider
HTTPS (Hypertext Transport Protocol Secure), Client Certificate Authentication, 184–185
Chapter 11 - Using WebSphere MQ as the JMS Provider
HTTPSessionActivationListener interface, 137–138 Appendix A - Deploying This Book's J2EE Examples Index HTTPSessionAttributeListener interface, 138–139 List of Figures
HTTPSessionBindingListener interface, 138
List of Tables
HTTPSessionListener interface, 137
List of Code Examples
Hypertext Markup Language (HTML) List of Sidebars building new HTML pages, 153 HTML Editor View, 29 Web project and HTML input forms, 332–333 HTML tags, creating, 335 Hypertext Transfer Protocol (HTTP) Basic Authentication, 184 HTTP session event listeners, 137–139 Hypertext Transport Protocol Secure (HTTPS), Client Certificate Authentication, 184–185
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
I
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in IBM teaching how to use the WebSphere Studio Application IBM Redbooks, 571 Developer (WSAD) tool for developing J2EE distributed MA0C serviceapplications. pack, 540–541 MA88 support pack, 539 Using Java online book, 540
Table of Contents
IBM Universal Test Client testing EJB modules and, 212–218 Introduction testing stateful session beans, 277–280
WebSphere Studio Application Developer 5.0: Practical J2EE Development Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
IBM WebSphere Application Server Chapter 1 - Introducing WSAD 5.0 V5.0 System Management and Configuration , 571 Chapter IBM WebSphere 2 - Setting Application Up the Development Server (WAS). Environment SeeWebSphere Application Server (WAS) Chapter 3 -property, Working 501 with the WSAD 5.0 Workbench Initial State Chapter 4
- Developing Database Applications
input screens, Web project customizing, 89–92 Chapter 5 - J2EE Development design,293–296 Chapter 6 - J2EE EJB Development HTML input forms, 332–333 Chapter 7 - input J2EE Web Development platform screen, 338
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 8
- J2EE XML Development
installation DB2 Extender, 425–428 Chapter 9 - J2EE Enterprise Messaging DB2 UDB, 11–13 Chapter 10 - Using the WSAD-Embedded JMS Provider DBDatasourceProjectApp application, 583–591 Chapter 11 - Using WebSphere MQ as the JMS Provider MA0C service pack, 540–541 Appendix A - Deploying This Book's J2EE Examples TechLibApp application, 592–602 IndexWebSphere MQ as JMS provider installing as WSAD JMS provider, 536–539 List of Figures Windowsaccounts, configuring, 535–536 List of Tables5.0 WSAD List of Code Examples installation files, 13–15 List of Sidebars installation requirements, 15–18 procedure,18–20 WSAD-embedded messaging support. See also Java Message Service (JMS), developing P2P applications basics of, 482–483 Part Three - Working with Enterprise Messaging
instance pooling, and thread-safe servlets, 157,158 interfaces.See also Java Naming and Directory Interface (JNDI) Application Programming Interfaces (APIs). SeeJava Message Service (JMS) BookInquiryHome interface source code, 244–245 Home Interface source code, 258 stateless session beans, 261–262 HTTP session event listeners and HTTPSessionActivationListener interface,137–138 HttpSessionAttributeListener interface, 138–139 HTTPSessionBindingListener interface, 138 HTTPSessionListener interface,137 Local Home interfaces, Book_activity and Book_catalog, 213 Local Interface basics of, 115 building business methods and, 199,203,204 developing stateless session beans and, 252 EJB 2.0 tier and, 111
MDBs and, 494 WebSphere Studio Application Developer 5.0: Practical as reference to EJB objects, 113–114 J2EE Development vs. Remote Interfaces, 5 ISBN:1590591208 by Igor Livshin setting,115–116 Apress © 2003 (630 pages) TechLibBook_activityLocalHome.java: Local Home Interface, 203 This book provides a practical, step-by-step approach in TechLibBook_activityLocal.java:Local Interface, 204 teaching how to use the WebSphere Studio Application TechLibBook_catalogLocal.java:Local Interface, 199distributed Developer (WSAD) tool for developing J2EE TechLibFacade1Local: applications. LocalInterface Class, 277 TechLibFacade1LocalHome: Local Home Interface Class, 276 testing,278 Table of WSAD Contents 5.0 support and, 6 WebSphere Application Developer 5.0: Practical J2EE Development RemoteStudio Interface Introduction basics of, 115 Part OneBookInquiry - Getting Started with WebSphere Remote Interface, 245Studio Application Developer (WSAD) 5.0 Chapter developing 1 - Introducing WSAD 5.0 stateless session beans and, 252 Chapter vs. 2 Local - Setting Up the Development Environment Interfaces, 5 Chapter MDBs 3 - Working and, 494with the WSAD 5.0 Workbench to, 246Database Applications Chapter promoting 4 - Developing session and,Distributed 357–362 Application Framework Part Twostateful - Working with beans J2EE: The Remote Interface Class, 259 Chapter TechLibFacade.java: 5 - J2EE Development 278 EJB Development Chapter testing, 6 - J2EE 5.0 Web support and, 6 Chapter WSAD 7 - J2EE Development ServletContextListener interface, 139–140 Chapter 8 - J2EE XML Development stateless session beans and, 252 Part Three - Working with Enterprise Messaging testing, 278 Chapter 9 - J2EE Enterprise Messaging WSAD Workbench, main interface, 21–22 Chapter 10 - Using the WSAD-Embedded JMS Provider WSAD’s graphical user interface. SeeWSAD 5.0 Workbench Chapter 11 - Using WebSphere MQ as the JMS Provider
Internet,Acustomizing 46 Examples Appendix - Deploying(Workbench), This Book's J2EE Index List of Figures List of Tables List of Code Examples List of Sidebars
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
J
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in J2EE,107–185. See also ExtensibleMarkup Language (XML);Web application development teaching how to use the WebSphere Studio Application application security, 175–181 Developer (WSAD) tool for developing J2EE distributed basics of, 175–176 applications. EJB resources, protecting, 178–180 programmatic security, 180–181 Table of Web Contents resources, protecting, 177–178 WebSphere Studio running Application 5.0: Practical Development applications, andDeveloper debugging. See ServerJ2EE Perspective Introduction EJB transactions, managing, 158–174.See also Commit Option Part Onebasics - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 of, 158–162 Chapter data 1 -integrity, Introducing WSAD 5.0 171–173 Chapter transaction 2 - Setting Up the Development Environment isolation levels, setting, 173–174 Chapter Enterprise 3 - Working messaging. with the SeeWSAD Java Message 5.0 Workbench Service (JMS) introduction to, 107–108 Chapter 4 - Developing Database Applications framework. SeeThe J2EE 1.3 framework Part J2EE Two - 1.3 Working with J2EE: Distributed Application Framework J2EE described, 43 Chapter 5 projects, - J2EE Development JMS6 providers and,Development 531 Chapter - J2EE EJB JNDI, Chapter 7 108–112 - J2EE Web Development utility, 112 Chapter dumpSpace 8 - J2EE XML Development for locating EJB components, 109–112 Part Three - Working with Enterprise Messaging security delegation, setting, 181–183 Chapter 9 - J2EE Enterprise Messaging user authentication, 183–185 Chapter 10 - Using the WSAD-Embedded JMS Provider
J2EE 1.3 113–158MQ as the JMS Provider Chapter 11 framework, - Using WebSphere EJB A 2.0- entity beans, 116–132 Appendix Deploying This Book's J2EE Examples dependent value classes, 117–119 EJB Query Language, 128–132 List of Figures find and select methods, 127 List of Tables persistence fields, 116–117 List of Code Examples relationship fields, 119–126 List of Sidebars EJB 2.0 tier, 113–116 Web tier, 132–158 character encoding, 140 classloaders,144–146 errors, processing, 148–151 filters,132–136 framesets, creating, 151–157 HTTP session event listeners, 137–139 JAR dependence, 140–144 ServletContext event listeners, 139–140 thread-safe servlets, developing, 157–158 WSAD development and runtime environments, 146–148 XForms,151 WSAD and support of J2EE 1.3 specifications, 3,5–6 Index
J2EE database application development, 74–103 application Deployment Descriptor, setting, 93–103 basics of, 93–96 Datasource connection, configuring, 98–100 testing applications, 101–103 unit test server environments, setting, 96–98 database connections, building, 75–77 database projects, creating, 74–75
input screens, customizing, 89–92 WebSphere Studio Application Developer 5.0: Practical user interfaces, building, 88–89 J2EE Development Web projects, creating new, 77–88 ISBN:1590591208 by Igor Livshin databases, importing, 79–80 Apress © 2003 (630 pages) getting started, 77–78 This book provides a practical, step-by-step approach in SQL statements, building, 80–82 teaching how to use the WebSphere Studio Application SQL statements, constructing, 82–88 Developer (WSAD) tool for developing J2EE distributed applications.571–604 J2EE, deploying examples, DBDatasourceProjectApp application, deploying, 582–591 exporting from WSAD, 582–583 Table of Contents installing,583–591 WebSphere Studio Application Developer 5.0: Practical J2EE Development introduction to, 571 Introduction TechLibApp application, deploying, 591–602 Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 exporting from WSAD, 591–592 Chapter 1 - Introducing WSAD 5.0 installing,592–602 Chapter 2 - Setting Up the Development Environment TechLibApp application, running, 602–603 Chapter 3 5.0, - Working the WSAD 5.0577–581 Workbench WAS definingwith Datasource for, Chapter 4 Developing Database Applications WAS environment, preparing, 572–577 Part Two - Working with J2EE: The Distributed Application Framework
J2EE EJB development, 187–281.See also entity beans development - J2EE Development EJB project organization, 187–188 Chapter 6 - J2EE EJB Development multiscreen considerations, 281 Chapter 7 - J2EE Web Development session beans, 251–280 Chapter stateful 8 - J2EE XML Development session beans, 264–277 Part Three Working with Enterprise Messaging stateful session beans, testing, 277–280 Chapter stateless 9 - J2EE Enterprise Messaging session beans, 252–260 Chapter stateless 10 - Using the WSAD-Embedded JMS Provider session beans, testing, 261–263 Chapter 5
Chapter 11 - Using WebSphere MQ as the JMS Provider
J2EE Perspective, 30–31
Appendix A - Deploying This Book's J2EE Examples
JAR JAR dependence, 140–144 List of Figures JAR library, and Web project, 404–405 Index
List of Tables
Java List of Code Examples classes, creating new, 53–55 List of Sidebars
code.See also Debug Perspective controlling appearance of, 46–47 customizing, Workbench, 46–47 “Hello World” Java application, building, 48–61 debugging,55–57 Java classes, creating new, 53–55 Java projects, creating new, 48–52 packages, creating new, 52 WSAD testing environment and, 57–61 help topics, and Help Perspective, 39–40 JavaBean class building,229–230,339 inserting in JSP module, 350 JavaBean Web pages, building, 290–293 packages, creating new, 52 processes, and Profiling Perspective, 37–39 projects creating new, 48–52 described,44
Java 1.1 Programmer’s Reference,397 Java Database Connectivity (JDBC) JDBC 2.0 drivers, configuring DB2 for, 13 JDBC provider, 576–578
XA-compliant database driver, 525–526
WebSphere Studio Application Developer 5.0: Practical
Java in a Nutshell, 397Development J2EE
ISBN:1590591208 by Igor(JMS), Livshin447–479. See also JMSAdmin utility Java Message Service Apress © 2003 (630 pages) basics of, 447–450 communicating This with book JMS provides messages, a practical, 450–453 step-by-step approach in how to use the WebSphere Studio Application header fields,teaching listed, 451 Developer (WSAD) tool for developing J2EE distributed P2P programming, 454–472 applications. introduction to, 454–457 JMS objects, closing, 461–462 QueueConnection object, 457–460 Table of JMS Contents MDBs, using, 467–471 WebSphere Studio Application Developer 5.0: Practical J2EE Development message selectors, 472 Introduction receiving, Part Onemessages, - Getting Started with462–467 WebSphere Studio Application Developer (WSAD) 5.0 460–461WSAD 5.0 Chapter rollbacks, 1 - Introducing P2P2programming, persistence, 472 Chapter - Setting Up message the Development Environment Pub/Sub programming, 473–478 Chapter 3 - Working with the WSAD 5.0 Workbench two-phase commit transactions, 478–479 Chapter 4 - Developing Database Applications WSAD and support of JMS message-driven Beans, 6 Part Two - Working with J2EE: The Distributed Application Framework
Java Message Service (JMS), developing P2P applications, 484–515 Chapter 5 - J2EE Development developing receiving part, 484–508 Chapter 6 - J2EE EJB Development of, 484–485 Chapter basics 7 - J2EE Web Development
Datasource, configuring, 495–498 - J2EE XML Development entity bean component, 486–488 Part Three - Working with Enterprise Messaging JMS-administered objects, configuring, 498–500 Chapter 9 - J2EE Enterprise Messaging JMS resource references, 502–506 Chapter 10 - Using the WSAD-Embedded JMS Provider listener port, configuring, 501–502 Chapter 11 - Using WebSphere MQ as the JMS Provider MDB component, 489–494 Appendix A - Deploying This Book's J2EE Examples receiving side, testing, 506–508 Index TECHBOOK database, importing, 486 List of Figures test server project, creating, 494–495 List of Tables developing sending part, 508–515 List of Code Examples basics of, 508–514 List of Sidebars runtime environment, setting, 514 Chapter 8
Java Message Service (JMS) providers.SeeJMS provider, WSAD-embedded; WebSphere MQ as JMS provider Java Naming and Directory Interface (JNDI), 247–248 binding the Datasource and, 206–207 dumpSpace utility, 112 EJB components, using for locating, 109–112 entity name for CMP Datasource resource, setting, 248 entity name for CMP entity beans, setting, 206–207 JNDI Explorer, 212–213,249 JNDI names mapping Datasource to, 595 mapping EJB modules to, 594 mapping individual CMP modules to Datasource JNDI names, 595 setting name for TechLibFacade1, 264 setting reference names, 503,504 JNDI namespaces, placing administered objects in, 547–548 Universal Test Client and, 212–213 Java Perspective, 27–29 Java Runtime Environment (JRE), replacing version, 47 Java Source directory basics of, 283
WSAD-generated files and, 296–297
WebSphere Studio Application Developer 5.0: Practical
JavaScriptValidating (code listing), 311–313 J2EEFunctions Development
by IgorFilter Livshin The javax.servlet.Filter Interface (code listing), 133
ISBN:1590591208
Apress © 2003 (630 pages)
JDBC (Java Database Connectivity) This book provides a practical, JDBC 2.0 drivers, configuring DB2 for, 13 step-by-step approach in teaching how to use the WebSphere Studio Application XA-compliant Developer database (WSAD) driver, 525–526 tool for developing J2EE distributed applications. JDBC provider, 576–578
JMS.SeeJava Message Service (JMS) Table Contents JMSof provider, WSAD-embedded, 481–530 WebSphere Studio Application Developer 5.0: Practical J2EE Development basics of, 481–482 Introduction installing WSAD-embedded Part Onemessaging - Getting Started with WebSphere Application Developer (WSAD) 5.0 support. See also Java Studio Message Service (JMS),
Chapter developing 1 - Introducing P2P applications WSAD 5.0
of, 482–483 Chapter basics 2 - Setting Up the Development Environment Pub/Sub 515–525 Chapter 3 - applications, Working with developing, the WSAD 5.0 Workbench objects, setting, 516–518 Chapter administered 4 - Developing Database Applications objects, references to, 522–524 Part Twoadministered - Working with J2EE: setting The Distributed Application Framework part, building, 518–522 Chapter sending 5 - J2EE Development 524–525 Chapter testing, 6 - J2EE EJB Development
two-phase commit transactions, using, 525–530 - J2EE Web Development
Chapter 7
JMSAdmin Chapter 8 -utility J2EE XML Development 547–550 Part basics Three -of, Working with Enterprise Messaging for building administered objects, 551–555 Chapter 9 - J2EE Enterprise Messaging Chapter 10 Java - Using the WSAD-Embedded JMS Provider JNDI.See Naming and Directory Interface (JNDI) Chapter 11 - Using WebSphere MQ as the JMS Provider Joshi, Daniel I., 397 Appendix A - Deploying This Book's J2EE Examples
JRE (Java Runtime Environment), replacing version, 47
Index
JSP library, 285–286 List of tag Figures List of Tables List of Code Examples List of Sidebars
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
K
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in keywords, and dumpSpace utility, 112 teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
L
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in LANGUAGE table field, 64 teaching how to use the WebSphere Studio Application
Developer (WSAD) tool for developing J2EE distributed languages (spoken), and character encoding, 140 applications.
Librarian security role, 178-180 libraries, and new Java projects, 50-51 Table of Contents
Library. xml (code listing), 399-400
WebSphere Studio Application Developer 5.0: Practical J2EE Development
Library.xsl (code listing), 440 Introduction Part One - Getting Started with438 WebSphere Studio Application Developer (WSAD) 5.0 Library.xsl File (code listing),
Chapter Introducing 5.0 Lifetime1 in -cache option,WSAD 168,170 Chapter 2
- Setting Up the Development Environment
listener port - Working with the WSAD 5.0 Workbench changed to topic, WebSphere MQ project testing, 567 Chapter 4 - Developing Database Applications configuring for P2P JMS application project, 501-502 Part Two - Working with J2EE: The Distributed Application Framework configuring for P2P, WebServer MQ, 561-562 Chapter 5 - J2EE Development defining, and MDB, 562-563 Chapter 6 for - J2EE Development setting JMSEJB Pub/Sub application project, 528-529 Chapter 3
Chapter 7
- J2EE Web Development
listeners Chapter 8 - J2EE XML Development defined, 137 Part Three - Working with Enterprise Messaging ServletContext event listeners, 139-140 Chapter 9 - J2EE Enterprise Messaging session event listeners, 137-139
Chapter 10 - Using the WSAD-Embedded JMS Provider
listings EJB development Appendix A - Deploying This Book's J2EE Examples BOOK_DETAILS Processing Results, 225 Index BookInquiryBean.java:Implementation Class, 233-244 List of Figures BookInquiryHome.java: HomeInterface Class, 244-245 List of Tables BookInquiry.java: Remote Interface Class, 245 List of Code Examples BookInquiryKey.java: Primary Key Class, 245-246 List of Sidebars Fragments of New Methods, 266-270 Primary Key Class TechLibBook_activityKey.java, 204-205 Primary Key Class TechLibBook_catalogKey.java, 200 TechLibBook_activityBean.java:Implementation Class,201-203 TechLibBook_activityLocalHome.java: Local Home Interface, 203 TechLibBook_activityLocal.java:Local Interface, 204 TechLibBook_catalogBean.java:Implementation Class, 197-199 TechLibBook_catalogLocal.java:Local Interface, 199 TechLibFacade1Bean.java:Implementation Class, 271-276 TechLibFacade1Local: LocalInterface Class, 277 TechLibFacade1LocalHome: LocalHome Interface Class, 276 TechLibFacadeBean.java:Implementation Class, 255-258 TechLibFacadeHome.java: HomeInterface Class, 258 TechLibFacade.java: RemoteInterface Class, 259 TechLibFacadeLocalHome.java:Local Home Interface, 259 TechLibFacadeLocal.java: LocalInterface, 259-260 HelloWorld.java,54-55 J2EE, deploying examples, BuildTechbookDatabase.sql, 572-576 J2EE development Book.java CMP Entity Bean, 120 CMP Entity Bean with the Dependent Value Class, 118 Code of the Bean-Managed Session Bean, 161-162 Dependent Value Class, 118 Chapter 11 - Using WebSphere MQ as the JMS Provider
The ejbPostCreate Method, 125-126 WebSphere Studio Application Developer 5.0: Practical Error Page Servlet Source Code, 149-150 J2EE Development Fragment of the Deployment Descriptor, 132 ISBN:1590591208 by Igor Livshin Fragment of the Deployment Descriptor with the Filter Chain Definition, 134 Apress © 2003 (630 pages) Fragment of the Listener Code, 139 This book provides a practical, step-by-step approach in The getAllCompanyNames Method, 124 teaching how to use the WebSphere Studio Application The javax.servlet.Filter Interface, DeveloperFilter (WSAD) tool for 133 developing J2EE distributed Logging Filterapplications. Code Example, 134-135 Meta-Code for Constructing the JNDI InitialContext, 110-111 Programmatic Security, 180-181 TablePublisher.java of Contents CMP Entity Bean, 119 WebSphere Application Option Developer J2EE Development Setting Studio the AutoCommit for 5.0: JTA Practical Transactions, 167 Introduction Setting the AutoCommit Option for LTC Transactions, 167 Part JMS One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1 -JMS Introducing Closing Objects,WSAD 462 5.0 Chapter 2 - Setting Up theof Development Environment Conceptual Fragment the MDB Code, 470-471 Chapter Example 3 - Working of the Listener with the Class, WSAD465-467 5.0 Workbench Locating File-Based JNDI Applications Context, 456 Chapter 4 - the Developing Database the LDAP 457 Application Framework Part Locating Two - Working with JNDI J2EE: Context, The Distributed Locating InitialContext Object with a Program Running Outside WSAD, 456 Chapter 5 - the J2EEWSAD Development A Pseudo-Synchronous Way of Receiving Messages, 463-464 Chapter 6 - J2EE EJB Development Seeing Pub/Sub in Action, 474-477 Chapter 7 -JMS J2EE Web Development Sending Message, 454-455 Chapter 8 - aJ2EE XML Development Setting a Global Transaction, 478-479 Part Three - Working with Enterprise Messaging Working with Different Types of Message Bodies, 453 Chapter 9 - J2EE Enterprise Messaging JMS provider Chapter 10 - Using the WSAD-Embedded JMS Provider PublishingServlet, 519-522 MQ as the JMS Provider Chapter 11 - Using WebSphere The ReceivingMDBBean MDB,J2EE 490-493 Appendix A - Deploying This Book's Examples IndexSendingServlet.java, 509-512
TECHBOOK List of Figures database BuildTextbookDatabase.sql, 65-69 List of Tables Execution Results, 69-71 List of Code Examples List of Sidebars Web application development
BookByPlatformController.java,346-348 BookByPlatformHelper1.java,340-343 BookByPlatformHelperX.java,357-362 BookByPlatformOutputForm.jsp,354-356 The BookHelper Class, 317-320 The BookRegisterController Class, BookRegisterController.java, 320-324 The BookRegisterController Class, BookRegisterInputForm Page, BookRegisterInputForm.html, 324328 The BookRegisterController Class, BookRegisterResultsForm Page, BookRegisterResultsForm.jsp, 328-330 BookRegisterController.java Servlet, 302-305 BookRegisterHelper.java,288-290 Fragment of the BookRegisterInputForm.html file, 297-298 JavaScriptValidating Functions, 311-313 The performServices Method, 300-301 WebSphere MQ CommandsForJMSAdmin.txt, 553 Fragment of the Changed JMSAdmin.config File, 549 Fragment of the JMSAdmin.config File, 549 The Modified JMSAdmin.bat File, 550 SetJMSAdminEnv.cmd,551-552
XML development WebSphere Studio Application Developer 5.0: Practical Corrected XML Schema Location, 406 J2EE Development Fragment of an XML Schema File, 377 ISBN:1590591208 by Igor Livshin Generated BookCatalog.xml File, 431-433 Apress © 2003 (630 pages) The Generated Library.xml Skeleton File, 397 This book provides a practical, step-by-step approach in Generated XML Schema, 393-395 teaching how to use the WebSphere Studio Application Library.xml,399-400 Developer (WSAD) tool for developing J2EE distributed Library.xsl,440applications. Library.xsl File, 438 ParserServlet. java, 415-424 TableParseServlet.java, of Contents 406-412 WebSphere Studio Developer A Simple XMLApplication Document, 373-3745.0: Practical J2EE Development Introduction Two XML Documents With a Potential Naming Conflict, 375-376 Part Using One - Getting Started withto WebSphere Studio Conflict, Application XML Namespaces Avoid a Naming 378Developer (WSAD) 5.0 Chapter 1 Introducing WSAD 5.0 XML File Built Based on the XML Schema with elementFormDefault='qualified', 382 Chapter XML 2 - Schema, Setting Up the Development Environment 385-386 Chapter The 3 -XML Working Schema with File the WSAD books.xsd, 5.0 Workbench 376-377 Root Element, 380 Chapter XML 4 - Schema Developing Database Applications Schema with a Default Namespace (books2.xsd), 379-380 Part TwoXML - Working with J2EE: The Distributed Application Framework with elementFormDefault='qualified', 382 Chapter XML 5 - Schema J2EE Development elementFormDefault='unqualified', 382-383 Chapter XML 6 - Schema J2EE EJBwith Development Chapter 7 - View J2EE Web Development Local Client Chapter EJB8objects - J2EE and, XML113-114 Development Part lookup Three - method Workingand, with111 Enterprise Messaging
Web9 projects, coding for,Messaging 332-339 Chapter - J2EE Enterprise Chapter 10 - Using the WSAD-Embedded JMS Provider Local Home interfaces, Book_activity and Book_catalog, 213 Chapter 11 - Using WebSphere MQ as the JMS Provider
Local Interface (Local Client View) EJB objects and, 113-114 Indexlookup method and, 111 List of Figures relationship fields and, 120 List of Tables setting,115-116
Appendix A - Deploying This Book's J2EE Examples
List of Code Examples
Local Interfaces business methods, building TechLibBook_activityLocalHome.j ava: Local Home Interface, 203 TechLibBook_activityLocal.java:Local Interface, 204 TechLibBook_catalogLocal.java:Local Interface (code listing), 199 vs. Remote Interfaces, 5 TechLibFacade1Local: Local Interface Class, 277 TechLibFacade1LocalHome: Local Home Interface Class, 276 testing,278 WSAD 5.0 support and, 6
List of Sidebars
Locating the File-Based JNDI Context (code listing), 456 Locating the LDAP JNDI Context (code listing), 457 Locating the WSAD InitialContext Object with a Program Running Outside WSAD (code listing), 456 LOCATION table field, 64 locking, optimistic/pessimistic, 169-171 Logging Filter Code Example (code listing), 134-135 logos, and Web pages inserting and previewing, 349 page logo style, setting, 334-335 lookup, Local Client View and, 111-112,115
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
M
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in MA0C service pack, installing, 540-541 teaching how to use the WebSphere Studio Application
Developer (WSAD) tool for developing J2EE distributed MA88 support pack, 539-540 applications.
MapMessage type, JMS, 452,453 markups, defined, 374 Table of Contents
Max connections property, JMS, 499
WebSphere Studio Application Developer 5.0: Practical J2EE Development
Max messages property, 501 Introduction Part - Getting Started MaxOne retries property, 501with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 - Introducing WSAD 5.0 Max sessions property, 501 Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
MDBs.SeeMessage Driven Beans (MDBs)
Meet in4the- Middle method, 227 Applications Chapter Developing Database Part Two - Working with J2EE: The Distributed Application Framework Meggison, David, 401
Chapter 5 channels, - J2EE Development message 533-534 Chapter 6
- J2EE EJB Development
Message Driven Beans (MDBs) component development in JMS P2P - J2EE Web Development applications,489-494 Chapter 8 - J2EE XML Development using,467-471 Chapter 7
Part Three - Working with Enterprise Messaging
message 452-453 Chapter 9 object, - J2EE JMS, Enterprise Messaging Message-Oriented Middleware (MOM), 448 Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 Queue - UsingInterface WebSphere MQchannels, as the JMS533 Provider Message (MQI) Appendix A - Deploying This Book's J2EE Examples
MESSAGE_BODY table field, 65
Index
MESSAGE_KEY table field, 65
List of Figures
messages List of Tables asynchronous communication and, 447-448,464 List of Code Examples BOOK_NOTIFY table List of Sidebars messages written in, 542-543 P2P messages in, 566 Pub/Sub messages in, 568 JMS basics of, 450-453 A Pseudo-Synchronous Way of Receiving Messages (code listing), 463-464 Sending a Message (code listing), 454-455 Working with Different Types of Message Bodies (code listing), 453 message bodies defined, 533 Working with Different Types of Message Bodies (code listing), 453 message channels, 533-534 message descriptor, defined, 533 MQ,533,542,568 P2P message persistence, regulating, 472 message selectors, 472 receiving,462-467 Meta-Code for Constructing the JNDI InitialContext (code listing), 110-111 methods BMP entity beans and testing, 249
transport object and, 232-233 WebSphere Studio Application Developer 5.0: Practical CMP entity beans and. See also Bottom Up method J2EE Development business methods, building, 191-205 ISBN:1590591208 by Igor Livshin Meet in the Middle method, 227 Apress © 2003 (630 pages) Top Down method, 218-225 book provides a practical, step-by-step approach in EJB methods,This setting transaction properties for, 159-161 teaching how to use the WebSphere Studio Application find and selectDeveloper methods,(WSAD) 127 tool for developing J2EE distributed fragments of, applications. stateful session beans, 266-270 lookup method, 111 MDB callback methods, 469-470 Tablerelationship of Contents fields and, 123-126 WebSphere Application remoteStudio methods, 217 Developer 5.0: Practical J2EE Development Introduction ServletContextListener interface, 139-140 Part setting One - Getting Started with174 WebSphere Studio Application Developer (WSAD) 5.0 for isolation level, Chapter 1 Introducing WSAD Test Client and, 213-216 5.0 Chapter - Setting Up 220 the Development Environment Top2Down method, Chapter 3 See - Working with the WSAD 5.0 Workbench Microsoft. Windows Chapter 4
- Developing Database Applications
Migrating to WebSphere V5.0:An End-To-End Migration Guide,10
Part Two - Working with J2EE: The Distributed Application Framework
Migration WSAD 5.0 Migration Guide Chapter 5 Guide. - J2EESee Development Chapter 6 to - WSAD J2EE EJB Development migration 5.0, 17-18 Chapter 7 J2EE Web Development Migration wizard, 18 Chapter 8
- J2EE XML Development
Min connections property, JMS, 499
Part Three - Working with Enterprise Messaging
Model-View-Controller (MVC) pattern Chapter 9 - J2EE Enterprise Messaging classes, implementation of, 297JMS Provider Chapter 10 - and Using the WSAD-Embedded stateful session development and, Chapter 11 -Web Using WebSphere MQ as the JMS331 Provider ModifiedAJMSAdmin.bat FileBook's (codeJ2EE listing), 550 Appendix - Deploying This Examples Index modules List of Figures DBDatasource ProjectApp and mapping modules to application servers, 586 List of Tables mapping virtual hosts to Webmodule servers, 585 List of J2EE, Code108 Examples
TechLibApp List of Sidebars and mapping EJB module references, 595-596 mapping EJB modules to JNDI names, 594 mapping individual CMP modules to Datasource JNDI names, 595 mapping modules to application servers, 596 mapping Web module to virtual hosts, 596 MOVE TYPE (name A) TYPE (name B ) command, 548 MQ Broker 2.1, 540 MQ Explorer, 546-547 MQI (Message Queue Interface) channels, 533 MQSeries.SeeWebSphere MQ Multiplicity field, Book_catalog, 121-122 multiscreen clients, 281 multiscreen conversational sessions, 370-371 MVC (Model-View-Controller) pattern classes, and implementation of, 297 stateful Web session development and, 331
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
N
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in namespaces, XML, 375-384 teaching how to use the WebSphere Studio Application defined, 375 Developer (WSAD) tool for developing J2EE distributed namespace declarations, applications. 377-384 default namespaces, using, 378-380 local elements qualification, 381-383 Table of XML Contents namespace attributes, 380-381 WebSphere Studionames, Application namespace 378 Developer 5.0: Practical J2EE Development Introduction XML Schema support for, 375-377,383-384 Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Navigator Views, Workbench, 46
Chapter 1
- Introducing WSAD 5.0
New Project wizard,Up 49,the 74-75 Chapter 2 - Setting Development Environment nonpersistent queues, 533the WSAD 5.0 Workbench Chapter 3 - Working with Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
O
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in ObjectMessage type, JMS, 452,453 teaching how to use the WebSphere Studio Application
Developer (WSAD) tool for developing J2EE distributed objects,568 applications. object, 580-581 configured DBDatasource EJB objects Local Client View, 113-114 Table of Contents Local Interface, 113-114 WebSphere Studio Application Developer 5.0: Practical J2EE Development transfer objects, 114 Introduction JMS-administered objects Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 building,547-548,551-555 Chapter 1 - Introducing WSAD 5.0 configuring, 498-500 Chapter 2 - Setting Up the Development Environment JMS P2P programming and Chapter JMS 3 -objects, Workingclosing, with the461-462 WSAD 5.0 Workbench Chapter JMS 4 -QueueConnection Developing Database Applications object, 457-460 Part Pub/Sub Two - Working with J2EE: The Distributed Application Framework administered objects setting, 516-518 Chapter 5
- J2EE Development
objects - J2EE EJB Development Pub/Sub administered objects Chapter 7 - J2EE Web Development setting references, 522-524 Chapter XA-compliant 8 - J2EE XMLadministered Developmentobject, 525 Part transport Three - Working with Enterprise Messaging object, building Chapter BookInquiryBean.java: 9 - J2EE Enterprise Messaging Chapter Implementation 10 - Using the WSAD-Embedded JMS233-244 Provider Class (code listing), Chapter BookInquiryHome.java: 11 - Using WebSphere MQ as the JMS Provider Home Interface Class (code listing), 244-245 AppendixBookInquiry.java: A - Deploying This Book's J2EE Examples Remote Interface Class (code listing), 245 Index BookInquiryKey.java: Primary Key Class (code listing), 245-246 checking reference and, 247-248 List of Figures introduction to, 229-230 List of Tables methods, 231-233 List of Code Examples TransportBean.java (code listing), 230-231 List of Sidebars WebSphere MQ and administered objects, setting, 569 MQ-based JMS objects, building, 546-547 queue object reference, setting, 564 XML Schemas, adding details for objects, 389-395 Chapter 6
optimistic concurrency, 169,170 Outline View, Workbench, 26
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
P
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in P2P teaching how to use the WebSphere Studio Application applications.See Java Message (JMS), developing P2P applications Developer (WSAD) Service tool for developing J2EE distributed domain of communication, applications. 449 programming introduction to, 454–457 Table of JMS Contents objects, closing, 461–462 WebSphere Application Developer 5.0: Practical J2EE Development JMSStudio QueueConnection object, 457–460 Introduction MDBs, using, 467–471 Part Onemessage - Gettingpersistence, Started with regulating, WebSphere472 Studio Application Developer (WSAD) 5.0 Chapter message 1 - Introducing WSAD 5.0 selectors, 472 Chapter messages, 2 - Setting Up the Development receiving, 462–467 Environment Chapter rollbacks, 3 - Working 460–461 with the WSAD 5.0 Workbench testing for, WebSphere MQ, 566–567 Chapter 4 projects - Developing Database Applications Part Two - Working The52 Distributed Application Framework packages, creatingwith newJ2EE: (Java),
Chapter 5
- J2EE Development
Page Designer Classic, WSAD - J2EE EJB Development basics of, 284–285 Chapter 7 - J2EE Web Development final source code, 317–331 Chapter 8 - J2EE Development introduction to,XML 308–311 Part JavaScript Three - Working with Validating Enterprise Functions Messaging (code listing), 311–313 Chapter 6
Chapter 9
- J2EE Enterprise Messaging
pages, static and dynamic, 29
Chapter 10 - Using the WSAD-Embedded JMS Provider
ParserServlet. javaWebSphere (code listing), Chapter 11 - Using MQ 415–424 as the JMS Provider Appendix ParseServlet.java A - Deploying (code This listing), Book's 406–412 J2EE Examples Index parsing XML documents, 401–424 List of Figures basics of, 401–407 List of Tables DOM parser, 407–415 List of Code Examples SAX parser, 415–424 List of Sidebars parts
defined, 13 WSAD 5.0, 14–15 performServices Method (code listing), 300–301 persistence entity beans persistence fields, 116–117 JMS P2P message persistence regulation,472 persistent queues, 533 Perspectives, WSAD basics of, 23–25 closing as good practice, 485 customizing, 41–42 defined, 23 multiple opened, 28 multiple ways to select, 27–28 Perspective Bar, 22,28 types of Data Perspective, 31 Debug Perspective, 32–33 Help Perspective, 39–41
J2EE Perspective, 30–31 WebSphere Studio Application Developer 5.0: Practical Java Perspective, 27–28,29 J2EE Development Profiling Perspective, 37–39 ISBN:1590591208 by Igor Livshin Server Perspective, 33–37 Apress © 2003 (630 pages) Web Perspective, 29–30 This book provides a practical, step-by-step approach in XML Perspective, 32 teaching how to use the WebSphere Studio Application
Developer (WSAD) tool for developing J2EE distributed pessimistic concurrency, 169–170 applications.
phantom reads, 173
PLATFORM table field, 64 Table of Contents
platforms codes and, 336–337 Introduction values of, 351
WebSphere Studio Application Developer 5.0: Practical J2EE Development Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Plug-in1projects, 44 Chapter - Introducing WSAD 5.0 polled bean Chapter 2 - option, Setting 163–168 Up the Development Environment Chapter ports 3
- Working with the WSAD 5.0 Workbench
Chapter 4 -port Developing Database Applications listener Part Twochanged - Working The Distributed Application Framework to with topic,J2EE: WebSphere MQ
Chapter project 5 - J2EE Development testing, 567 Chapter configuring 6 - J2EE EJB for P2P, Development 501–502,561–562
and MDB, 562–563 Chapter defining, 7 - J2EE Web Development 528–529 Chapter setting, 8 - J2EE XML Development conflicts, avoiding, 572 Part port Three - Working with Enterprise Messaging Chapter 9 - J2EE Enterprise Messaging Pre-compile JSP WAS installation option, 584 Chapter 10 - Using the WSAD-Embedded JMS Provider
Prepare MQSeries Wizard, 536
Chapter 11 - Using WebSphere MQ as the JMS Provider
Primary Key Class BookInquiryKey.java: Primary Key Class (code listing), 245–246 Index Primary Key Class TechLibBook_activityKey.java (code listing), 204–205 List of Figures Primary Key Class TechLibBook_catalogKey.java (code listing), 200 Appendix A - Deploying This Book's J2EE Examples
List of Tables
processing logic adding for new Web applications, 339–343 List of Sidebars calculating Home and Remote Interfaces and, 362–363 examining, 344 List of Code Examples
Profiling Perspective, 37–39 programmatic security, 175,180–181 projects.See also examples accessing on the Workbench, 140–143 application projects, setting up new, 151–153 database project, creating, 74–75 DBDatasourceProjectApp application, deploying, 582–591 exporting from WSAD, 582–583 installing,583–591 defined, 43 EJB project accessing other projects from, 142 building,188 importing database into, 189 organization of, 187–188 Java projects, creating new, 48–52 JMS application, receiving part, 484–508 basics of, 484–485 Datasource, configuring, 495–498 entity bean component, developing, 486–488
JMS-administered objects, configuring, 498–500 WebSphere Studio Application Developer 5.0: Practical listener port, configuring, 501–502 J2EE Development MDB component, developing, 489–494 ISBN:1590591208 by Igor Livshin receiving side, testing, 506–508 Apress © 2003 (630 pages) resource references, 502–506 This book provides a practical, step-by-step approach in TECHBOOK database, importing, 486 teaching how to use the WebSphere Studio Application test serverDeveloper project, creating, (WSAD) 494–495 tool for developing J2EE distributed JMS application, sending part, 508–515 applications. basics of, 508–514 runtime environment, setting, 514 TableTechLibApp of Contentsapplication WebSphere Studio from Application Developer exporting WSAD, 591–5925.0: Practical J2EE Development Introduction installing,592–602 Part Onerunning, - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 602–603 Chapter 1 Introducing 5.0 TECHBOOK into, 189 TechLibEJB project, WSAD importing Chapter 2 Server - Setting Up the Development Environment testing projects, 57–58 Chapter Web3 project, - Working creating with new, the WSAD 77–885.0 Workbench importing, 79–80Applications Chapter database, 4 - Developing Database started, Part Twogetting - Working with77–78 J2EE: The Distributed Application Framework building, 80–82 Chapter SQL 5 - statement, J2EE Development constructing, 82–88 Chapter SQL 6 - statements, J2EE EJB Development Web7 projects Chapter - J2EE Web Development projects from, 141 Chapter accessing 8 - J2EE other XML Development framesets and, 151–153 Part Three - Working with Enterprise Messaging WSAD projects, 43–45 Chapter 9 - J2EE Enterprise Messaging XML project, building, 434–443 Chapter 10 - Using the WSAD-Embedded JMS Provider stylesheet editing, 438–441 Chapter 11 - Using WebSphere MQ as the JMS Provider XSL debugging, 435–437 Appendix A - Deploying This Book's J2EE Examples XSL transformation, alternate creation, 441–443 Index XSLT stylesheet, creating, 434–435 List of Figures
properties, JMS listener port properties, 501 List of Code Examples P2P persistence properties, 472 List of Sidebars runtime connection factories and, 499–500 server-level properties, 499 standard message properties, 450–451 List of Tables
pseudo-synchronous receipt of messages, 462–464 PTF CSD03, 541–542 Pub/Sub domain of communication, 449–450 MA0C service pack and, 540 programming,473–478 Pub/Sub applications, developing, 515–525 administered objects, setting, 516–518 administered objects, setting references to, 522–524 sending part, building, 518–522 testing,524–525 testing projects for, WebSphere MQ, 567–568 Publisher.java CMP Entity Bean (code listing), 119 publishers, JMS, 473 PublishingServlet, building, 518 PublishingServlet (code listing), 519–522 Purge Policy property, JMS, 500
WebSphere Studio Application Developer 5.0: Practical J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Table of Contents WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
Q
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
book provides a practical, step-by-step approach in queries, dynamic,This defined, 8 teaching how to use the WebSphere Studio Application
Developer (WSAD) tool for developing J2EE distributed queues applications. basics of, 533-534 defined, 448,449,533 JMS and Table of Contents mapping listener ports to, 502 WebSphere Studio Application Developer 5.0: Practical J2EE Development queue sessions, 458-460 Introduction queues and queue connection factory names, setting, 500 Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 persistent and nonpersistent, 533 Chapter 1 - Introducing WSAD 5.0 Queue, configuring, 513 Chapter 2 - Setting Up the Development Environment QueueConnection object, 457-460 Chapter 3 - Working with the WSAD 5.0 Workbench QueueConnectionFactory, configuring, 512-513 Chapter 4 Developing Database Applications remote queues, 534 Part transmission Two - Working with J2EE: queues, 532The Distributed Application Framework Chapter 5 J2EE Development WebSphere MQ and Chapter MQ-based 6 - J2EE EJB JMSDevelopment objects, building and, 546-547 Chapter MQ 7 -clients J2EE Web and, Development 534 Chapter queue 8 - J2EE managers, XML Development 533-534,546-547 Part Three unit- test Working server with environments, Enterprise Messaging and, 557-559 Chapter configuring 9 - J2EE Enterprise Messaging Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
R
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in RAM teaching how to use the WebSphere Studio Application requirements Developer for examples, xx tool for developing J2EE distributed (WSAD) requirements applications. for WSAD, 9
Rational ClearCase LT Source Configuration Management (SCM) package, 14 Reapoftime property, JMS, 500 Table Contents WebSphere referencesStudio Application Developer 5.0: Practical J2EE Development Introduction checking Datasource reference, 247-248 Part EJB One -and Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter Local 1 - Introducing 5.0 to EJB objects, 113-114 Interface asWSAD reference Chapter mapping 2 - Setting EJBUp module the Development references,Environment 595-596
JMS3 resource references, 502-506 Chapter - Working with the WSAD 5.0 Workbench mapping the resource, 585 Applications Chapter 4 - to Developing Database administered objects, setting references to, Framework 522-524 Part Pub/Sub Two - Working with J2EE: The Distributed Application setting BookRegisterController servlet, 306-307 Chapter 5 for - J2EE Development WebSphere MQ setting queue object references, 564 Chapter 6 - J2EE EJBand Development Chapter referential 7 integrity, - J2EE Web andDevelopment XML Schemas, 392 Chapter 8 - J2EE XML Development RegisterMQAdminObjects.cmd procedure, 552,554 Part Three - Working with Enterprise Messaging
relationship fields - J2EE Enterprise Messaging EJB, 119-126 Chapter 10 - Using the WSAD-Embedded JMS Provider Local Interface (Local Client View) and, 120 Chapter 11 - Using WebSphere MQ as the JMS Provider methods and, 123-126 Chapter 9
Appendix A - Deploying This Book's J2EE Examples
Reload interval WAS installation option, 585
Index
Remote Interfaces List of Figures BookInquiry.java: Remote Interface Class (code listing), 245 List of Tables vs.Code Local Interfaces, 5 List of Examples
stateful session beans and, 357-362 TechLibFacade.java: Remote Interface Class, 259 testing,278 WSAD 5.0 support and, 6
List of Sidebars
Remote Method Invocation Code (RMIC) generating,494 MDBs and, 494 remote queues, 534 repeatable reads, 173 request-reply pattern defined, 454 synchronous request-reply pattern, 467 request synchronization, and thread-safe servlets, 157-158 Resolver field, and transaction context control, 166 resources EJB resources, protecting, 178-180 JMS resource references and developing receiving port, 502-506 mapping references to, 585 setting for Datasource, 563 Web resources, protecting, 177-178 WSAD and
importing into, 60-61 WebSphere Studio Application Developer 5.0: Practical requirements, 9-10 J2EE Development
RMI-IIOP, 447
ISBN:1590591208 by Igor Livshin Apress © 2003 (630 pages) RMIC (Remote Method Invocation Code) generating,494 This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application MDBs and, 494 Developer (WSAD) tool for developing J2EE distributed rollbacks applications.
basics of, 460-461 MDBs and, 469 Table of Contents
runtime environments J2EE, deploying examples and, 571 Introduction Java Runtime Environment (JRE), 47 Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 JMS P2P application and, setting, 494,514 Chapter 1 - Introducing WSAD 5.0 WSAD,146-148 WebSphere Studio Application Developer 5.0: Practical J2EE Development
Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
S
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in Schemas. SeeXML Schemas teaching how to use the WebSphere Studio Application
Developer (WSAD) tool for developing distributed SCM (Source Configuration Management) packages, J2EE 14-15 applications.
screens input screens, Web project Table of customizing, Contents 89-92 design, 293-296 WebSphere Studio Application Developer 5.0: Practical J2EE Development HTML input forms, 332-333 Introduction input screen, Part Oneplatform - Getting Started with 338 WebSphere Studio Application Developer (WSAD) 5.0 TECHBOOK database Chapter 1 - Introducing WSAD 5.0 Views Up page screen,Environment 91 Chapter Details 2 - Setting the design Development input screens, customizing, 89-92 Chapter 3 - Working with the WSAD 5.0 Workbench output screen design, 90 Chapter 4 - Developing Database Applications user interface screens, 88-89 Part Two - Working with J2EE: The Distributed Application Framework View Bean Data Page screen, 88 Chapter 5
- J2EE Development security, 175-181 Chapter 6 J2EE, - J2EE EJB Development
basics 175-176 Chapter 7 of, - J2EE Web Development
EJB resources, protecting, 178-180 - J2EE XML Development programmatic security, 180-181 Part Three - Working with Enterprise Messaging security delegation, setting, 181-183 Chapter 9 - J2EE Enterprise Messaging Web resources, protecting, 177-178 Chapter 8
Chapter 10 - Using the WSAD-Embedded JMS Provider
select methods, EJB, 127 Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix send-and-forget A - Deploying pattern, This 454, Book's 467 J2EE Examples Index Sending a Message (code listing), 454-455 List of Figures
SendingServlet.java (code listing), 509-512
List of Tables
Serializable isolation level value, 173 List of Code Examples Server Configuration View, 34,35 List of Sidebars Server Perspective, 33-37 Server projects creating new, 58-60 described,44 servers application servers mapping modules to, 596 restarting,581 Datasource, adding, 208-209 defining and configuring, 33-34 test servers configuring, 208-212 project for creating for JMS P2P applications and, 494-495 setting unit test server environment, 96-98 Service Packs 2 and 3,11 ServletContext event listeners, Web tier, 139-140 ServletContextListener interface, 139-140 servlets access authorization, 177-178 BookByPlatformController servlet, 348
BookByPlatformHelper1 code and, 345-348 WebSphere Studio Application Developer 5.0: Practical BookRegisterController.java Servlet (code listing), 302-305 J2EE Development changing, WAS, 370 ISBN:1590591208 by Igor Livshin error page servlets, 149-150 Apress © 2003 (630 pages) The javax.servlet.Filter Filter Interface (code listing), 133 This book provides a practical, step-by-step approach in JMS teaching how to use the WebSphere Studio Application in P2P application projects, Developer (WSAD)484 tool for developing J2EE distributed Pub/Sub applications, applications. PublishingServlet, 518 JMS provider PublishingServlet,519-522 Table of SendingServlet.java, Contents 509-512 WebSphere Application Developer 5.0: Practical J2EE Development servlet Studio mapping, and filters, 135-136 Introduction thread-safe servlets, developing, 157-158 Part XML One -development Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 Chapter ParserServlet. 1 - Introducing WSAD 5.0 java, 415-424 Chapter ParseServlet.java, 2 - Setting Up the Development Environment 406-412 Chapter - Working with the WSAD 5.0 Workbench session3beans, 251-280 Chapter 4 -session Developing Database Applications stateful beans, 264-277 Part stateful Two - Working J2EE: The Distributed sessionwith beans, testing, 277-280 Application Framework
Chapter 5 - J2EE Development stateless session beans, 252-260 Chapter 6 - J2EE EJBbeans, Development stateless session testing, 261-263 Chapter 7 J2EE Web Development transactions and, 161 Chapter - J2EE and XML EJB Development Session8 Facade, 2.0 tier, 114 Part Three - Working with Enterprise Messaging
sessions - J2EE Enterprise Messaging multiscreen conversational sessions, 370-371 Chapter 10 - Using the WSAD-Embedded JMS Provider queue sessions, 458-460 Chapter 11 - Using WebSphere MQ as the JMS Provider session event listeners, HTTP, 137-139 Chapter 9
Appendix A - Deploying This Book's J2EE Examples
SetJMSAdminEnv.cmd,551-552
Index
setter/getter List of Figures methods BookRegisterHelper.java class and, 288 List of Tables entity business methods and, 191-192,196 List of Codebean's Examples message List of Sidebarsobject and, JMS, 452-453 transport object and, 231-232
Setting a Global Transaction (code listing), 478-479 Setting the AutoCommit Option for JTA Transactions (code listing), 167 Setting the AutoCommit Option for LTC Transactions (code listing), 167 Simple API for XML (SAX) parser basics of, 401-402 vs. DOM, 401 using,415-424 Simple projects, 44 software J2EE, deploying examples and, 571 packages in the book, downloading, xx WebSphere MQ and extending,539-542 popularity of, 532 prerequisites,537 source code EJB development BookInquiry modules, 233-244 BookInquiryHome interface, 244-245
BookInquiryKey Primary Key class, 245-246 WebSphere Studio Application Developer 5.0: Practical Home Interfaces, 258 J2EE Development TechLibBook_activity entity bean, 199 ISBN:1590591208 by Igor Livshin TechLibBook_activityBean entity bean, 201-203 Apress © 2003 (630 pages) TechLibBook_activityKey Primary Key class, 204-205 This book provides a practical, step-by-step approach in TechLibBook_activityLocal interface, 204 teaching how to use the WebSphere Studio Application TechLibBook_activityLocalHome interface, 203J2EE distributed Developer (WSAD) tool for developing TechLibBook_catalogKey Primary Key class, 200 applications. TechLibFacade Home interface, 258 TechLibFacade Remote Interface, 259 Table of TechLibFacade1Bean Contents implementation class, 271-276 WebSphere Studio Application Developer 5.0: Practical TechLibFacade1Local Local Interface class, J2EE 277 Development Introduction TechLibFacade1LocalHome Local Home Interface class, 276 Part OneTechLibFacadeBean - Getting Started with WebSphere Application Developer (WSAD) 5.0 session bean,Studio 255-258 Chapter TechLibFacadeLocal 1 - Introducing WSAD 5.0 Local Interface, 259-260 Chapter TechLibFacadeLocalHome 2 - Setting Up the Development LocalEnvironment Home Interface, 259 Chapter JMS3 provider - Working with the WSAD 5.0 Workbench class, 518-522 Chapter PublishingServlet.java 4 - Developing Database Applications 490-493 Part TwoReceivingMDBBean, - Working with J2EE: The Distributed Application Framework class, 508-512 Chapter SendingServlet.java 5 - J2EE Development Web6 development Chapter - J2EE EJB Development class, 340-343 Chapter BookByPlatformHelper1 7 - J2EE Web Development BookByPlatformOutputForm.jsp, 354-357 Chapter 8 - J2EE XML Development BookByPlatformOutputForm.jsp module, 354-356 Part Three - Working with Enterprise Messaging BookRegisterController, 302-305 Chapter 9 - J2EE Enterprise Messaging BookRegisterHelper,288-290 Chapter 10 - Using the WSAD-Embedded JMS Provider source code for book modules, 233-246 Chapter 11 - Using WebSphere MQ as the JMS Provider Web application final source code, 317-330 Appendix A - Deploying This Book's J2EE Examples XML development Index Library.xml,399-400 List of Figures ParserServlet, 415-424 List of Tables ParseServlet,407-412 List of Code Examples
Source Configuration Management (SCM) packages, 14-15
List of Sidebars
SQL (Structured Query Language) statements building,80-82 constructing,82-88 stale bean option, 163 State Comparison, and data integrity, 172 stateful session beans basics of, 264-277 multiscreen conversations and, 370-371 testing,277-280 stateful Web applications session development, 331-339 Local Client View coding, 332-339 MVC pattern, 331 testing,363-370 breakpoints, using, 367-370 introduction to, 363-365 TechLibWEB project debugging, 365-367 stateless session beans basics of, 252-260 testing,261-263 stateless Web session development, 287-293
BookRegisterHelper source code, 288-290 WebSphere Studio Application Developer 5.0: Practical generating Web pages, 290-293 J2EE Development introduction to, 285-288 by Igor Livshin
ISBN:1590591208
static pages, defined, 29© 2003 (630 pages) Apress store-and-forwardThis communication, book provides defined, a practical, 448 step-by-step approach in teaching how to use the WebSphere Studio Application
StramMessage type, JMS, 452 Developer (WSAD) tool for developing J2EE distributed Structured Queryapplications. Language (SQL) statements building,80-82 constructing,82-88
Table of Contents
stylesheetsStudio Application Developer 5.0: Practical J2EE Development WebSphere Library.xsl stylesheet, editing, 438-441 Introduction files, selecting, 435-436 Part XSL One -stylesheet Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 XSLT creating, 434-435 Chapter 1 stylesheets, - Introducing WSAD 5.0 subscribers, JMS, 473 Chapter 2 - Setting Up the Development Environment Chapter 3 - Working with the WSAD 5.0 Workbench Sun Microsystems, 107 Chapter 4
- Developing Database Applications
synchronous request-reply pattern, 467
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
T
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in tables teaching how to use the WebSphere Studio Application defining new, Developer 221-223 (WSAD) tool for developing J2EE distributed dynamic tables, generating, 351-363 applications. basics of, 351-354 BookByPlatformOutputForm.jsp source code, 354-357 Table of processing Contents logic, examining, 362-363 WebSphere Studio Application Developer 5.0: Practical J2EE Development Remote Client View code, 357-362 Introduction entity bean attributes, mapping to database tables, 225-226 Part importing One - Getting Started and, with 189 WebSphere Studio Application Developer (WSAD) 5.0 databases Chapter 1 Introducing WSAD 5.0 mapping,427-428 Chapter 2 - Setting selecting, 426-427Up the Development Environment Chapter tables 3 fields, - Working selecting, with the 82-84 WSAD 5.0 Workbench TECHBOOK database Chapter 4 - Developing Database Applications table, 65, 188 Part TwoBOOK_ACTIVITY - Working with J2EE: The Distributed Application Framework table, 64,188 Chapter BOOK_CATALOG 5 - J2EE Development table, 65 Chapter BOOK_NOTIFY 6 - J2EE EJB Development Center, 71-72 Chapter checking 7 - J2EEusing Web Control Development selecting, 82-83 Chapter 8 - J2EE XML Development table data, checking, 72-74 Messaging Part Three - Working with Enterprise
targetNamespace attribute, 380, 381 Chapter 9 - J2EE Enterprise Messaging Chapter 10 - Using the WSAD-Embedded JMS Provider Tasks View, Workbench, 26-27 Chapter 11 - Using WebSphere MQ as the JMS Provider
TECHBOOK database basics of, 63-65 IndexBook_catalog and Book_activty and, 188 List of Figures65-74 building, List of Tables database and tables, checking in Control Center, 71-72 List of Code Examples getting started, 65-71 List of Sidebars table data, checking, 72-74 hierarchical view, 76 importing into JMS P2P applications, 486 importing into TechLibEJB project, 189 Appendix A - Deploying This Book's J2EE Examples
TechLibApp project building,188 deploying,591-602 exporting from WSAD, 591-592 installing,592-602 running,602-603 TechLibBook_activityBean.java:Implementation Class (code listing), 201-203 TechLibBook_activityLocalHome.java:Local Home Interface (code listing), 203 TechLibBook_activityLocal.java: Local Interface (code listing), 204 TechLibBook_catalogBean.java:Implementation Class (code listing), 197-199 TechLibBook_catalogLocal.java: Local Interface (code listing), 199 TechLibEJB project. See also Bottom Up method building,188 importing database into, 189 TechLibFacade1Bean.java:Implementation Class (code listing), 271-276 TechLibFacade1Local: Local Interface Class (code listing), 277
TechLibFacade1LocalHome: Local Home Interface Class (code listing), 276 WebSphere Studio Application Developer 5.0: Practical
TechLibFacadeBean.java:Implementation Class (code listing), 255-258 J2EE Development
ISBN:1590591208 by Igor Livshin TechLibFacadeHome.java: Home Interface Class (code listing), 258
Apress © 2003 (630 pages)
TechLibFacade.java: Remote InterfaceClass (code listing), 259
This book provides a practical, step-by-step approach in
TechLibFacadeLocalHome.java: Local Interface (code listing), 259 teaching how to use theHome WebSphere Studio Application Developer (WSAD) tool for (code developing J2EE distributed TechLibFacadeLocal.java: Local Interface listing), 259-260 applications.
TechLibWEB project, debugging, 365-367 test servers configuring, 208-212 WebSphere Studio Application Developer 5.0: Practical J2EE Development project for creating for JMS P2P applications, 494-495 Introduction setting unit test server environment, 96-98
Table of Contents
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
testing.See- also Universal Test Client Introducing WSAD 5.0 BMP entity beans, 249-251 Chapter 2 - Setting Up the Development Environment entity beans, 208-212 Chapter 3 - Working with the WSAD 5.0 Workbench J2EE database application, 101-103 Chapter 4 - Developing Database Applications Pub/Sub applications, 524-525 Part Two - Working with J2EE: The Distributed Application Framework receiving side, JMS P2P application Chapter 5 - J2EE Development project, 506-508 Chapter 6 -session J2EE EJB Development stateful beans, 277-280 Chapter 7 J2EE Web Development stateful Web applications, 363-370 Chapter breakpoints, 8 - J2EE XML Development using, 367-370 Part Three - Workingto, with Enterprise Messaging introduction 363-365 Chapter TechLibWEB 9 - J2EE Enterprise Messaging 365-367 project debugging, Chapter 10 - Using thebeans, WSAD-Embedded stateless session 261-263 JMS Provider Chapter test 11 harness - Using generation, WebSphere 429-430 MQ as the JMS Provider Web Aapplication, 307-308 Appendix - Deploying This Book's J2EE Examples IndexWSAD testing environment, 57-61 Chapter 1
List of Figures type, JMS, 452, 453 TextMessage List of Tables
thread-safe servlets, Web tier, 157-158
List of Code Examples
Thumbnail View, Workbench, 25
List of Sidebars
Timestamp, and data integrity, 171,172 tools.See also WSAD's XML tools customizing external tools, Workbench, 46 MQ Explorer, 546-547 Views and, 23 Top Down method, 218-225 Topic configuring, 523 setting,513 TopicConnectionFactory configuring, 523 setting,516 topics defined, MOM, 448 setting when configuring unit test server environments, 560-591 wildcards and, 474 transaction isolation levels, EJB, 173-174 transactions defined, 158 EJB methods, setting transaction properties for, 159-161
EJB transactions, managing. See also Commit Option WebSphere Studio Application Developer 5.0: Practical basics of, 158-162 J2EE Development high-penalty transactions, defined, 169 ISBN:1590591208 by Igor Livshin session beans and, 161 Apress © 2003 (630 pages) transaction context control, 166 This book provides a practical, step-by-step approach in two-phase commit transactions, JMS teaching how to use the WebSphere Studio Application basics of, 478-479 Developer (WSAD) tool for developing J2EE distributed using,525-530 applications. transfer objects, and EJB 2.0 tier, 114 transformations, Table of Contents XSL, 434, 441-443 WebSphere Studio Application Developer 5.0: J2EE Development transient variables, and facade1Home andPractical facade1Remote, 362 Introduction
transmission queues, 532
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
transport buildingWSAD 5.0 Chapter 1 object, - Introducing
BookInquiryBean.java:Implementation Class (code listing), 233-244 - Setting Up the Development Environment BookInquiryHome.java: Home Interface Class (code listing), 244-245 Chapter 3 - Working with the WSAD 5.0 Workbench BookInquiry.java: Remote Interface Class (code listing), 245 Chapter 4 - Developing Database Applications BookInquiryKey.java: Primary Key Class (code listing), 245-246 Part Two - Working with J2EE: The Distributed Application Framework introduction to, 229-230 Chapter 5 - J2EE Development methods,231-233 Chapter 6 - J2EE EJB Development TransportBean.java (code listing), 230-231 Chapter 2
Chapter 7
- J2EE Web Development
two-phase commit transactions, JMS Chapter 8 - J2EE XML Development basics of, 478-479 Part Three - Working with Enterprise Messaging using,525-530 Chapter 9
- J2EE Enterprise Messaging TXN_DATE 65 Chapter 10 - table Using field, the WSAD-Embedded JMS Provider Chapter TXN_TIME 11 - table Usingfield, WebSphere 65 MQ as the JMS Provider Appendix A - table Deploying TXN_TYPE field,This 65 Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
U
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in UDB (Universal Database), DB2 UDB, teaching how to use the WebSphere Studio Application downloading and installing, 11-13 Developer (WSAD) tool for developing J2EE distributed applications. unit test server environment configuring for WebSphere MQ, 555-562 setting,96-98 Table of Contents
units of work, defined, 158 Developer 5.0: Practical J2EE Development WebSphere Studio Application Introduction Universal Database (UDB), Part DB2 One -UDB, Getting Started with WebSphere downloading and installing,Studio 11-13 Application Developer (WSAD) 5.0
Chapter 1 the - Introducing WSAD 5.0 Datasource resource, 248 setting entity name for CMP Chapter setting 2 the - Setting entity Up name the for Development CMP entityEnvironment beans, 206-207 Chapter 3 Resource - WorkingIdentifiers with the WSAD 5.0and Workbench Universal (URIs), XML namespaces, 375 Chapter 4 - Developing Database Applications
Universal Test Client P2P JMS applications and enabling, 495 Chapter 5 - J2EE Development testing the receiving side and, 506-507 Chapter 6 - J2EE EJB Development testing EJB modules and, 212-218 Chapter 7 stateful - J2EE Web Development testing session beans, 277-280 Chapter 8 stateless - J2EE XML Development testing session beans and, 261
Part Two - Working with J2EE: The Distributed Application Framework
Part Three - Working with Enterprise Messaging
Unresolver action field, 166
Chapter 9
- J2EE Enterprise Messaging
Unused10timeout property, JMS, 500 Chapter - Using the WSAD-Embedded JMS Provider Chapter URIs (Universal 11 - Using Resource WebSphere Identifiers), MQ as the and JMS XML Provider namespaces, 375 Appendix A -Configuration Deploying This Book's J2EE Examples Use Binary WAS installation option, 584 Index
user interfaces building screens, Web project, 88-89 List of Tables output user interface design, Web project, 305-307 List of Code Examples WSAD's graphical user interface. SeeWSAD 5.0 Workbench List of Figures
List of Sidebars
users user authentication, J2EE, 183-185 user identity and security, 181-183 Using Java online book, 540 utilities. See also tools DB2 Control Center utility, 71-72 dumpSpace utility, 112 JMSAdmin utility basics of, 547-550 for building administered objects, 551-555 WAS First Steps utility, 600-601 UTS (unit test server) environment configuring for WebSphere MQ, 555-562 setting,96-98
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
V
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
This book provides a practical, step-by-step approach in validation, defined (XML), 374 teaching how to use the WebSphere Studio Application
Developer (WSAD)172 tool for developing J2EE distributed Version Count, and data integrity, applications.
Views, WSAD 5.0 Workbench basics of, 25-27 23 Tabledefined, of Contents WebSphere Studio See Application virtual channels. queues;Developer topics 5.0: Practical J2EE Development Introduction
virtual fields, defined, 116
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Vorobiev, A., 397 WSAD 5.0 Chapter 1 Pavel - Introducing Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
W
by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
book provides a practical, step-by-step approach in WAR classloaderThis mode, 146 teaching how to use the WebSphere Studio Application
Developer WAS Express, targeting, 10(WSAD) tool for developing J2EE distributed applications.
Web application development, 284-372 application testing, 307-308 servlet, 348 TableBookByPlatformController of Contents BookByPlatformHelper1 code, 344-348 WebSphere Studio Application Developer 5.0: Practical J2EE Development BookByPlatformOutputForm output form, 348-351 Introduction logic,Started adding, 300-305 Part business One - Getting with WebSphere Studio Application Developer (WSAD) 5.0 dynamic generating, 351-363 Chapter 1 - tables, Introducing WSAD 5.0 basics of, 351-354 Chapter 2 - Setting Up the Development Environment BookByPlatformOutputForm.jsp source code, 354-357 Chapter 3 - Working with the WSAD 5.0 Workbench processing logic, examining, 362-363 Chapter 4 - Developing Database Applications Remote Client View code, 357-362 Part Two - Working with J2EE: The Distributed Application Framework form design, improving, 293-296 Chapter 5 - J2EE Development multiscreen conversational sessions, 370-371 Chapter 6 - J2EE EJB Development output user interface design, 305-307 Chapter 7 - J2EE Web Development processing logic, adding, 339-343 Chapter 8 -Web J2EEapplication XML Development stateful testing, 363-370 Part Three Working with Enterprise breakpoints, using, 367-370 Messaging Chapter introduction 9 - J2EE Enterprise Messaging to, 363-365 Chapter TechLibWEB 10 - Using the WSAD-Embedded Provider project debugging, JMS 365-367 Chapter 11 Using WebSphere MQ as the JMS Provider stateful Web session development, 331-339 AppendixLocal A - Deploying This Book's J2EE Examples Client View coding, 332-339 Index MVC pattern, 331 stateless List of Figures Web session development, 287-293 BookRegisterHelper source code, 288-290 List of Tables generating Web pages, 290-293 List of Code Examples introduction to, 285-288 List of Sidebars Web project, creating new, 285-287 WSAD-generated files, working with, 296-300 WSAD Page Designer, 308-331 final source code, 317-331 introduction to, 308-311 JavaScript Validating Functions (code listing), 311-313 running the application, 309-310 Web browsers, customizing (Workbench), 47 Web Content directory basics of, 284 WSAD-generated files and, 296-297 Web development. SeeWeb application development Web modules defined, 283 J2EE,108,145 mapping to virtual hosts, 596 mapping virtual hosts to Web module servers, 585 Web pages attributes and processing for input field, 315-316
selecting for, 291-292 WebSphere Studio Application Developer 5.0: Practical Database Web Pages wizard, 81 J2EE Development form design, improving, 293-296 ISBN:1590591208 by Igor Livshin generating,290-293 Apress © 2003 (630 pages) logos and This book provides a practical, step-by-step approach in inserting and previewing and, 349 teaching how to use the WebSphere Studio Application page logo Developer style, setting, 334-335 (WSAD) tool for developing J2EE distributed testing data validation, 316 applications. Web Perspective, 24-25,29-30 Webofprojects Table Contents accessing other projects Developer from, 1415.0: Practical J2EE Development WebSphere Studio Application creating new, 77-88,285-287 Introduction importing, Part Onedatabases, - Getting Started with79-80 WebSphere Studio Application Developer (WSAD) 5.0 started, 77-78 Chapter getting 1 - Introducing WSAD 5.0 building, 80-82 Environment Chapter SQL 2 - statements, Setting Up the Development
SQL- statements, constructing, 82-88 Working with the WSAD 5.0 Workbench described,43,45 Chapter 4 - Developing Database Applications organization of, 283-284 Part Two - Working with J2EE: The Distributed Application Framework specifying dependent JAR files for, 142-143 Chapter 3
Chapter 5
- J2EE Development
Web resources, 177-178 Chapter 6 - J2EEprotecting, EJB Development Chapter Web Services 7 - J2EE Journal Web Development awards,3-4 Chapter 8 - J2EE XML Development Web sites Part for Three - Working with Enterprise Messaging downloading
Chapter BookByPlatformHelper1 9 - J2EE Enterprise Messaging class, 339 Chapter BuildTechbookDatabase.sql, 10 - Using the WSAD-Embedded 572 JMS Provider Chapter BuildTextbookDatabase.sql, 11 - Using WebSphere MQ as 65the JMS Provider AppendixCSD03 A - Deploying PTF, 541 This Book's J2EE Examples
CVS,14 DB2 UDB, trial version, 11 List of Figures DB2 XML Extender, 425 List of Tables IBM Examples WebSphere Application Server V5.0 System Management and List of Code Configuration, 571 List of Sidebars MA0C service pack, 540 MA88 support pack, 539 ready-made HTML files, 155 Service Pack 3,11 SetJMSAdminEnv.cmd,551 software packages for book examples, xx source code for book examples, xx WebSphere MQ, 537 WSAD 5.0 trial version, 13 for information Apress Web site, 155,339 CSD03 PTF, 541 IBM Redbooks, 571 IBM WebSphere Developer Domain, 13 Migrating to WebSphere V5.0: An End-To-End Migration Guide,10 Universal Test Client, 212 Using Java online book, 540 World Wide Web Consortium, 401 WSAD 5.0 Migration Guide, 10 Index
Web tier, J2EE 1.3 applications, 132-158 character encoding, 140
classloaders,144-146 WebSphere Studio Application Developer 5.0: Practical errors, processing, 148-151 J2EE Development filters,132-136 ISBN:1590591208 by Igor Livshin framesets, creating, 151-157 Apress © 2003 (630 pages) HTTP session event listeners, 137-139 This book provides a practical, step-by-step approach in JAR dependence, 140-144 teaching how to use the WebSphere Studio Application ServletContext event listeners, Developer (WSAD)139-140 tool for developing J2EE distributed thread-safe servlets, developing, 157-158 applications. WSAD development and runtime environments, 146-148 XForms,151
Table of Contents
WebSphere Application Server (WAS) changing servlets or JPSs and, 370 Introduction embedded, running inside WSAD environment, 36 Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 importance of, 4 Chapter 1 - Introducing WSAD 5.0 JMS provider and, 481-482 Chapter 2 - Setting Up the Development Environment port conflicts, avoiding, 572 Chapter 3 - Working with the of WSAD 5.0 Workbench preparing for deployment J2EE examples, 572-577 Chapter 4 Developing Database Applications WAS 4.0x, targeting, 10 Part WAS Two - 5.0 Working with J2EE: The Distributed Application Framework Chapter defining 5 - J2EE Development Datasource for, 577-581 Chapter targeting, 6 - J2EE EJB Development 10 Chapter 7 Express, - J2EE Web Development WAS targeting, 10 WebSphere Studio Application Developer 5.0: Practical J2EE Development
Chapter 8 - J2EE WebSphere MQ XML Development Part setting Three - extensions, Working with 94Enterprise Messaging
Chapter 9 - J2EE Enterprise Messaging WebSphere MQ Event Broker, 540 Chapter 10 - Using the WSAD-Embedded JMS Provider
WebSphere MQ as JMS provider, 531-569 downloading and installing, 535-543 Appendix A - Deploying This Book's J2EE Examples example,542-543 Index installing as WSAD JMS provider, 536-539 List of Figures middleware, extending, 539-542 List of Tables Windowsaccounts, configuring, 535-536 List of Code Examples introduction to, 531-535 List of Sidebars MQ clients, 534 MQ messages, 533 queue managers, queues and channels, 533-534 listener port configuration and, 502 provider link and, 514 using,543-569.See also WebSphere MQ test server project administered objects, setting, 569 building new application examples, 544-545 Deployment Descriptors, configuring, 562-569 WAS 5.0 and, 481 Chapter 11 - Using WebSphere MQ as the JMS Provider
WebSphere MQ test server project, 545-562 Datasource configuration, 545-546 JMSAdmin utility basics of, 547-550 building administered objects, 551-555 MQ-based JMS objects, building, 546-547 unit test server environment, configuring, 555-562 WebSphere Studio Application Developer Integration Edition (WSAD IE), 9 WebSphere Studio Application Developer (WSAD) 5.0 administered objects, setting, 569 cleanup of, 484-485 described,3,9
as development tool. Seedatabase applications development exporting fromWebSphere Studio Application Developer 5.0: Practical J2EE Development DBDatasourceProjectApp application, 582-583 ISBN:1590591208 by Igor Livshin TechLibApp application, 591-592 Apress © 2003 (630 pages) features,5-9 This book provides a practical, step-by-step approach in enhancements, 7-8 teaching how to use the WebSphere Studio Application supportingDeveloper J2EE 1.3 (WSAD) and EJBtool 2.0for specs, 5-6 J2EE distributed developing supportingapplications. JMS message-driven Beans, 6 WebSphere Studio products, 8-9 importance of, 3-4 Tableimporting of Contents resources into, 60-61 WebSphere Studio installation of Application Developer 5.0: Practical J2EE Development Introduction installation files, downloading, 13-15 Part Oneinstallation - Getting Started with WebSphere requirements, 15-18 Studio Application Developer (WSAD) 5.0 Chapter procedure, 1 - Introducing WSAD 5.0 18-20 Chapter 2 - Setting Migration Guide, Up 10 the Development Environment Chapter Page 3 Designer, - Working 308-331 with the WSAD 5.0 Workbench code,Database 317-331Applications Chapter final 4 -source Developing to, 308-311 Part Twointroduction - Working with J2EE: The Distributed Application Framework Functions (code listing), 311-313 Chapter JavaScript 5 - J2EE Validating Development port6conflicts, 572 Chapter - J2EE avoiding, EJB Development projects, Chapter 7 - 43-45 J2EE Web Development resource requirements, 9-10 Chapter 8 - J2EE XML Development workspace directory, 15-16, 19 Messaging Part Three - Working with Enterprise WSAD development and runtime environments, J2EE 1.3 and, 146-148 Chapter 9 - J2EE Enterprise Messaging WSAD-embedded JMS provider. SeeJMS provider, WSAD-embedded Chapter 10 - Using the WSAD-Embedded JMS Provider WSAD-generated files, working with, 296-300 Chapter 11 - Using WebSphere MQ as the JMS Provider
WebSphere Studio Application Appendix A - Deploying This Book's J2EE Examples IndexDeveloper (WSAD) Workbench. SeeWSAD 5.0 Workbench
WebSphere List of Figures Studio Enterprise Developer (WSAD EE), 9 List of Tables Studio products. See also specific WebSphere Studio products WebSphere List of Code Examples awards given to, 3-4 List of listSidebars of, 8-9
WebSphere Studio Site Developer (WSSD), 8 well-formed documents, defined (XML), 374 wildcards, and topics, 474 windows active windows, defined, 23 Workbench window layout, 21-23 Windows WebSphere MQ and installing MQ as the WAD JMS provider and, 537 Windowsaccounts, configuring, 535-536 Windows 2000 platform development environment, setting up and, 11 examples in this book and, xx installation documentation, 571 wizards Database Web Pages wizard, 81 Generate DAD file wizard, 428 Migration wizard, 18 New Project wizard, 49,74-75 Prepare MQSeries Wizard, 536
XSL wizards, 438
WebSphere Studio Application Developer 5.0: Practical
Workbench.SeeWSAD 5.0 Workbench workspace, defined, 22 J2EE Development
ISBN:1590591208 by Igor Livshin WSAD 5.0. SeeWebSphere Studio Application Developer (WSAD) 5.0
Apress © 2003 (630 pages)
WSAD 5.0 Migration Guide, 10
This book provides a practical, step-by-step approach in
WSAD 5.0 Workbench, teaching21-61 how to use the WebSphere Studio Application customizing, 45-47 Developer (WSAD) tool for developing J2EE distributed applications. external tools/Internet customization, 46 'Hello World' Java application, building,48-61 Table of Contents debugging,55-57 WebSphere Studio Application Developer 5.0: Practical J2EE Development Java classes, creating new, 53-55 Introduction Java projects, creating new, 48-52 Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0 packages, creating new, 52 Chapter 1 - Introducing WSAD 5.0 WSAD testing environment and, 57-61 Chapter 2 customizing, - Setting Up46-47 the Development Environment Java, Chapter 3 - Working with the WSAD 5.0 Workbench Perspectives Chapter customizing, 4 - Developing Database Applications 41-42, 46 Part TwoData - Working with J2EE: Perspective, 31 The Distributed Application Framework Chapter Debug 5 - J2EE Development Perspective, 32-33 Chapter Help 6 - Perspective, J2EE EJB Development 39-41 Chapter J2EE 7 - Perspective, J2EE Web Development 30-31 Java Perspective, 29 Chapter 8 - J2EE XML Development multiple wayswith to select, 27-28Messaging Part Three - Working Enterprise Perspective basics, 23-25 Chapter 9 - J2EE Enterprise Messaging Perspective, 37-39 Chapter Profiling 10 - Using the WSAD-Embedded JMS Provider Server Perspective, 33-37 Chapter 11 - Using WebSphere MQ as the JMS Provider 29-30 AppendixWeb A - Perspective, Deploying This Book's J2EE Examples XML Perspective, 32 Index Preferences dialog, 46 List of Figures projects,43-45 List of Tables Views, 25-27 List of Code Examples Web browser, customizing, 46-47 List of Sidebars window layout, 21-23 WSAD EE (WebSphere Studio Enterprise Developer), 9 WSAD IE (WebSphere Studio Application Developer Integration Edition), 9 WSAD's XML tools, 384-424 introduction to, 384 parsing XML documents and, 401-424 basics of, 401-407 DOM parser, 407-415 SAX parser, 415-424 XML documents, building and, 395-400 XML Schemas, building, 385-395 basics of, 385-388 details for objects, adding, 389-395 global elements, adding, 388-389 XML Schemas, validating, 395 WSSD (WebSphere Studio Site Developer), 8
Index
WebSphere Studio Application Developer 5.0: Practical J2EE Development
X
by Igor Livshin Apress © 2003 (630 pages)
XA
ISBN:1590591208
This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application XA-compliant Developer administered objects, 525developing J2EE distributed (WSAD) tool for XA-compliant applications. database drivers, 525-526
XA-compliant Datasource, 526-527 XForms, Web tier, 151
Table of Contents
XML.SeeExtensible Markup Developer Language5.0: (XML) WebSphere Studio Application Practical J2EE Development Introduction XML File Built Based on the XML Schema with elementFormDefault='qualified' (code listing), 382 Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
XML Perspective, 32
Chapter 1
- Introducing WSAD 5.0
XML Schema (code listing), 385-386 Chapter 2 - Setting Up the Development Environment The XML File books.xsd (code listing), 376-377 Chapter 3 Schema - Working with the WSAD 5.0 Workbench Chapter 4 - Developing Database Applications XML Schema Root Element (code listing), 380 Part Two - Working with J2EE: The Distributed Application Framework
XML Schema with a Default Namespace (books2.xsd) (code listing), 379-380
Chapter 5
- J2EE Development
XML Schema with elementFormDefault='qualified' (code listing), 382 - J2EE EJB Development
Chapter 6
XML Schema withWeb elementFormDefault='unqualified' (code listing), 382-383 Chapter 7 - J2EE Development Chapter 8 - J2EE XML Development XML Schemas Part building, Three - Working 385-395with Enterprise Messaging
Chapter basics 9 - J2EE Enterprise Messaging of, 385-388 Chapter details 10 - Using for objects, the WSAD-Embedded adding, 389-395 JMS Provider
elements, adding, 388-389 Chapter global 11 - Using WebSphere MQ as the JMS Provider considerations for use, Appendix A - Deploying This383-384 Book's J2EE Examples Indexsupport for namespaces, 375-377
validating, List of Figures 395 XML Schema Editor, 387,388,392,395 List of Tables XML SeeWSAD's XML tools List of tools. Code Examples List of (Extensible Sidebars XSL Stylesheet Language)
debugging,435-437 stylesheet editing, 438-441 XSL transformations, 434,441-443 XSLT introduction to, 434 XSLT stylesheets, creating, 434-435
WebSphere Studio Application Developer 5.0: Practical List of Figures J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
Chapter 2: Setting Up the Development Environment This book provides a practical, step-by-step approach in teaching how tospecifying use the WebSphere Studiodirectory Application Figure 2-1: WSAD shortcut the workspace Developer (WSAD) tool for developing J2EE distributed applications.
Figure 2-2: WSAD installation screen
Figure 2-3: Setting the WSAD workspace
Table of Contents
WebSphere Studio Application Developer 5.0: Practical J2EE Development
Chapter 3: Working with the WSAD 5.0 Workbench
Introduction
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Figure The WSAD Workbench Chapter 1 -3-1: Introducing WSAD 5.0 Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Figure 3-2: Perspective selection list
Chapter 4 -3-3: Developing Database Applications Figure The Web Perspective Part Two - Working with J2EE: The Distributed Application Framework
Figure The Thumbnail View Chapter 5 -3-4: J2EE Development Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Figure 3-5: The Outline View
Chapter 8 -3-6: J2EE XML Development Figure The Tasks View Part Three - Working with Enterprise Messaging
Figure The Java Perspective Chapter 9 -3-7: J2EE Enterprise Messaging Chapter 10 - Using the WSAD-Embedded JMS Provider
Figure 3-8: The Web Perspective's Preview View
Chapter 11 - Using WebSphere MQ as the JMS Provider
Appendix A -3-9: Deploying This Book's J2EE Examples Figure The project's Deployment Descriptor in the J2EE Perspective Index List ofFigure Figures3-10: The Database Connection screen List of Tables
Figure 3-11: The XML Perspective
List of Code Examples
List ofFigure Sidebars 3-12: The Debug Perspective
Figure 3-13: The Server Perspective Figure 3-14: The opened server configuration Figure 3-15: Setting the CLASSPATH and ws.ext.dirsenvironment variables Figure 3-16: Embedded WAS running inside the WSAD environment Figure 3-17: Embedded WAS Administrative Console Figure 3-18: Launching a local Java process Figure 3-19: Launching a remote Java process Figure 3-20: Results of a search for Java help topics Figure 3-21: The Create a Web Application help screen Figure 3-22: The Working with the Web projects help screen Figure 3-23: Customizing Perspectives Figure 3-24: Customizing the Workbench
Figure 3-25: Building a Java project
WebSphere Studio Application Developer 5.0: Practical
Development Figure 3-26: J2EE The New Java Project wizard by Igor Livshin
ISBN:1590591208
Figure 3-27: Apress The Projects © 2003 (630tab pages) This book provides a practical, step-by-step approach in
Figure 3-28: teaching The Libraries tabthe WebSphere Studio Application how to use Developer (WSAD) tool for developing J2EE distributed
Figure 3-29: applications. The Order and Export tab Figure 3-30: Building a Java package Table of Contents
FigureStudio 3-31: Application Building Java class 5.0: Practical J2EE Development WebSphere Developer Introduction
Figure 3-32: WSAD-generated Java class skeleton
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 -3-33: Introducing WSAD 5.0 program Figure Debugging a Java Chapter 2 - Setting Up the Development Environment
Figure Selecting theWSAD test server Chapter 3 -3-34: Working with the 5.0 Workbench Chapter 4
- Developing Database Applications
Figure 3-35: Importing resources in the WSAD environment
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter- J2EE 4: Developing EJB Development Database Applications
Chapter 6 Chapter 7
- J2EE Web Development
Figure The DB2 Control Center Chapter 8 -4-1: J2EE XML Development Part Three - Working with Enterprise Messaging
Figure 4-2: The BOOK_CATALOG table structure
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 -4-3: Using the WSAD-Embedded Figure Entering the command JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider
Figure The contents of theJ2EE BOOK_CATALOG table Appendix A -4-4: Deploying This Book's Examples Index
Figure 4-5: Creating a simple project
List of Figures
List ofFigure Tables4-6: Naming the project List of Code Examples
Figure 4-7: The Database Connection screen
List of Sidebars
Figure 4-8: The TECHBOOK database hierarchical view Figure 4-9: Creating a new Web project Figure 4-10: Working with the J2EE settings Figure 4-11: Importing the TECHBOOK database into DBDatasourceProject Figure 4-12: Confirming the TECHBOOK import Figure 4-13: Building database Web pages Figure 4-14: Generating the database Web pages Figure 4-15: Selecting an existing database model Figure 4-16: Selecting tables Figure 4-17: Selecting table fields Figure 4-18: Selecting column values Figure 4-19: The constructed SQL statement Figure 4-20: Setting the variable value
Figure 4-21: WebSphere The SQL processing results Studio Application Developer 5.0: Practical J2EE Development
Figure 4-22: by Selecting the connection pool Igor Livshin
ISBN:1590591208
Apress © 2003 (630 pages)
Figure 4-23: The View Bean Data Page screen This book provides a practical, step-by-step approach in to use the WebSphere Studio Application Figure 4-24: teaching The inputhow screen design Developer (WSAD) tool for developing J2EE distributed applications.
Figure 4-25: The output screen design
Figure 4-26: The Details Views page design
Table of Contents
WebSphere 5.0: Practical J2EE Development FigureStudio 4-27: Application Setting the Developer common prefix Introduction
Figure 4-28: Started The generated modules Studio Application Developer (WSAD) 5.0 Part One - Getting with WebSphere Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Figure 4-29: Selecting a Datasource
Chapter 3 -4-30: Working with the the WSAD 5.0 Workbench Figure Configuring Datasource Chapter 4
- Developing Database Applications
Figure 4-31: Setting WebSphere extensions Part Two - Working with J2EE: The Distributed Application Framework Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Figure 4-32: Setting a Datasource for BookSearchMasterView
Chapter 7 -4-33: J2EESetting Web Development Figure the Datasource for BookSearchDetailsView Chapter 8 - J2EE XML Development
Figure- Working 4-34: Creating the serverMessaging project Part Three with Enterprise Chapter 9
- J2EE Enterprise Messaging
Figure 4-35: Creating the server project configuration
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 -4-36: UsingSetting WebSphere as the JMS Provider Figure serverMQ configuration Appendix A - Deploying This Book's J2EE Examples IndexFigure 4-37: Modifying the Datasource List of Figures
Figure 4-38: The Modify Resource Properties screen
List of Tables
List ofFigure Code Examples 4-39: The Datasourcesetting screen List of Sidebars
Figure 4-40: Starting the server Figure 4-41: Testing the project Figure 4-42: The processing results screen Figure 4-43: The Details View results screen
Chapter 5: J2EE Development Figure 5-1: Setting an entity bean relationship Figure 5-2: Setting multiplicity for the CMP bean relationship Figure 5-3: Relationship set in the Deployment Descriptor Figure 5-4: Local reference to the Book_catalogCMP bean Figure 5-5: Creating a new filter in a chain Figure 5-6: Creating a findermethod Figure 5-7: Building the EJB QL query
Figure 5-8: Creating a new filter in a chain
WebSphere Studio Application Developer 5.0: Practical
J2EE Development Figure 5-9: Servlet mapping by Igor Livshin
ISBN:1590591208
Figure 5-10: Apress Including a JAR in the WEB-INF/libfolder © 2003 (630 file pages) This book provides a practical, step-by-step approach in
Figure 5-11: teaching Accessing other projects on the Workbench from the Web project how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed
Figure 5-12: applications. Accessing other projects on the Workbench from the EJB project Figure 5-13: Specifying dependent JAR files for the Web project Table of Contents
FigureStudio 5-14: Application Specifying Developer dependent5.0: JARPractical files forJ2EE the EJB project WebSphere Development Introduction
Figure 5-15: Setting JAR dependencies
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 -5-16: Introducing 5.0 Figure Setting WSAD policies Chapter 2
- Setting Up the Development Environment Figure Setting policy and WAR classloader mode Chapter 3 -5-17: Working withthe theclassloader WSAD 5.0 Workbench Chapter 4
- Developing Database Applications
Figure 5-18: Setting the development environment
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 -5-19: J2EESetting Development Figure the runtime environment Chapter 6 - J2EE EJB Development
Figure up a new Web project Chapter 7 -5-20: J2EESetting Web Development Chapter 8
- J2EE XML Development
Figure 5-21: Setting up a new application project
Part Three - Working with Enterprise Messaging
Chapter 9 -5-22: J2EEBuilding Enterprise Messaging Figure a new HTML page Chapter 10 - Using the WSAD-Embedded JMS Provider
Figure a new Chapter 11 -5-23: UsingBuilding WebSphere MQfolder as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
Figure 5-24: Building a new folder
Index
List ofFigure Figures5-25: The frameset List of Tables
5-26: The structure of the frameset List ofFigure Code Examples List of Sidebars
Figure 5-27: The copied files displayed in the frameset Figure 5-28: The already-made frameset page Figure 5-29: The QQQ portfolio screen Figure 5-30: Setting transaction properties for EJB beans Figure 5-31: Setting transaction properties for EJB bean methods Figure 5-32: Setting Commit Option Figure 5-33: The 'Local Transaction 2.0' section Figure 5-34: Selecting the isolation level Figure 5-35: Setting the methods for the isolation level Figure 5-36: Setting the Librarian security role Figure 5-37: Setting the Director security role Figure 5-38: Setting security groups Figure 5-39: Setting security constrains
Figure 5-40: Servlet access authorization
WebSphere Studio Application Developer 5.0: Practical
Development Figure 5-41: J2EE Selecting the Librarian security role by Igor Livshin
ISBN:1590591208
Figure 5-42: Apress EJB modules © 2003 (630 permitted pages) to be accessed by the Librarian security role This book provides a practical, step-by-step approach in
Figure 5-43: teaching EJB method be accessed by Application the Librarian security role how permitted to use the to WebSphere Studio Developer (WSAD) tool for developing J2EE distributed
Figure 5-44: applications. Bean-level user identity Figure 5-45: Selecting beans to use this security identity Table of Contents
FigureStudio 5-46: Application User identity of the specific securityJ2EE roleDevelopment WebSphere Developer 5.0: Practical Introduction
Figure 5-47: Login settings
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 6: J2EE Development Chapter 2 - Setting Up theEJB Development Environment Chapter 3
- Working with the WSAD 5.0 Workbench Figure Generated entity bean and field mapping Chapter 4 -6-1: Developing Database Applications Part Two - Working with J2EE: The Distributed Application Framework
Figure 6-2: The Outline View
Chapter 5
- J2EE Development
Chapter 6 -6-3: J2EE EJBFinder Development Figure Add Descriptor dialog Chapter 7 - J2EE Web Development
Figure -6-4: EJB QL query statement for the findByBookmethod J2EE XML Development
Chapter 8
Part Three - Working with Enterprise Messaging
Figure 6-5: EJB QL query statement for the findByCompanymethod
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 -6-6: Using the WSAD-Embedded JMS Provider Figure Section of the EJB Deployment Descriptor with entered EJB QL statements Chapter 11 - Using WebSphere MQ as the JMS Provider
Figure SectionThis of the Deployment Descriptor with entered EJB QL statements Appendix A -6-7: Deploying Book's J2EE Examples IndexFigure 6-8: Binding the CMP entity bean to the Datasource List of Figures List ofFigure Tables6-9: Setting the JNDI name for the Book_activityCMP entity bean List of Code Examples
Figure 6-10: Setting the JNDI name for the Book_catalogCMP entity bean
List of Sidebars
Figure 6-11: Adding a Datasourceto the server configuration Figure 6-12:Datasourceconfiguration Figure 6-13: Setting the database name Figure 6-14: Fragment of the server configuration Figure 6-15: Classloader setting Figure 6-16: The Universal Test Client Figure 6-17: JNDI Explorer Figure 6-18: Local Home Interfaces of the entity beans Figure 6-19: Request to find a Book_catalogwith a key of 00002 Figure 6-20: Displaying the author of the book Figure 6-21: Displaying the book title Figure 6-22: Displaying the first book title Figure 6-23: Displaying the second book title
Figure 6-24: WebSphere Creating a new database record Developer 5.0: Practical Studio Application J2EE Development
Figure 6-25: by Finding records with the AAA_Companyfield value ISBN:1590591208 Igor Livshin Apress © 2003 (630 pages)
Figure 6-26: The processing results
This book provides a practical, step-by-step approach in
use the WebSphere Studio Application Figure 6-27: teaching Creatinghow CMPtoattributes Developer (WSAD) tool for developing J2EE distributed applications. Figure 6-28:Enterprise Bean Details screen
Figure 6-29:Table Definition screen
Table of Contents
WebSphere 5.0: Practical J2EE Development FigureStudio 6-30: Application The TableDeveloper Columns screen Introduction
Figure 6-31: Started Primarywith Key WebSphere screen Part One - Getting Studio Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Figure 6-32: Generated DDL file
Chapter 3 -6-33: Working with the WSAD Figure Exporting a DDL file5.0 Workbench Chapter 4
- Developing Database Applications
Figure 6-34: Mapping attributes to database fields Framework Part Two - Working with J2EE: The Distributed Application Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Figure 6-35: Building a BMP entity bean
Chapter 7 -6-36: J2EEBMP Web details Development Figure screen Chapter 8
- J2EE XML Development
Figure- Working 6-37: Creating a Java class Part Three with Enterprise Messaging Chapter 9
- J2EE Enterprise Messaging
Figure 6-38: Building getter/setter methods
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 -6-39: UsingThe WebSphere MQ as the JMS Provider Figure Deployment Descriptor 'WebSphere Bindings' section Appendix A - Deploying This Book's J2EE Examples IndexFigure 6-40: Setting the Datasourcereference List of Figures
Figure 6-41: Setting the JNDI name for the Datasourceresource
List of Tables
List ofFigure Code Examples 6-42: Executing the createmethod List of Sidebars
Figure 6-43: The result of the DB2 command execution Figure 6-44: Testing a BMP entity bean Figure 6-45: The result of executing the getCompanyNamemethod Figure 6-46: The Create an Enterprise Bean screen Figure 6-47: Setting the JNDI name for TechLibFacade Figure 6-48: The Enterprise Bean Details screen Figure 6-49: The Add EJB Local Reference screen Figure 6-50: Setting EJB references Figure 6-51: Generating deployment code Figure 6-52: The Universal Test Client Figure 6-53: Home Interface of the session bean Figure 6-54: A collection of object references is returned Figure 6-55: The result of executing the getAuthormethod
Figure 6-56: The result of executing the getTitlemethod
WebSphere Studio Application Developer 5.0: Practical
Development Figure 6-57: J2EE Setting the JNDI name for TechLibFacade1 by Igor Livshin
ISBN:1590591208
Figure 6-58: Apress Setting©the second EJB references for TechLibFacade1 2003 (630 pages) This book provides a practical, step-by-step approach in
Figure 6-59: teaching Testing the session bean inStudio the Universal Test Client howstateful to use the WebSphere Application Developer (WSAD) tool for developing J2EE distributed
Figure 6-60: applications. Returning multiple objects Figure 6-61: Getting the title of the last object Table of Contents
FigureStudio 6-62: Application Getting theDeveloper company 5.0: name of the object WebSphere Practical J2EE Development Introduction
Chapter 7: J2EE Web Development
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0
Chapter 2 -7-1: Setting Up the Development Figure Creating a Web project Environment Chapter 3 - Working with the WSAD 5.0 Workbench
Figure -7-2: Module Dependences screen Developing Database Applications
Chapter 4
Part Two - Working with J2EE: The Distributed Application Framework
Figure 7-3: Building the BookRegisterHelperclass
Chapter 5
- J2EE Development
Chapter 6 -7-4: J2EE EJB Development Figure Generating the getter/setter methods Chapter 7 - J2EE Web Development
Figure Generating JavaBean Web pages Chapter 8 -7-5: J2EE XML Development Part Three - Working with Enterprise Messaging
Figure 7-6: Creating Web pages that access JavaBeans
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 -7-7: Using the WSAD-Embedded Figure Selecting the JavaBean JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider
Figure Selecting attributes for building Web pages Appendix A -7-8: Deploying This Book's J2EE Examples Index
Figure 7-9: Input page design screen
List of Figures
List ofFigure Tables7-10: Modifying the input page List of Code Examples
Figure 7-11: Modifying the results form
List of Sidebars
Figure 7-12: Specifying the prefix Figure 7-13: The Web project structure Figure 7-14: The Web project Deployment Descriptor Figure 7-15: The Web project Deployment Descriptor Figure 7-16: Output screen design Figure 7-17: Setting a local reference to the Book_catalogentity bean Figure 7-18: Checking the local reference to the Book_catalogentity bean Figure 7-19: Filling the input screen Figure 7-20: A successful registration status Figure 7-21: Inserting the button controls Figure 7-22: Running the application Figure 7-23: The processing results Figure 7-24: Event processing
Figure 7-25: WebSphere Event/action Studio assignment Application Developer 5.0: Practical J2EE Development
Figure 7-26: by Event/action assignment for the last field Igor Livshin
ISBN:1590591208
Apress © 2003 (630 pages)
Figure 7-27: Processing attributes for the input field
This book provides a practical, step-by-step approach in
how validation to use the WebSphere Studio Application Figure 7-28: teaching Testing data Developer (WSAD) tool for developing J2EE distributed applications.
Figure 7-29: Testing data validation of the last field Figure 7-30: Creating the HTML input form
Table of Contents
WebSphere Developer 5.0: form Practical J2EE Development FigureStudio 7-31: Application Creating the HTML input Introduction
Figure 7-32: Started Setting the logo style Part One - Getting withpage WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0
Chapter 2
- Setting Up the Development Environment
Figure 7-33: Setting the page logo attributes
Chapter 3 -7-34: Working with the 5.0 Workbench Figure Creating the WSAD FormHTML tag Chapter 4
- Developing Database Applications
Figure 7-35: Entering theThe item-value pairs in the Choice list Part Two - Working with J2EE: Distributed Application Framework Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Figure 7-36: Creating the form page
Chapter 7 -7-37: J2EEInserting Web Development Figure the Submitbutton Chapter 8
- J2EE XML Development
Figure- Working 7-38: The designed inputMessaging screen Part Three with Enterprise Chapter 9
- J2EE Enterprise Messaging
Figure 7-39: The Links View
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 -7-40: UsingBuilding WebSphere MQ as the class JMS Provider Figure the JavaBean Appendix A - Deploying This Book's J2EE Examples IndexFigure 7-41: Creating a new servlet component List of Figures
Figure 7-42: Setting servlet attributes
List of Tables
List ofFigure Code Examples 7-43: Building the JSP component List of Sidebars
Figure 7-44: Previewing the logo Figure 7-45: Inserting the JavaBean class in the JSP module Figure 7-46: Inserting the Tablecontrol Figure 7-47: Setting the Tablecontrol's attributes Figure 7-48: Setting dynamic attributes Figure 7-49: Property display settings Figure 7-50:TechLibFacadebean setting Figure 7-51: Starting the application and filling the input screen Figure 7-52: The processing results Figure 7-53: Setting a breakpoint Figure 7-54: Server started in the debug mode Figure 7-55: Stopping the debugging program at the breakpoint Figure 7-56: The Variables View
Figure 7-57: The Debug View
WebSphere Studio Application Developer 5.0: Practical
Development Figure 7-58: J2EE Stepping through the program by Igor Livshin
ISBN:1590591208
Figure 7-59: Apress End of ©the 2003 program (630 pages) debugging This book provides a practical, step-by-step approach in to use the WebSphere Studio Application Chapter 8: teaching J2EE how XML Development Developer (WSAD) tool for developing J2EE distributed applications.
Figure 8-1: Building the XML Schema Table Figure of Contents 8-2: The XML Schema Editor WebSphere Studio Application Developer 5.0: Practical J2EE Development
Figure 8-3: XML Schema general outline Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Figure 8-4: XML Schema simple type details
Chapter 1
- Introducing WSAD 5.0
Chapter Figure 2 -8-5: Setting Details Up for the the Development XML Schema Environment complex type FirstName Chapter 3
- Working with the WSAD 5.0 Workbench
Figure -8-6: Details for the XML Schema complex type Author Developing Database Applications
Chapter 4
Part Two - Working with J2EE: The Distributed Application Framework
Figure 8-7: Adding a required attribute
Chapter 5
- J2EE Development
Chapter Figure 6 -8-8: J2EE Details EJB Development for the XML Schema complex type bookType Chapter 7
- J2EE Web Development
Figure Changed namespace prefix Chapter 8 -8-9: J2EE XML Development Part Three - Working with Enterprise Messaging
Figure 8-10: Validating the XML Schema
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 -8-11: UsingGenerating the WSAD-Embedded Figure the XML fileJMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider
Figure XML Editor View J2EE Examples Appendix A -8-12: Deploying This Book's Index
Figure 8-13: Editing the XML file
List of Figures
List ofFigure Tables8-14: Library.xml List of Code Examples
Figure 8-15: Building the DTD file
List of Sidebars
Figure 8-16: List of WSAD environment variables Figure 8-17: Adding environment variables to the Java Build Path Figure 8-18: Selecting the JAR library Figure 8-19: Adding the JAR library to the Web-INF/libfolder Figure 8-20: Setting the initialization parameter Figure 8-21: The DOM parsing results Figure 8-22: The SAX parsing results Figure 8-23: Selecting database tables Figure 8-24: RDB to XML Mapping Editor Figure 8-25: Generating the test harness Figure 8-26: Selecting the XSL stylesheet file Figure 8-27: XML Debug Perspective Figure 8-28: Transformation results
Figure 8-29: WebSphere Definition of the template element Studio Application Developer 5.0: Practical J2EE Development
Figure 8-30: by Ready Igor XSLT Livshinstylesheet
ISBN:1590591208
Apress © 2003 (630 pages)
Figure 8-31: Transformation results
This book provides a practical, step-by-step approach in
howthe to XSL use the WebSphere Studio Application Figure 8-32: teaching Debugging transformation Developer (WSAD) tool for developing J2EE distributed applications.
Figure 8-33: Transformation results
Figure 8-34: XML to XML transformation examples
Table of Contents
WebSphere Studio Application Developer 5.0: Practical J2EE Development
Chapter 10: Using the WSAD-Embedded JMS Provider
Introduction
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Figure Choosing to install Chapter 1 -10-1: Introducing WSAD 5.0 the WSAD embedded client and server Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Figure 10-2: Building a new EJB project
Chapter 4 -10-3: Developing Database Applications Figure Building new CMP bean Part Two - Working with J2EE: The Distributed Application Framework
Figure EJB to RDB Mapping screen Chapter 5 -10-4: J2EEThe Development Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Figure 10-5: Mapping database columns to the attributes of the entity bean
Chapter 8 -10-6: J2EEBuilding XML Development Figure an MDB Part Three - Working with Enterprise Messaging
Figure the deployment and Remote Method Invocation Code (RMIC) Chapter 9 -10-7: J2EEGenerating Enterprise Messaging Chapter 10 - Using the WSAD-Embedded JMS Provider
Figure 10-8: Enabling the Administrative Console and Universal Test Client
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A -10-9: Deploying This Book's J2EE Examples Figure Setting DBDatasource Index List ofFigure Figures10-10: Setting the database name List of Tables
Figure 10-11: The Data sources page
List of Code Examples
List ofFigure Sidebars 10-12: Configuring runtime connection factories
Figure 10-13: Setting queue and queue connection factory names Figure 10-14: Mapping the listener port Figure 10-15: Mapping the listener port to a queue Figure 10-16: Setting a reference to the entity bean component Figure 10-17: Setting the JNDI name for reference Figure 10-18: Setting the JNDI name reference to the Book_notify entity bean Figure 10-19: Setting a reference to the entity bean component Figure 10-20: Configuring the entity bean component Figure 10-21: The Universal Test Client Figure 10-22: Testing the create method Figure 10-23: Testing the getMessage method Figure 10-24: Configuring QueueConnectionFactory
Figure 10-25: Configuring Queue
WebSphere Studio Application Developer 5.0: Practical
Development Figure 10-26:J2EE Setting TopicConnectionFactoryandTopic by Igor Livshin
ISBN:1590591208
Figure 10-27:Apress The EJB © 2003 tab(630 pages) This book provides a practical, step-by-step approach in
Figure 10-28:teaching Setting how the destination type for theStudio ReceivingMDB to use the WebSphere Applicationcomponent Developer (WSAD) tool for developing J2EE distributed
Figure 10-29:applications. Building PublishingServlet
Figure 10-30: Configuring the topic connection factory Table of Contents
FigureStudio 10-31:Application Configuring the topic5.0: Practical J2EE Development WebSphere Developer Introduction
Figure 10-32: Execution results of the Pub/Sub example
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 -10-33: Introducing WSAD Figure Selecting the5.0 XA-compliant DB2 driver Chapter 2 - Setting Up the Development Environment
Figure Setting XA-compliant Datasource Chapter 3 -10-34: Working with the the WSAD 5.0 Workbench Chapter 4
Developing Database Applications Figure -10-35: Setting the database name for the XA-compliant Datasource
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 -10-36: J2EE Development Figure Changing the transaction setting to Required Chapter 6 - J2EE EJB Development
Figure The Development processing results Chapter 7 -10-37: J2EE Web Chapter 8
- J2EE XML Development
Figure 10-38: Setting the listener port
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 11: Using WebSphere MQ as the JMS Provider
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 - Using WebSphere MQ as the JMS Provider
Figure Simplified MQ message processing Appendix A -11-1: Deploying This Book's J2EE Examples Index
Figure 11-2: Checking software prerequisites
List of Figures
List ofFigure Tables11-3: Summary of installation options List of Code Examples
Figure 11-4: Messages produced by the running application
List of Sidebars
Figure 11-5: Messages written in the BOOK_NOTIFY table Figure 11-6: MQ Explorer's main window Figure 11-7: The default queue manager that is running Figure 11-8: Registered administered objects Figure 11-9: Setting the PATH Figure 11-10: Setting the generic JMS provider as the MQ JMS provider Figure 11-11: Setting the queue connection factory Figure 11-12: Setting a queue Figure 11-13: Setting the topic connection factory Figure 11-14: Setting the topic Figure 11-15: Configuring the listener port for the P2P domain Figure 11-16: Setting the listener port Figure 11-17: Setting a Datasourceresource
Figure 11-18:WebSphere Setting the queue reference Studioobject Application Developer 5.0: Practical J2EE Development
Figure 11-19:bySetting the new queue connection factory reference ISBN:1590591208 Igor Livshin Apress © 2003 (630 pages)
Figure 11-20: Setting the new queue reference
This book provides a practical, step-by-step approach in
how to use the WebSphere Application Figure 11-21:teaching P2P execution results displayed inStudio the Console View Developer (WSAD) tool for developing J2EE distributed applications.
Figure 11-22: P2P messages in the BOOK_NOTIFY table Figure 11-23: Listener port changed to topic
Table of Contents
WebSphere 5.0: Practical Development FigureStudio 11-24:Application MessagesDeveloper printed during programJ2EE execution Introduction
Figure 11-25:Started Pub/Sub messages in the BOOK_NOTIFY table Part One - Getting with WebSphere Studio Application Developer (WSAD) 5.0 Chapter 1
- Introducing WSAD 5.0
- Setting Up the Development Environment Appendix A: Deploying This Book's J2EE Examples
Chapter 2 Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4 -A-1: Developing Applications Figure DefiningDatabase the JDBC provider Part Two - Working with J2EE: The Distributed Application Framework
Figure Attributes of the DB2 JDBC provider Chapter 5 -A-2: J2EE Development Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Figure A-3: Creating the authentication alias
Chapter 8 -A-4: J2EE XML Development Figure Setting the authentication alias for the Datasource Part Three - Working with Enterprise Messaging
Figure The configured DBDatasourceobject Chapter 9 -A-5: J2EE Enterprise Messaging Chapter 10 - Using the WSAD-Embedded JMS Provider
Figure A-6: Exporting the DBDatasourceProjectAppapplication
Chapter 11 - Using WebSphere MQ as the JMS Provider
Appendix A -A-7: Deploying This Book's J2EE Examples Figure Installing the DBDatasourceProjectApp application Index List ofFigure FiguresA-8: Generic installation options List of Tables
Figure A-9: Additional installation options
List of Code Examples
List ofFigure Sidebars A-10: Mapping a resource reference to the resource
Figure A-11: Mapping a virtual host to a Web module server Figure A-12: Mapping modules to application servers Figure A-13: The installation Summaryscreen Figure A-14: The installation results Figure A-15: List of installed applications Figure A-16: Restarting the server Figure A-17: The started DBDatasourceProjectAppapplication Figure A-18: The application Deployment Descriptor Figure A-19: The user input screen Figure A-20: The main processing results Figure A-21: The Details View page Figure A-22: Exporting the TechLibAppapplication
Figure A-23: Installing the TechLibAppapplication
WebSphere Studio Application Developer 5.0: Practical
Development Figure A-24: J2EE Preparing for the application installation screen by Igor Livshin
ISBN:1590591208
Figure A-25: Apress Installation © 2003options (630 pages) This book provides a practical, step-by-step approach in
Figure A-26: teaching Mappinghow EJBtomodules to JNDI names use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed
Figure A-27: applications. Mapping the Datasourceto the JNDI name
Figure A-28: Mapping individual CMP modules to the DatasourceJNDI names Table of Contents
FigureStudio A-29: Application Mapping EJB module5.0: references WebSphere Developer Practical J2EE Development Introduction
Figure A-30: Mapping EJB module references
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 -A-31: Introducing WSAD 5.0 module to the virtual host Figure Mapping the Web Chapter 2 - Setting Up the Development Environment
Figure Mapping modules application server Chapter 3 -A-32: Working with the WSAD to 5.0the Workbench Chapter 4
- Developing Database Applications
Figure A-33: Setting EJB module protection
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 -A-34: J2EE The Development Figure installation summary Chapter 6 - J2EE EJB Development
Figure results Chapter 7 -A-35: J2EE Installation Web Development Chapter 8
- J2EE XML Development
Figure A-36: List of installed applications
Part Three - Working with Enterprise Messaging
Chapter 9 -A-37: J2EE WAS Enterprise Messaging Figure message Chapter 10 - Using the WSAD-Embedded JMS Provider
Figure WAS Fist Steps utility's main screen Chapter 11 -A-38: UsingThe WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
Figure A-39: The WAS First Steps utility, after the server has started
Index
List ofFigure FiguresA-40: The started TechLibAppapplication List of Tables
A-41: Registering a new book List ofFigure Code Examples List of Sidebars
Figure A-42: The book's registration results Figure A-43: Searching for all books written for Cross platform Figure A-44: The cross-platform search results
WebSphere Studio Application Developer 5.0: Practical List of Tables J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
Chapter 4: Developing Database Applications This book provides a practical, step-by-step approach in teaching how to use theTable WebSphere Studio Application Table 4-1: The BOOK_CATALOG Developer (WSAD) tool for developing J2EE distributed applications.
Table 4-2: The BOOK_ACTIVITY Table Table 4-3: The BOOK_NOTIFY Table
Table of Contents
WebSphere Studio Application Developer 5.0: Practical J2EE Development
Chapter 5: J2EE Development
Introduction
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Table Transaction Isolation Chapter 1 5-1: - Introducing WSAD 5.0 Level Chapter 2
- Setting Up the Development Environment
with the WSAD 5.0 Workbench Chapter- Working 7: J2EE Web Development
Chapter 3 Chapter 4
- Developing Database Applications
Part Two - Working with J2EE: Distributed Table 7-1: Platforms andThe Their Codes Application Framework
Chapter 5
- J2EE Development
Chapter 6
EJB Development Chapter- J2EE 9: J2EE Enterprise Messaging
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Table 9-1: JMS Standard Message Properties
Part Three - Working with Enterprise Messaging
Chapter 9 9-2: - J2EE Enterprise Table JMS Header Messaging Fields Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider
Chapter 11: Using WebSphere MQ as the JMS Provider
Appendix A - Deploying This Book's J2EE Examples Index
Table 11-1: JMSAdmin Commands
List of Figures List of Tables
List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical List of Code Examples J2EE Development by Igor Livshin Apress © 2003 (630 pages)
ISBN:1590591208
Chapter 3: Working with the WSAD 5.0 Workbench This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Listing 3-1. HelloWorld.java Developer (WSAD) tool for developing J2EE distributed applications.
Chapter 4: Developing Database Applications Table of Contents
Listing 4-1. BuildTextbookDatabase.sql
WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Listing 4-2. Execution Results Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1
- Introducing WSAD 5.0 Chapter 5: J2EE Development Chapter 2 - Setting Up the Development Environment Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Listing 5-1. Meta-Code for Constructing the JNDI InitialContext
Part Two - Working with J2EE:Value The Distributed Application Framework Listing 5-2. Dependent Class
Chapter 5
- J2EE Development Listing CMP Bean with the Dependent Value Class Chapter 6 -5-3. J2EE EJB Entity Development Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Listing 5-4. Publisher.javaCMP Entity Bean
Part Three with Enterprise Messaging Listing- Working 5-5. Book.java CMP Entity Bean
Chapter 9
- J2EE Enterprise Messaging
Listing The getAllCompanyNamesMethod Chapter 10 -5-6. Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider
Listing 5-7. The ejbPostCreateMethod
Appendix A - Deploying This Book's J2EE Examples IndexListing 5-8. Fragment of the Deployment Descriptor List of Figures List ofListing Tables5-9. The javax.servlet.FilterFilter Interface List of Code Examples
Listing 5-10. Fragment of the Deployment Descriptor with the Filter Chain Definition
List of Sidebars
Listing 5-11. Logging Filter Code Example Listing 5-12. Fragment of the Listener Code Listing 5-13. Error Page Servlet Source Code Listing 5-14. Code of the Bean-Managed Session Bean Listing 5-15. Setting the AutoCommitOption for LTC Transactions Listing 5-16. Setting the AutoCommitOption for JTA Transactions Listing 5-17. Programmatic Security
Chapter 6: J2EE EJB Development Listing 6-1. TechLibBook_catalogBean.java:Implementation Class Listing 6-2. TechLibBook_catalogLocal.java:Local Interface Listing 6-3. Primary Key Class TechLibBook_catalogKey.java Listing 6-4. TechLibBook_activityBean.java:Implementation Class
Listing 6-5. TechLibBook_activityLocalHome.java:Local Home Interface WebSphere Studio Application Developer 5.0: Practical
J2EE Development Listing 6-6. TechLibBook_activityLocal.java: Local Interface by Igor Livshin
ISBN:1590591208
Listing 6-7.Primary Apress Key © 2003 Class (630 pages) TechLibBook_activityKey.java This book provides a practical, step-by-step approach in
Listing 6-8. BOOK_DETAILS Processing ResultsStudio Application teaching how to use the WebSphere Developer (WSAD) tool for developing J2EE distributed
Listing 6-9. TransportBean.java applications. Listing 6-10. BookInquiryBean.java:Implementation Class Table of Contents
ListingStudio 6-11. BookInquiryHome.java: HomeJ2EE Interface Class WebSphere Application Developer 5.0: Practical Development Introduction
isting 6-12. BookInquiry.java:Remote Interface Class
Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Chapter 1 -6-13. Introducing WSAD 5.0 Listing BookInquiryKey.java:Primary Key Class Chapter 2 - Setting Up the Development Environment
Listing TechLibFacadeBean.java: Implementation Class Chapter 3 -6-14. Working with the WSAD 5.0 Workbench Chapter 4
Developing Database Applications Listing -6-15. TechLibFacadeHome.java:Home Interface Class
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5 -6-16. J2EETechLibFacade.java: Development Listing Remote Interface Class Chapter 6 - J2EE EJB Development
Listing Local Home Interface Chapter 7 -6-17. J2EETechLibFacadeLocalHome.java: Web Development Chapter 8
J2EE XML Development Listing -6-18. TechLibFacadeLocal.java:Local Interface
Part Three - Working with Enterprise Messaging
Chapter 9 -6-19. J2EEFragments Enterprise Messaging Listing of New Methods Chapter 10 - Using the WSAD-Embedded JMS Provider
Listing TechLibFacade1Bean.java: Implementation Class Chapter 11 -6-20. Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples
Listing 6-21. TechLibFacade1LocalHome: Local Home Interface Class
Index
List ofListing Figures6-22. TechLibFacade1Local: Local Interface Class List of Tables
Chapter 7: J2EE Web Development
List of Code Examples List of Sidebars
Listing 7-1. BookRegisterHelper.java Listing 7-2. Fragment of the BookRegisterInputForm.htmlfile Listing 7-3. The performServicesMethod Listing 7-4. BookRegisterController.javaServlet Listing 7-5. JavaScript Validating Functions Listing 7-6. The BookHelperClass Listing 7-7. The BookRegisterController Class, BookRegisterController.java Listing 7-8. The BookRegisterInputForm Page, BookRegisterInputForm.html Listing 7-9. The BookRegisterResultsForm Page, BookRegisterResultsForm.jsp Listing 7-10. BookByPlatformHelper1.java Listing 7-11. BookByPlatformController.java Listing 7-12. BookByPlatformOutputForm.jsp Listing 7-13. BookByPlatformHelperX.java
Studio Application Developer 5.0: Practical Chapter 8: WebSphere J2EE XML Development J2EE Development by Igor Livshin
ISBN:1590591208
Listing 8-1. AApress Simple© XML Document 2003 (630 pages) ThisXML bookDocuments provides a practical, step-by-step approach in Listing 8-2. Two With a Potential Naming Conflict teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed Listing 8-3. The XML Schema File books.xsd applications.
Listing 8-4. Fragment of an XML Schema File Table of Contents
Listing 8-5. Using XML Namespaces to Avoid a Naming Conflict
WebSphere Studio Application Developer 5.0: Practical J2EE Development Introduction Listing 8-6. XML Schema with a Default Namespace (books2.xsd) Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Listing XML Schema Chapter 1 -8-7. Introducing WSADRoot 5.0 Element Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Listing 8-8. XML Schema with elementFormDefault="qualified"
Chapter 4 -8-9. Developing Applications Listing XML FileDatabase Built Based on the XML Schema with elementFormDefault="qualified" Part Two - Working with J2EE: The Distributed Application Framework
Listing Schema with elementFormDefault="unqualified" Chapter 5 -8-10. J2EEXML Development Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Listing 8-11. XML File Built Based on the XML Schema with
Chapter 8 -8-12. J2EEXML XML Schema Development Listing Part Three - Working with Enterprise Messaging
Listing XML Schema Chapter 9 -8-13. J2EEGenerated Enterprise Messaging Chapter 10 - Using the WSAD-Embedded JMS Provider
Listing 8-14. The Generated Library.xmlSkeleton File
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A -8-15. Deploying This Book's J2EE Examples Listing Library.xml Index List ofListing Figures8-16. Corrected XML Schema Location List of Tables
Listing 8-17. ParseServlet.java
List of Code Examples
List ofListing Sidebars 8-18. ParserServlet.java
Listing 8-19. Generated BookCatalog.xmlFile Listing 8-20. Library.xslFile Listing 8-21. Library.xsl
Chapter 9: J2EE Enterprise Messaging Listing 9-1. Working with Different Types of Message Bodies Listing 9-2. Sending a Message Listing 9-3. Locating the WSAD InitialContextObject with a Program Running Outside WSAD Listing 9-4. Locating the File-Based JNDI Context Listing 9-5. Locating the LDAP JNDI Context Listing 9-6. Closing JMS Objects Listing 9-7. A Pseudo-Synchronous Way of Receiving Messages Listing 9-8. Example of the ListenerClass
Listing 9-9. Conceptual Fragment of the MDB Code
WebSphere Studio Application Developer 5.0: Practical J2EE Development
Listing 9-10. Seeing JMS Pub/Sub in Action
ISBN:1590591208 by Igor Livshin Apress © 2003 (630 pages) Listing 9-11. Setting a Global Transaction This book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer (WSAD) tool for developing J2EE distributed applications.
Chapter 10: Using the WSAD-Embedded JMS Provider Listing 10-1. The ReceivingMDBBean MDB Table Listing of Contents 10-2. SendingServlet.java WebSphere Studio Application Developer 5.0: Practical J2EE Development
Listing 10-3. PublishingServlet Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
WSAD 5.0 Chapter- Introducing 11: Using WebSphere MQ as the JMS Provider
Chapter 1 Chapter 2
- Setting Up the Development Environment
Chapter 3 -11-1. Working with the 5.0 Workbench Listing Fragment of WSAD the JMSAdmin.config File Chapter 4
- Developing Database Applications
Listing 11-2. Fragment theDistributed Changed JMSAdmin.config File Part Two - Working with J2EE:ofThe Application Framework Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Listing 11-3. The Modified JMSAdmin.batFile
Chapter 7 -11-4. J2EESetJMSAdminEnv.cmd Web Development Listing Chapter 8
- J2EE XML Development
Listing- Working 11-5. CommandsForJMSAdmin.txt Part Three with Enterprise Messaging Chapter 9
- J2EE Enterprise Messaging
Appendix A: Deploying This Book's J2EE Examples
Chapter 10 - Using the WSAD-Embedded JMS Provider
Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A -A-1. Deploying This Book's J2EE Examples Listing BuildTechbookDatabase.sql Index List of Figures List of Tables List of Code Examples List of Sidebars
WebSphere Studio Application Developer 5.0: Practical
J2EE Development List of Sidebars by Igor Livshin
ISBN:1590591208
Apress © 2003 (630 pages)
Chapter 2: This Setting Up the Development Environment book provides a practical, step-by-step approach in teaching how to use the WebSphere Studio Application Developer Installing WSAD on the(WSAD) Server tool for developing J2EE distributed applications.
Chapter 6: J2EE EJB Development Table of Contents WebSphere StudioConsiderations Application Developer 5.0: Practical J2EE Development Multiscreen Introduction Part One - Getting Started with WebSphere Studio Application Developer (WSAD) 5.0
Appendix A: Deploying This Book's J2EE Examples - Introducing WSAD 5.0
Chapter 1 Chapter 2
- Setting Up the Development Environment
Chapter 3
- Working with the WSAD 5.0 Workbench
Chapter 4
- Developing Database Applications
Avoiding Port Conflicts
Part Two - Working with J2EE: The Distributed Application Framework
Chapter 5
- J2EE Development
Chapter 6
- J2EE EJB Development
Chapter 7
- J2EE Web Development
Chapter 8
- J2EE XML Development
Part Three - Working with Enterprise Messaging
Chapter 9
- J2EE Enterprise Messaging
Chapter 10 - Using the WSAD-Embedded JMS Provider Chapter 11 - Using WebSphere MQ as the JMS Provider Appendix A - Deploying This Book's J2EE Examples Index List of Figures List of Tables List of Code Examples List of Sidebars