SlideShare a Scribd company logo
Visit https://ebookultra.com to download the full version and
explore more ebooks
Designing Enterprise Applications with the J2EE
Platform 2nd Edition Inderjeet Singh
_____ Click the link below to download _____
https://ebookultra.com/download/designing-enterprise-
applications-with-the-j2ee-platform-2nd-edition-
inderjeet-singh/
Explore and download more ebooks at ebookultra.com
Here are some suggested products you might be interested in.
Click the link to download
Customers inside customers outside designing and
succeeding with enterprise customer centricity concepts
practices and applications First Edition Lowenstein
https://ebookultra.com/download/customers-inside-customers-outside-
designing-and-succeeding-with-enterprise-customer-centricity-concepts-
practices-and-applications-first-edition-lowenstein/
Developing Facebook Platform Applications with Rails 1st
Edition Michael J. Mangino
https://ebookultra.com/download/developing-facebook-platform-
applications-with-rails-1st-edition-michael-j-mangino/
Developing applications with enterprise SOA 1st Edition
Martin Huvar
https://ebookultra.com/download/developing-applications-with-
enterprise-soa-1st-edition-martin-huvar/
Programming Wireless Devices with the Java 2 Platform 2nd
Edition Roger Riggs
https://ebookultra.com/download/programming-wireless-devices-with-the-
java-2-platform-2nd-edition-roger-riggs/
Designing Embedded Systems with PIC Microcontrollers
Second Edition Principles and Applications Tim Wilmshurst
https://ebookultra.com/download/designing-embedded-systems-with-pic-
microcontrollers-second-edition-principles-and-applications-tim-
wilmshurst/
POJOs in Action Developing Enterprise Applications with
Lightweight Frameworks 1st Edition Chris Richardson
https://ebookultra.com/download/pojos-in-action-developing-enterprise-
applications-with-lightweight-frameworks-1st-edition-chris-richardson/
Sun Certification Training Guide 310 080 Java 2 Enterprise
Edition J2EE Web Component Developer Alain Trottier
https://ebookultra.com/download/sun-certification-training-
guide-310-080-java-2-enterprise-edition-j2ee-web-component-developer-
alain-trottier/
Java 2 Enterprise Edition J2EE Web Component Developer
Exam Cram 2 Exam Cram 310 080 Alain Trottier
https://ebookultra.com/download/java-2-enterprise-edition-j2ee-web-
component-developer-exam-cram-2-exam-cram-310-080-alain-trottier/
Designing SQL Server 2000 Databases for Net Enterprise
Servers 1st Edition Robert A. Patton
https://ebookultra.com/download/designing-sql-server-2000-databases-
for-net-enterprise-servers-1st-edition-robert-a-patton/
Designing Enterprise Applications with the J2EE Platform 2nd Edition Inderjeet Singh
Designing Enterprise Applications with the J2EE
Platform 2nd Edition Inderjeet Singh Digital Instant
Download
Author(s): Inderjeet Singh
ISBN(s): 0201787903
Edition: 2
File Details: PDF, 5.07 MB
Year: 2002
Language: english
Designing Enterprise Applications with the J2EE Platform 2nd Edition Inderjeet Singh
Designing Enterprise Applications
with the J2EETM
Platform, Second Edition
DEA2e.book Page 1 Friday, March 8, 2002 12:31 AM
The Java™
Series
(AW to Provide Film)
DEA2e.book Page 2 Friday, March 8, 2002 12:31 AM
Designing Enterprise Applications
with the J2EETM
Platform, Second Edition
Inderjeet Singh, Beth Stearns,
Mark Johnson, and the Enterprise Team
Boston • San Francisco • New York • Toronto • Montreal
London • Munich • Paris • Madrid
Capetown • Sydney • Tokyo • Singapore • Mexico City
DEA2e.book Page 3 Friday, March 8, 2002 12:31 AM
Copyright © 2002 Sun Microsystems, Inc.
901 San Antonio Road, Palo Alto, California 94303 U.S.A.
All rights reserved.
Sun Microsystems, Inc., has intellectual property rights relating to implementations of the technology
described in this publication. In particular, and without limitation, these intellectual property rights
may include one or more U.S. patents, foreign patents, or pending applications. Sun, Sun Microsys-
tems, the Sun Logo, Java Embedded Server, Java, Jini, Solaris, Forte, JDK, PersonalJava, J2ME, Java-
Beans, EJB, and JavaMail are trademarks or registered trademarks of Sun Microsystems, Inc., in the
United States and other countries. UNIX is a registered trademark in the United States and other coun-
tries, exclusively licensed through X/Open Company, Ltd.
THIS PUBLICATION IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAR-
RANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-
INFRINGEMENT.
THIS PUBLICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHI-
CAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION HEREIN;
THESE CHANGES WILL BE INCORPORATED IN NEW EDITIONS OF THE PUBLICATION.
SUN MICROSYSTEMS, INC., MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE
PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THIS PUBLICATION AT ANY
TIME.
The publisher offers discounts on this book when ordered in quantity for special sales. For more infor-
mation, please contact:
Pearson Education Corporate Sales Division
One Lake Street
Upper Saddle River, NJ 07458
(800) 382-3419
corpsales@pearsontechgroup.com
Visit Addison-Wesley on the Web: www.aw.com/cseng/
Library of Congress Control Number: 2002102513
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or
transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording, or other-
wise, without the prior consent of the publisher. Printed in the United States of America. Published
simultaneously in Canada.
ISBN 0-201-78790-3
Text printed on recycled paper
1 2 3 4 5 6 7 8 9 10—CRS—0605040302
First printing, March 2002
DEA2e.book Page 4 Friday, March 8, 2002 12:31 AM
Contents
v
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xiii
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xv
About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..xix
1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1
1.1 Challenges of Enterprise Application Development. . . . . . . . . . . . . . 2
1.1.1 Programming Productivity . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1.2 Integration with Existing Systems. . . . . . . . . . . . . . . . . . . . . 4
1.1.3 Freedom of Choice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1.4 Response to Demand. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1.5 Maintaining Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 The Platform for Enterprise Solutions . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2.1 J2EE Platform Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2.2 J2EE Platform Benefits . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.3 J2EE Application Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.3.1 Multitier Application Scenario . . . . . . . . . . . . . . . . . . . . . . 16
1.3.2 Stand-Alone Client Scenario. . . . . . . . . . . . . . . . . . . . . . . . 18
1.3.3 Web-Centric Application Scenario . . . . . . . . . . . . . . . . . . . 19
1.3.4 Business-to-Business Scenario . . . . . . . . . . . . . . . . . . . . . . 20
1.4 How This Book Is Organized . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1.6 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2 J2EE Platform Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
2.1 Component Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.1.1 Types of J2EE Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.1.2 Web Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.1.3 Enterprise JavaBeans Components . . . . . . . . . . . . . . . . . . . 28
2.1.4 Components, Containers, and Services . . . . . . . . . . . . . . . . 31
2.2 Platform Roles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
DEA2e.book Page v Friday, March 8, 2002 12:31 AM
CONTENTS
vi
2.2.1 J2EE Product Provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.2.2 Application Component Provider . . . . . . . . . . . . . . . . . . . . 33
2.2.3 Application Assembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.2.4 Deployer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.2.5 System Administrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.2.6 Tool Provider. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.3 Platform Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.3.1 Naming Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.3.2 Deployment Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.3.3 Transaction Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.3.4 Security Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
2.4 Service Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.4.1 JDBC API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.4.2 Java Transaction API and Service. . . . . . . . . . . . . . . . . . . . 43
2.4.3 Java Naming and Directory Interface . . . . . . . . . . . . . . . . . 43
2.4.4 J2EE Connector Architecture . . . . . . . . . . . . . . . . . . . . . . . 43
2.4.5 Java API for XML Processing Technology . . . . . . . . . . . . 44
2.5 Communication Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2.5.1 Internet Protocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2.5.2 Remote Method Invocation Protocols. . . . . . . . . . . . . . . . . 46
2.5.3 Object Management Group Protocols. . . . . . . . . . . . . . . . . 46
2.5.4 Messaging Technologies. . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.5.5 Data Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
2.6 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
2.7 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3 The Client Tier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51
3.1 Client Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.1.1 Network Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.1.2 Security Considerations. . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.1.3 Platform Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.2 General Design Issues and Guidelines . . . . . . . . . . . . . . . . . . . . . . . 54
3.3 Design Issues and Guidelines for Browser Clients. . . . . . . . . . . . . . 54
3.3.1 Presenting the User Interface . . . . . . . . . . . . . . . . . . . . . . . 55
3.3.2 Validating User Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.3.3 Communicating with the Server . . . . . . . . . . . . . . . . . . . . . 58
3.3.4 Managing Conversational State . . . . . . . . . . . . . . . . . . . . . 59
3.4 Design Issues and Guidelines for Java Clients . . . . . . . . . . . . . . . . . 60
3.4.1 Presenting the User Interface . . . . . . . . . . . . . . . . . . . . . . . 61
DEA2e.book Page vi Friday, March 8, 2002 12:31 AM
CONTENTS vii
3.4.2 Validating User Inputs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
3.4.3 Communicating with the Server . . . . . . . . . . . . . . . . . . . . . 65
3.4.4 Managing Conversational State. . . . . . . . . . . . . . . . . . . . . . 69
3.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
3.6 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
4 The Web Tier. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75
4.1 The Purpose of the Web Tier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
4.2 Web-Tier Technologies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
4.2.1 Traditional Web-Tier Technologies . . . . . . . . . . . . . . . . . . 76
4.2.2 Web-Tier Technologies in the J2EE Platform. . . . . . . . . . . 78
4.2.3 The Web Container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
4.2.4 Java Servlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
4.2.5 JavaServer Pages(JSP) Technology . . . . . . . . . . . . . . . . . . 80
4.2.6 Web-Tier Technology Guidelines. . . . . . . . . . . . . . . . . . . . 82
4.3 Web-Tier Application Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
4.4 Web-Tier Application Framework Design . . . . . . . . . . . . . . . . . . . . 94
4.4.1 Structuring the Web Tier. . . . . . . . . . . . . . . . . . . . . . . . . . . 96
4.4.2 Web-Tier MVC Controller Design . . . . . . . . . . . . . . . . . . . 98
4.4.3 Web-Tier MVC View Design . . . . . . . . . . . . . . . . . . . . . . 110
4.4.4 Web-Tier MVC Model Design . . . . . . . . . . . . . . . . . . . . . 113
4.4.5 Web Application Frameworks. . . . . . . . . . . . . . . . . . . . . . 114
4.4.6 Separating Business Logic from Presentation. . . . . . . . . . 115
4.4.7 Web-Tier State. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
4.4.8 Distributable Web Applications . . . . . . . . . . . . . . . . . . . . 123
4.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
4.6 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
5 The Enterprise JavaBeans Tier. . . . . . . . . . . . . . . . . . . . . . . . . . . . .129
5.1 Business Logic and Business Objects. . . . . . . . . . . . . . . . . . . . . . . 130
5.1.1 Common Requirements of Business Objects . . . . . . . . . . 131
5.2 Enterprise Beans as J2EE Business Objects . . . . . . . . . . . . . . . . . . 134
5.2.1 Enterprise Beans and EJB Containers. . . . . . . . . . . . . . . . 136
5.3 Remote and Local Client Views . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
5.3.1 Guidelines for Using Local or Remote Client Views . . . . 141
5.3.2 Entity Beans and Local Client Views . . . . . . . . . . . . . . . . 142
5.4 Entity Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
5.4.1 Guidelines for Using Entity Beans . . . . . . . . . . . . . . . . . . 143
5.4.2 Entity Bean Persistence. . . . . . . . . . . . . . . . . . . . . . . . . . . 144
DEA2e.book Page vii Friday, March 8, 2002 12:31 AM
CONTENTS
viii
5.4.3 When to Use Bean-Managed Persistence . . . . . . . . . . . . . 149
5.5 Session Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
5.5.1 Stateful Session Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
5.5.2 Stateless Session Beans. . . . . . . . . . . . . . . . . . . . . . . . . . . 151
5.6 Message-Driven Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
5.6.1 Uses of Message-Driven Beans. . . . . . . . . . . . . . . . . . . . . 154
5.6.2 Example: Invoice Message-Driven Bean . . . . . . . . . . . . . 155
5.7 Design Guidelines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
5.7.1 Remote versus Local Client Access for Entity Beans. . . . 157
5.7.2 Session Beans as a Facade to Entity Beans. . . . . . . . . . . . 157
5.7.3 Fine-Grained versus Coarse-Grained Object Access . . . . 158
5.7.4 Master-Detail Modeling Using Enterprise Beans . . . . . . . 160
5.7.5 Data Access Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
5.7.6 Implementing an Entity Bean without a Create Method. . 163
5.7.7 Representing References to Entity Beans . . . . . . . . . . . . . 163
5.8 Portability Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
5.8.1 Typecast Remote References . . . . . . . . . . . . . . . . . . . . . . 165
5.8.2 Mark Non-Serializable Fields Transient . . . . . . . . . . . . . . 165
5.8.3 Bean-Managed Persistence and Portability. . . . . . . . . . . . 166
5.9 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
5.10 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
6 Integrating with the Enterprise Information System Tier. . . . .171
6.1 Integration Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
6.1.1 An Internet E-Store Application . . . . . . . . . . . . . . . . . . . . 172
6.1.2 An Intranet Human Resources Application . . . . . . . . . . . 174
6.1.3 A Distributed Purchasing Application . . . . . . . . . . . . . . . 174
6.1.4 An Order Fulfillment Application. . . . . . . . . . . . . . . . . . . 176
6.2 J2EE Integration Technologies. . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
6.2.1 J2EE Connector Architecture . . . . . . . . . . . . . . . . . . . . . . 177
6.2.2 Java Message Service API . . . . . . . . . . . . . . . . . . . . . . . . 179
6.2.3 JDBC and RDBMS Access. . . . . . . . . . . . . . . . . . . . . . . . 180
6.3 Application Integration Design Approaches. . . . . . . . . . . . . . . . . . 181
6.3.1 Synchronous Integration . . . . . . . . . . . . . . . . . . . . . . . . . . 182
6.3.2 Asynchronous Integration . . . . . . . . . . . . . . . . . . . . . . . . . 183
6.3.3 Comparing Approaches. . . . . . . . . . . . . . . . . . . . . . . . . . . 185
6.3.4 Data Integration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
6.4 Developing an Integration Layer . . . . . . . . . . . . . . . . . . . . . . . . . . 186
6.4.1 Programming Access to Data and Functions . . . . . . . . . . 187
DEA2e.book Page viii Friday, March 8, 2002 12:31 AM
CONTENTS ix
6.4.2 Using Tools for EIS Integration . . . . . . . . . . . . . . . . . . . . 187
6.4.3 Developing EIS Access Objects . . . . . . . . . . . . . . . . . . . . 188
6.4.4 Guidelines for Connection Management. . . . . . . . . . . . . . 193
6.4.5 Security Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
6.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
6.6 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
7 Packaging and Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .201
7.1 Packaging Components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
7.2 Roles and Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
7.2.1 Application Component Provider Tasks . . . . . . . . . . . . . . 204
7.2.2 Application Assembler Tasks . . . . . . . . . . . . . . . . . . . . . . 206
7.2.3 Deployer Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
7.3 Packaging J2EE Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
7.3.1 EJB Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
7.3.2 EJB Module Packaging Guidelines. . . . . . . . . . . . . . . . . . 210
7.3.3 Web Modules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
7.3.4 Packaging Components into Web Modules . . . . . . . . . . . 215
7.3.5 Application Client Modules . . . . . . . . . . . . . . . . . . . . . . . 222
7.3.6 Resource Adapter Modules . . . . . . . . . . . . . . . . . . . . . . . . 222
7.4 Deployment Descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
7.4.1 J2EE Naming Environment. . . . . . . . . . . . . . . . . . . . . . . . 223
7.4.2 Specifying Deployment Descriptor Elements . . . . . . . . . . 225
7.4.3 Naming Convention Recommendations . . . . . . . . . . . . . . 239
7.5 Deployment Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
7.5.1 Deployment Tool Actions . . . . . . . . . . . . . . . . . . . . . . . . . 242
7.5.2 Deployment Tool Requirements . . . . . . . . . . . . . . . . . . . . 244
7.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
7.7 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
8 Transaction Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .251
8.1 Transactional Concepts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
8.1.1 ACID Transaction Properties . . . . . . . . . . . . . . . . . . . . . . 252
8.1.2 Transaction Participants . . . . . . . . . . . . . . . . . . . . . . . . . . 253
8.1.3 Transaction Demarcation. . . . . . . . . . . . . . . . . . . . . . . . . . 253
8.1.4 Distributed Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . 253
8.1.5 Two-Phase Commit Protocol . . . . . . . . . . . . . . . . . . . . . . 255
8.2 J2EE Platform Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
8.2.1 Accessing Multiple Resources within a Transaction. . . . . 256
8.2.2 Transactions across Servers. . . . . . . . . . . . . . . . . . . . . . . . 258
DEA2e.book Page ix Friday, March 8, 2002 12:31 AM
CONTENTS
x
8.3 J2EE Transaction Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
8.4 Client Tier Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
8.5 Web Tier Transaction Guidelines. . . . . . . . . . . . . . . . . . . . . . . . . . 261
8.6 Enterprise JavaBeans Tier Transactions. . . . . . . . . . . . . . . . . . . . . 262
8.6.1 Bean-Managed Transaction Demarcation. . . . . . . . . . . . . 263
8.6.2 Container-Managed Transaction Demarcation . . . . . . . . . 264
8.6.3 Transaction Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
8.6.4 Enterprise JavaBeans Tier Transaction Guidelines. . . . . . 266
8.7 EIS Tier Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
8.7.1 JTA Transactions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
8.7.2 Resource Manager Local Transactions . . . . . . . . . . . . . . . 269
8.7.3 EIS Tier Transaction Guidelines. . . . . . . . . . . . . . . . . . . . 269
8.7.4 Compensating Transactions . . . . . . . . . . . . . . . . . . . . . . . 269
8.7.5 Isolation Level. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
8.7.6 Performance with Multiple Resource Managers. . . . . . . . 273
8.8 J2EE Resource Manager Types . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
8.8.1 JDBC Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
8.8.2 JMS Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
8.8.3 J2EE Connector Architecture . . . . . . . . . . . . . . . . . . . . . . 274
8.9 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
8.10 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
9 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279
9.1 Security Threats and Mechanisms . . . . . . . . . . . . . . . . . . . . . . . . . 279
9.2 Authentication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
9.2.1 Protection Domains. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
9.2.2 Authentication Mechanisms . . . . . . . . . . . . . . . . . . . . . . . 284
9.2.3 Authentication Call Patterns . . . . . . . . . . . . . . . . . . . . . . . 292
9.2.4 Exposing Authentication Boundaries with References. . . 293
9.3 Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
9.3.1 Declarative Authorization . . . . . . . . . . . . . . . . . . . . . . . . . 294
9.3.2 Programmatic Authorization. . . . . . . . . . . . . . . . . . . . . . . 295
9.3.3 Declarative versus Programmatic Authorization . . . . . . . 296
9.3.4 Isolation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
9.3.5 Affects of Identity Selection . . . . . . . . . . . . . . . . . . . . . . . 297
9.3.6 Encapsulation for Access Control. . . . . . . . . . . . . . . . . . . 297
9.3.7 Controlling Access to J2EE Resources . . . . . . . . . . . . . . . 298
9.3.8 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
9.4 Protecting Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
DEA2e.book Page x Friday, March 8, 2002 12:31 AM
CONTENTS xi
9.4.1 Integrity Mechanisms . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
9.4.2 Confidentiality Mechanisms . . . . . . . . . . . . . . . . . . . . . . . 305
9.4.3 Identifying Sensitive Components . . . . . . . . . . . . . . . . . . 305
9.4.4 Ensuring Confidentiality of Web Resources. . . . . . . . . . . 306
9.5 Auditing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
9.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
9.7 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
10 J2EE Internationalization and Localization . . . . . . . . . . . . . . . . .311
10.1 Internationalization Concepts and Terminology. . . . . . . . . . . . . . . 312
10.1.1 Internationalization, Localization, and Locale . . . . . . . . . 312
10.1.2 Character Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
10.1.3 Encodings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
10.2 Using J2SE Internationalization APIs in J2EE Applications . . . . . 316
10.2.1 Resource Bundles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
10.2.2 Message Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
10.2.3 Date Formatting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
10.2.4 Collation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
10.3 Web Tier Internationalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
10.3.1 Tracking Locales and Encodings. . . . . . . . . . . . . . . . . . . . 321
10.3.2 Presentation Component Design . . . . . . . . . . . . . . . . . . . . 325
10.3.3 Internationalizing and Localizing JSP Pages . . . . . . . . . . 327
10.4 EIS Tier Internationalization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
10.4.1 Persistent Localized Data . . . . . . . . . . . . . . . . . . . . . . . . . 332
10.4.2 Internationalizing Database Schema . . . . . . . . . . . . . . . . . 334
10.5 Internationalized Application Design . . . . . . . . . . . . . . . . . . . . . . . 336
10.6 Internationalizing Applications with XML. . . . . . . . . . . . . . . . . . . 337
10.6.1 Generating Localized Dynamic Content with XSLT . . . . 337
10.6.2 Communicating Locale within an Application . . . . . . . . . 338
10.6.3 Communicating Locale among Applications . . . . . . . . . . 338
10.7 Localizing Error and Logging Messages . . . . . . . . . . . . . . . . . . . . 341
10.7.1 Client Messages and Application Exceptions . . . . . . . . . . 341
10.7.2 System Exceptions and Message Logging . . . . . . . . . . . . 344
10.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
10.9 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
11 Architecture of the Sample Application . . . . . . . . . . . . . . . . . . . . .347
11.1 J2EE Architecture Approaches . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
11.1.1 Model-View-Controller Architecture . . . . . . . . . . . . . . . . 348
DEA2e.book Page xi Friday, March 8, 2002 12:31 AM
CONTENTS
xii
11.1.2 J2EE Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
11.2 Sample Application Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
11.3 Designing the Sample Application . . . . . . . . . . . . . . . . . . . . . . . . . 353
11.3.1 Choosing Application Tiers . . . . . . . . . . . . . . . . . . . . . . . 355
11.3.2 Choosing Local or Distributed Architecture . . . . . . . . . . . 357
11.4 Architecture of the Sample Application . . . . . . . . . . . . . . . . . . . . . 359
11.4.1 Application Web Site Architecture . . . . . . . . . . . . . . . . . . 360
11.4.2 Fulfillment Center Architecture . . . . . . . . . . . . . . . . . . . . 375
11.5 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
11.6 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
Afterword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .385
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .387
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .405
DEA2e.book Page xii Friday, March 8, 2002 12:31 AM
xiii
Foreword
YOU’RE holding one part of a truly stellar phenomenon in the computing indus-
try: the Java 2 Platform, Enterprise Edition. This book is a key piece of a visionary
effort that began more than two years ago with the introduction of the J2EE plat-
form. In that time, the J2EE engineering team has defined a new ecosystem for net-
worked computing and taught the world a new way to develop distributed
applications.
This team has changed the computing world on many levels. They’ve rein-
forced the core values of Java technology: portability, scalability, security, and
community. They’ve redefined the model for developing big, industrial-strength
enterprise applications. They’ve invented new licensing models, driven a new
compatibility model, and invigorated a new adoption model. Through the Java
Community Process, they’ve taught intense competitors that working together—
and building smarter—can be the key to successfully growing a marketplace that
offers more for everyone.
With the release of the J2EE 1.3 platform, the momentum continues. Six
months after the initial release of the J2EE 1.3 platform, the introduction of com-
patible products is running 56% over the rate for the previous version.
Part of the reason for this phenomenal uptake is, of course, the range of new
features in the J2EE 1.3 platform. These include improved container-managed
persistence, the new EJB Query Language, message-driven EJBs, support for the
J2EE Connector architecture, as well as enhancements such as servlet filters and
improved JSP tag library support. Our J2EE licensees have been eager to intro-
duce these features to the platform, and J2EE developers have been anxious to
begin taking advantage of them.
In this regard, the Java BluePrints team truly stands alone—first out of the box
with real solutions and tested guidelines to help you use these features to best
advantage. Because of the quality of their efforts, Java BluePrints has also been a
phenomenal success during the past two years. More than a half million develop-
ers have downloaded the BluePrints book and demo application code. A dozen
application server vendors now redistribute J2EE BluePrints with their J2EE com-
patible products. Four vendors have even introduced commercial products based
on J2EE BluePrints. Elsewhere, BluePrints is recognized, written about, and
praised by every major Java technology-focused publication. A number of techni-
DEA2e.book Page xiii Friday, March 8, 2002 12:31 AM
FOREWORD
xiv
cal institutes even use BluePrints to train the next generation of Java application
developers.
The Java software organization focuses on efforts like these because we see
the net effect: a huge win for software developers everywhere, at all levels of the
software development food chain. By fostering Java technology standards like the
J2EE platform and providing content like BluePrints, we’re working to ensure that
the Java software development community continues to grow, flourish, and
mature.
This book is central to that effort. The enterprise team who brought it together
are thought leaders who can help you build the skill sets you need to be ready for
new opportunities. Like you, they stay awake nights thinking about how to build
applications that are more flexible, more portable, higher performance, and easier
to develop. They’re tuned into solving the problems that you face day to day.
Working alongside the folks who define and implement the technologies they are
using, they explore the “what-if” scenarios that this rich platform suggests and sift
through design options to come up with clear guidelines for the what and how of
software design on the J2EE platform.
The future holds great things for Java technology and the BluePrints program.
During the coming months, our Java Web Services Developer Pack, The Java Web
Services Tutorial, and Java BluePrints for Web Services will help developers build
applications that take advantage of the services-on-demand promised by the Sun
ONE architecture. Building on what’s already available, these offerings will
enhance the phenomenal success of the J2EE platform and the Java application
marketplace.
By taking advantage of the gold mine of advice you’ll find in this book, you
too can be part of the phenomenal success that is the J2EE platform.
Rich Green
Vice President and General Manager
Java and XML Software, Sun Microsystems
Santa Clara, California
February, 2002
DEA2e.book Page xiv Friday, March 8, 2002 12:31 AM
xv
Preface
THIS book, now in its second edition, describes standard approaches to designing
multitier enterprise applications with the JavaTM
2 Platform, Enterprise Edition.
This book, and the accompanying Java Pet Store sample application, are part of the
successful Java BluePrints program created by Sun Microsystems with the introduc-
tion of the J2EE platform. This program has been used by thousands of application
architects, developers, and students to attain better understanding of the program-
ming model inherent in the J2EE platform.
This book and the Java BluePrints program don’t provide information on how to
use individual Java technologies to write applications—that’s the role of the com-
panion Java Tutorial program. Instead, Java BluePrints focuses on guidelines for
application architecture, such as distributing J2EE application functionality across
tiers and choosing among design options within each tier. This book assumes that
the reader already has basic knowledge of the J2EE platform. We recommend that
readers without this knowledge familiarize themselves with the J2EE Tutorial either
before or while reading this volume. See “Related Information” later in the Preface
for details.
This book describes the architecture and design principles employed in building
J2EE applications, and explores of the specific approach adopted by the sample
application. Striking a balance between specific details and broad principles is
never easy. The hope behind this effort is that the principles presented here are both
consistent with and a useful complement to the implementation provided by the
sample applications documented in this book.
This book is intended primarily for system architects and enterprise application
developers engaged in or considering a transition to the J2EE platform. It is also
useful for product vendors interested in developing applications consistent with the
J2EE standard.
Obtaining the Sample Application
You can download the Java Pet Store sample application, version 1.3, which is
described in this book, from:
http://java.sun.com/blueprints/code/
DEA2e.book Page xv Friday, March 8, 2002 12:31 AM
PREFACE
xvi
The sample application requires a J2EE v1.3-compliant platform on which to
run. You can download J2EE SDKTM
, which is a freely available implementation of
that platform, from:
http://java.sun.com/j2ee/download.html
Related Information
Pointers to J2EE documentation can be found at:
http://java.sun.com/j2ee/docs.html
For information on how to use the J2EE SDK to construct multitier enterprise appli-
cations, refer to the J2EE Tutorial, available at:
http://java.sun.com/j2ee/tutorial/
The J2EE technologies cited in this book are described in their specifications:
• Java™ 2 Platform, Enterprise Edition Specification, Version 1.3 (J2EE spec-
ification). Available at <http://java.sun.com/j2ee/download.html>
• Java™ 2 Platform, Standard Edition Specification, Version 1.3 (J2SE specifi-
cation). Available at <http://java.sun.com/j2se/1.3/docs/>
• Java™ Servlet Specification, Version 2.3 (Servlet specification). Available at
<http://java.sun.com/products/servlet/>
• JavaServer Pages™ Specification, Version 1.2 (JSP specification). Available
at <http://java.sun.com/products/jsp/>
• Enterprise JavaBeans™Specification, Version 2.0 (EJB specification). Avail-
able at <http://java.sun.com/products/ejb/>
• Java™ API for XML Processing Specification, Version 1.1 (JAXP specifica-
tion). Available at <http://java.sun.com/xml/jaxp/>
• J2EE™ Connector Architecture Specification, Version 1.0 (Connector speci-
fication). Available at <http://java.sun.com/j2ee/connector/>
• JDBC™ API Specification, Version 2.0 (JDBC specification). Available at
<http://java.sun.com/products/jdbc/>
DEA2e.book Page xvi Friday, March 8, 2002 12:31 AM
PREFACE xvii
• JDBC™ Standard Extension API Specification, Version 2.0 (JDBC extension
specification). Available at <http://java.sun.com/products/jdbc/>
• Java™ Transaction API Specification, Version 1.0.1 (JTA specification).
Available at <http://java.sun.com/products/jta/>
• Java Naming and Directory Interface™ Specification, Version 1.2 (JNDI
specification). Available at <http://java.sun.com/products/jndi/>
• Java IDL. Available at <http://java.sun.com/j2se/1.3/docs/guide/idl/>
• RMI over IIOP. Available at <http://java.sun.com/products/rmi-iiop/>
• Java™ Message Service Specification, Version 1.0.2 (JMS specification).
Available at <http://java.sun.com/products/jms/>
• Java™ Authentication and Authorization Service Specification, Version 1.0
(JAAS specification). Available at <http://java.sun.com/products/jaas/>
• JavaMail™ API Specification, Version 1.2 (JavaMail specification).
Available at <http://java.sun.com/products/javamail/>
• JavaBeans™ Activation Framework Specification, Version 1.0.1 (JAF speci-
fication). Available at <http://java.sun.com/products/javabeans/glas-
gow/jaf.html>
Typographic Conventions
Table 0.1 describes the typographic conventions used in this book.
Table 0.1 Typographic Conventions
Typeface or
Symbol Meaning Example
AaBbCc123 The names of commands, files, and
directories; interface, class,
method, and deployment descriptor
element names; programming
language keywords
Edit the file Main.jsp.
How to retrieve a UserTransaction
object.
Specify the resource-ref element.
AaBbCc123 Variable name The files are named XYZfile.
AaBbCc123 Book titles, new words or terms, or
words to be emphasized
Read Chapter 6 in User’s Guide. These
are called class options. You must be root
to do this.
DEA2e.book Page xvii Friday, March 8, 2002 12:31 AM
PREFACE
xviii
Acknowledgments
This book is the result of many people’s efforts.
The authors listed for each chapter had primary responsibility for the content
provided there and also made significant contributions to other chapters. In addition,
Abhishek Chauhan, Vinita Khanna, and Stephanie Bodoff contributed significantly
to the chapters in the first edition of this book. Liz Blair was instrumental in devel-
oping the initial drafts of the EJB-tier chapter.
We are indebted to Thierry Violleau, Umit Yalcinalp, Kate Stout, Norbert Lin-
denberg, and Danny Coward for their comprehensive reviews and thoughtful com-
ments on many chapters. We would also like to thank Eduardo Pelegri-Llopart, Jon
Ellis, David Bowen, Monica Pawlan, Tim Lindholm, Tom Kast, Mark Hapner, Bill
Shannon, John Crupi, Sanjeev Krishnan, Stephanie Bodoff, Dale Green, Mark Roth,
Martin Flynn, Brian Beck, Andrey Dikanskiy, and Craig McClanahan for their
input.
Our special thanks go to our management, Larry Freeman, Cori Kaylor, Vivek
Nagar, and Jeff Jackson, for their whole-hearted support and commitment to the
BluePrints program and to this book in particular.
We would never have made it to the end of this project without the support of
Suzy Pelouch who did an excellent job at pulling together all the pieces.
The authors of the J2EE specifications and the developers of the reference
implementation provided useful input at various points during the development of
the J2EE programming model.
DEA2e.book Page xviii Friday, March 8, 2002 12:31 AM
xix
About the Authors
Authors listed in alphabetical order by first name:
BETH STEARNS is the principal partner of ComputerEase Publishing, a computer
consulting firm she founded in 1982. Her client list includes Sun Microsystems,
Inc., Silicon Graphics, Inc., Oracle Corporation, and Xerox Corporation. Among
her publications are the “Java Native Interface” chapter in The Java Tutorial Contin-
ued book in the Addison-Wesley Java Series, “The EJB Programming Guide” for
Inprise Corporation, and “Understanding EDT,” a guide to Digital Equipment Cor-
poration’s text editor. She co-authored with Vlada Matena the book, Applying
Enterprise JavaBeans: Component-Based Development for the J2EE Platform,
which is part of the Addison-Wesley Java Series. She is also a co-author with Rahul
Sharma and Tony Ng of another book in the Addison-Wesley Java Series, J2EE
Connector Architecture and Enterprise Application Integration.
GREG MURRAY is a member of the Java BluePrints team at Sun Microsystems.
He is a contributing author to the first edition of this book. Greg contributed to the
design of the Java Pet Store sample application with an emphasis on the Web tier.
Prior to working on the Java BluePrints team, Greg was a member of the Global
Products Engineering group of Sun Microsystems, where he developed internation-
alization tools.
INDERJEET SINGH is the lead architect on the Java BluePrints team at Sun Micro-
systems, where he investigates the best uses of J2EE technologies for enterprise
application design. Inderjeet has been involved with the Java BluePrints program
since its inception. He is a regular speaker on enterprise application design. In the
past, Inderjeet has also designed fault-tolerance software for large-scale distributed
telecommunications switching systems. Inderjeet holds an M.S. in computer science
from Washington University in Saint Louis, and a B.Tech. in computer science and
engineering from Indian Institute of Technology, Delhi.
DEA2e.book Page xix Friday, March 8, 2002 12:31 AM
ABOUT THE AUTHORS
xx
JIM INSCORE manages technical publications for the Java 2 Platform, Enterprise
Edition, in the Java Software Group of Sun Microsystems. His roles include over-
seeing developer documentation, such as the J2EE Tutorial and J2EE BluePrints,
providing developer content for the java.sun.com Web site. Jim serves as technical
editor on the Java Series, Enterprise Edition, from Addison-Wesley and is a co-
author, with Rick Cattel, of the Java Series book, J2EE Technology in Practice. Jim
has been involved with object-oriented and enterprise-related technologies for more
than 15 years, working with developer documentation and marketing programs for
organizations that include Oracle, Ingres, NeXT, Kaleida, and Macromedia. Prior to
that, he spent 10 years writing marketing communications materials for the techni-
cal marketplace.
LINDA DEMICHIEL is the specification lead of the Expert Group for the Enter-
prise JavaBeansTM specification, under the Java Community Process program, and a
Senior Staff Engineer in the J2EE platform group at Sun Microsystems. She has
over 15 years of industry experience in the areas of databases, distributed comput-
ing, and OO. She has a Ph.D. in computer science from Stanford University.
MARK JOHNSON is a software developer, trainer, writer, and speaker living in
Fort Collins, Colorado. He is President of Elucify Technical Communications, a
Colorado corporation dedicated to making accessible difficult or novel topics in
science and technology through clear explanation and example. He has been a col-
umnist at JavaWorld since 1997 and is a member of the National Association of
Science Writers. He is currently a consultant with the Java BluePrints group at Sun.
Mark completed a B. S. in computer and electrical engineering at Purdue University
in 1986, followed by two years of graduate work at Purdue, concentrating in signal
processing and computer systems.
NICHOLAS KASSEM is a Senior Staff Engineer with Sun Microsystems and has
influenced and had responsibility for a number of technologies and initiatives within
Java Software, including the Java Web Server, Java Embedded Server, the Servlet
API, JavaServer Pages, Java Message Queuing, and the J2EE programming model.
He is currently leading the Java API for XML Messaging (JAXM) initiative. Nicho-
las has more than twenty years of industry experience and has held senior engineer-
ing and management positions at Philips (Data Systems) and the Santa Cruz
Operation. He has had direct responsibility for a wide variety of engineering
projects, including the development of Data Communications Gateway Hardware
(DISOSS), Novell and Lan Manager protocol stacks, and an implementation of OSF
DEA2e.book Page xx Friday, March 8, 2002 12:31 AM
ABOUT THE AUTHORS xxi
DCE on SCO UNIX. He is an engineering graduate of Birmingham University in
the United Kingdom.
RAHUL SHARMA is the lead architect and specification lead of J2EE Connector
Architecture 1.0 and JAX-RPC specifications. He works as an architect in the J2EE
platform group of Sun Microsystems, Inc. Rahul has also worked on exploring how
the Java platform can be used for building carrier-grade applications. Rahul has an
MBA from Haas School of Business, University of California at Berkeley, and a
B.E. in computer engineering from Delhi University.
RAY ORTIGAS is an engineer with the Java BluePrints group at Sun Microsys-
tems, where he works on wireless and enterprise applications using Java technology.
A former intern with the Java Tutorial, where he authored the “First Cup of Java”
trail, Ray earned his B.Sc. in computer science from the University of Toronto in
Canada.
RON MONZILLO is a Senior Staff Engineer at Sun Microsystems, where he is the
J2EE security specification lead. Ron was responsible for the design and standard-
ization of the EJB secure interoperability protocol, CSIv2. Prior to joining Sun, Ron
worked for the Open Group where he contributed to the evolution of the Distributed
Computing Environment. Ron has also worked for BBN, where he developed
Network Management systems, and as a Principal Investigator for the MITRE Cor-
poration where he researched fault-tolerant distributed database systems and multi-
processor architectures. Ron received an M.S. in computer science from the Univer-
sity of Connecticut and a B.S. in biology from Bates College.
SEAN BRYDON is a member of the Java BluePrints team at Sun Microsystems.
Sean contributed to the design of the Java Pet Store sample application with an
emphasis on the application and the tiers for EIS and the EJB component architec-
ture. In the past, Sean has worked on the JavaLoadTM
team and has spent a summer
as an intern at SunLabs. Sean holds an M.S. in computer science from the Univer-
sity of California at Santa Barbara and also a B.S. in computer science from the Uni-
versity of California at Santa Barbara.
TONY NG is the technical lead of the J2EE SDK and Reference Implementation
at Sun Microsystems, Inc. Previously, he was the implementation lead of the J2EE
Connector Architecture. He is a contributing author to the first edition of Designing
Enterprise Applications with the Java 2 Platform, Enterprise Edition, and J2EE
DEA2e.book Page xxi Friday, March 8, 2002 12:31 AM
ABOUT THE AUTHORS
xxii
Connector Architecture and Enterprise Application Integration in the Addison-
Wesley Java Series. Tony has an M.S. in electrical engineering and computer
science from Massachusetts Institute of Technology and a B.S. in computer
science from the University of Illinois, Urbana-Champaign.
VIJAY RAMACHANDRAN is a member of the technical staff at Sun Microsys-
tems, where he works as the Team Lead of the Java BluePrints team. His major con-
tributions include guidelines on best practices when developing business solutions
using enterprise beans. Before joining the BluePrints team, Vijay was a member of
the Enterprise Server Products Group of Sun Microsystems working on Sun’s enter-
prise server products line. Vijay holds an M.S. in computer science from Santa Clara
University, California, and a B.E. in electrical engineering from Madras University,
India.
DEA2e.book Page xxii Friday, March 8, 2002 12:31 AM
1
C H A P T E R 1
Introduction
by Jim Inscore and Nicholas Kassem
SINCE its introduction more than two years ago, the Java 2 Platform, Enterprise
Edition (J2EE), has rapidly established a new model for developing distributed
applications. This model is based on well-defined components that can automati-
cally take advantage of sophisticated platform services. These components can be
developed according to standard guidelines, combined into applications, deployed
on a variety of compatible server products, and reused for maximum programmer
productivity. This model is intended to both standardize and simplify the kind of
distributed applications required for today’s networked information economy. The
success of the J2EE platform is in large part due to the success of this model.
Today, all leading application server and enterprise information system
vendors have adopted the J2EE standard and introduced products based on the
J2EE platform specification. Application architects and developers have come to
rely on the J2EE standard to help them solve the various design challenges that
face them day to day.
While the fundamentals of the J2EE platform are relatively easy to describe,
mapping these features to architectural issues in the design of distributed applica-
tions requires deeper understanding and careful decision making. Although the
J2EE standard offers a simplified programming model compared to previous alter-
natives, the platform isn’t monolithic. Certain features require that architects and
developers weigh their options before making design decisions and be prepared to
re-think those decisions as they uncover new challenges. That, in turn, requires
some understanding of the design motivations behind the platform and of the
trade-offs involved in applying specific design features to a specific architectural
problem.
DEA2e.book Page 1 Friday, March 8, 2002 12:31 AM
CHAPTER 1 INTRODUCTION
2
Different implementations of the J2EE platform may provide distinguishing
characteristics that improve their performance or development ease in particular
areas. However, the level of abstraction provided by the J2EE standard enables
common themes to be developed, explained, and explored and certain common
design guidelines to be developed. That’s what Java BluePrints is all about. It
answers questions like:
• What’s the best way to apply each type of J2EE component?
• Where does it make sense to use Java servlets and where to use JavaServer
Pages?
• What’s the best way to factor business logic between entity beans and session
beans?
• How do you choose between container-managed and bean-managed persis-
tence when using entity beans?
• What are the design and performance trade-offs between choosing a distribut-
ed architecture and one based on local interfaces?
• In this increasingly security-conscious world, how do you design distributed
applications to be accessible to users who need them and secure from unwant-
ed intrusion?
Before the remainder of this book takes you more deeply into these and other
details of J2EE application architectures, this chapter gives you a look at some of
the design motivations behind the J2EE platform. It describes the high-level bene-
fits of the J2EE platform and discusses ways that using it as the underlying archi-
tecture for distributed applications makes sense for a variety of application
requirements.
1.1 Challenges of Enterprise Application Development
Timing has always been a critical factor when organizations adopt new technolo-
gies, and the accelerated pace of the information-driven business model puts greater
emphasis on response times. Organizations need to be able to project enterprise
systems into various client channels, and to do so in a way that’s reliable, produc-
tive, and capable of sustaining frequent updates to both information and services.
The principal issue is how to keep up with today’s business challenges—whatever
DEA2e.book Page 2 Friday, March 8, 2002 12:31 AM
CHALLENGES OF ENTERPRISE APPLICATION DEVELOPMENT 3
they may be—while maintaining and leveraging the value of existing information
assets. In this environment, timeliness, productivity, security, and predictability are
all absolutely critical to building and maintaining momentum. A number of factors
can enhance or impede an organization’s ability to deliver custom enterprise appli-
cations quickly and to maximize their value over their lifetime.
1.1.1 Programming Productivity
The ability to develop and deploy applications is key to success in the information
economy. Applications must go quickly from prototype to production and must con-
tinue to evolve even after they are deployed.
Productivity is thus vital to responsive application development. Providing
application development teams with standard means to access the services
required by multitier applications and standard ways to support a variety of clients
can contribute to both responsiveness and flexibility.
The current divergence of technologies and programming models is a destabi-
lizing factor in Internet and other distributed computing applications. Traditional
Web technologies such as HTML and Common Gateway Interface (CGI) have
provided a mechanism for distributing dynamic content, while back-end systems
such as transaction processors and database management systems have provided
controlled access to the data to be presented and manipulated. These technologies
present a diversity of programming models: some based on well-defined stan-
dards; others on more ad-hoc standards; and others still on proprietary architec-
tures.
With no single application model, it can be difficult for teams to communicate
application requirements effectively and productively. As a result, architecting
applications becomes more complex. What’s more, the skill sets required to inte-
grate these technologies aren’t well organized for effective division of labor. For
example, CGI development requires coders to define both content and layout of a
dynamic Web page.
Another complicating factor in application development time is the choice of
clients. While many applications can be distributed to Web browser clients
through static or dynamically generated HTML, others may need to support a spe-
cific type of client or to support several types of clients simultaneously. The pro-
gramming model needs to support a variety of client configurations, with
minimum effect on basic application architecture and on the application’s core
business logic.
DEA2e.book Page 3 Friday, March 8, 2002 12:31 AM
CHAPTER 1 INTRODUCTION
4
1.1.2 Integration with Existing Systems
Much of the data of value to organizations has been collected over the years by
existing enterprise information systems. Much of the programming investment
resides in applications on those same systems. The challenge for developers of
enterprise applications is how to reuse and commoditize these existing information
assets.
To achieve this goal, application developers need standard ways to access
middle-tier and back-end services such as database management systems and
transaction monitors. They also need systems that provide these services consis-
tently, so that new programming models or styles aren’t required as integration
expands to encompass various systems within an enterprise.
1.1.3 Freedom of Choice
Application development responsiveness requires the ability to mix and match solu-
tions to come up with the optimum configuration for the task at hand. Freedom of
choice in enterprise application development should extend from servers to tools to
components. The wide range of J2EE compatible solutions available today and in
the future ensures the maximum freedom of choice.
The availability of choices among server products gives an organization the
ability to select configurations tailored to their application requirements. It also
provides the ability to move quickly and easily from one configuration to another
as internal and external demand requires.
Access to the appropriate tools for the job is another important choice. Devel-
opment teams should be able to adopt new tools as new needs arise, including
tools from server vendors and third-party tool developers. What’s more, each
member of a development team should have access to tools that are most appro-
priate to their skill set and contribution.
Finally, developers should be able to choose from a ready market of off-the-
shelf application components to take advantage of external expertise and to
enhance development productivity.
1.1.4 Response to Demand
When designing large-scale distributed applications, both availability and scalability
are key considerations. The more easily and automatically that an application can
handle changes in use patterns and system configurations, the better. Systems that
DEA2e.book Page 4 Friday, March 8, 2002 12:31 AM
THE PLATFORM FOR ENTERPRISE SOLUTIONS 5
require any redesign, recoding, or redeployment to achieve either availability or
scalability will limit flexibility and diminish expected performance.
To scale effectively, systems need to be designed to handle multiple client
interactions with ease. They need mechanisms for efficient management of system
resources and services such as database connections and transactions. For highest
availability, they need access to features such as automatic load balancing and
failover, without any effort on the part of the application developer. Applications
should be able to run on any server configuration appropriate to anticipated client
volumes and to easily switch configurations when the need arises. Support for
clustered application deployment environments contributes to achieving many of
these goals.
1.1.5 Maintaining Security
More than ever, information systems security is on the minds of IT managers and
system architects. That’s because protecting information assets to maximize their
value can jeopardize that very value. Traditionally, IT departments have been able to
maintain a relatively high level of control over the environment of both servers and
clients. When information assets are exposed in less-protected environments, it
becomes increasingly important to maintain tight security over the most sensitive
assets, while allowing seemingly unencumbered access to others.
One of the difficulties in integrating disparate systems is providing a unified
security model. Single sign on across internal application and asset boundaries is
important to creating a positive user experience with the applications. Security
needs to be compatible with existing mechanisms. In cases where customers need
to access secure information, the mechanisms need to maintain high security (and
user confidence) while remaining as unobtrusive and transparent as possible.
1.2 The Platform for Enterprise Solutions
The J2EE platform represents a single standard for implementing and deploying
enterprise applications. During its first two years, the J2EE standard’s success has
transformed the marketplace for distributed computing products. This success is
largely due to the fact that the J2EE platform has been designed through an open
process, engaging a range of enterprise computing vendors to ensure that it meets
the widest possible range of enterprise application requirements. As a result, the
J2EE platform addresses the core issues that impede organizations’ efforts to main-
DEA2e.book Page 5 Friday, March 8, 2002 12:31 AM
CHAPTER 1 INTRODUCTION
6
tain a competitive pace in the information economy. Organizations have recognized
this and quickly adopted the new platform standard.
1.2.1 J2EE Platform Overview
The J2EE platform is designed to provide server-side and client-side support for
developing distributed, multitier applications. Such applications are typically con-
figured as a client tier to provide the user interface, one or more middle-tier modules
that provide client services and business logic for an application, and back-end
enterprise information systems providing data management. Figure 1.1 illustrates
the various components and services that make up a typical J2EE environment.
Figure 1.1 J2EE Environment
1.2.1.1 Multitier Model
As illustrated, the J2EE platform provides a multitier distributed application model.
This means that the various parts of an application can run on different devices. The
DEA2e.book Page 6 Friday, March 8, 2002 12:31 AM
THE PLATFORM FOR ENTERPRISE SOLUTIONS 7
J2EE architecture defines a client tier, a middle tier (consisting of one or more sub-
tiers), and a back-end tier. The client tier supports a variety of client types, both
outside and inside of corporate firewalls. The middle tier supports client services
through Web containers in the Web tier and supports business logic component ser-
vices through Enterprise JavaBeansTM
(EJBTM
) containers in the EJB tier. On the back
end, the enterprise information systems in the EIS tier are accessible by way of stan-
dard APIs.
1.2.1.2 Container-Based Component Management
Central to the J2EE component-based development model is the notion of contain-
ers. Containers are standardized runtime environments that provide specific services
to components. Components can expect these services to be available on any J2EE
platform from any vendor. For example, all J2EE Web containers provide runtime
support for responding to client requests, performing request-time processing (such
as invoking JSP pages or servlet behavior), and returning results to the client. In
addition, they provide APIs to support user session management. All EJB containers
provide automated support for transaction and life cycle management of EJB com-
ponents, as well as bean lookup and other services. Containers also provide stan-
dardized access to enterprise information systems; for example, providing access to
relational data through the JDBC API.
In addition, containers provide a mechanism for selecting application behav-
iors at assembly or deployment time. Through the use of deployment descriptors
(XML files that specify component and container behavior), components can be
configured to a specific container’s environment when deployed, rather than in
component code. Features that can be configured at deployment time include
security checks, transaction control, and other management responsibilities.
While the J2EE specification defines the component containers that a platform
implementation must support, it doesn’t specify or restrict the containers’ configu-
rations. Thus, both container types can run on a single platform, Web containers
can live on one platform and EJB containers on another, or a J2EE platform can be
made up of multiple containers on multiple platforms.
1.2.1.3 Support for Client Components
The J2EE client tier provides support for a variety of client types, both within the
enterprise firewall and outside. Clients can be offered through Web browsers by
using plain HTML pages, HTML generated dynamically by JavaServer PagesTM
DEA2e.book Page 7 Friday, March 8, 2002 12:31 AM
CHAPTER 1 INTRODUCTION
8
(JSPTM
) technology, or Java applets. Clients can also be offered as stand-alone Java
language applications. J2EE clients are assumed to access the middle tier primarily
using Web standards, namely HTTP, HTML, and XML. Because of its flexible pro-
gramming model, the J2EE platform can support a number of simple application
models implemented primarily on the strengths of its Web tier component technolo-
gies.
To support more complex user interactions, it may be necessary to provide
functionality directly in the client tier. This functionality is typically implemented
as JavaBeansTM
components that interact with the service in the middle tier via
servlets. Client-tier JavaBeans components would typically be provided by the
service as an applet that is downloaded automatically into a user’s browser. To
eliminate problems caused by old or non-standard versions of the Java Virtual
Machine in a user’s browser, the J2EE application model provides special support
for automatically downloading and installing the Java Plug-in. In addition, the
J2EE platform is flexible enough to support alternate client models easily, includ-
ing wireless phones and handheld devices that use programming models provided
by the Java 2 Platform, Micro Edition.
Client-tier beans can also be contained in a stand-alone application client
written in the Java programming language. In this case, the enterprise typically
would make the client available for users to download from a browser using Java
Web Start technology. Java Web Start technology makes application deployment
portable by providing browser-based download and installation mechanisms. With
both application and deployment portability, this ensures that users can always
access and work with the latest versions of stand-alone application clients.
If desired, non-Java clients such as Visual Basic programs can present J2EE
services to users. Since the service is presented by servlets in the middle tier to
first-tier clients using the standard HTTP protocol, it is easy to access it from
practically any program running on any operating system.
1.2.1.4 Support for Business Logic Components
While simple J2EE applications may be built largely in the client tier, business logic
is often implemented on the J2EE platform in the middle tier as Enterprise
JavaBeanscomponents (also known as enterprise beans). Enterprise beans allow the
component or application developer to concentrate on the business logic while the
complexities of delivering a reliable, scalable service are handled by the EJB con-
tainer.
DEA2e.book Page 8 Friday, March 8, 2002 12:31 AM
THE PLATFORM FOR ENTERPRISE SOLUTIONS 9
In many ways, the J2EE platform and EJB architecture have complementary
goals. The EJB component model is the backbone of industrial-strength application
architectures in the J2EE programming model. The J2EE platform complements the
EJB specification by:
• Fully specifying the APIs that an enterprise bean developer can use to imple-
ment enterprise beans
• Defining the larger, distributed programming environment in which enterprise
beans are used as business logic components
1.2.1.5 Support for the J2EE Standard
The J2EE standard is defined through a set of related specifications. Key among
these are the J2EE specification, the Enterprise JavaBeans specification, the Java
Servlet specification, and the JavaServer Pages specification. Together, these specifi-
cations define the architecture described in this book. In addition to the specifica-
tions, several other technology deliverables support the J2EE standard, including the
J2EE Compatibility Test Suite, the J2EE reference implementation, and the J2EE
SDK.
The J2EE Compatibility Test Suite (CTS) helps maximize the portability of
applications by validating the specification compliance of a J2EE platform product.
This test suite begins where the basic Java Conformance Kit (JCK) leaves off. The
CTS tests conformance to the Java standard extension APIs that are not covered
by a JCK. In addition, it tests a J2EE platform’s ability to run standard end-to-end
applications.
The J2EE reference implementation, a complete implementation of the J2EE
standard provided by Sun Microsystems, represents an operational definition of the
J2EE platform. It is used by licensees as the “gold standard” to determine what their
product must do under a particular set of application circumstances. It is the stan-
dard platform for running the J2EE Compatibility Test Suite, and it can be used by
developers to verify the portability of an application. The J2EE reference implemen-
tation is available in both binary and source code form.
The J2EE SDK, based on the J2EE reference implementation binary, is pro-
vided freely to the developer community to help expedite developer adoption of
the J2EE standard. Although not a commercial product and not available for com-
mercial use, the J2EE SDK is useful for developing application demos and proto-
types, such as the Java Pet Store sample application described in this book. The
J2EE SDK also includes application verification and deployment tools to simplify
DEA2e.book Page 9 Friday, March 8, 2002 12:31 AM
CHAPTER 1 INTRODUCTION
10
development, and the J2EE Tutorial, which provides step-by-step examples and
information that developers need to begin working with the platform.
Another word on J2EE standards and portability: The J2EE specifications have,
by design, set the platform-compatibility bar at a level that’s relatively easy to clear.
Because the platform specifications are developed collaboratively, platform vendors
must have plenty of opportunity to supply J2EE platform implementations. Obvious
and unreasonable implementation hurdles were avoided. For example, there are no
restrictions on vendors adding value to J2EE products by supporting services not
defined in the specifications.
While the J2EE standard is designed to encourage component portability, spe-
cific results are primarily a function of how a component uses services provided by
its container. Vendor-specific features limit component portability. The J2EE speci-
fications spell out a base set of capabilities that a component can count on, providing
components with a level of cross-container portability. Needless to say, an applica-
tion developer expecting to deploy on a specific vendor implementation of the J2EE
platform should be able to do so across a wide range of operating systems and hard-
ware architectures.
1.2.2 J2EE Platform Benefits
With features designed to expedite the process of developing distributed applica-
tions, the J2EE platform offers several benefits:
• Simplified architecture and development
• Freedom of choice in servers, tools, and components
• Integration with existing information systems
• Scalability to meet demand variations
• Flexible security model
1.2.2.1 Simplified Architecture and Development
The J2EE platform supports a simplified, component-based development model.
Because it is based on the Java programming language and the Java 2 Platform,
Standard Edition (J2SETM
platform), this model offers “Write-Once-Run-Any-
whereTM
” portability, supported by any server product that conforms to the J2EE
standard.
DEA2e.book Page 10 Friday, March 8, 2002 12:31 AM
THE PLATFORM FOR ENTERPRISE SOLUTIONS 11
The component-based J2EE development model can enhance application
development productivity in a number of ways:
• Maps easily to application functionality—Component-based application
models map easily and flexibly to the functionality desired from an applica-
tion. As the examples presented throughout this book illustrate, the J2EE plat-
form provides a variety of ways to configure the architecture of an application,
depending on such things as client types required, level of access required to
data sources, and other considerations. Component-based design also simpli-
fies application maintenance, since components can be updated and replaced
independently—new functionality can be shimmed into existing applications
simply by updating selected components.
• Enables assembly- and deploy-time behaviors—Because of the high level of
service standardization, much of the code of a J2EE application can be gener-
ated automatically by tools, with minimal developer intervention. In addition,
components can expect standard services to be available in the runtime envi-
ronment and can dynamically connect to other components by means of con-
sistent interfaces. As a result, many application behaviors can be configured at
application assembly or deployment time, without recoding. Component de-
velopers can communicate requirements to application deployers through spe-
cific deployment descriptors and settings. Tools can automate this process to
further expedite development.
• Supports division of labor—Components help divide the labor of application
development among specific skill sets, enabling each member of a develop-
ment team to focus on his or her ability. Web page authors can create JSP tem-
plates, Java programming language coders can implement application
behavior, domain experts can develop business logic, and application develop-
ers and integrators can assemble and deploy applications. This division of la-
bor also expedites application maintenance. For example, the user interface is
the most dynamic part of many applications, particularly on the Web. With the
J2EE platform, Web page authors can tweak the look and feel of JSP pages
without programmer intervention.
The J2EE specifications define a number of roles, including application com-
ponent provider, application assembler, and application deployer. On some devel-
opment teams, one or two people may perform all these roles, while on others
DEA2e.book Page 11 Friday, March 8, 2002 12:31 AM
CHAPTER 1 INTRODUCTION
12
these tasks may be further subdivided into more specific skill sets (such as user
interface designers, programmers, and so on).
1.2.2.2 Integrating Existing Enterprise Information Systems
The J2EE platform, together with the J2SE platform, includes a number of industry
standard APIs for accessing existing enterprise information systems. Basic access to
these systems is provided by the following APIs:
• The J2EE Connector architecture is the infrastructure for interacting with a va-
riety of Enterprise Information System types, including ERP, CRM, and other
legacy systems.
• The JDBCTM
API is used for accessing relational data from the Java program-
ming language.
• The Java Transaction API (JTA) is the API for managing and coordinating
transactions across heterogeneous enterprise information systems.
• The Java Naming and Directory InterfaceTM
(JNDI) is the API for accessing in-
formation in enterprise name and directory services.
• The Java Message Service (JMS) is the API for sending and receiving messag-
es via enterprise messaging systems such as IBM MQ Series and TIBCO Ren-
dezvous. In the J2EE platform version 1.3, message-driven beans provide a
component-based approach to encapsulating messaging functionality.
• The JavaMailTM
API is used for sending and receiving e-mail.
• Java IDL provides the mechanism for calling CORBA services.
• Java APIs for XML provide support for integration with legacy systems and
applications, and for implementing Web services in the J2EE platform.
In addition, specialized access to enterprise resource planning and mainframe
systems such as IBM’s CICS and IMS is provided through the J2EE Connector
architecture. Since each of these systems is highly complex and specialized, they
require unique tools and support to ensure utmost simplicity to application devel-
opers. Thanks to new integration features in the platform, enterprise beans can
combine the use of connector access objects and service APIs with middle-tier
business logic to accomplish their business functions.
DEA2e.book Page 12 Friday, March 8, 2002 12:31 AM
THE PLATFORM FOR ENTERPRISE SOLUTIONS 13
1.2.2.3 Choice of Servers, Tools, and Components
The J2EE standard and J2EE brand have created a huge marketplace for servers,
tools, and components. The J2EE brand on a server product ensures the consistent
level of service that is fundamental to the goals of the J2EE platform. At the same
time, J2EE standards ensure a lively marketplace for tools and components. Based
on past experience and industry momentum, all leading enterprise software vendors
are expected to provide the marketplace for J2EE 1.3 products.
The standardization and branding of the J2EE platform provides many bene-
fits, including:
• A range of server choices—Application development organizations can ex-
pect J2EE branded platforms from a variety of vendors, providing a range of
choices in hardware platforms, operating systems, and server configurations.
This ensures that businesses get a choice of servers appropriate to their needs.
• Designed for tool support—Both enterprise beans and JSP page components
are designed to be manipulated by graphical development tools and to allow
automating many of the application development tasks traditionally requiring
the ability to write and debug code. Both J2EE server providers and third-party
tool developers have developed tools that conform to J2EE standards and sup-
port various application development tasks and styles. Application developers
have a choice of tools to manipulate and assemble components, and individual
team members may choose tools that best suit their specific requirements.
• A marketplace for components—Component-based design ensures that
many types of behavior can be standardized, packaged, and reused by any
J2EE application. Component vendors will provide a variety of off-the-shelf
component solutions, including accounting beans, user interface templates,
and even vertical market functionality of interest in specific industries. Appli-
cation architects get a choice of standardized components to handle common
or specialized tasks.
The J2EE standard and associated branding program ensure that solutions are
compatible. By setting the stage for freedom of choice, the J2EE platform makes
it possible to develop with confidence that the value of your investment will be
protected.
DEA2e.book Page 13 Friday, March 8, 2002 12:31 AM
CHAPTER 1 INTRODUCTION
14
1.2.2.4 Scales Easily
J2EE containers provide a mechanism that supports simplified scaling of distributed
applications, with no application development effort.
Because J2EE containers provide components with transaction support, data-
base connections, life cycle management, and other features that influence perfor-
mance, they can be designed to provide scalability in these areas. For example,
containers may pool database connections, providing clients with quick, efficient
access to data.
Because containers may run on multiple systems, Web containers can auto-
matically balance load in response to fluctuating demand.
1.2.2.5 Simplified, Unified Security Model
The J2EE security model is designed to support single sign on access to application
services. Component developers can specify the security requirements of a compo-
nent at the method level to ensure that only users with appropriate permissions can
access specific data operations. While both Enterprise JavaBeans technology and
Java Servlet APIs provide programmatic security control, the basic role-based secu-
rity mechanism (where groups of users share specific permissions) is specified
entirely at application deployment time. This provides both greater flexibility and
better security control.
1.3 J2EE Application Scenarios
The following sections present a number of application scenarios, setting the stage
for a detailed discussion of the sample application. The J2EE specifications encour-
age architectural diversity. The J2EE specifications and technologies make few
assumptions about the details of API implementations. The application-level deci-
sions and choices are ultimately a trade-off between functional richness and com-
plexity.
The J2EE programming model is flexible enough for applications that support
a variety of client types, with both the Web container and EJB container as
optional. Figure 1.2 reflects a range of possible application configurations, includ-
ing cases where clients interact solely with the Web container, where clients inter-
act directly with the EJB container, and full-blown multitier applications with
stand-alone clients, Web-tier components, middle-tier EJB components, and EIS-
tier access to resources and data. While the J2EE platform has no implicit bias
DEA2e.book Page 14 Friday, March 8, 2002 12:31 AM
J2EE APPLICATION SCENARIOS 15
favoring one application scenario over another, a J2EE product should be able to
support any and all of these scenarios.
Figure 1.2 J2EE Application Scenarios
The sample application is a multitier application that uses both a Web con-
tainer and an EJB container. The following enterprise requirements heavily influ-
enced the choices made in developing the sample application:
• The need to make rapid and frequent changes to the “look” of the application
• The need to partition the application along the lines of presentation and busi-
ness logic so as to increase modularity
• The need to simplify the process of assigning suitably trained human resources
to accomplish the development task such that work can proceed along relative-
ly independent but cooperating tracks
• The need to have developers familiar with back-office applications unbur-
dened from GUI and graphic design work, for which they may not be ideally
qualified
• The need to have the necessary vocabulary to communicate the business logic
to teams concerned with human factors and the aesthetics of the application
DEA2e.book Page 15 Friday, March 8, 2002 12:31 AM
CHAPTER 1 INTRODUCTION
16
• The ability to assemble back-office applications using components from a va-
riety of sources, including off-the-shelf business logic components
• The ability to deploy transactional components across multiple hardware and
software platforms independently of the underlying database technology
• The ability to externalize internal data without having to make many assump-
tions about the consumer of the data and to accomplish this in a loosely cou-
pled manner
Clearly, relaxing any or all of these requirements would influence some of the
application-level decisions and choices that a designer would make. Although it is
reasonable to speak of “throw-away” presentation logic (that is, applications with
a look and feel that ages rapidly), there is still significant inertia associated with
business logic. This is even more true in the case of database schemas and data in
general. It is fair to say that as one moves further away from EIS resources, the
volatility of the application code increases dramatically; that is, the code’s “shelf-
life” drops significantly.
In summary, the J2EE programming model promotes a model that anticipates
growth, encourages component-oriented code reusability, and leverages the
strengths of inter-tier communication. It is the tier integration that lies at the heart
of the J2EE programming model.
1.3.1 Multitier Application Scenario
Figure 1.3 illustrates an application scenario in which the Web container hosts Web
components that are almost exclusively dedicated to handling a given application’s
presentation logic. JSP pages, supported by servlets, generate dynamic Web content
for delivery to the client. The EJB container hosts application components that use
EIS resources to service requests from Web-tier components. This architecture
decouples data access from the application’s user interface. The architecture is also
DEA2e.book Page 16 Friday, March 8, 2002 12:31 AM
J2EE APPLICATION SCENARIOS 17
implicitly scalable. Application back-office functionality is relatively isolated from
the end-user look and feel.
Figure 1.3 Multitier Application
It is worth noting that XML plays an integral role in this scenario. The ability
to both produce and consume XML data messages in the Web container is an
extremely flexible way to embrace a diverse set of client types. These platforms
range from general purpose XML-enabled browsers to specialized XML render-
ing engines targeting vertical solutions. XML data messages typically use HTTP
as their transport protocol. Java and XML are complementary technologies: The
Java language offers portable code, XML provides portable data.
In the Web tier, the question of whether to use JSP pages or servlets comes up
repeatedly. JSP technology is intended for application user interface components,
while Java Servlets are preferred for request processing and application control
logic. Servlets and JSP pages work together to provide dynamic content from the
Web tier.
DEA2e.book Page 17 Friday, March 8, 2002 12:31 AM
CHAPTER 1 INTRODUCTION
18
1.3.2 Stand-Alone Client Scenario
Figure 1.4 illustrates a stand-alone client scenario.
Figure 1.4 Stand-Alone Clients
The stand-alone client may be one of three types:
• EJB clients interacting directly with enterprise beans hosted in an EJB contain-
er within an EJB server, as shown in Figure 1.5. This scenario uses RMI-IIOP,
and the EJB server accesses EIS resources using JDBC and the J2EE Connec-
tor architecture.
Figure 1.5 EJB-Centric Java Client
DEA2e.book Page 18 Friday, March 8, 2002 12:31 AM
J2EE APPLICATION SCENARIOS 19
• Stand-alone clients, implemented in the Java language or another program-
ming language, consuming dynamic Web content (usually XML data messag-
es). In this scenario, the Web container essentially handles XML
transformations and provides Web connectivity to clients. Presentation logic
occurs in the client tier. The Web tier handles business logic and may directly
access EIS resources. Ideally, business logic is implemented as enterprise
beans to take advantage of the rich enterprise beans component model.
• Stand-alone Java application clients accessing enterprise information system
resources directly using JDBC or Connectors. In this scenario, presentation
and business logic are co-located on the client platform and may in fact be
tightly integrated into a single application. This scenario is a classic two-tier
client-server architecture, with its associated distribution, maintenance, and
scalability issues.
1.3.3 Web-Centric Application Scenario
Figure 1.6 illustrates a three-tier Web-centric application scenario.
Figure 1.6 Web-Centric Application Scenario
There are a number of scenarios in which the use of enterprise beans in an
application would be considered overkill: sort of like using a sledgehammer to
crack a nut. The J2EE specification doesn’t mandate a specific application config-
uration, nor could it realistically do so. The J2EE platform is flexible enough to
support the application configuration most appropriate to a specific application
design requirement.
As demonstrated in the book J2EE Technology In Practice, a three-tier Web-
centric application scenario is widely used as the starting point for many J2EE
DEA2e.book Page 19 Friday, March 8, 2002 12:31 AM
CHAPTER 1 INTRODUCTION
20
applications. The Web container hosts both presentation and business logic, and it
is assumed that JDBC and the J2EE Connector architecture are used to access EIS
resources.
Figure 1.7 provides a closer look at the Web container in a Web application
scenario.
Figure 1.7 Web Container in a Three-Tier Scenario
Keep in mind that the term “Web container” has a precise meaning. It doesn’t
necessarily mean a distinct process running on a distinct piece of hardware. In
many cases, J2EE platform providers may co-locate their Web and EJB contain-
ers, running them within the same Java Virtual Machine (JVM). J2EE applications
deployed on such an implementation are still considered multitier applications,
because of the division of responsibilities that the separate technologies imply.
1.3.4 Business-to-Business Scenario
Figure 1.8 illustrates a business-to-business scenario. This scenario focuses on peer-
level interactions between both Web and EJB containers. The J2EE programming
model promotes the use of XML data messaging over HTTP as the primary means
DEA2e.book Page 20 Friday, March 8, 2002 12:31 AM
HOW THIS BOOK IS ORGANIZED 21
of establishing loosely coupled communications between Web containers. This is a
natural fit for the development and deployment of Web-based commerce solutions.
Figure 1.8 Business-to-Business Scenario
The peer-level communications between EJB containers is currently a more
tightly coupled solution most suitable for intranet environments. With support for
JMS and message-driven beans, the J2EE 1.3 platform makes developing loosely-
coupled intranet solutions increasingly practical.
Future releases of the J2EE platform will provide additional functionality in
the form of Java APIs for XML, which enable more complete support for loosely
coupled applications through XML-based Web services.
1.4 How This Book Is Organized
The remainder of this book is divided into the following chapters:
• Chapter 2, “J2EE Platform Technologies,” provides an overview of the
component, service, and communication technologies supported by the J2EE
platform.
• Chapter 3, “The Client Tier,” presents implementation options for J2EE cli-
ents and provides guidelines for choosing among these options.
DEA2e.book Page 21 Friday, March 8, 2002 12:31 AM
CHAPTER 1 INTRODUCTION
22
• Chapter 4, “The Web Tier,” describes technologies available for supporting
development in the Web tier. It includes guidelines and techniques for using
J2EE Web components and describes several Web application architectures.
• Chapter 5, “The Enterprise JavaBeans Tier,” describes the capabilities of
the EJB tier of the J2EE platform and discusses design choices for implement-
ing business logic.
• Chapter 6, “Integrating with the Enterprise Information System Tier,”
describes recommended approaches for accessing enterprise information sys-
tems and how J2EE components must be configured to access them.
• Chapter 7, “Packaging and Deployment,” describes the capabilities provid-
ed by the J2EE platform for packaging and deploying J2EE applications, and
provides heuristics and practical tips on how to use these capabilities.
• Chapter 8, “Transaction Management,” describes the transaction services
provided by the J2EE platform and provides recommendations on how best to
use those services.
• Chapter 9, “Security,” describes the mapping of the J2EE security model to
enterprise computing environments and infrastructures.
• Chapter 10, “J2EE Internationalization and Localization,” new in this edi-
tion, explains how to expand an application’s reach across the globe by cus-
tomizing its interfaces and logic for multiple languages, countries, and
cultures.
• Chapter 11, “Architecture of the Sample Application,” pulls all of the topics
in the preceding chapters into a coherent programming model for interactive ap-
plications in the J2EE platform, and provides specific architectural guidelines.
• “Glossary,” is a list of words and phrases found in this book and their defini-
tions.
Additional information is available on the Java BluePrints Web site, listed in
Section 1.6 on page 23. The Web site includes additional content, available only
online, that describes in detail the architecture of the Java Pet Store sample appli-
cation.
DEA2e.book Page 22 Friday, March 8, 2002 12:31 AM
Another Random Scribd Document
with Unrelated Content
"Excuse me if I have forced upon you a disagreeable topic," said the
passenger, in a tone of sympathy. "His term of confinement will
expire, and then he can return to you."
"That is just what troubles me, sir," said Grit bluntly. "We are
expecting him in a day or two, and then our quiet life will be at an
end."
"Will he make things disagreeable for you?"
"Yes, sir."
"At least, you will not have to work so hard."
"Yes, sir. I shall have to work harder, for I shall have to support him,
too."
"Won't he be willing to work?"
"No, sir, he is very lazy, and if he can live without work, he will."
"That is certainly unfortunate."
"It is worse than having no father at all," said Grit bluntly. "I don't
care to have him remain in prison, if he will only keep away from us,
but I should be glad if I could never set eyes upon him again."
"Well, my boy, you must bear the trial as well as you can. We all
have our trials, and yours comes in the shape of a disagreeable
stepfather——"
He did not finish the sentence, for there was a startling interruption.
Mr. Jackson and Grit had been so much engaged in their
conversation that they had not watched the little boy. Willie had
amused himself in bending over the side of the boat, and dipping his
little fingers in the rippling water. With childish imprudence he
leaned too far, and fell head first into the swift stream.
A splash told the startled father what had happened.
"Good Heaven!" he exclaimed, "my boy is overboard, and I cannot
swim."
He had scarcely got the words out of his mouth than Grit was in the
water, swimming for the spot where the boy went down, now a rod
or two distant, for the boat had been borne onward by the impulse
of the oars.
The young boatman was an expert swimmer. It would naturally have
been expected, since so much of his time had been spent on the
river. He had often engaged in swimming-matches with his boy
companions, and there was no one who could surpass him in speed
or endurance.
He struck out boldly, and, as Willie rose to the surface for the second
time, he seized him by the arm, and, turning, struck out for the
boat. The little boy struggled, and this made his task more difficulty
but Grit was strong and wary, and, holding Willie in a strong grasp,
he soon gained the boat.
Mr. Jackson leaned over, and drew the boy, dripping, into its safe
refuge.
"Climb in, too, Grit!" he said.
"No, I shall upset it. If you will row to the shore, I will swim there."
"Very well."
Mr. Jackson was not wholly a stranger to the use of oars, and the
shore was very near. In three minutes the boat touched the bank,
and almost at the same time Grit clambered on shore.
"You have saved my boy's life," said Mr. Jackson, his voice betraying
the strong emotion he felt. "I shall not forget it."
"Willie is cold!" said the little boy.
"Our house is close by," said Grit. "Let us take him there at once,
and mother will take care of him, and dry his clothes."
The suggestion was adopted, and Mr. Jackson and his two young
companions were soon standing at the door of the plain cottage on
the bluff.
When his mother admitted them, Grit noticed that she looked
disturbed, and he seized the first chance to ask her if anything were
the matter.
"Your stepfather has come!" she answered.
CHAPTER V.
THE STEPFATHER.
Grit was disagreeably surprised at the news of Mr. Brandon's arrival,
and he looked about him in the expectation of seeing his unwelcome
figure, in vain.
"Where is he, mother?" the boy inquired.
"Gone to the tavern," she answered significantly.
"Did you give him any money?"
"I gave him a dollar," she replied sadly. "It is easy to tell how it will
be spent."
Grit had no time to inquire further at that time, for he was assisting
his mother in necessary attentions to their guests, having hurriedly
exchanged his own wet clothes for dry ones.
Mr. Jackson seemed very grateful to Mrs. Morris for her attention to
Willie. She found an old suit of Grit's, worn by him at the age of
eight, and dressed Willie in it, while his own wet suit was being
dried. The little boy presented a comical spectacle, the suit being
three or four sizes too large for him.
"I don't like it," he said. "It is too big."
"So it is, Willie," said his father; "but you won't have to wear it long.
You would catch your death of cold if you wore your wet clothes.
How long will it take to dry his clothes, Mrs. Morris?"
"Two or three hours at least," answered the widow.
"I have a great mind to go back to Portville, and get a change of
garments," said the father.
"That would be the best thing, probably."
"But I should have to burden you with Willie; for I should need to
take Grit with me to ferry me across."
"It will be no trouble, sir. I will take good care of him."
"Willie, will you stay here while I go after your other clothes?" asked
Mr. Jackson.
Willie readily consented, especially after Grit had brought him a
picture-book to look over. Then he accompanied the father to the
river, and they started to go across. While they were gone, Mr.
Brandon returned to the cottage. His flushed face and unsteady gait
showed that he had been drinking. He lifted the latch, and went in.
When he saw Willie sitting in a small chair beside his wife, he gazed
at the child in astonishment.
"Is that the cub?" he asked doubtfully. "Seems to me he's grown
smaller since I saw him."
"I ain't a cub," said Willie indignantly.
"Oh! yer ain't a cub, hey?" repeated Brandon mockingly.
"No, I ain't. My name is Willie Jackson, and my papa lives in New
York."
"What is the meaning of this, Mrs. Brandon?" asked the inebriate.
"Where did you pick up this youngster?"
His wife explained in a few words.
"I thought it wasn't the cub," said Mr. Brandon indistinctly. "Where is
he?"
"He has gone to row Mr. Jackson over to Portville."
"I say, Mrs. B., does he earn much money that way?"
"He earns all the money that supports us," answered his wife coldly.
"I must see to that," said Brandon unsteadily. "He must bring me his
money every night—do you hear, Mrs. B.?—must bring me his
money every night."
"To spend for liquor, I suppose?" she responded bitterly.
"I'm a gentleman. My money—that is, his money is my money. D'ye
understand?"
"I understand only too well, Mr. Brandon."
"That's all right. I feel tired. Guess I'll go and lie down."
To his wife's relief he went up-stairs, and was soon stretched out on
the bed in a drunken sleep.
"I am glad he is out of the way. I should be ashamed to have Mr.
Jackson see him," thought Grit's mother, or Mrs. Brandon, as we
must now call her.
"Who is that man?" asked Willie anxiously.
"His name is Brandon," answered Grit's mother.
"He isn't a nice man. I don't like him."
Mrs. Brandon said nothing. What could she say? If she had spoken
as she felt, she would have been compelled to agree with the boy.
Yet this man was her husband, and was likely to be to her a daily
source of anxiety and annoyance.
"I am afraid Grit and he won't agree," she thought anxiously. "Oh I
why did he ever come back? For the last five years we have been
happy. We have lived plainly and humbly, but our home has been
peaceful. Now, Heaven knows what trouble is in store for us."
Half an hour later Mr. Jackson and Grit returned.
Designing Enterprise Applications with the J2EE Platform 2nd Edition Inderjeet Singh
CHAPTER VI.
GRIT'S RECOMPENSE.
No time was lost in arraying Willie in clothes more suitable for him.
The little boy was glad to lay aside Grit's old suit, which certainly
was not very becoming to him.
"Are we going now, papa?" asked the little boy.
"Yes, Willie; but first I must express to this good lady my great
thanks for her kindness."
"I have done but little, sir," said Mrs. Brandon; "but that little I was
very glad to do."
"I am sure of that," said the visitor cordially.
"If you remain in the neighborhood, I shall hope to see your little
boy again, and yourself, also."
"I will come," said Willie promptly.
"He answers for himself," said his father, smiling, "and he will keep
his promise. Now, Grit," he said, turning to the young boatman, "I
will ask you to accompany me to the hotel."
"Certainly, sir."
When they had passed from the cottage, Mr. Jackson turned to the
boy and grasped his hand.
"I have not yet expressed to you my obligations," he said, with
emotion, "for the great service you have done me—the greatest in
the power of any man, or boy."
"Don't speak of it, sir," said Grit modestly.
"But I must. You have saved the life of my darling boy."
"I don't know, sir."
"But I do. I cannot swim a stroke, and but for your prompt bravery,
he would have drowned before my eyes."
Grit could not well contradict this statement, for it was incontestably
true.
"It was lucky I could swim," he answered.
"Yes, it was. It seems providential that I should have had with me so
brave a boy, when Willie's life was in peril. It will be something that
you will remember with satisfaction to the end of your own life."
"Yes, sir, there is no doubt of that," answered Grit sincerely.
"I shudder to think what a sad blank my own life would have been if
I had lost my dear boy. He is my only child, and for this reason I
should have missed him the more. Your brave act is one that I
cannot fitly reward——"
"I don't need any reward, Mr. Jackson," said Grit hastily.
"I am sure you do not. You do not look like a mercenary boy. But,
for all that, I owe it to myself to see that so great a favor does not
go unacknowledged. My brave boy, accept this wallet and what it
contains, not as the payment of a debt, but as the first in the series
of my acknowledgments to you."
As he spoke, he put into the hand of the young boatman a wallet.
"I am very much obliged to you, Mr. Jackson," said Grit, "but I am
not sure that I ought to take this."
"Then let me decide for you," said the broker, smiling. "I am older,
and may be presumed to have more judgment."
"It will seem as if I took pay for saving Willie from drowning."
"If you did, it would be perfectly proper. But you forget that I have
had the use of your boat and your own services for the greater part
of the afternoon."
"I presume you have paid me more than I ask for such services."
"Very likely," answered Mr. Jackson. "In fact, outside of my
obligations to you, I have formed a good opinion of a boy who works
hard and faithfully to support his mother. I was a poor boy once, and
I have not forgotten how to sympathize with those who are
beginning the conflict with narrow means. Mind, Grit, I don't condole
with you. You have good health and strong hands, and in our
favored country there is no reason why, when you reach my age,
you may not be equally well off."
"I wish I might—for mother's sake," said Grit, his face lighting up
with hope.
"I shall see more of you while I am here, but I may as well say now
that I mean to bear you in mind, and wish you to come to me, either
here or in the city, when you stand in need of advice or assistance."
Grit expressed his gratitude. Mr. Jackson selected a room at the
hotel, and promised to take up his quarters there the next day. Then
Grit once more took up his oars and ferried Willie and his father
across the river.
It was not for some time, therefore, that he had a chance to
examine the wallet which had been given him.
CHAPTER VII.
GRIT ASTONISHES PHIL.
Grit was not wholly without curiosity, and, as was natural, he
speculated as to the amount which the wallet contained. When Mr.
Jackson and Willie had left him, he took it out of his pocket and
opened it.
He extracted a roll of bills and counted them over. There were ten
five-dollar bills, and ten dollars in notes of a smaller denomination.
"Sixty dollars!" ejaculated Grit, with a thrill of pleasure. "I never was
so rich in all my life."
He felt that the sum was too large for him to accept, and he was
half tempted to run after Mr. Jackson and say so. But quick reflection
satisfied him that the generous New Yorker wished him to retain it,
and, modest though he was, he was conscious that in saving the
little boy's life he had placed his passenger under an obligation
which a much larger sum would not have overpaid. Besides, he saw
two new passengers walking toward his boat, who doubtless wished
to be ferried across the river. They were Phil Courtney and Marion
Clarke.
"We are just in time, Mr. Grit," said the young lady, smiling.
"Yes, my good fellow," said Phil condescendingly, "we will employ
you again."
"You are very kind," answered Grit, with a smile of amusement.
"I like to encourage you," continued Phil, who was not very quick to
interpret the looks of others.
Grit looked at Marion, and noticed that she, too, looked amused.
"Have you had any passengers since we came over?" asked Phil, in a
patronizing tone.
He was quite ready to employ his old schoolmate, provided he would
show proper gratitude, and be suitably impressed by his
condescension.
"I have been across several times," answered Grit briefly.
"And how much have you made now?" asked Phil, with what he
intended to pass for benevolent interest.
If Phil had been his friend, Grit would not have minded telling him;
but he had the pride of self-respect, and he objected to being
patronized or condescended to.
"I haven't counted up," he answered.
"I might have brought my own boat," said Phil, "but I like to
encourage you."
"Really, Phil, you are appearing in a new character," said Marion. "I
never should have taken you for a philanthropist before. I thought
you told your mother it would be too much bother to row over in
your own boat."
"That was one reason," said Phil, looking slightly embarrassed.
"Besides, I didn't want to interfere with Grit's business. He is poor,
and has to support his mother out of his earnings."
This was in bad taste, and Grit chafed against it.
"That is true," he said, "but I don't ask any sympathy. I am
prosperous enough."
"Oh, yes; you are doing well enough for one in your position, I don't
doubt. How much would you give, now, to have as much money as I
carry in this pocketbook?" asked Phil boastfully.
He had just passed his birthday, and had received a present of ten
dollars from his father, and five dollars each from his mother and an
aunt. He had spent a part of it for a hat and in other ways, but still
he had seventeen dollars left.
"Perhaps I have as much money," answered Grit quietly.
"Oho! That's a good joke," said Phil.
"No joke at all," said Grit. "I don't know how much money you have
in your pocketbook, but I presume I can show more."
Phil's face grew red with anger. He was one of those disagreeable
boys who are purse-proud, and he was provoked at hearing such a
ridiculous assertion from a poor boy who had to earn his own living.
Even Marion regarded Grit with some wonder, for she happened to
know how much money her cousin carried, and it seemed to her
very improbable that the young boatman should have as much in his
possession.
"Don't make a fool of yourself, Grit!" said Phil sharply.
"Thank you; I don't propose to."
"But you are doing it."
"How?"
"Didn't you say you had more money than I?"
"I think I have."
"Hear him talk!" said Phil, with a glance of derision.
By this time the young boatman's grit was up, if I may use the
expression, and he resolved to surprise and mortify his young
adversary.
"If you are not afraid to test it," he said, "I will leave it to the young
lady to decide. Let her count the money in your pocketbook, and I
will then give her my wallet for the same purpose."
"Done!" said Phil promptly.
Marion, wondering a little at Grit's confidence, took her cousin's
pocketbook, and counted the contents.
"Well, Marion, how much is there?" said Phil exultingly.
"Seventeen dollars and thirty-seven cents," was the announcement
of the fair umpire.
Phil smiled triumphantly.
"You didn't think I had so much—eh, Grit?" he said.
"No, I didn't," Grit admitted.
"Now hand over your wallet."
"With pleasure, if Miss Marion will take the trouble," answered the
young boatman, with a polite bow.
When Marion opened the wallet, and saw the roll of bills, both she
and Phil looked astonished. She proceeded to count the bills,
however, and in a tone of serious surprise announced:
"I find sixty dollars here."
"That is right," said Grit quietly, as he received back his wallet, and
thrust it into his pocket.
Phil hardly knew whether he was more surprised or mortified at this
unexpected result. But a thought struck him.
"Whose money is that?" he demanded abruptly.
"It is mine."
"I don't believe it. You are carrying it over to some one in Chester."
"Perhaps I am; but, if so, that some one is my mother."
"You don't mean to say that you have sixty dollars of your own?"
"Yes, I do. You didn't think I had so much money—eh, Phil?" he
retorted, with a smile.
"I don't believe a word of it," returned Phil crossly. "It is ridiculous
that a boy like you should have so much money. It can't be yours."
"Do you doubt it, Miss Marion?" asked Grit, turning to the young
lady.
"No; I believe that it is yours since you say so."
"Thank you."
"If it is yours, where did you get it?" asked Phil, whose curiosity
overcame his mortification sufficiently to induce him to ask the
question.
"I don't feel called upon to tell you," answered Grit.
"Then I can guess."
"Very well. If you guess right, I will admit it."
"You found it, and won't be long before finding the owner."
"You are wrong. The money is mine, and was paid me in the course
of business."
Phil did not know what to say, but Marion said pleasantly:
"Allow me to congratulate you, Mr. Grit, on being so well off. You are
richer than either of your passengers. I never had sixty dollars of my
own in my life."
By this time they had reached the other side of the river, and the
two passengers disembarked.
"Well, Phil, you came off second best," said his cousin.
"I can't understand how the boy came into possession of such a sum
of money," said Phil, frowning.
"Nor I; but I am sure of one thing."
"What is that?"
"That he came by it honestly."
"Don't be too sure of that," said Phil, shaking his head.
"Phil, you are too bad," said Marion warmly. "You seem to have
taken an unaccountable prejudice against Grit. I am sure he seems
to me a very nice boy."
"You're welcome to the young boatman's society," said Phil, with a
sneer. "You seem to be fond of low company."
"If you call him low company, then perhaps I am. I never met Grit
before this morning, but he seems a very polite, spirited boy, and it
is certainly to his credit that he supports his mother."
"I can tell you something about him that may chill your ardor? His
father is in jail."
"I heard that it was his stepfather."
"Oh, well, it doesn't matter which."
"In one sense, no. The boy isn't to blame for it."
"No, but it shows of what stock he comes."
Meanwhile, Grit, having fastened his boat, made his way to the
cottage on the bluff. He wanted to tell his mother of his good
fortune.
CHAPTER VIII.
GRIT PUTS HIS MONEY AWAY.
"You seem to be in good spirits, Grit," said his mother, as our hero
opened the outside door and entered the room where she sat
sewing.
"Yes, mother, I have reason to be. Is—is Mr. Brandon home?"
"Yes; he is up-stairs lying down," answered Mrs. Brandon, with a
sigh.
Grit rose and closed the door.
"I don't want him to hear what I'm going to tell you," he said.
"Mother, I have been very lucky to-day."
"I suppose Mr. Jackson was liberal."
"I should say he was. Guess how much money I have in this wallet,
mother."
"Five dollars."
"Multiply that by twelve."
"You don't mean to say that he gave you sixty dollars?" inquired his
mother quickly.
"Yes, I do. See here," and Grit displayed the roll of bills.
"You are, indeed, in luck, Grit. How much good this money will do
us. But I forgot," she added, her expression changing to one of
anxious solicitude.
"What did you forget, mother?"
"That your father—that Mr. Brandon had returned."
"What difference will that make, mother? I suppose, of course, it will
increase our expenses."
"If that were all, Grit."
"What is it, then, you fear, mother?"
"That he will take this money away from you."
"I should like to see him try it," exclaimed Grit, compressing his lips.
"He will try it, Grit. He said only an hour ago that you would have to
account to him for your daily earnings."
"Doesn't he mean to do any work himself?"
"I fear not. You know what sort of a man he is, Grit. He probably
means to live on what we can earn, and spend his time and what
money he can get hold of at the tavern."
"And he calls himself a man!" said Grit disdainfully.
"I am afraid our quiet, happy life is at an end, Grit," sighed his
mother.
Grit did not answer for a moment, but he looked stern and
determined. Finally, he answered:
"I don't want to make any disturbance, mother, or to act improperly,
but I feel sure that we ought not to submit to such treatment."
"What can we do, Grit?"
"If Mr. Brandon cares to stay here we will provide him a home, give
him his board, but, as to supplying him with money, we ought not to
do it."
"I agree with you, Grit, but I don't see how we can help it. Mr.
Brandon is a man, and you are only a boy. I don't want you to
quarrel with him."
"I won't if I can help it. By the way, mother, I don't think it will be
prudent to leave all this money in the house."
"What can we do with it?"
"I will put it out of my hands. Perhaps I had better not tell you what
I am going to do with it, for Mr. Brandon might ask you, and it is
better that you should be able to tell him that you don't know."
"You are right, Grit."
"I will attend to that matter at once, mother. I will be back in half or
three-quarters of an hour," and the young boatman hurried from the
house.
He bent his steps to the house of his particular friend, Fred
Lawrence, the son of a lawyer in the village. Mr. Lawrence was rated
as wealthy by the people in the village, and lived in a house quite as
good as Mr. Courtney's, but his son Fred was a very different style of
boy. He had no purse-pride, and it never occurred to him that Grit
was unfit to associate with, simply because he was poor, and had to
earn a living for himself and his mother by ferrying passengers
across the Kennebec. In fact, he regarded Grit as his most intimate
friend, and spent as much time in his company as their differing
engagements would allow.
Phil Courtney, though he condescended to Grit, regarded Fred as his
social equal, and wished to be intimate with him; but Fred did not
fancy Phil, and the latter saw, with no little annoyance, that the
young boatman's company was preferred to his. It displayed
shocking bad taste on the part of Fred, but he did not venture to
express himself to the lawyer's son as he would not scruple to do to
the young ferryman.
Naturally, when Grit felt the need of advice, he thought of his most
intimate friend, and sought the lawyer's house.
He met Fred on the way.
"Hello, Grit!" said Fred cordially. "Where are you going?"
"I was going to your house."
"Then turn round, and we will go there."
"I can talk with you in the street. I want your advice and help."
"My advice is probably very valuable," said Fred, smiling,
"considering my age and experience. However, my help you can rely
upon, if I can give it."
"Did you hear that Mr. Brandon had got home?" asked Grit abruptly.
"Your stepfather?"
"Yes; I am sorry to say that there is that tie between us. I presume
you know where he has spent the last five years?"
"Yes," answered Fred.
"Of course, I am glad for his sake that he is free; but I am afraid he
is going to give us trouble."
"How does he appear?"
"I have not seen him yet."
"How's that?"
"He only arrived to-day, and I was absent when he reached home."
"Does he mean to live here?"
"I am afraid so; and, what is more, I am afraid he means that
mother and I shall pay his expenses. He has already told mother
that he shall require me to account to him for my daily earnings."
"That will be hard on you."
"Yes; I need all I can make to pay our daily expenses, and I don't
feel like letting mother suffer for the necessaries of life in order to
supply Mr. Brandon with money for drink."
"You are right there, Grit. I sympathize with you; but how can I help
it?"
"That is what I am coming to. I want to deposit my money with you
—that is, what I don't need to use."
"I suppose you haven't much. It might not be well to trust me too
far," said Fred, smiling.
"I have sixty dollars here, which I would like to put in your hands—
that is, all but two dollars."
"Sixty dollars! Where on earth did you get so much money, Grit?"
asked his friend, opening his eyes wide in astonishment.
Grit told the story briefly, and received the warm congratulations of
his friend.
"You deserve it all, Grit," he said, "for your brave deed."
"Don't flatter me, Fred, or I may put on airs like Phil Courtney. But,
to come back to business—will you do me this favor?"
"Of course, I will. Father has a safe in his office, and I will put the
money in there. Whenever you want any of it, you have only to ask
me."
"Thank you. That will suit me. I shan't break in upon it unless I am
obliged to, as I would like to have it in reserve to fall back upon."
"Come and take supper with us, Grit, won't you?" asked Fred
cordially.
"Thank you, Fred; not to-night. I haven't seen Mr. Brandon yet, and
I may as well get over the first interview as soon as possible. We
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebookultra.com

