(eBook - PDF - Java) J2EE Tutorial.pdf
(
6215 KB
)
Pobierz
The J2EE
TM
Tutorial
Stephanie Bodoff
Dale Green
Kim Haase
Eric Jendrock
Monica Pawlan
Beth Stearns
January 24, 2002
Copyright © 2002 by Sun Microsystems, Inc.
901 San Antonio Road, Palo Alto, California 94303 U.S.A.
All rights reserved.
RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the United States Government is
subject to the restrictions set forth in DFARS 252.227-7013(c)(1)(iii) and FAR 52.227-19.
The release described in this book may be protected by one or more U.S. patents, foreign patents, or
pending applications.
Sun, Sun Microsystems, Sun Microsystems Computer Corporation, the Sun logo, the Sun Microsystems
Computer Corporation logo, Java, JavaSoft, Java Software, JavaScript, JDBC, JDBC Compliant, Jav-
aOS, JavaBeans, Enterprise JavaBeans, JavaServer Pages, J2EE, J2SE, JavaMail, Java Naming and
Directory Interface, EJB, and JSP are trademarks or registered trademarks of Sun Microsystems, Inc.
UNIX
®
is a registered trademark in the United States and other countries, exclusively licensed through
X/Open Company, Ltd. All other product names mentioned herein are the trademarks of their respective
owners.
THIS PUBLICATION IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
THIS PUBLICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL
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 PROD-
UCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THIS PUBLICATION AT ANY TIME.
Contents
Foreword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxi
Chapter 1: Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Distributed Multitiered Applications
2
J2EE Components
3
J2EE Clients
4
Web Components
6
Business Components
7
Enterprise Information System Tier
8
J2EE Containers
8
Container Services
8
Container Types
10
Packaging
10
Development Roles
11
J2EE Product Provider
12
Tool Provider
12
Application Component Provider
12
Application Assembler
13
Application Deployer and Administrator
14
Reference Implementation Software
14
Database Access
15
J2EE APIs
15
Simplified Systems Integration
18
Tools
19
v
vi
C
ONTENTS
Chapter 2: Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
Setting Up
22
Getting the Example Code
22
Getting the Build Tool (ant)
22
Checking the Environment Variables
23
Starting the J2EE™ Server
23
Starting the deploytool
23
Creating the J2EE™ Application
24
Creating the Enterprise Bean
24
Coding the Enterprise Bean
24
Compiling the Source Files
26
Packaging the Enterprise Bean
26
Creating the J2EE™ Application Client
28
Coding the J2EE Application Client
28
Compiling the Application Client
31
Packaging the J2EE Application Client
31
Specifying the Application Client’s Enterprise Bean Reference
32
Creating the Web Client
32
Coding the Web Client
32
Compiling the Web Client
34
Packaging the Web Client
34
Specifying the Web Client’s Enterprise Bean Reference
35
Specifying the JNDI Names
35
Deploying the J2EE™ Application
37
Running the J2EE™ Application Client
37
Running the Web Client
38
Modifying the J2EE™ Application
39
Modifying a Class File
39
Adding a File
40
ModifyingtheWebClient
40
Modifying a Deployment Setting
40
Common Problems and Their Solutions
41
Cannot Start the J2EE Server
41
Compilation Errors
42
Deployment Errors
43
J2EE Application Client Runtime Errors
43
Web Client Runtime Errors
45
Detecting Problems With the Verifier Tool
45
Comparing Your EAR Files with Ours
46
When All Else Fails
46
vii
C
ONTENTS
Chapter 3: Enterprise Beans. . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
What Is an Enterprise Bean? 48
Benefits of Enterprise Beans 48
When to Use Enterprise Beans 49
Types of Enterprise Beans 49
What Is a Session Bean? 49
State Management Modes 50
When to Use Session Beans 51
What Is an Entity Bean? 51
What Makes Entity Beans Different from Session Beans? 52
Container-Managed Persistence 53
When to Use Entity Beans 56
What Is a Message-Driven Bean? 56
What Makes Message-Driven Beans Different from Session and Entity
Beans?
57
When to Use Message-Driven Beans
57
Defining Client Access with Interfaces
58
Remote Access
58
Local Access
59
Local Interfaces and Container-Managed Relationships
59
Deciding on Remote or Local Access
60
Performance and Access
61
Method Parameters and Access
61
The Contents of an Enterprise Bean
62
Naming Conventions for Enterprise Beans
63
The Life Cycles of Enterprise Beans
63
TheLifeCycleofaStatefulSessionBean
64
The Life Cycle of a Stateless Session Bean
65
The Life Cycle of an Entity Bean
65
TheLifeCycleofaMessage-DrivenBean
67
Chapter 4: A Session Bean Example. . . . . . . . . . . . . . . . . . . . . 69
The CartEJB Example
70
Session Bean Class
70
Home Interface
75
Remote Interface
76
Helper Classes
76
Running the CartEJB Example
76
Other Enterprise Bean Features
78
Accessing Environment Entries
78
Comparing Enterprise Beans
80
Passing an Enterprise Bean’s Object Reference
80
Plik z chomika:
atari666
Inne pliki z tego folderu:
Kernighan, Ritchie _ Jezyk ANSI C.pdf
(26610 KB)
Kurs C++.doc
(8676 KB)
Podstawy Programowania W Qt4 - Rafał Rawicki.pdf
(309 KB)
Sapek A. _ W glab jezyka C.pdf
(983 KB)
Visual C++ for Dummies - Wright.pdf
(10774 KB)
Inne foldery tego chomika:
audio
automatyka
budownictwo
chemia
czasopisma
Zgłoś jeśli
naruszono regulamin