More Related Content

PDF
Designing Enterprise Applications With The J2ee Platform 2nd Edition 2nd Edit...
PDF
Report on e-Notice App (An Android Application)
PDF
Work Measurement Application - Ghent Internship Report - Adel Belasker
PDF
PDF
DBMS_Lab_Manual_&_Solution
PDF
Deployment guide series ibm tivoli composite application manager for web reso...
PDF
Deployment guide series ibm tivoli composite application manager for web reso...
PDF
Chat Application [Full Documentation]
Designing Enterprise Applications With The J2ee Platform 2nd Edition 2nd Edit...
Report on e-Notice App (An Android Application)
Work Measurement Application - Ghent Internship Report - Adel Belasker
DBMS_Lab_Manual_&_Solution
Deployment guide series ibm tivoli composite application manager for web reso...
Deployment guide series ibm tivoli composite application manager for web reso...
Chat Application [Full Documentation]

Similar to Designing Enterprise Applications with the J2EE Platform 2nd Edition Inderjeet Singh (20)

PDF
PDF
Ibm web sphere datapower b2b appliance xb60 revealed
PDF
Deployment guide series ibm total storage productivity center for data sg247140
PDF
Securing your mobile business with ibm worklight
PDF
Extending your business to mobile devices with ibm worklight
PDF
PDF
OpenScape Contact Center Enterprise V10 Manager Administration Guide Administ...
PDF
Ibm mobile first in action for mgovernment and citizen mobile services red
PDF
Report-V1.5_with_comments
PDF
Ibm tivoli monitoring for network performance v2.1 the mainframe network mana...
PDF
Data over dab
PDF
Enabling mobile apps with ibm worklight application center red
PDF
PDF
Sg248203
PDF
Ibm system z in a mobile world providing secure and timely mobile access to...
PDF
IBM Streams - Redbook
PDF
BOOK - IBM Sterling B2B Integration and Managed File Transfer Solutions
PDF
Modifying infor erp_syte_line_5140
PDF
PDF
Managing disk subsystems using ibm total storage productivity center sg247097
Ibm web sphere datapower b2b appliance xb60 revealed
Deployment guide series ibm total storage productivity center for data sg247140
Securing your mobile business with ibm worklight
Extending your business to mobile devices with ibm worklight
OpenScape Contact Center Enterprise V10 Manager Administration Guide Administ...
Ibm mobile first in action for mgovernment and citizen mobile services red
Report-V1.5_with_comments
Ibm tivoli monitoring for network performance v2.1 the mainframe network mana...
Data over dab
Enabling mobile apps with ibm worklight application center red
Sg248203
Ibm system z in a mobile world providing secure and timely mobile access to...
IBM Streams - Redbook
BOOK - IBM Sterling B2B Integration and Managed File Transfer Solutions
Modifying infor erp_syte_line_5140
Managing disk subsystems using ibm total storage productivity center sg247097
Ad

Recently uploaded (20)

PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Pre independence Education in Inndia.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Lesson notes of climatology university.
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Institutional Correction lecture only . . .
PDF
Computing-Curriculum for Schools in Ghana
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Classroom Observation Tools for Teachers
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
01-Introduction-to-Information-Management.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
master seminar digital applications in india
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
O5-L3 Freight Transport Ops (International) V1.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
TR - Agricultural Crops Production NC III.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Pre independence Education in Inndia.pdf
O7-L3 Supply Chain Operations - ICLT Program
Lesson notes of climatology university.
human mycosis Human fungal infections are called human mycosis..pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Institutional Correction lecture only . . .
Computing-Curriculum for Schools in Ghana
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Classroom Observation Tools for Teachers
Abdominal Access Techniques with Prof. Dr. R K Mishra
Microbial disease of the cardiovascular and lymphatic systems
01-Introduction-to-Information-Management.pdf
VCE English Exam - Section C Student Revision Booklet
master seminar digital applications in india
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Ad

Designing Enterprise Applications with the J2EE Platform 2nd Edition Inderjeet Singh

  • 1. Visit https://ebookultra.com to download the full version and explore more ebooks Designing Enterprise Applications with the J2EE Platform 2nd Edition Inderjeet Singh _____ Click the link below to download _____ https://ebookultra.com/download/designing-enterprise- applications-with-the-j2ee-platform-2nd-edition- inderjeet-singh/ Explore and download more ebooks at ebookultra.com
  • 2. Here are some suggested products you might be interested in. Click the link to download Customers inside customers outside designing and succeeding with enterprise customer centricity concepts practices and applications First Edition Lowenstein https://ebookultra.com/download/customers-inside-customers-outside- designing-and-succeeding-with-enterprise-customer-centricity-concepts- practices-and-applications-first-edition-lowenstein/ Developing Facebook Platform Applications with Rails 1st Edition Michael J. Mangino https://ebookultra.com/download/developing-facebook-platform- applications-with-rails-1st-edition-michael-j-mangino/ Developing applications with enterprise SOA 1st Edition Martin Huvar https://ebookultra.com/download/developing-applications-with- enterprise-soa-1st-edition-martin-huvar/ Programming Wireless Devices with the Java 2 Platform 2nd Edition Roger Riggs https://ebookultra.com/download/programming-wireless-devices-with-the- java-2-platform-2nd-edition-roger-riggs/
  • 3. Designing Embedded Systems with PIC Microcontrollers Second Edition Principles and Applications Tim Wilmshurst https://ebookultra.com/download/designing-embedded-systems-with-pic- microcontrollers-second-edition-principles-and-applications-tim- wilmshurst/ POJOs in Action Developing Enterprise Applications with Lightweight Frameworks 1st Edition Chris Richardson https://ebookultra.com/download/pojos-in-action-developing-enterprise- applications-with-lightweight-frameworks-1st-edition-chris-richardson/ Sun Certification Training Guide 310 080 Java 2 Enterprise Edition J2EE Web Component Developer Alain Trottier https://ebookultra.com/download/sun-certification-training- guide-310-080-java-2-enterprise-edition-j2ee-web-component-developer- alain-trottier/ Java 2 Enterprise Edition J2EE Web Component Developer Exam Cram 2 Exam Cram 310 080 Alain Trottier https://ebookultra.com/download/java-2-enterprise-edition-j2ee-web- component-developer-exam-cram-2-exam-cram-310-080-alain-trottier/ Designing SQL Server 2000 Databases for Net Enterprise Servers 1st Edition Robert A. Patton https://ebookultra.com/download/designing-sql-server-2000-databases- for-net-enterprise-servers-1st-edition-robert-a-patton/
  • 5. Designing Enterprise Applications with the J2EE Platform 2nd Edition Inderjeet Singh Digital Instant Download Author(s): Inderjeet Singh ISBN(s): 0201787903 Edition: 2 File Details: PDF, 5.07 MB Year: 2002 Language: english
  • 7. Designing Enterprise Applications with the J2EETM Platform, Second Edition DEA2e.book Page 1 Friday, March 8, 2002 12:31 AM
  • 8. The Java™ Series (AW to Provide Film) DEA2e.book Page 2 Friday, March 8, 2002 12:31 AM
  • 9. Designing Enterprise Applications with the J2EETM Platform, Second Edition Inderjeet Singh, Beth Stearns, Mark Johnson, and the Enterprise Team Boston • San Francisco • New York • Toronto • Montreal London • Munich • Paris • Madrid Capetown • Sydney • Tokyo • Singapore • Mexico City DEA2e.book Page 3 Friday, March 8, 2002 12:31 AM
  • 10. Copyright © 2002 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California 94303 U.S.A. All rights reserved. Sun Microsystems, Inc., has intellectual property rights relating to implementations of the technology described in this publication. In particular, and without limitation, these intellectual property rights may include one or more U.S. patents, foreign patents, or pending applications. Sun, Sun Microsys- tems, the Sun Logo, Java Embedded Server, Java, Jini, Solaris, Forte, JDK, PersonalJava, J2ME, Java- Beans, EJB, and JavaMail are trademarks or registered trademarks of Sun Microsystems, Inc., in the United States and other countries. UNIX is a registered trademark in the United States and other coun- tries, exclusively licensed through X/Open Company, Ltd. THIS PUBLICATION IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAR- RANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON- INFRINGEMENT. THIS PUBLICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHI- CAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION HEREIN; THESE CHANGES WILL BE INCORPORATED IN NEW EDITIONS OF THE PUBLICATION. SUN MICROSYSTEMS, INC., MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THIS PUBLICATION AT ANY TIME. The publisher offers discounts on this book when ordered in quantity for special sales. For more infor- mation, please contact: Pearson Education Corporate Sales Division One Lake Street Upper Saddle River, NJ 07458 (800) 382-3419 corpsales@pearsontechgroup.com Visit Addison-Wesley on the Web: www.aw.com/cseng/ Library of Congress Control Number: 2002102513 All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording, or other- wise, without the prior consent of the publisher. Printed in the United States of America. Published simultaneously in Canada. ISBN 0-201-78790-3 Text printed on recycled paper 1 2 3 4 5 6 7 8 9 10—CRS—0605040302 First printing, March 2002 DEA2e.book Page 4 Friday, March 8, 2002 12:31 AM
  • 11. Contents v Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xiii Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xv About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..xix 1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 1.1 Challenges of Enterprise Application Development. . . . . . . . . . . . . . 2 1.1.1 Programming Productivity . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.1.2 Integration with Existing Systems. . . . . . . . . . . . . . . . . . . . . 4 1.1.3 Freedom of Choice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.1.4 Response to Demand. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.1.5 Maintaining Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.2 The Platform for Enterprise Solutions . . . . . . . . . . . . . . . . . . . . . . . . 5 1.2.1 J2EE Platform Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.2.2 J2EE Platform Benefits . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.3 J2EE Application Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 1.3.1 Multitier Application Scenario . . . . . . . . . . . . . . . . . . . . . . 16 1.3.2 Stand-Alone Client Scenario. . . . . . . . . . . . . . . . . . . . . . . . 18 1.3.3 Web-Centric Application Scenario . . . . . . . . . . . . . . . . . . . 19 1.3.4 Business-to-Business Scenario . . . . . . . . . . . . . . . . . . . . . . 20 1.4 How This Book Is Organized . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 1.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 1.6 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2 J2EE Platform Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25 2.1 Component Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.1.1 Types of J2EE Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 2.1.2 Web Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 2.1.3 Enterprise JavaBeans Components . . . . . . . . . . . . . . . . . . . 28 2.1.4 Components, Containers, and Services . . . . . . . . . . . . . . . . 31 2.2 Platform Roles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 DEA2e.book Page v Friday, March 8, 2002 12:31 AM
  • 12. CONTENTS vi 2.2.1 J2EE Product Provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 2.2.2 Application Component Provider . . . . . . . . . . . . . . . . . . . . 33 2.2.3 Application Assembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 2.2.4 Deployer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 2.2.5 System Administrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 2.2.6 Tool Provider. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 2.3 Platform Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 2.3.1 Naming Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 2.3.2 Deployment Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 2.3.3 Transaction Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 2.3.4 Security Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 2.4 Service Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 2.4.1 JDBC API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 2.4.2 Java Transaction API and Service. . . . . . . . . . . . . . . . . . . . 43 2.4.3 Java Naming and Directory Interface . . . . . . . . . . . . . . . . . 43 2.4.4 J2EE Connector Architecture . . . . . . . . . . . . . . . . . . . . . . . 43 2.4.5 Java API for XML Processing Technology . . . . . . . . . . . . 44 2.5 Communication Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 2.5.1 Internet Protocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 2.5.2 Remote Method Invocation Protocols. . . . . . . . . . . . . . . . . 46 2.5.3 Object Management Group Protocols. . . . . . . . . . . . . . . . . 46 2.5.4 Messaging Technologies. . . . . . . . . . . . . . . . . . . . . . . . . . . 47 2.5.5 Data Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 2.6 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 2.7 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 3 The Client Tier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51 3.1 Client Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 3.1.1 Network Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 3.1.2 Security Considerations. . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 3.1.3 Platform Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 3.2 General Design Issues and Guidelines . . . . . . . . . . . . . . . . . . . . . . . 54 3.3 Design Issues and Guidelines for Browser Clients. . . . . . . . . . . . . . 54 3.3.1 Presenting the User Interface . . . . . . . . . . . . . . . . . . . . . . . 55 3.3.2 Validating User Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 3.3.3 Communicating with the Server . . . . . . . . . . . . . . . . . . . . . 58 3.3.4 Managing Conversational State . . . . . . . . . . . . . . . . . . . . . 59 3.4 Design Issues and Guidelines for Java Clients . . . . . . . . . . . . . . . . . 60 3.4.1 Presenting the User Interface . . . . . . . . . . . . . . . . . . . . . . . 61 DEA2e.book Page vi Friday, March 8, 2002 12:31 AM
  • 13. CONTENTS vii 3.4.2 Validating User Inputs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 3.4.3 Communicating with the Server . . . . . . . . . . . . . . . . . . . . . 65 3.4.4 Managing Conversational State. . . . . . . . . . . . . . . . . . . . . . 69 3.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 3.6 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 4 The Web Tier. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75 4.1 The Purpose of the Web Tier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 4.2 Web-Tier Technologies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 4.2.1 Traditional Web-Tier Technologies . . . . . . . . . . . . . . . . . . 76 4.2.2 Web-Tier Technologies in the J2EE Platform. . . . . . . . . . . 78 4.2.3 The Web Container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 4.2.4 Java Servlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 4.2.5 JavaServer Pages(JSP) Technology . . . . . . . . . . . . . . . . . . 80 4.2.6 Web-Tier Technology Guidelines. . . . . . . . . . . . . . . . . . . . 82 4.3 Web-Tier Application Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 4.4 Web-Tier Application Framework Design . . . . . . . . . . . . . . . . . . . . 94 4.4.1 Structuring the Web Tier. . . . . . . . . . . . . . . . . . . . . . . . . . . 96 4.4.2 Web-Tier MVC Controller Design . . . . . . . . . . . . . . . . . . . 98 4.4.3 Web-Tier MVC View Design . . . . . . . . . . . . . . . . . . . . . . 110 4.4.4 Web-Tier MVC Model Design . . . . . . . . . . . . . . . . . . . . . 113 4.4.5 Web Application Frameworks. . . . . . . . . . . . . . . . . . . . . . 114 4.4.6 Separating Business Logic from Presentation. . . . . . . . . . 115 4.4.7 Web-Tier State. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 4.4.8 Distributable Web Applications . . . . . . . . . . . . . . . . . . . . 123 4.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 4.6 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 5 The Enterprise JavaBeans Tier. . . . . . . . . . . . . . . . . . . . . . . . . . . . .129 5.1 Business Logic and Business Objects. . . . . . . . . . . . . . . . . . . . . . . 130 5.1.1 Common Requirements of Business Objects . . . . . . . . . . 131 5.2 Enterprise Beans as J2EE Business Objects . . . . . . . . . . . . . . . . . . 134 5.2.1 Enterprise Beans and EJB Containers. . . . . . . . . . . . . . . . 136 5.3 Remote and Local Client Views . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 5.3.1 Guidelines for Using Local or Remote Client Views . . . . 141 5.3.2 Entity Beans and Local Client Views . . . . . . . . . . . . . . . . 142 5.4 Entity Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 5.4.1 Guidelines for Using Entity Beans . . . . . . . . . . . . . . . . . . 143 5.4.2 Entity Bean Persistence. . . . . . . . . . . . . . . . . . . . . . . . . . . 144 DEA2e.book Page vii Friday, March 8, 2002 12:31 AM
  • 14. CONTENTS viii 5.4.3 When to Use Bean-Managed Persistence . . . . . . . . . . . . . 149 5.5 Session Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 5.5.1 Stateful Session Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 5.5.2 Stateless Session Beans. . . . . . . . . . . . . . . . . . . . . . . . . . . 151 5.6 Message-Driven Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 5.6.1 Uses of Message-Driven Beans. . . . . . . . . . . . . . . . . . . . . 154 5.6.2 Example: Invoice Message-Driven Bean . . . . . . . . . . . . . 155 5.7 Design Guidelines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 5.7.1 Remote versus Local Client Access for Entity Beans. . . . 157 5.7.2 Session Beans as a Facade to Entity Beans. . . . . . . . . . . . 157 5.7.3 Fine-Grained versus Coarse-Grained Object Access . . . . 158 5.7.4 Master-Detail Modeling Using Enterprise Beans . . . . . . . 160 5.7.5 Data Access Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 5.7.6 Implementing an Entity Bean without a Create Method. . 163 5.7.7 Representing References to Entity Beans . . . . . . . . . . . . . 163 5.8 Portability Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 5.8.1 Typecast Remote References . . . . . . . . . . . . . . . . . . . . . . 165 5.8.2 Mark Non-Serializable Fields Transient . . . . . . . . . . . . . . 165 5.8.3 Bean-Managed Persistence and Portability. . . . . . . . . . . . 166 5.9 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 5.10 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 6 Integrating with the Enterprise Information System Tier. . . . .171 6.1 Integration Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 6.1.1 An Internet E-Store Application . . . . . . . . . . . . . . . . . . . . 172 6.1.2 An Intranet Human Resources Application . . . . . . . . . . . 174 6.1.3 A Distributed Purchasing Application . . . . . . . . . . . . . . . 174 6.1.4 An Order Fulfillment Application. . . . . . . . . . . . . . . . . . . 176 6.2 J2EE Integration Technologies. . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 6.2.1 J2EE Connector Architecture . . . . . . . . . . . . . . . . . . . . . . 177 6.2.2 Java Message Service API . . . . . . . . . . . . . . . . . . . . . . . . 179 6.2.3 JDBC and RDBMS Access. . . . . . . . . . . . . . . . . . . . . . . . 180 6.3 Application Integration Design Approaches. . . . . . . . . . . . . . . . . . 181 6.3.1 Synchronous Integration . . . . . . . . . . . . . . . . . . . . . . . . . . 182 6.3.2 Asynchronous Integration . . . . . . . . . . . . . . . . . . . . . . . . . 183 6.3.3 Comparing Approaches. . . . . . . . . . . . . . . . . . . . . . . . . . . 185 6.3.4 Data Integration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 6.4 Developing an Integration Layer . . . . . . . . . . . . . . . . . . . . . . . . . . 186 6.4.1 Programming Access to Data and Functions . . . . . . . . . . 187 DEA2e.book Page viii Friday, March 8, 2002 12:31 AM
  • 15. CONTENTS ix 6.4.2 Using Tools for EIS Integration . . . . . . . . . . . . . . . . . . . . 187 6.4.3 Developing EIS Access Objects . . . . . . . . . . . . . . . . . . . . 188 6.4.4 Guidelines for Connection Management. . . . . . . . . . . . . . 193 6.4.5 Security Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 6.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 6.6 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 7 Packaging and Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .201 7.1 Packaging Components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 7.2 Roles and Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 7.2.1 Application Component Provider Tasks . . . . . . . . . . . . . . 204 7.2.2 Application Assembler Tasks . . . . . . . . . . . . . . . . . . . . . . 206 7.2.3 Deployer Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 7.3 Packaging J2EE Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 7.3.1 EJB Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 7.3.2 EJB Module Packaging Guidelines. . . . . . . . . . . . . . . . . . 210 7.3.3 Web Modules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 7.3.4 Packaging Components into Web Modules . . . . . . . . . . . 215 7.3.5 Application Client Modules . . . . . . . . . . . . . . . . . . . . . . . 222 7.3.6 Resource Adapter Modules . . . . . . . . . . . . . . . . . . . . . . . . 222 7.4 Deployment Descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 7.4.1 J2EE Naming Environment. . . . . . . . . . . . . . . . . . . . . . . . 223 7.4.2 Specifying Deployment Descriptor Elements . . . . . . . . . . 225 7.4.3 Naming Convention Recommendations . . . . . . . . . . . . . . 239 7.5 Deployment Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 7.5.1 Deployment Tool Actions . . . . . . . . . . . . . . . . . . . . . . . . . 242 7.5.2 Deployment Tool Requirements . . . . . . . . . . . . . . . . . . . . 244 7.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 7.7 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 8 Transaction Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .251 8.1 Transactional Concepts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 8.1.1 ACID Transaction Properties . . . . . . . . . . . . . . . . . . . . . . 252 8.1.2 Transaction Participants . . . . . . . . . . . . . . . . . . . . . . . . . . 253 8.1.3 Transaction Demarcation. . . . . . . . . . . . . . . . . . . . . . . . . . 253 8.1.4 Distributed Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . 253 8.1.5 Two-Phase Commit Protocol . . . . . . . . . . . . . . . . . . . . . . 255 8.2 J2EE Platform Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 8.2.1 Accessing Multiple Resources within a Transaction. . . . . 256 8.2.2 Transactions across Servers. . . . . . . . . . . . . . . . . . . . . . . . 258 DEA2e.book Page ix Friday, March 8, 2002 12:31 AM
  • 16. CONTENTS x 8.3 J2EE Transaction Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 8.4 Client Tier Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 8.5 Web Tier Transaction Guidelines. . . . . . . . . . . . . . . . . . . . . . . . . . 261 8.6 Enterprise JavaBeans Tier Transactions. . . . . . . . . . . . . . . . . . . . . 262 8.6.1 Bean-Managed Transaction Demarcation. . . . . . . . . . . . . 263 8.6.2 Container-Managed Transaction Demarcation . . . . . . . . . 264 8.6.3 Transaction Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 8.6.4 Enterprise JavaBeans Tier Transaction Guidelines. . . . . . 266 8.7 EIS Tier Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 8.7.1 JTA Transactions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 8.7.2 Resource Manager Local Transactions . . . . . . . . . . . . . . . 269 8.7.3 EIS Tier Transaction Guidelines. . . . . . . . . . . . . . . . . . . . 269 8.7.4 Compensating Transactions . . . . . . . . . . . . . . . . . . . . . . . 269 8.7.5 Isolation Level. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 8.7.6 Performance with Multiple Resource Managers. . . . . . . . 273 8.8 J2EE Resource Manager Types . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 8.8.1 JDBC Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 8.8.2 JMS Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 8.8.3 J2EE Connector Architecture . . . . . . . . . . . . . . . . . . . . . . 274 8.9 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 8.10 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 9 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279 9.1 Security Threats and Mechanisms . . . . . . . . . . . . . . . . . . . . . . . . . 279 9.2 Authentication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 9.2.1 Protection Domains. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 9.2.2 Authentication Mechanisms . . . . . . . . . . . . . . . . . . . . . . . 284 9.2.3 Authentication Call Patterns . . . . . . . . . . . . . . . . . . . . . . . 292 9.2.4 Exposing Authentication Boundaries with References. . . 293 9.3 Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 9.3.1 Declarative Authorization . . . . . . . . . . . . . . . . . . . . . . . . . 294 9.3.2 Programmatic Authorization. . . . . . . . . . . . . . . . . . . . . . . 295 9.3.3 Declarative versus Programmatic Authorization . . . . . . . 296 9.3.4 Isolation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 9.3.5 Affects of Identity Selection . . . . . . . . . . . . . . . . . . . . . . . 297 9.3.6 Encapsulation for Access Control. . . . . . . . . . . . . . . . . . . 297 9.3.7 Controlling Access to J2EE Resources . . . . . . . . . . . . . . . 298 9.3.8 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302 9.4 Protecting Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 DEA2e.book Page x Friday, March 8, 2002 12:31 AM
  • 17. CONTENTS xi 9.4.1 Integrity Mechanisms . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 9.4.2 Confidentiality Mechanisms . . . . . . . . . . . . . . . . . . . . . . . 305 9.4.3 Identifying Sensitive Components . . . . . . . . . . . . . . . . . . 305 9.4.4 Ensuring Confidentiality of Web Resources. . . . . . . . . . . 306 9.5 Auditing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 9.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308 9.7 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 10 J2EE Internationalization and Localization . . . . . . . . . . . . . . . . .311 10.1 Internationalization Concepts and Terminology. . . . . . . . . . . . . . . 312 10.1.1 Internationalization, Localization, and Locale . . . . . . . . . 312 10.1.2 Character Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 10.1.3 Encodings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 10.2 Using J2SE Internationalization APIs in J2EE Applications . . . . . 316 10.2.1 Resource Bundles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 10.2.2 Message Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 10.2.3 Date Formatting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 10.2.4 Collation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 10.3 Web Tier Internationalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 10.3.1 Tracking Locales and Encodings. . . . . . . . . . . . . . . . . . . . 321 10.3.2 Presentation Component Design . . . . . . . . . . . . . . . . . . . . 325 10.3.3 Internationalizing and Localizing JSP Pages . . . . . . . . . . 327 10.4 EIS Tier Internationalization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 10.4.1 Persistent Localized Data . . . . . . . . . . . . . . . . . . . . . . . . . 332 10.4.2 Internationalizing Database Schema . . . . . . . . . . . . . . . . . 334 10.5 Internationalized Application Design . . . . . . . . . . . . . . . . . . . . . . . 336 10.6 Internationalizing Applications with XML. . . . . . . . . . . . . . . . . . . 337 10.6.1 Generating Localized Dynamic Content with XSLT . . . . 337 10.6.2 Communicating Locale within an Application . . . . . . . . . 338 10.6.3 Communicating Locale among Applications . . . . . . . . . . 338 10.7 Localizing Error and Logging Messages . . . . . . . . . . . . . . . . . . . . 341 10.7.1 Client Messages and Application Exceptions . . . . . . . . . . 341 10.7.2 System Exceptions and Message Logging . . . . . . . . . . . . 344 10.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345 10.9 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345 11 Architecture of the Sample Application . . . . . . . . . . . . . . . . . . . . .347 11.1 J2EE Architecture Approaches . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 11.1.1 Model-View-Controller Architecture . . . . . . . . . . . . . . . . 348 DEA2e.book Page xi Friday, March 8, 2002 12:31 AM
  • 18. CONTENTS xii 11.1.2 J2EE Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350 11.2 Sample Application Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352 11.3 Designing the Sample Application . . . . . . . . . . . . . . . . . . . . . . . . . 353 11.3.1 Choosing Application Tiers . . . . . . . . . . . . . . . . . . . . . . . 355 11.3.2 Choosing Local or Distributed Architecture . . . . . . . . . . . 357 11.4 Architecture of the Sample Application . . . . . . . . . . . . . . . . . . . . . 359 11.4.1 Application Web Site Architecture . . . . . . . . . . . . . . . . . . 360 11.4.2 Fulfillment Center Architecture . . . . . . . . . . . . . . . . . . . . 375 11.5 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382 11.6 References and Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383 Afterword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .385 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .387 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .405 DEA2e.book Page xii Friday, March 8, 2002 12:31 AM
  • 19. xiii Foreword YOU’RE holding one part of a truly stellar phenomenon in the computing indus- try: the Java 2 Platform, Enterprise Edition. This book is a key piece of a visionary effort that began more than two years ago with the introduction of the J2EE plat- form. In that time, the J2EE engineering team has defined a new ecosystem for net- worked computing and taught the world a new way to develop distributed applications. This team has changed the computing world on many levels. They’ve rein- forced the core values of Java technology: portability, scalability, security, and community. They’ve redefined the model for developing big, industrial-strength enterprise applications. They’ve invented new licensing models, driven a new compatibility model, and invigorated a new adoption model. Through the Java Community Process, they’ve taught intense competitors that working together— and building smarter—can be the key to successfully growing a marketplace that offers more for everyone. With the release of the J2EE 1.3 platform, the momentum continues. Six months after the initial release of the J2EE 1.3 platform, the introduction of com- patible products is running 56% over the rate for the previous version. Part of the reason for this phenomenal uptake is, of course, the range of new features in the J2EE 1.3 platform. These include improved container-managed persistence, the new EJB Query Language, message-driven EJBs, support for the J2EE Connector architecture, as well as enhancements such as servlet filters and improved JSP tag library support. Our J2EE licensees have been eager to intro- duce these features to the platform, and J2EE developers have been anxious to begin taking advantage of them. In this regard, the Java BluePrints team truly stands alone—first out of the box with real solutions and tested guidelines to help you use these features to best advantage. Because of the quality of their efforts, Java BluePrints has also been a phenomenal success during the past two years. More than a half million develop- ers have downloaded the BluePrints book and demo application code. A dozen application server vendors now redistribute J2EE BluePrints with their J2EE com- patible products. Four vendors have even introduced commercial products based on J2EE BluePrints. Elsewhere, BluePrints is recognized, written about, and praised by every major Java technology-focused publication. A number of techni- DEA2e.book Page xiii Friday, March 8, 2002 12:31 AM
  • 20. FOREWORD xiv cal institutes even use BluePrints to train the next generation of Java application developers. The Java software organization focuses on efforts like these because we see the net effect: a huge win for software developers everywhere, at all levels of the software development food chain. By fostering Java technology standards like the J2EE platform and providing content like BluePrints, we’re working to ensure that the Java software development community continues to grow, flourish, and mature. This book is central to that effort. The enterprise team who brought it together are thought leaders who can help you build the skill sets you need to be ready for new opportunities. Like you, they stay awake nights thinking about how to build applications that are more flexible, more portable, higher performance, and easier to develop. They’re tuned into solving the problems that you face day to day. Working alongside the folks who define and implement the technologies they are using, they explore the “what-if” scenarios that this rich platform suggests and sift through design options to come up with clear guidelines for the what and how of software design on the J2EE platform. The future holds great things for Java technology and the BluePrints program. During the coming months, our Java Web Services Developer Pack, The Java Web Services Tutorial, and Java BluePrints for Web Services will help developers build applications that take advantage of the services-on-demand promised by the Sun ONE architecture. Building on what’s already available, these offerings will enhance the phenomenal success of the J2EE platform and the Java application marketplace. By taking advantage of the gold mine of advice you’ll find in this book, you too can be part of the phenomenal success that is the J2EE platform. Rich Green Vice President and General Manager Java and XML Software, Sun Microsystems Santa Clara, California February, 2002 DEA2e.book Page xiv Friday, March 8, 2002 12:31 AM
  • 21. xv Preface THIS book, now in its second edition, describes standard approaches to designing multitier enterprise applications with the JavaTM 2 Platform, Enterprise Edition. This book, and the accompanying Java Pet Store sample application, are part of the successful Java BluePrints program created by Sun Microsystems with the introduc- tion of the J2EE platform. This program has been used by thousands of application architects, developers, and students to attain better understanding of the program- ming model inherent in the J2EE platform. This book and the Java BluePrints program don’t provide information on how to use individual Java technologies to write applications—that’s the role of the com- panion Java Tutorial program. Instead, Java BluePrints focuses on guidelines for application architecture, such as distributing J2EE application functionality across tiers and choosing among design options within each tier. This book assumes that the reader already has basic knowledge of the J2EE platform. We recommend that readers without this knowledge familiarize themselves with the J2EE Tutorial either before or while reading this volume. See “Related Information” later in the Preface for details. This book describes the architecture and design principles employed in building J2EE applications, and explores of the specific approach adopted by the sample application. Striking a balance between specific details and broad principles is never easy. The hope behind this effort is that the principles presented here are both consistent with and a useful complement to the implementation provided by the sample applications documented in this book. This book is intended primarily for system architects and enterprise application developers engaged in or considering a transition to the J2EE platform. It is also useful for product vendors interested in developing applications consistent with the J2EE standard. Obtaining the Sample Application You can download the Java Pet Store sample application, version 1.3, which is described in this book, from: http://java.sun.com/blueprints/code/ DEA2e.book Page xv Friday, March 8, 2002 12:31 AM
  • 22. PREFACE xvi The sample application requires a J2EE v1.3-compliant platform on which to run. You can download J2EE SDKTM , which is a freely available implementation of that platform, from: http://java.sun.com/j2ee/download.html Related Information Pointers to J2EE documentation can be found at: http://java.sun.com/j2ee/docs.html For information on how to use the J2EE SDK to construct multitier enterprise appli- cations, refer to the J2EE Tutorial, available at: http://java.sun.com/j2ee/tutorial/ The J2EE technologies cited in this book are described in their specifications: • Java™ 2 Platform, Enterprise Edition Specification, Version 1.3 (J2EE spec- ification). Available at <http://java.sun.com/j2ee/download.html> • Java™ 2 Platform, Standard Edition Specification, Version 1.3 (J2SE specifi- cation). Available at <http://java.sun.com/j2se/1.3/docs/> • Java™ Servlet Specification, Version 2.3 (Servlet specification). Available at <http://java.sun.com/products/servlet/> • JavaServer Pages™ Specification, Version 1.2 (JSP specification). Available at <http://java.sun.com/products/jsp/> • Enterprise JavaBeans™Specification, Version 2.0 (EJB specification). Avail- able at <http://java.sun.com/products/ejb/> • Java™ API for XML Processing Specification, Version 1.1 (JAXP specifica- tion). Available at <http://java.sun.com/xml/jaxp/> • J2EE™ Connector Architecture Specification, Version 1.0 (Connector speci- fication). Available at <http://java.sun.com/j2ee/connector/> • JDBC™ API Specification, Version 2.0 (JDBC specification). Available at <http://java.sun.com/products/jdbc/> DEA2e.book Page xvi Friday, March 8, 2002 12:31 AM
  • 23. PREFACE xvii • JDBC™ Standard Extension API Specification, Version 2.0 (JDBC extension specification). Available at <http://java.sun.com/products/jdbc/> • Java™ Transaction API Specification, Version 1.0.1 (JTA specification). Available at <http://java.sun.com/products/jta/> • Java Naming and Directory Interface™ Specification, Version 1.2 (JNDI specification). Available at <http://java.sun.com/products/jndi/> • Java IDL. Available at <http://java.sun.com/j2se/1.3/docs/guide/idl/> • RMI over IIOP. Available at <http://java.sun.com/products/rmi-iiop/> • Java™ Message Service Specification, Version 1.0.2 (JMS specification). Available at <http://java.sun.com/products/jms/> • Java™ Authentication and Authorization Service Specification, Version 1.0 (JAAS specification). Available at <http://java.sun.com/products/jaas/> • JavaMail™ API Specification, Version 1.2 (JavaMail specification). Available at <http://java.sun.com/products/javamail/> • JavaBeans™ Activation Framework Specification, Version 1.0.1 (JAF speci- fication). Available at <http://java.sun.com/products/javabeans/glas- gow/jaf.html> Typographic Conventions Table 0.1 describes the typographic conventions used in this book. Table 0.1 Typographic Conventions Typeface or Symbol Meaning Example AaBbCc123 The names of commands, files, and directories; interface, class, method, and deployment descriptor element names; programming language keywords Edit the file Main.jsp. How to retrieve a UserTransaction object. Specify the resource-ref element. AaBbCc123 Variable name The files are named XYZfile. AaBbCc123 Book titles, new words or terms, or words to be emphasized Read Chapter 6 in User’s Guide. These are called class options. You must be root to do this. DEA2e.book Page xvii Friday, March 8, 2002 12:31 AM
  • 24. PREFACE xviii Acknowledgments This book is the result of many people’s efforts. The authors listed for each chapter had primary responsibility for the content provided there and also made significant contributions to other chapters. In addition, Abhishek Chauhan, Vinita Khanna, and Stephanie Bodoff contributed significantly to the chapters in the first edition of this book. Liz Blair was instrumental in devel- oping the initial drafts of the EJB-tier chapter. We are indebted to Thierry Violleau, Umit Yalcinalp, Kate Stout, Norbert Lin- denberg, and Danny Coward for their comprehensive reviews and thoughtful com- ments on many chapters. We would also like to thank Eduardo Pelegri-Llopart, Jon Ellis, David Bowen, Monica Pawlan, Tim Lindholm, Tom Kast, Mark Hapner, Bill Shannon, John Crupi, Sanjeev Krishnan, Stephanie Bodoff, Dale Green, Mark Roth, Martin Flynn, Brian Beck, Andrey Dikanskiy, and Craig McClanahan for their input. Our special thanks go to our management, Larry Freeman, Cori Kaylor, Vivek Nagar, and Jeff Jackson, for their whole-hearted support and commitment to the BluePrints program and to this book in particular. We would never have made it to the end of this project without the support of Suzy Pelouch who did an excellent job at pulling together all the pieces. The authors of the J2EE specifications and the developers of the reference implementation provided useful input at various points during the development of the J2EE programming model. DEA2e.book Page xviii Friday, March 8, 2002 12:31 AM
  • 25. xix About the Authors Authors listed in alphabetical order by first name: BETH STEARNS is the principal partner of ComputerEase Publishing, a computer consulting firm she founded in 1982. Her client list includes Sun Microsystems, Inc., Silicon Graphics, Inc., Oracle Corporation, and Xerox Corporation. Among her publications are the “Java Native Interface” chapter in The Java Tutorial Contin- ued book in the Addison-Wesley Java Series, “The EJB Programming Guide” for Inprise Corporation, and “Understanding EDT,” a guide to Digital Equipment Cor- poration’s text editor. She co-authored with Vlada Matena the book, Applying Enterprise JavaBeans: Component-Based Development for the J2EE Platform, which is part of the Addison-Wesley Java Series. She is also a co-author with Rahul Sharma and Tony Ng of another book in the Addison-Wesley Java Series, J2EE Connector Architecture and Enterprise Application Integration. GREG MURRAY is a member of the Java BluePrints team at Sun Microsystems. He is a contributing author to the first edition of this book. Greg contributed to the design of the Java Pet Store sample application with an emphasis on the Web tier. Prior to working on the Java BluePrints team, Greg was a member of the Global Products Engineering group of Sun Microsystems, where he developed internation- alization tools. INDERJEET SINGH is the lead architect on the Java BluePrints team at Sun Micro- systems, where he investigates the best uses of J2EE technologies for enterprise application design. Inderjeet has been involved with the Java BluePrints program since its inception. He is a regular speaker on enterprise application design. In the past, Inderjeet has also designed fault-tolerance software for large-scale distributed telecommunications switching systems. Inderjeet holds an M.S. in computer science from Washington University in Saint Louis, and a B.Tech. in computer science and engineering from Indian Institute of Technology, Delhi. DEA2e.book Page xix Friday, March 8, 2002 12:31 AM
  • 26. ABOUT THE AUTHORS xx JIM INSCORE manages technical publications for the Java 2 Platform, Enterprise Edition, in the Java Software Group of Sun Microsystems. His roles include over- seeing developer documentation, such as the J2EE Tutorial and J2EE BluePrints, providing developer content for the java.sun.com Web site. Jim serves as technical editor on the Java Series, Enterprise Edition, from Addison-Wesley and is a co- author, with Rick Cattel, of the Java Series book, J2EE Technology in Practice. Jim has been involved with object-oriented and enterprise-related technologies for more than 15 years, working with developer documentation and marketing programs for organizations that include Oracle, Ingres, NeXT, Kaleida, and Macromedia. Prior to that, he spent 10 years writing marketing communications materials for the techni- cal marketplace. LINDA DEMICHIEL is the specification lead of the Expert Group for the Enter- prise JavaBeansTM specification, under the Java Community Process program, and a Senior Staff Engineer in the J2EE platform group at Sun Microsystems. She has over 15 years of industry experience in the areas of databases, distributed comput- ing, and OO. She has a Ph.D. in computer science from Stanford University. MARK JOHNSON is a software developer, trainer, writer, and speaker living in Fort Collins, Colorado. He is President of Elucify Technical Communications, a Colorado corporation dedicated to making accessible difficult or novel topics in science and technology through clear explanation and example. He has been a col- umnist at JavaWorld since 1997 and is a member of the National Association of Science Writers. He is currently a consultant with the Java BluePrints group at Sun. Mark completed a B. S. in computer and electrical engineering at Purdue University in 1986, followed by two years of graduate work at Purdue, concentrating in signal processing and computer systems. NICHOLAS KASSEM is a Senior Staff Engineer with Sun Microsystems and has influenced and had responsibility for a number of technologies and initiatives within Java Software, including the Java Web Server, Java Embedded Server, the Servlet API, JavaServer Pages, Java Message Queuing, and the J2EE programming model. He is currently leading the Java API for XML Messaging (JAXM) initiative. Nicho- las has more than twenty years of industry experience and has held senior engineer- ing and management positions at Philips (Data Systems) and the Santa Cruz Operation. He has had direct responsibility for a wide variety of engineering projects, including the development of Data Communications Gateway Hardware (DISOSS), Novell and Lan Manager protocol stacks, and an implementation of OSF DEA2e.book Page xx Friday, March 8, 2002 12:31 AM
  • 27. ABOUT THE AUTHORS xxi DCE on SCO UNIX. He is an engineering graduate of Birmingham University in the United Kingdom. RAHUL SHARMA is the lead architect and specification lead of J2EE Connector Architecture 1.0 and JAX-RPC specifications. He works as an architect in the J2EE platform group of Sun Microsystems, Inc. Rahul has also worked on exploring how the Java platform can be used for building carrier-grade applications. Rahul has an MBA from Haas School of Business, University of California at Berkeley, and a B.E. in computer engineering from Delhi University. RAY ORTIGAS is an engineer with the Java BluePrints group at Sun Microsys- tems, where he works on wireless and enterprise applications using Java technology. A former intern with the Java Tutorial, where he authored the “First Cup of Java” trail, Ray earned his B.Sc. in computer science from the University of Toronto in Canada. RON MONZILLO is a Senior Staff Engineer at Sun Microsystems, where he is the J2EE security specification lead. Ron was responsible for the design and standard- ization of the EJB secure interoperability protocol, CSIv2. Prior to joining Sun, Ron worked for the Open Group where he contributed to the evolution of the Distributed Computing Environment. Ron has also worked for BBN, where he developed Network Management systems, and as a Principal Investigator for the MITRE Cor- poration where he researched fault-tolerant distributed database systems and multi- processor architectures. Ron received an M.S. in computer science from the Univer- sity of Connecticut and a B.S. in biology from Bates College. SEAN BRYDON is a member of the Java BluePrints team at Sun Microsystems. Sean contributed to the design of the Java Pet Store sample application with an emphasis on the application and the tiers for EIS and the EJB component architec- ture. In the past, Sean has worked on the JavaLoadTM team and has spent a summer as an intern at SunLabs. Sean holds an M.S. in computer science from the Univer- sity of California at Santa Barbara and also a B.S. in computer science from the Uni- versity of California at Santa Barbara. TONY NG is the technical lead of the J2EE SDK and Reference Implementation at Sun Microsystems, Inc. Previously, he was the implementation lead of the J2EE Connector Architecture. He is a contributing author to the first edition of Designing Enterprise Applications with the Java 2 Platform, Enterprise Edition, and J2EE DEA2e.book Page xxi Friday, March 8, 2002 12:31 AM
  • 28. ABOUT THE AUTHORS xxii Connector Architecture and Enterprise Application Integration in the Addison- Wesley Java Series. Tony has an M.S. in electrical engineering and computer science from Massachusetts Institute of Technology and a B.S. in computer science from the University of Illinois, Urbana-Champaign. VIJAY RAMACHANDRAN is a member of the technical staff at Sun Microsys- tems, where he works as the Team Lead of the Java BluePrints team. His major con- tributions include guidelines on best practices when developing business solutions using enterprise beans. Before joining the BluePrints team, Vijay was a member of the Enterprise Server Products Group of Sun Microsystems working on Sun’s enter- prise server products line. Vijay holds an M.S. in computer science from Santa Clara University, California, and a B.E. in electrical engineering from Madras University, India. DEA2e.book Page xxii Friday, March 8, 2002 12:31 AM
  • 29. 1 C H A P T E R 1 Introduction by Jim Inscore and Nicholas Kassem SINCE its introduction more than two years ago, the Java 2 Platform, Enterprise Edition (J2EE), has rapidly established a new model for developing distributed applications. This model is based on well-defined components that can automati- cally take advantage of sophisticated platform services. These components can be developed according to standard guidelines, combined into applications, deployed on a variety of compatible server products, and reused for maximum programmer productivity. This model is intended to both standardize and simplify the kind of distributed applications required for today’s networked information economy. The success of the J2EE platform is in large part due to the success of this model. Today, all leading application server and enterprise information system vendors have adopted the J2EE standard and introduced products based on the J2EE platform specification. Application architects and developers have come to rely on the J2EE standard to help them solve the various design challenges that face them day to day. While the fundamentals of the J2EE platform are relatively easy to describe, mapping these features to architectural issues in the design of distributed applica- tions requires deeper understanding and careful decision making. Although the J2EE standard offers a simplified programming model compared to previous alter- natives, the platform isn’t monolithic. Certain features require that architects and developers weigh their options before making design decisions and be prepared to re-think those decisions as they uncover new challenges. That, in turn, requires some understanding of the design motivations behind the platform and of the trade-offs involved in applying specific design features to a specific architectural problem. DEA2e.book Page 1 Friday, March 8, 2002 12:31 AM
  • 30. CHAPTER 1 INTRODUCTION 2 Different implementations of the J2EE platform may provide distinguishing characteristics that improve their performance or development ease in particular areas. However, the level of abstraction provided by the J2EE standard enables common themes to be developed, explained, and explored and certain common design guidelines to be developed. That’s what Java BluePrints is all about. It answers questions like: • What’s the best way to apply each type of J2EE component? • Where does it make sense to use Java servlets and where to use JavaServer Pages? • What’s the best way to factor business logic between entity beans and session beans? • How do you choose between container-managed and bean-managed persis- tence when using entity beans? • What are the design and performance trade-offs between choosing a distribut- ed architecture and one based on local interfaces? • In this increasingly security-conscious world, how do you design distributed applications to be accessible to users who need them and secure from unwant- ed intrusion? Before the remainder of this book takes you more deeply into these and other details of J2EE application architectures, this chapter gives you a look at some of the design motivations behind the J2EE platform. It describes the high-level bene- fits of the J2EE platform and discusses ways that using it as the underlying archi- tecture for distributed applications makes sense for a variety of application requirements. 1.1 Challenges of Enterprise Application Development Timing has always been a critical factor when organizations adopt new technolo- gies, and the accelerated pace of the information-driven business model puts greater emphasis on response times. Organizations need to be able to project enterprise systems into various client channels, and to do so in a way that’s reliable, produc- tive, and capable of sustaining frequent updates to both information and services. The principal issue is how to keep up with today’s business challenges—whatever DEA2e.book Page 2 Friday, March 8, 2002 12:31 AM
  • 31. CHALLENGES OF ENTERPRISE APPLICATION DEVELOPMENT 3 they may be—while maintaining and leveraging the value of existing information assets. In this environment, timeliness, productivity, security, and predictability are all absolutely critical to building and maintaining momentum. A number of factors can enhance or impede an organization’s ability to deliver custom enterprise appli- cations quickly and to maximize their value over their lifetime. 1.1.1 Programming Productivity The ability to develop and deploy applications is key to success in the information economy. Applications must go quickly from prototype to production and must con- tinue to evolve even after they are deployed. Productivity is thus vital to responsive application development. Providing application development teams with standard means to access the services required by multitier applications and standard ways to support a variety of clients can contribute to both responsiveness and flexibility. The current divergence of technologies and programming models is a destabi- lizing factor in Internet and other distributed computing applications. Traditional Web technologies such as HTML and Common Gateway Interface (CGI) have provided a mechanism for distributing dynamic content, while back-end systems such as transaction processors and database management systems have provided controlled access to the data to be presented and manipulated. These technologies present a diversity of programming models: some based on well-defined stan- dards; others on more ad-hoc standards; and others still on proprietary architec- tures. With no single application model, it can be difficult for teams to communicate application requirements effectively and productively. As a result, architecting applications becomes more complex. What’s more, the skill sets required to inte- grate these technologies aren’t well organized for effective division of labor. For example, CGI development requires coders to define both content and layout of a dynamic Web page. Another complicating factor in application development time is the choice of clients. While many applications can be distributed to Web browser clients through static or dynamically generated HTML, others may need to support a spe- cific type of client or to support several types of clients simultaneously. The pro- gramming model needs to support a variety of client configurations, with minimum effect on basic application architecture and on the application’s core business logic. DEA2e.book Page 3 Friday, March 8, 2002 12:31 AM
  • 32. CHAPTER 1 INTRODUCTION 4 1.1.2 Integration with Existing Systems Much of the data of value to organizations has been collected over the years by existing enterprise information systems. Much of the programming investment resides in applications on those same systems. The challenge for developers of enterprise applications is how to reuse and commoditize these existing information assets. To achieve this goal, application developers need standard ways to access middle-tier and back-end services such as database management systems and transaction monitors. They also need systems that provide these services consis- tently, so that new programming models or styles aren’t required as integration expands to encompass various systems within an enterprise. 1.1.3 Freedom of Choice Application development responsiveness requires the ability to mix and match solu- tions to come up with the optimum configuration for the task at hand. Freedom of choice in enterprise application development should extend from servers to tools to components. The wide range of J2EE compatible solutions available today and in the future ensures the maximum freedom of choice. The availability of choices among server products gives an organization the ability to select configurations tailored to their application requirements. It also provides the ability to move quickly and easily from one configuration to another as internal and external demand requires. Access to the appropriate tools for the job is another important choice. Devel- opment teams should be able to adopt new tools as new needs arise, including tools from server vendors and third-party tool developers. What’s more, each member of a development team should have access to tools that are most appro- priate to their skill set and contribution. Finally, developers should be able to choose from a ready market of off-the- shelf application components to take advantage of external expertise and to enhance development productivity. 1.1.4 Response to Demand When designing large-scale distributed applications, both availability and scalability are key considerations. The more easily and automatically that an application can handle changes in use patterns and system configurations, the better. Systems that DEA2e.book Page 4 Friday, March 8, 2002 12:31 AM
  • 33. THE PLATFORM FOR ENTERPRISE SOLUTIONS 5 require any redesign, recoding, or redeployment to achieve either availability or scalability will limit flexibility and diminish expected performance. To scale effectively, systems need to be designed to handle multiple client interactions with ease. They need mechanisms for efficient management of system resources and services such as database connections and transactions. For highest availability, they need access to features such as automatic load balancing and failover, without any effort on the part of the application developer. Applications should be able to run on any server configuration appropriate to anticipated client volumes and to easily switch configurations when the need arises. Support for clustered application deployment environments contributes to achieving many of these goals. 1.1.5 Maintaining Security More than ever, information systems security is on the minds of IT managers and system architects. That’s because protecting information assets to maximize their value can jeopardize that very value. Traditionally, IT departments have been able to maintain a relatively high level of control over the environment of both servers and clients. When information assets are exposed in less-protected environments, it becomes increasingly important to maintain tight security over the most sensitive assets, while allowing seemingly unencumbered access to others. One of the difficulties in integrating disparate systems is providing a unified security model. Single sign on across internal application and asset boundaries is important to creating a positive user experience with the applications. Security needs to be compatible with existing mechanisms. In cases where customers need to access secure information, the mechanisms need to maintain high security (and user confidence) while remaining as unobtrusive and transparent as possible. 1.2 The Platform for Enterprise Solutions The J2EE platform represents a single standard for implementing and deploying enterprise applications. During its first two years, the J2EE standard’s success has transformed the marketplace for distributed computing products. This success is largely due to the fact that the J2EE platform has been designed through an open process, engaging a range of enterprise computing vendors to ensure that it meets the widest possible range of enterprise application requirements. As a result, the J2EE platform addresses the core issues that impede organizations’ efforts to main- DEA2e.book Page 5 Friday, March 8, 2002 12:31 AM
  • 34. CHAPTER 1 INTRODUCTION 6 tain a competitive pace in the information economy. Organizations have recognized this and quickly adopted the new platform standard. 1.2.1 J2EE Platform Overview The J2EE platform is designed to provide server-side and client-side support for developing distributed, multitier applications. Such applications are typically con- figured as a client tier to provide the user interface, one or more middle-tier modules that provide client services and business logic for an application, and back-end enterprise information systems providing data management. Figure 1.1 illustrates the various components and services that make up a typical J2EE environment. Figure 1.1 J2EE Environment 1.2.1.1 Multitier Model As illustrated, the J2EE platform provides a multitier distributed application model. This means that the various parts of an application can run on different devices. The DEA2e.book Page 6 Friday, March 8, 2002 12:31 AM
  • 35. THE PLATFORM FOR ENTERPRISE SOLUTIONS 7 J2EE architecture defines a client tier, a middle tier (consisting of one or more sub- tiers), and a back-end tier. The client tier supports a variety of client types, both outside and inside of corporate firewalls. The middle tier supports client services through Web containers in the Web tier and supports business logic component ser- vices through Enterprise JavaBeansTM (EJBTM ) containers in the EJB tier. On the back end, the enterprise information systems in the EIS tier are accessible by way of stan- dard APIs. 1.2.1.2 Container-Based Component Management Central to the J2EE component-based development model is the notion of contain- ers. Containers are standardized runtime environments that provide specific services to components. Components can expect these services to be available on any J2EE platform from any vendor. For example, all J2EE Web containers provide runtime support for responding to client requests, performing request-time processing (such as invoking JSP pages or servlet behavior), and returning results to the client. In addition, they provide APIs to support user session management. All EJB containers provide automated support for transaction and life cycle management of EJB com- ponents, as well as bean lookup and other services. Containers also provide stan- dardized access to enterprise information systems; for example, providing access to relational data through the JDBC API. In addition, containers provide a mechanism for selecting application behav- iors at assembly or deployment time. Through the use of deployment descriptors (XML files that specify component and container behavior), components can be configured to a specific container’s environment when deployed, rather than in component code. Features that can be configured at deployment time include security checks, transaction control, and other management responsibilities. While the J2EE specification defines the component containers that a platform implementation must support, it doesn’t specify or restrict the containers’ configu- rations. Thus, both container types can run on a single platform, Web containers can live on one platform and EJB containers on another, or a J2EE platform can be made up of multiple containers on multiple platforms. 1.2.1.3 Support for Client Components The J2EE client tier provides support for a variety of client types, both within the enterprise firewall and outside. Clients can be offered through Web browsers by using plain HTML pages, HTML generated dynamically by JavaServer PagesTM DEA2e.book Page 7 Friday, March 8, 2002 12:31 AM
  • 36. CHAPTER 1 INTRODUCTION 8 (JSPTM ) technology, or Java applets. Clients can also be offered as stand-alone Java language applications. J2EE clients are assumed to access the middle tier primarily using Web standards, namely HTTP, HTML, and XML. Because of its flexible pro- gramming model, the J2EE platform can support a number of simple application models implemented primarily on the strengths of its Web tier component technolo- gies. To support more complex user interactions, it may be necessary to provide functionality directly in the client tier. This functionality is typically implemented as JavaBeansTM components that interact with the service in the middle tier via servlets. Client-tier JavaBeans components would typically be provided by the service as an applet that is downloaded automatically into a user’s browser. To eliminate problems caused by old or non-standard versions of the Java Virtual Machine in a user’s browser, the J2EE application model provides special support for automatically downloading and installing the Java Plug-in. In addition, the J2EE platform is flexible enough to support alternate client models easily, includ- ing wireless phones and handheld devices that use programming models provided by the Java 2 Platform, Micro Edition. Client-tier beans can also be contained in a stand-alone application client written in the Java programming language. In this case, the enterprise typically would make the client available for users to download from a browser using Java Web Start technology. Java Web Start technology makes application deployment portable by providing browser-based download and installation mechanisms. With both application and deployment portability, this ensures that users can always access and work with the latest versions of stand-alone application clients. If desired, non-Java clients such as Visual Basic programs can present J2EE services to users. Since the service is presented by servlets in the middle tier to first-tier clients using the standard HTTP protocol, it is easy to access it from practically any program running on any operating system. 1.2.1.4 Support for Business Logic Components While simple J2EE applications may be built largely in the client tier, business logic is often implemented on the J2EE platform in the middle tier as Enterprise JavaBeanscomponents (also known as enterprise beans). Enterprise beans allow the component or application developer to concentrate on the business logic while the complexities of delivering a reliable, scalable service are handled by the EJB con- tainer. DEA2e.book Page 8 Friday, March 8, 2002 12:31 AM
  • 37. THE PLATFORM FOR ENTERPRISE SOLUTIONS 9 In many ways, the J2EE platform and EJB architecture have complementary goals. The EJB component model is the backbone of industrial-strength application architectures in the J2EE programming model. The J2EE platform complements the EJB specification by: • Fully specifying the APIs that an enterprise bean developer can use to imple- ment enterprise beans • Defining the larger, distributed programming environment in which enterprise beans are used as business logic components 1.2.1.5 Support for the J2EE Standard The J2EE standard is defined through a set of related specifications. Key among these are the J2EE specification, the Enterprise JavaBeans specification, the Java Servlet specification, and the JavaServer Pages specification. Together, these specifi- cations define the architecture described in this book. In addition to the specifica- tions, several other technology deliverables support the J2EE standard, including the J2EE Compatibility Test Suite, the J2EE reference implementation, and the J2EE SDK. The J2EE Compatibility Test Suite (CTS) helps maximize the portability of applications by validating the specification compliance of a J2EE platform product. This test suite begins where the basic Java Conformance Kit (JCK) leaves off. The CTS tests conformance to the Java standard extension APIs that are not covered by a JCK. In addition, it tests a J2EE platform’s ability to run standard end-to-end applications. The J2EE reference implementation, a complete implementation of the J2EE standard provided by Sun Microsystems, represents an operational definition of the J2EE platform. It is used by licensees as the “gold standard” to determine what their product must do under a particular set of application circumstances. It is the stan- dard platform for running the J2EE Compatibility Test Suite, and it can be used by developers to verify the portability of an application. The J2EE reference implemen- tation is available in both binary and source code form. The J2EE SDK, based on the J2EE reference implementation binary, is pro- vided freely to the developer community to help expedite developer adoption of the J2EE standard. Although not a commercial product and not available for com- mercial use, the J2EE SDK is useful for developing application demos and proto- types, such as the Java Pet Store sample application described in this book. The J2EE SDK also includes application verification and deployment tools to simplify DEA2e.book Page 9 Friday, March 8, 2002 12:31 AM
  • 38. CHAPTER 1 INTRODUCTION 10 development, and the J2EE Tutorial, which provides step-by-step examples and information that developers need to begin working with the platform. Another word on J2EE standards and portability: The J2EE specifications have, by design, set the platform-compatibility bar at a level that’s relatively easy to clear. Because the platform specifications are developed collaboratively, platform vendors must have plenty of opportunity to supply J2EE platform implementations. Obvious and unreasonable implementation hurdles were avoided. For example, there are no restrictions on vendors adding value to J2EE products by supporting services not defined in the specifications. While the J2EE standard is designed to encourage component portability, spe- cific results are primarily a function of how a component uses services provided by its container. Vendor-specific features limit component portability. The J2EE speci- fications spell out a base set of capabilities that a component can count on, providing components with a level of cross-container portability. Needless to say, an applica- tion developer expecting to deploy on a specific vendor implementation of the J2EE platform should be able to do so across a wide range of operating systems and hard- ware architectures. 1.2.2 J2EE Platform Benefits With features designed to expedite the process of developing distributed applica- tions, the J2EE platform offers several benefits: • Simplified architecture and development • Freedom of choice in servers, tools, and components • Integration with existing information systems • Scalability to meet demand variations • Flexible security model 1.2.2.1 Simplified Architecture and Development The J2EE platform supports a simplified, component-based development model. Because it is based on the Java programming language and the Java 2 Platform, Standard Edition (J2SETM platform), this model offers “Write-Once-Run-Any- whereTM ” portability, supported by any server product that conforms to the J2EE standard. DEA2e.book Page 10 Friday, March 8, 2002 12:31 AM
  • 39. THE PLATFORM FOR ENTERPRISE SOLUTIONS 11 The component-based J2EE development model can enhance application development productivity in a number of ways: • Maps easily to application functionality—Component-based application models map easily and flexibly to the functionality desired from an applica- tion. As the examples presented throughout this book illustrate, the J2EE plat- form provides a variety of ways to configure the architecture of an application, depending on such things as client types required, level of access required to data sources, and other considerations. Component-based design also simpli- fies application maintenance, since components can be updated and replaced independently—new functionality can be shimmed into existing applications simply by updating selected components. • Enables assembly- and deploy-time behaviors—Because of the high level of service standardization, much of the code of a J2EE application can be gener- ated automatically by tools, with minimal developer intervention. In addition, components can expect standard services to be available in the runtime envi- ronment and can dynamically connect to other components by means of con- sistent interfaces. As a result, many application behaviors can be configured at application assembly or deployment time, without recoding. Component de- velopers can communicate requirements to application deployers through spe- cific deployment descriptors and settings. Tools can automate this process to further expedite development. • Supports division of labor—Components help divide the labor of application development among specific skill sets, enabling each member of a develop- ment team to focus on his or her ability. Web page authors can create JSP tem- plates, Java programming language coders can implement application behavior, domain experts can develop business logic, and application develop- ers and integrators can assemble and deploy applications. This division of la- bor also expedites application maintenance. For example, the user interface is the most dynamic part of many applications, particularly on the Web. With the J2EE platform, Web page authors can tweak the look and feel of JSP pages without programmer intervention. The J2EE specifications define a number of roles, including application com- ponent provider, application assembler, and application deployer. On some devel- opment teams, one or two people may perform all these roles, while on others DEA2e.book Page 11 Friday, March 8, 2002 12:31 AM
  • 40. CHAPTER 1 INTRODUCTION 12 these tasks may be further subdivided into more specific skill sets (such as user interface designers, programmers, and so on). 1.2.2.2 Integrating Existing Enterprise Information Systems The J2EE platform, together with the J2SE platform, includes a number of industry standard APIs for accessing existing enterprise information systems. Basic access to these systems is provided by the following APIs: • The J2EE Connector architecture is the infrastructure for interacting with a va- riety of Enterprise Information System types, including ERP, CRM, and other legacy systems. • The JDBCTM API is used for accessing relational data from the Java program- ming language. • The Java Transaction API (JTA) is the API for managing and coordinating transactions across heterogeneous enterprise information systems. • The Java Naming and Directory InterfaceTM (JNDI) is the API for accessing in- formation in enterprise name and directory services. • The Java Message Service (JMS) is the API for sending and receiving messag- es via enterprise messaging systems such as IBM MQ Series and TIBCO Ren- dezvous. In the J2EE platform version 1.3, message-driven beans provide a component-based approach to encapsulating messaging functionality. • The JavaMailTM API is used for sending and receiving e-mail. • Java IDL provides the mechanism for calling CORBA services. • Java APIs for XML provide support for integration with legacy systems and applications, and for implementing Web services in the J2EE platform. In addition, specialized access to enterprise resource planning and mainframe systems such as IBM’s CICS and IMS is provided through the J2EE Connector architecture. Since each of these systems is highly complex and specialized, they require unique tools and support to ensure utmost simplicity to application devel- opers. Thanks to new integration features in the platform, enterprise beans can combine the use of connector access objects and service APIs with middle-tier business logic to accomplish their business functions. DEA2e.book Page 12 Friday, March 8, 2002 12:31 AM
  • 41. THE PLATFORM FOR ENTERPRISE SOLUTIONS 13 1.2.2.3 Choice of Servers, Tools, and Components The J2EE standard and J2EE brand have created a huge marketplace for servers, tools, and components. The J2EE brand on a server product ensures the consistent level of service that is fundamental to the goals of the J2EE platform. At the same time, J2EE standards ensure a lively marketplace for tools and components. Based on past experience and industry momentum, all leading enterprise software vendors are expected to provide the marketplace for J2EE 1.3 products. The standardization and branding of the J2EE platform provides many bene- fits, including: • A range of server choices—Application development organizations can ex- pect J2EE branded platforms from a variety of vendors, providing a range of choices in hardware platforms, operating systems, and server configurations. This ensures that businesses get a choice of servers appropriate to their needs. • Designed for tool support—Both enterprise beans and JSP page components are designed to be manipulated by graphical development tools and to allow automating many of the application development tasks traditionally requiring the ability to write and debug code. Both J2EE server providers and third-party tool developers have developed tools that conform to J2EE standards and sup- port various application development tasks and styles. Application developers have a choice of tools to manipulate and assemble components, and individual team members may choose tools that best suit their specific requirements. • A marketplace for components—Component-based design ensures that many types of behavior can be standardized, packaged, and reused by any J2EE application. Component vendors will provide a variety of off-the-shelf component solutions, including accounting beans, user interface templates, and even vertical market functionality of interest in specific industries. Appli- cation architects get a choice of standardized components to handle common or specialized tasks. The J2EE standard and associated branding program ensure that solutions are compatible. By setting the stage for freedom of choice, the J2EE platform makes it possible to develop with confidence that the value of your investment will be protected. DEA2e.book Page 13 Friday, March 8, 2002 12:31 AM
  • 42. CHAPTER 1 INTRODUCTION 14 1.2.2.4 Scales Easily J2EE containers provide a mechanism that supports simplified scaling of distributed applications, with no application development effort. Because J2EE containers provide components with transaction support, data- base connections, life cycle management, and other features that influence perfor- mance, they can be designed to provide scalability in these areas. For example, containers may pool database connections, providing clients with quick, efficient access to data. Because containers may run on multiple systems, Web containers can auto- matically balance load in response to fluctuating demand. 1.2.2.5 Simplified, Unified Security Model The J2EE security model is designed to support single sign on access to application services. Component developers can specify the security requirements of a compo- nent at the method level to ensure that only users with appropriate permissions can access specific data operations. While both Enterprise JavaBeans technology and Java Servlet APIs provide programmatic security control, the basic role-based secu- rity mechanism (where groups of users share specific permissions) is specified entirely at application deployment time. This provides both greater flexibility and better security control. 1.3 J2EE Application Scenarios The following sections present a number of application scenarios, setting the stage for a detailed discussion of the sample application. The J2EE specifications encour- age architectural diversity. The J2EE specifications and technologies make few assumptions about the details of API implementations. The application-level deci- sions and choices are ultimately a trade-off between functional richness and com- plexity. The J2EE programming model is flexible enough for applications that support a variety of client types, with both the Web container and EJB container as optional. Figure 1.2 reflects a range of possible application configurations, includ- ing cases where clients interact solely with the Web container, where clients inter- act directly with the EJB container, and full-blown multitier applications with stand-alone clients, Web-tier components, middle-tier EJB components, and EIS- tier access to resources and data. While the J2EE platform has no implicit bias DEA2e.book Page 14 Friday, March 8, 2002 12:31 AM
  • 43. J2EE APPLICATION SCENARIOS 15 favoring one application scenario over another, a J2EE product should be able to support any and all of these scenarios. Figure 1.2 J2EE Application Scenarios The sample application is a multitier application that uses both a Web con- tainer and an EJB container. The following enterprise requirements heavily influ- enced the choices made in developing the sample application: • The need to make rapid and frequent changes to the “look” of the application • The need to partition the application along the lines of presentation and busi- ness logic so as to increase modularity • The need to simplify the process of assigning suitably trained human resources to accomplish the development task such that work can proceed along relative- ly independent but cooperating tracks • The need to have developers familiar with back-office applications unbur- dened from GUI and graphic design work, for which they may not be ideally qualified • The need to have the necessary vocabulary to communicate the business logic to teams concerned with human factors and the aesthetics of the application DEA2e.book Page 15 Friday, March 8, 2002 12:31 AM
  • 44. CHAPTER 1 INTRODUCTION 16 • The ability to assemble back-office applications using components from a va- riety of sources, including off-the-shelf business logic components • The ability to deploy transactional components across multiple hardware and software platforms independently of the underlying database technology • The ability to externalize internal data without having to make many assump- tions about the consumer of the data and to accomplish this in a loosely cou- pled manner Clearly, relaxing any or all of these requirements would influence some of the application-level decisions and choices that a designer would make. Although it is reasonable to speak of “throw-away” presentation logic (that is, applications with a look and feel that ages rapidly), there is still significant inertia associated with business logic. This is even more true in the case of database schemas and data in general. It is fair to say that as one moves further away from EIS resources, the volatility of the application code increases dramatically; that is, the code’s “shelf- life” drops significantly. In summary, the J2EE programming model promotes a model that anticipates growth, encourages component-oriented code reusability, and leverages the strengths of inter-tier communication. It is the tier integration that lies at the heart of the J2EE programming model. 1.3.1 Multitier Application Scenario Figure 1.3 illustrates an application scenario in which the Web container hosts Web components that are almost exclusively dedicated to handling a given application’s presentation logic. JSP pages, supported by servlets, generate dynamic Web content for delivery to the client. The EJB container hosts application components that use EIS resources to service requests from Web-tier components. This architecture decouples data access from the application’s user interface. The architecture is also DEA2e.book Page 16 Friday, March 8, 2002 12:31 AM
  • 45. J2EE APPLICATION SCENARIOS 17 implicitly scalable. Application back-office functionality is relatively isolated from the end-user look and feel. Figure 1.3 Multitier Application It is worth noting that XML plays an integral role in this scenario. The ability to both produce and consume XML data messages in the Web container is an extremely flexible way to embrace a diverse set of client types. These platforms range from general purpose XML-enabled browsers to specialized XML render- ing engines targeting vertical solutions. XML data messages typically use HTTP as their transport protocol. Java and XML are complementary technologies: The Java language offers portable code, XML provides portable data. In the Web tier, the question of whether to use JSP pages or servlets comes up repeatedly. JSP technology is intended for application user interface components, while Java Servlets are preferred for request processing and application control logic. Servlets and JSP pages work together to provide dynamic content from the Web tier. DEA2e.book Page 17 Friday, March 8, 2002 12:31 AM
  • 46. CHAPTER 1 INTRODUCTION 18 1.3.2 Stand-Alone Client Scenario Figure 1.4 illustrates a stand-alone client scenario. Figure 1.4 Stand-Alone Clients The stand-alone client may be one of three types: • EJB clients interacting directly with enterprise beans hosted in an EJB contain- er within an EJB server, as shown in Figure 1.5. This scenario uses RMI-IIOP, and the EJB server accesses EIS resources using JDBC and the J2EE Connec- tor architecture. Figure 1.5 EJB-Centric Java Client DEA2e.book Page 18 Friday, March 8, 2002 12:31 AM
  • 47. J2EE APPLICATION SCENARIOS 19 • Stand-alone clients, implemented in the Java language or another program- ming language, consuming dynamic Web content (usually XML data messag- es). In this scenario, the Web container essentially handles XML transformations and provides Web connectivity to clients. Presentation logic occurs in the client tier. The Web tier handles business logic and may directly access EIS resources. Ideally, business logic is implemented as enterprise beans to take advantage of the rich enterprise beans component model. • Stand-alone Java application clients accessing enterprise information system resources directly using JDBC or Connectors. In this scenario, presentation and business logic are co-located on the client platform and may in fact be tightly integrated into a single application. This scenario is a classic two-tier client-server architecture, with its associated distribution, maintenance, and scalability issues. 1.3.3 Web-Centric Application Scenario Figure 1.6 illustrates a three-tier Web-centric application scenario. Figure 1.6 Web-Centric Application Scenario There are a number of scenarios in which the use of enterprise beans in an application would be considered overkill: sort of like using a sledgehammer to crack a nut. The J2EE specification doesn’t mandate a specific application config- uration, nor could it realistically do so. The J2EE platform is flexible enough to support the application configuration most appropriate to a specific application design requirement. As demonstrated in the book J2EE Technology In Practice, a three-tier Web- centric application scenario is widely used as the starting point for many J2EE DEA2e.book Page 19 Friday, March 8, 2002 12:31 AM
  • 48. CHAPTER 1 INTRODUCTION 20 applications. The Web container hosts both presentation and business logic, and it is assumed that JDBC and the J2EE Connector architecture are used to access EIS resources. Figure 1.7 provides a closer look at the Web container in a Web application scenario. Figure 1.7 Web Container in a Three-Tier Scenario Keep in mind that the term “Web container” has a precise meaning. It doesn’t necessarily mean a distinct process running on a distinct piece of hardware. In many cases, J2EE platform providers may co-locate their Web and EJB contain- ers, running them within the same Java Virtual Machine (JVM). J2EE applications deployed on such an implementation are still considered multitier applications, because of the division of responsibilities that the separate technologies imply. 1.3.4 Business-to-Business Scenario Figure 1.8 illustrates a business-to-business scenario. This scenario focuses on peer- level interactions between both Web and EJB containers. The J2EE programming model promotes the use of XML data messaging over HTTP as the primary means DEA2e.book Page 20 Friday, March 8, 2002 12:31 AM
  • 49. HOW THIS BOOK IS ORGANIZED 21 of establishing loosely coupled communications between Web containers. This is a natural fit for the development and deployment of Web-based commerce solutions. Figure 1.8 Business-to-Business Scenario The peer-level communications between EJB containers is currently a more tightly coupled solution most suitable for intranet environments. With support for JMS and message-driven beans, the J2EE 1.3 platform makes developing loosely- coupled intranet solutions increasingly practical. Future releases of the J2EE platform will provide additional functionality in the form of Java APIs for XML, which enable more complete support for loosely coupled applications through XML-based Web services. 1.4 How This Book Is Organized The remainder of this book is divided into the following chapters: • Chapter 2, “J2EE Platform Technologies,” provides an overview of the component, service, and communication technologies supported by the J2EE platform. • Chapter 3, “The Client Tier,” presents implementation options for J2EE cli- ents and provides guidelines for choosing among these options. DEA2e.book Page 21 Friday, March 8, 2002 12:31 AM
  • 50. CHAPTER 1 INTRODUCTION 22 • Chapter 4, “The Web Tier,” describes technologies available for supporting development in the Web tier. It includes guidelines and techniques for using J2EE Web components and describes several Web application architectures. • Chapter 5, “The Enterprise JavaBeans Tier,” describes the capabilities of the EJB tier of the J2EE platform and discusses design choices for implement- ing business logic. • Chapter 6, “Integrating with the Enterprise Information System Tier,” describes recommended approaches for accessing enterprise information sys- tems and how J2EE components must be configured to access them. • Chapter 7, “Packaging and Deployment,” describes the capabilities provid- ed by the J2EE platform for packaging and deploying J2EE applications, and provides heuristics and practical tips on how to use these capabilities. • Chapter 8, “Transaction Management,” describes the transaction services provided by the J2EE platform and provides recommendations on how best to use those services. • Chapter 9, “Security,” describes the mapping of the J2EE security model to enterprise computing environments and infrastructures. • Chapter 10, “J2EE Internationalization and Localization,” new in this edi- tion, explains how to expand an application’s reach across the globe by cus- tomizing its interfaces and logic for multiple languages, countries, and cultures. • Chapter 11, “Architecture of the Sample Application,” pulls all of the topics in the preceding chapters into a coherent programming model for interactive ap- plications in the J2EE platform, and provides specific architectural guidelines. • “Glossary,” is a list of words and phrases found in this book and their defini- tions. Additional information is available on the Java BluePrints Web site, listed in Section 1.6 on page 23. The Web site includes additional content, available only online, that describes in detail the architecture of the Java Pet Store sample appli- cation. DEA2e.book Page 22 Friday, March 8, 2002 12:31 AM
  • 51. Another Random Scribd Document with Unrelated Content
  • 52. "Excuse me if I have forced upon you a disagreeable topic," said the passenger, in a tone of sympathy. "His term of confinement will expire, and then he can return to you." "That is just what troubles me, sir," said Grit bluntly. "We are expecting him in a day or two, and then our quiet life will be at an end." "Will he make things disagreeable for you?" "Yes, sir." "At least, you will not have to work so hard." "Yes, sir. I shall have to work harder, for I shall have to support him, too." "Won't he be willing to work?" "No, sir, he is very lazy, and if he can live without work, he will." "That is certainly unfortunate." "It is worse than having no father at all," said Grit bluntly. "I don't care to have him remain in prison, if he will only keep away from us, but I should be glad if I could never set eyes upon him again." "Well, my boy, you must bear the trial as well as you can. We all have our trials, and yours comes in the shape of a disagreeable stepfather——" He did not finish the sentence, for there was a startling interruption. Mr. Jackson and Grit had been so much engaged in their conversation that they had not watched the little boy. Willie had amused himself in bending over the side of the boat, and dipping his little fingers in the rippling water. With childish imprudence he leaned too far, and fell head first into the swift stream. A splash told the startled father what had happened.
  • 53. "Good Heaven!" he exclaimed, "my boy is overboard, and I cannot swim." He had scarcely got the words out of his mouth than Grit was in the water, swimming for the spot where the boy went down, now a rod or two distant, for the boat had been borne onward by the impulse of the oars. The young boatman was an expert swimmer. It would naturally have been expected, since so much of his time had been spent on the river. He had often engaged in swimming-matches with his boy companions, and there was no one who could surpass him in speed or endurance. He struck out boldly, and, as Willie rose to the surface for the second time, he seized him by the arm, and, turning, struck out for the boat. The little boy struggled, and this made his task more difficulty but Grit was strong and wary, and, holding Willie in a strong grasp, he soon gained the boat. Mr. Jackson leaned over, and drew the boy, dripping, into its safe refuge. "Climb in, too, Grit!" he said. "No, I shall upset it. If you will row to the shore, I will swim there." "Very well." Mr. Jackson was not wholly a stranger to the use of oars, and the shore was very near. In three minutes the boat touched the bank, and almost at the same time Grit clambered on shore. "You have saved my boy's life," said Mr. Jackson, his voice betraying the strong emotion he felt. "I shall not forget it." "Willie is cold!" said the little boy. "Our house is close by," said Grit. "Let us take him there at once, and mother will take care of him, and dry his clothes."
  • 54. The suggestion was adopted, and Mr. Jackson and his two young companions were soon standing at the door of the plain cottage on the bluff. When his mother admitted them, Grit noticed that she looked disturbed, and he seized the first chance to ask her if anything were the matter. "Your stepfather has come!" she answered.
  • 55. CHAPTER V. THE STEPFATHER. Grit was disagreeably surprised at the news of Mr. Brandon's arrival, and he looked about him in the expectation of seeing his unwelcome figure, in vain. "Where is he, mother?" the boy inquired. "Gone to the tavern," she answered significantly. "Did you give him any money?" "I gave him a dollar," she replied sadly. "It is easy to tell how it will be spent." Grit had no time to inquire further at that time, for he was assisting his mother in necessary attentions to their guests, having hurriedly exchanged his own wet clothes for dry ones. Mr. Jackson seemed very grateful to Mrs. Morris for her attention to Willie. She found an old suit of Grit's, worn by him at the age of eight, and dressed Willie in it, while his own wet suit was being dried. The little boy presented a comical spectacle, the suit being three or four sizes too large for him. "I don't like it," he said. "It is too big." "So it is, Willie," said his father; "but you won't have to wear it long. You would catch your death of cold if you wore your wet clothes. How long will it take to dry his clothes, Mrs. Morris?" "Two or three hours at least," answered the widow. "I have a great mind to go back to Portville, and get a change of garments," said the father.
  • 56. "That would be the best thing, probably." "But I should have to burden you with Willie; for I should need to take Grit with me to ferry me across." "It will be no trouble, sir. I will take good care of him." "Willie, will you stay here while I go after your other clothes?" asked Mr. Jackson. Willie readily consented, especially after Grit had brought him a picture-book to look over. Then he accompanied the father to the river, and they started to go across. While they were gone, Mr. Brandon returned to the cottage. His flushed face and unsteady gait showed that he had been drinking. He lifted the latch, and went in. When he saw Willie sitting in a small chair beside his wife, he gazed at the child in astonishment. "Is that the cub?" he asked doubtfully. "Seems to me he's grown smaller since I saw him." "I ain't a cub," said Willie indignantly. "Oh! yer ain't a cub, hey?" repeated Brandon mockingly. "No, I ain't. My name is Willie Jackson, and my papa lives in New York." "What is the meaning of this, Mrs. Brandon?" asked the inebriate. "Where did you pick up this youngster?" His wife explained in a few words. "I thought it wasn't the cub," said Mr. Brandon indistinctly. "Where is he?" "He has gone to row Mr. Jackson over to Portville." "I say, Mrs. B., does he earn much money that way?"
  • 57. "He earns all the money that supports us," answered his wife coldly. "I must see to that," said Brandon unsteadily. "He must bring me his money every night—do you hear, Mrs. B.?—must bring me his money every night." "To spend for liquor, I suppose?" she responded bitterly. "I'm a gentleman. My money—that is, his money is my money. D'ye understand?" "I understand only too well, Mr. Brandon." "That's all right. I feel tired. Guess I'll go and lie down." To his wife's relief he went up-stairs, and was soon stretched out on the bed in a drunken sleep. "I am glad he is out of the way. I should be ashamed to have Mr. Jackson see him," thought Grit's mother, or Mrs. Brandon, as we must now call her. "Who is that man?" asked Willie anxiously. "His name is Brandon," answered Grit's mother. "He isn't a nice man. I don't like him." Mrs. Brandon said nothing. What could she say? If she had spoken as she felt, she would have been compelled to agree with the boy. Yet this man was her husband, and was likely to be to her a daily source of anxiety and annoyance. "I am afraid Grit and he won't agree," she thought anxiously. "Oh I why did he ever come back? For the last five years we have been happy. We have lived plainly and humbly, but our home has been peaceful. Now, Heaven knows what trouble is in store for us." Half an hour later Mr. Jackson and Grit returned.
  • 59. CHAPTER VI. GRIT'S RECOMPENSE. No time was lost in arraying Willie in clothes more suitable for him. The little boy was glad to lay aside Grit's old suit, which certainly was not very becoming to him. "Are we going now, papa?" asked the little boy. "Yes, Willie; but first I must express to this good lady my great thanks for her kindness." "I have done but little, sir," said Mrs. Brandon; "but that little I was very glad to do." "I am sure of that," said the visitor cordially. "If you remain in the neighborhood, I shall hope to see your little boy again, and yourself, also." "I will come," said Willie promptly. "He answers for himself," said his father, smiling, "and he will keep his promise. Now, Grit," he said, turning to the young boatman, "I will ask you to accompany me to the hotel." "Certainly, sir." When they had passed from the cottage, Mr. Jackson turned to the boy and grasped his hand. "I have not yet expressed to you my obligations," he said, with emotion, "for the great service you have done me—the greatest in the power of any man, or boy." "Don't speak of it, sir," said Grit modestly.
  • 60. "But I must. You have saved the life of my darling boy." "I don't know, sir." "But I do. I cannot swim a stroke, and but for your prompt bravery, he would have drowned before my eyes." Grit could not well contradict this statement, for it was incontestably true. "It was lucky I could swim," he answered. "Yes, it was. It seems providential that I should have had with me so brave a boy, when Willie's life was in peril. It will be something that you will remember with satisfaction to the end of your own life." "Yes, sir, there is no doubt of that," answered Grit sincerely. "I shudder to think what a sad blank my own life would have been if I had lost my dear boy. He is my only child, and for this reason I should have missed him the more. Your brave act is one that I cannot fitly reward——" "I don't need any reward, Mr. Jackson," said Grit hastily. "I am sure you do not. You do not look like a mercenary boy. But, for all that, I owe it to myself to see that so great a favor does not go unacknowledged. My brave boy, accept this wallet and what it contains, not as the payment of a debt, but as the first in the series of my acknowledgments to you." As he spoke, he put into the hand of the young boatman a wallet. "I am very much obliged to you, Mr. Jackson," said Grit, "but I am not sure that I ought to take this." "Then let me decide for you," said the broker, smiling. "I am older, and may be presumed to have more judgment." "It will seem as if I took pay for saving Willie from drowning."
  • 61. "If you did, it would be perfectly proper. But you forget that I have had the use of your boat and your own services for the greater part of the afternoon." "I presume you have paid me more than I ask for such services." "Very likely," answered Mr. Jackson. "In fact, outside of my obligations to you, I have formed a good opinion of a boy who works hard and faithfully to support his mother. I was a poor boy once, and I have not forgotten how to sympathize with those who are beginning the conflict with narrow means. Mind, Grit, I don't condole with you. You have good health and strong hands, and in our favored country there is no reason why, when you reach my age, you may not be equally well off." "I wish I might—for mother's sake," said Grit, his face lighting up with hope. "I shall see more of you while I am here, but I may as well say now that I mean to bear you in mind, and wish you to come to me, either here or in the city, when you stand in need of advice or assistance." Grit expressed his gratitude. Mr. Jackson selected a room at the hotel, and promised to take up his quarters there the next day. Then Grit once more took up his oars and ferried Willie and his father across the river. It was not for some time, therefore, that he had a chance to examine the wallet which had been given him.
  • 62. CHAPTER VII. GRIT ASTONISHES PHIL. Grit was not wholly without curiosity, and, as was natural, he speculated as to the amount which the wallet contained. When Mr. Jackson and Willie had left him, he took it out of his pocket and opened it. He extracted a roll of bills and counted them over. There were ten five-dollar bills, and ten dollars in notes of a smaller denomination. "Sixty dollars!" ejaculated Grit, with a thrill of pleasure. "I never was so rich in all my life." He felt that the sum was too large for him to accept, and he was half tempted to run after Mr. Jackson and say so. But quick reflection satisfied him that the generous New Yorker wished him to retain it, and, modest though he was, he was conscious that in saving the little boy's life he had placed his passenger under an obligation which a much larger sum would not have overpaid. Besides, he saw two new passengers walking toward his boat, who doubtless wished to be ferried across the river. They were Phil Courtney and Marion Clarke. "We are just in time, Mr. Grit," said the young lady, smiling. "Yes, my good fellow," said Phil condescendingly, "we will employ you again." "You are very kind," answered Grit, with a smile of amusement. "I like to encourage you," continued Phil, who was not very quick to interpret the looks of others. Grit looked at Marion, and noticed that she, too, looked amused.
  • 63. "Have you had any passengers since we came over?" asked Phil, in a patronizing tone. He was quite ready to employ his old schoolmate, provided he would show proper gratitude, and be suitably impressed by his condescension. "I have been across several times," answered Grit briefly. "And how much have you made now?" asked Phil, with what he intended to pass for benevolent interest. If Phil had been his friend, Grit would not have minded telling him; but he had the pride of self-respect, and he objected to being patronized or condescended to. "I haven't counted up," he answered. "I might have brought my own boat," said Phil, "but I like to encourage you." "Really, Phil, you are appearing in a new character," said Marion. "I never should have taken you for a philanthropist before. I thought you told your mother it would be too much bother to row over in your own boat." "That was one reason," said Phil, looking slightly embarrassed. "Besides, I didn't want to interfere with Grit's business. He is poor, and has to support his mother out of his earnings." This was in bad taste, and Grit chafed against it. "That is true," he said, "but I don't ask any sympathy. I am prosperous enough." "Oh, yes; you are doing well enough for one in your position, I don't doubt. How much would you give, now, to have as much money as I carry in this pocketbook?" asked Phil boastfully.
  • 64. He had just passed his birthday, and had received a present of ten dollars from his father, and five dollars each from his mother and an aunt. He had spent a part of it for a hat and in other ways, but still he had seventeen dollars left. "Perhaps I have as much money," answered Grit quietly. "Oho! That's a good joke," said Phil. "No joke at all," said Grit. "I don't know how much money you have in your pocketbook, but I presume I can show more." Phil's face grew red with anger. He was one of those disagreeable boys who are purse-proud, and he was provoked at hearing such a ridiculous assertion from a poor boy who had to earn his own living. Even Marion regarded Grit with some wonder, for she happened to know how much money her cousin carried, and it seemed to her very improbable that the young boatman should have as much in his possession. "Don't make a fool of yourself, Grit!" said Phil sharply. "Thank you; I don't propose to." "But you are doing it." "How?" "Didn't you say you had more money than I?" "I think I have." "Hear him talk!" said Phil, with a glance of derision. By this time the young boatman's grit was up, if I may use the expression, and he resolved to surprise and mortify his young adversary. "If you are not afraid to test it," he said, "I will leave it to the young lady to decide. Let her count the money in your pocketbook, and I
  • 65. will then give her my wallet for the same purpose." "Done!" said Phil promptly. Marion, wondering a little at Grit's confidence, took her cousin's pocketbook, and counted the contents. "Well, Marion, how much is there?" said Phil exultingly. "Seventeen dollars and thirty-seven cents," was the announcement of the fair umpire. Phil smiled triumphantly. "You didn't think I had so much—eh, Grit?" he said. "No, I didn't," Grit admitted. "Now hand over your wallet." "With pleasure, if Miss Marion will take the trouble," answered the young boatman, with a polite bow. When Marion opened the wallet, and saw the roll of bills, both she and Phil looked astonished. She proceeded to count the bills, however, and in a tone of serious surprise announced: "I find sixty dollars here." "That is right," said Grit quietly, as he received back his wallet, and thrust it into his pocket. Phil hardly knew whether he was more surprised or mortified at this unexpected result. But a thought struck him. "Whose money is that?" he demanded abruptly. "It is mine." "I don't believe it. You are carrying it over to some one in Chester." "Perhaps I am; but, if so, that some one is my mother."
  • 66. "You don't mean to say that you have sixty dollars of your own?" "Yes, I do. You didn't think I had so much money—eh, Phil?" he retorted, with a smile. "I don't believe a word of it," returned Phil crossly. "It is ridiculous that a boy like you should have so much money. It can't be yours." "Do you doubt it, Miss Marion?" asked Grit, turning to the young lady. "No; I believe that it is yours since you say so." "Thank you." "If it is yours, where did you get it?" asked Phil, whose curiosity overcame his mortification sufficiently to induce him to ask the question. "I don't feel called upon to tell you," answered Grit. "Then I can guess." "Very well. If you guess right, I will admit it." "You found it, and won't be long before finding the owner." "You are wrong. The money is mine, and was paid me in the course of business." Phil did not know what to say, but Marion said pleasantly: "Allow me to congratulate you, Mr. Grit, on being so well off. You are richer than either of your passengers. I never had sixty dollars of my own in my life." By this time they had reached the other side of the river, and the two passengers disembarked. "Well, Phil, you came off second best," said his cousin.
  • 67. "I can't understand how the boy came into possession of such a sum of money," said Phil, frowning. "Nor I; but I am sure of one thing." "What is that?" "That he came by it honestly." "Don't be too sure of that," said Phil, shaking his head. "Phil, you are too bad," said Marion warmly. "You seem to have taken an unaccountable prejudice against Grit. I am sure he seems to me a very nice boy." "You're welcome to the young boatman's society," said Phil, with a sneer. "You seem to be fond of low company." "If you call him low company, then perhaps I am. I never met Grit before this morning, but he seems a very polite, spirited boy, and it is certainly to his credit that he supports his mother." "I can tell you something about him that may chill your ardor? His father is in jail." "I heard that it was his stepfather." "Oh, well, it doesn't matter which." "In one sense, no. The boy isn't to blame for it." "No, but it shows of what stock he comes." Meanwhile, Grit, having fastened his boat, made his way to the cottage on the bluff. He wanted to tell his mother of his good fortune.
  • 68. CHAPTER VIII. GRIT PUTS HIS MONEY AWAY. "You seem to be in good spirits, Grit," said his mother, as our hero opened the outside door and entered the room where she sat sewing. "Yes, mother, I have reason to be. Is—is Mr. Brandon home?" "Yes; he is up-stairs lying down," answered Mrs. Brandon, with a sigh. Grit rose and closed the door. "I don't want him to hear what I'm going to tell you," he said. "Mother, I have been very lucky to-day." "I suppose Mr. Jackson was liberal." "I should say he was. Guess how much money I have in this wallet, mother." "Five dollars." "Multiply that by twelve." "You don't mean to say that he gave you sixty dollars?" inquired his mother quickly. "Yes, I do. See here," and Grit displayed the roll of bills. "You are, indeed, in luck, Grit. How much good this money will do us. But I forgot," she added, her expression changing to one of anxious solicitude. "What did you forget, mother?"
  • 69. "That your father—that Mr. Brandon had returned." "What difference will that make, mother? I suppose, of course, it will increase our expenses." "If that were all, Grit." "What is it, then, you fear, mother?" "That he will take this money away from you." "I should like to see him try it," exclaimed Grit, compressing his lips. "He will try it, Grit. He said only an hour ago that you would have to account to him for your daily earnings." "Doesn't he mean to do any work himself?" "I fear not. You know what sort of a man he is, Grit. He probably means to live on what we can earn, and spend his time and what money he can get hold of at the tavern." "And he calls himself a man!" said Grit disdainfully. "I am afraid our quiet, happy life is at an end, Grit," sighed his mother. Grit did not answer for a moment, but he looked stern and determined. Finally, he answered: "I don't want to make any disturbance, mother, or to act improperly, but I feel sure that we ought not to submit to such treatment." "What can we do, Grit?" "If Mr. Brandon cares to stay here we will provide him a home, give him his board, but, as to supplying him with money, we ought not to do it." "I agree with you, Grit, but I don't see how we can help it. Mr. Brandon is a man, and you are only a boy. I don't want you to
  • 70. quarrel with him." "I won't if I can help it. By the way, mother, I don't think it will be prudent to leave all this money in the house." "What can we do with it?" "I will put it out of my hands. Perhaps I had better not tell you what I am going to do with it, for Mr. Brandon might ask you, and it is better that you should be able to tell him that you don't know." "You are right, Grit." "I will attend to that matter at once, mother. I will be back in half or three-quarters of an hour," and the young boatman hurried from the house. He bent his steps to the house of his particular friend, Fred Lawrence, the son of a lawyer in the village. Mr. Lawrence was rated as wealthy by the people in the village, and lived in a house quite as good as Mr. Courtney's, but his son Fred was a very different style of boy. He had no purse-pride, and it never occurred to him that Grit was unfit to associate with, simply because he was poor, and had to earn a living for himself and his mother by ferrying passengers across the Kennebec. In fact, he regarded Grit as his most intimate friend, and spent as much time in his company as their differing engagements would allow. Phil Courtney, though he condescended to Grit, regarded Fred as his social equal, and wished to be intimate with him; but Fred did not fancy Phil, and the latter saw, with no little annoyance, that the young boatman's company was preferred to his. It displayed shocking bad taste on the part of Fred, but he did not venture to express himself to the lawyer's son as he would not scruple to do to the young ferryman. Naturally, when Grit felt the need of advice, he thought of his most intimate friend, and sought the lawyer's house.
  • 71. He met Fred on the way. "Hello, Grit!" said Fred cordially. "Where are you going?" "I was going to your house." "Then turn round, and we will go there." "I can talk with you in the street. I want your advice and help." "My advice is probably very valuable," said Fred, smiling, "considering my age and experience. However, my help you can rely upon, if I can give it." "Did you hear that Mr. Brandon had got home?" asked Grit abruptly. "Your stepfather?" "Yes; I am sorry to say that there is that tie between us. I presume you know where he has spent the last five years?" "Yes," answered Fred. "Of course, I am glad for his sake that he is free; but I am afraid he is going to give us trouble." "How does he appear?" "I have not seen him yet." "How's that?" "He only arrived to-day, and I was absent when he reached home." "Does he mean to live here?" "I am afraid so; and, what is more, I am afraid he means that mother and I shall pay his expenses. He has already told mother that he shall require me to account to him for my daily earnings." "That will be hard on you."
  • 72. "Yes; I need all I can make to pay our daily expenses, and I don't feel like letting mother suffer for the necessaries of life in order to supply Mr. Brandon with money for drink." "You are right there, Grit. I sympathize with you; but how can I help it?" "That is what I am coming to. I want to deposit my money with you —that is, what I don't need to use." "I suppose you haven't much. It might not be well to trust me too far," said Fred, smiling. "I have sixty dollars here, which I would like to put in your hands— that is, all but two dollars." "Sixty dollars! Where on earth did you get so much money, Grit?" asked his friend, opening his eyes wide in astonishment. Grit told the story briefly, and received the warm congratulations of his friend. "You deserve it all, Grit," he said, "for your brave deed." "Don't flatter me, Fred, or I may put on airs like Phil Courtney. But, to come back to business—will you do me this favor?" "Of course, I will. Father has a safe in his office, and I will put the money in there. Whenever you want any of it, you have only to ask me." "Thank you. That will suit me. I shan't break in upon it unless I am obliged to, as I would like to have it in reserve to fall back upon." "Come and take supper with us, Grit, won't you?" asked Fred cordially. "Thank you, Fred; not to-night. I haven't seen Mr. Brandon yet, and I may as well get over the first interview as soon as possible. We
  • 73. Welcome to our website – the ideal destination for book lovers and knowledge seekers. With a mission to inspire endlessly, we offer a vast collection of books, ranging from classic literary works to specialized publications, self-development books, and children's literature. Each book is a new journey of discovery, expanding knowledge and enriching the soul of the reade Our website is not just a platform for buying books, but a bridge connecting readers to the timeless values of culture and wisdom. With an elegant, user-friendly interface and an intelligent search system, we are committed to providing a quick and convenient shopping experience. Additionally, our special promotions and home delivery services ensure that you save time and fully enjoy the joy of reading. Let us accompany you on the journey of exploring knowledge and personal growth! ebookultra.com